double click on a component button to select all of that type

This commit is contained in:
bancika
2011-08-26 17:56:33 +00:00
parent 15ac8ff2e9
commit f137a398dc
5 changed files with 53 additions and 20 deletions
@@ -192,6 +192,15 @@ public interface IPlugInPort {
*/ */
List<IDIYComponent<?>> getSelectedComponents(); List<IDIYComponent<?>> getSelectedComponents();
/**
* Updates the selection with the specified list of component. Also, updates
* control point map with all components that are stuck to the newly
* selected components.
*
* @param newSelection
*/
void updateSelection(List<IDIYComponent<?>> newSelection);
/** /**
* Selects all components in the project. * Selects all components in the project.
*/ */
@@ -157,7 +157,8 @@ public class ComponentProcessor {
} }
/** /**
* Returns properties mutual for all the selected components. * Returns properties that have the same value for all the selected
* components.
* *
* @param selectedComponents * @param selectedComponents
* @return * @return
@@ -1062,14 +1062,7 @@ public class Presenter implements IPlugInPort {
drawingManager.setTheme(theme); drawingManager.setTheme(theme);
} }
/** public void updateSelection(List<IDIYComponent<?>> newSelection) {
* Updates the selection with the specified {@link ComponentTransferable}.
* Also, updates control point map with all components that are stuck to the
* newly selected components.
*
* @param newSelection
*/
private void updateSelection(List<IDIYComponent<?>> newSelection) {
this.selectedComponents = newSelection; this.selectedComponents = newSelection;
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>(); Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
for (IDIYComponent<?> component : selectedComponents) { for (IDIYComponent<?> component : selectedComponents) {
@@ -7,11 +7,16 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton; import javax.swing.JButton;
import org.diylc.common.ComponentType; import org.diylc.common.ComponentType;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.core.IDIYComponent;
/** /**
* {@link JButton} that displays component type icon and instantiates the * {@link JButton} that displays component type icon and instantiates the
@@ -37,22 +42,43 @@ class ComponentButton extends JButton {
setToolTipText("<html><b>" + componentType.getName() + "</b><br>" setToolTipText("<html><b>" + componentType.getName() + "</b><br>"
+ componentType.getDescription() + "<br>Author: " + componentType.getAuthor() + componentType.getDescription() + "<br>Author: " + componentType.getAuthor()
+ "<br><br>Double click to select all components of this type"
+ "</html>"); + "</html>");
// initializeDnD(); // initializeDnD();
addActionListener(new ActionListener() { addMouseListener(new MouseAdapter() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void mouseClicked(MouseEvent e) {
// plugInPort.setCursorIcon(componentType.getIcon()); if (e.getClickCount() == 1) {
plugInPort.setNewComponentTypeSlot(componentType); plugInPort.setNewComponentTypeSlot(componentType);
// try { } else {
// plugInPort.instantiateComponent(componentType List<IDIYComponent<?>> components = plugInPort.getCurrentProject().getComponents();
// .getComponentInstanceClass(), null); List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
// } catch (Exception e1) { for (IDIYComponent<?> component : components) {
// e1.printStackTrace(); if (componentType.getInstanceClass().equals(component.getClass())) {
// } newSelection.add(component);
}
}
plugInPort.updateSelection(newSelection);
plugInPort.setNewComponentTypeSlot(null);
plugInPort.refresh();
}
} }
}); });
// addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// // plugInPort.setCursorIcon(componentType.getIcon());
// plugInPort.setNewComponentTypeSlot(componentType);
// // try {
// // plugInPort.instantiateComponent(componentType
// // .getComponentInstanceClass(), null);
// // } catch (Exception e1) {
// // e1.printStackTrace();
// // }
// }
// });
addKeyListener(new KeyAdapter() { addKeyListener(new KeyAdapter() {
@Override @Override
@@ -334,6 +334,10 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Outline mode that resembles PCB silkscreen</description> <description>Outline mode that resembles PCB silkscreen</description>
</com.diyfever.gui.update.Change> </com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Double click on a component button in the toolbar selects all components of that type</description>
</com.diyfever.gui.update.Change>
</changes> </changes>
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url> <url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
</com.diyfever.gui.update.Version> </com.diyfever.gui.update.Version>