mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added export trace
improved status message on selection
This commit is contained in:
+13
-1
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.JPopupMenu.Separator;
|
||||
@@ -123,7 +124,18 @@ public interface IPlugInPort {
|
||||
* @param menuName
|
||||
* name of the menu to insert into
|
||||
*/
|
||||
public void injectMenuAction(Action action, String menuName);
|
||||
void injectMenuAction(Action action, String menuName);
|
||||
|
||||
/**
|
||||
* Injects a custom submenu into application's main menu. If
|
||||
* <code>action</code> is set to null {@link Separator} will be added. If
|
||||
* the specified menu does not exist it will be automatically created.
|
||||
*
|
||||
* @param name
|
||||
* @param icon
|
||||
* @param parentMenuName
|
||||
*/
|
||||
void injectSubmenu(String name, Icon icon, String parentMenuName);
|
||||
|
||||
/**
|
||||
* Returns current zoom level where <code>zoomLevel = 1.0d</code> means
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.diylc.gui;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
|
||||
/**
|
||||
* Base interface for the main GUI component.
|
||||
*
|
||||
@@ -38,4 +38,13 @@ public interface IView {
|
||||
* @see IPlugInPort#injectMenuAction
|
||||
*/
|
||||
void addMenuAction(Action action, String menuName);
|
||||
|
||||
/**
|
||||
* Adds a submenu to an existing menu.
|
||||
*
|
||||
* @param name
|
||||
* @param icon
|
||||
* @param parentMenuName
|
||||
*/
|
||||
void addSubmenu(String name, Icon icon, String parentMenuName);
|
||||
}
|
||||
|
||||
+19
-5
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
@@ -177,6 +178,23 @@ public class MainFrame extends JFrame implements IView {
|
||||
|
||||
@Override
|
||||
public void addMenuAction(Action action, String menuName) {
|
||||
JMenu menu = findOrCreateMenu(menuName);
|
||||
if (action == null) {
|
||||
menu.addSeparator();
|
||||
} else {
|
||||
menu.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubmenu(String name, Icon icon, String parentMenuName) {
|
||||
JMenu menu = findOrCreateMenu(parentMenuName);
|
||||
JMenu submenu = new JMenu(name);
|
||||
menu.add(submenu);
|
||||
menuMap.put(name, submenu);
|
||||
}
|
||||
|
||||
private JMenu findOrCreateMenu(String menuName) {
|
||||
JMenu menu;
|
||||
if (menuMap.containsKey(menuName)) {
|
||||
menu = menuMap.get(menuName);
|
||||
@@ -185,10 +203,6 @@ public class MainFrame extends JFrame implements IView {
|
||||
menuMap.put(menuName, menu);
|
||||
getMainMenuBar().add(menu);
|
||||
}
|
||||
if (action == null) {
|
||||
menu.addSeparator();
|
||||
} else {
|
||||
menu.add(action);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-10
@@ -19,6 +19,7 @@ import org.diylc.core.Project;
|
||||
import org.diylc.gui.DialogFactory;
|
||||
import org.diylc.images.IconLoader;
|
||||
|
||||
import com.diyfever.gui.IDrawingProvider;
|
||||
import com.diyfever.gui.export.DrawingExporter;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
@@ -33,8 +34,11 @@ public class FileManager implements IPlugIn {
|
||||
private static final Logger LOG = Logger.getLogger(FileManager.class);
|
||||
|
||||
private static final String FILE_TITLE = "File";
|
||||
private static final String TRACE_MASK_TITLE = "Trace Mask";
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private ProjectDrawingProvider drawingProvider;
|
||||
private TraceMaskDrawingProvider traceMaskDrawingProvider;
|
||||
|
||||
private XStream xStream = new XStream(new DomDriver());
|
||||
|
||||
@@ -42,18 +46,24 @@ public class FileManager implements IPlugIn {
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
this.drawingProvider = new ProjectDrawingProvider(plugInPort);
|
||||
this.traceMaskDrawingProvider = new TraceMaskDrawingProvider(plugInPort);
|
||||
|
||||
plugInPort.injectMenuAction(new NewAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new OpenAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new SaveAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new SaveAsAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(null, FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new ExportPDFAction(drawingProvider), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new ExportPNGAction(drawingProvider), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new PrintAction(drawingProvider), FILE_TITLE);
|
||||
plugInPort.injectSubmenu(TRACE_MASK_TITLE, null, FILE_TITLE);
|
||||
plugInPort
|
||||
.injectMenuAction(new ExportPDFAction(traceMaskDrawingProvider), TRACE_MASK_TITLE);
|
||||
plugInPort
|
||||
.injectMenuAction(new ExportPNGAction(traceMaskDrawingProvider), TRACE_MASK_TITLE);
|
||||
plugInPort.injectMenuAction(new PrintAction(traceMaskDrawingProvider), TRACE_MASK_TITLE);
|
||||
plugInPort.injectMenuAction(new CreateBomAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(null, FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new ExportPDFAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new ExportPNGAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new PrintAction(), FILE_TITLE);
|
||||
plugInPort.injectMenuAction(null, FILE_TITLE);
|
||||
plugInPort.injectMenuAction(new ExitAction(), FILE_TITLE);
|
||||
}
|
||||
|
||||
@@ -194,8 +204,11 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ExportPDFAction() {
|
||||
private IDrawingProvider drawingProvider;
|
||||
|
||||
public ExportPDFAction(IDrawingProvider drawingProvider) {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
putValue(AbstractAction.NAME, "Export to PDF");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.PDF.getIcon());
|
||||
}
|
||||
@@ -205,7 +218,7 @@ public class FileManager implements IPlugIn {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PDF.getFilter(),
|
||||
null, FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
DrawingExporter.getInstance().exportPDF(drawingProvider, file);
|
||||
DrawingExporter.getInstance().exportPDF(this.drawingProvider, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,8 +227,11 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ExportPNGAction() {
|
||||
private IDrawingProvider drawingProvider;
|
||||
|
||||
public ExportPNGAction(IDrawingProvider drawingProvider) {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
putValue(AbstractAction.NAME, "Export to PNG");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Image.getIcon());
|
||||
}
|
||||
@@ -225,7 +241,7 @@ public class FileManager implements IPlugIn {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PNG.getFilter(),
|
||||
null, FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
DrawingExporter.getInstance().exportPNG(drawingProvider, file);
|
||||
DrawingExporter.getInstance().exportPNG(this.drawingProvider, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,15 +250,18 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PrintAction() {
|
||||
private IDrawingProvider drawingProvider;
|
||||
|
||||
public PrintAction(IDrawingProvider drawingProvider) {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
putValue(AbstractAction.NAME, "Print...");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Print.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
DrawingExporter.getInstance().print(drawingProvider);
|
||||
DrawingExporter.getInstance().print(this.drawingProvider);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-6
@@ -6,7 +6,6 @@ import java.awt.Graphics2D;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
import com.diyfever.gui.IDrawingProvider;
|
||||
@@ -31,11 +30,6 @@ public class ProjectDrawingProvider implements IDrawingProvider {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING), null);
|
||||
}
|
||||
|
||||
public void draw(Graphics g, IComponentFiler filter) {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING),
|
||||
filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
return plugInPort.getCanvasDimensions(true);
|
||||
|
||||
+5
@@ -12,6 +12,7 @@ import java.io.FileInputStream;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
@@ -59,6 +60,10 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
|
||||
@Override
|
||||
public void addMenuAction(Action action, String menuName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubmenu(String name, Icon icon, String parentMenuName) {
|
||||
}
|
||||
});
|
||||
xStream = new XStream(new DomDriver());
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package org.diylc.plugins.file;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.ComponentZOrderFiler;
|
||||
|
||||
import com.diyfever.gui.IDrawingProvider;
|
||||
|
||||
/**
|
||||
* {@link IDrawingProvider} implementation that uses {@link IPlugInPort} to draw
|
||||
* a project onto the canvas.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class TraceMaskDrawingProvider implements IDrawingProvider {
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private IComponentFiler filter;
|
||||
|
||||
public TraceMaskDrawingProvider(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.filter = new ComponentZOrderFiler(IDIYComponent.ABOVE_BOARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING),
|
||||
this.filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
return plugInPort.getCanvasDimensions(true);
|
||||
}
|
||||
}
|
||||
+27
-5
@@ -57,6 +57,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
private ComponentType componentSlot;
|
||||
private List<IDIYComponent<?>> componentsUnderCursor;
|
||||
private List<String> selectedComponentNames;
|
||||
private List<String> stuckComponentNames;
|
||||
|
||||
public StatusBar() {
|
||||
super();
|
||||
@@ -189,12 +190,19 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
break;
|
||||
case SELECTION_CHANGED:
|
||||
ComponentSelection selection = (ComponentSelection) params[0];
|
||||
Collection<IDIYComponent<?>> stuckComponents = (Collection<IDIYComponent<?>>) params[1];
|
||||
Collection<String> componentNames = new HashSet<String>();
|
||||
for (IDIYComponent<?> component : selection) {
|
||||
componentNames.add(component.getName());
|
||||
}
|
||||
this.selectedComponentNames = new ArrayList<String>(componentNames);
|
||||
Collections.sort(this.selectedComponentNames);
|
||||
this.stuckComponentNames = new ArrayList<String>();
|
||||
for (IDIYComponent<?> component : stuckComponents) {
|
||||
this.stuckComponentNames.add(component.getName());
|
||||
}
|
||||
this.stuckComponentNames.removeAll(this.selectedComponentNames);
|
||||
Collections.sort(this.stuckComponentNames);
|
||||
refreshStatusText();
|
||||
break;
|
||||
case SELECTION_SIZE_CHANGED:
|
||||
@@ -245,18 +253,32 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
}
|
||||
getStatusLabel().setText("Drag " + formattedNames);
|
||||
} else if (selectedComponentNames != null && !selectedComponentNames.isEmpty()) {
|
||||
String formattedNames = "";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < selectedComponentNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
if (i == selectedComponentNames.size() - 1) {
|
||||
formattedNames += " and ";
|
||||
builder.append(" and ");
|
||||
} else {
|
||||
formattedNames += ", ";
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
formattedNames += selectedComponentNames.get(i);
|
||||
builder.append(selectedComponentNames.get(i));
|
||||
}
|
||||
getStatusLabel().setText("Selection: " + formattedNames);
|
||||
if (!stuckComponentNames.isEmpty()) {
|
||||
builder.append(" (");
|
||||
for (int i = 0; i < stuckComponentNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
if (i == stuckComponentNames.size() - 1) {
|
||||
builder.append(" and ");
|
||||
} else {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
builder.append(stuckComponentNames.get(i));
|
||||
}
|
||||
builder.append(" would be affected by dragging as well)");
|
||||
}
|
||||
getStatusLabel().setText("Selection: " + builder.toString());
|
||||
} else {
|
||||
getStatusLabel().setText("");
|
||||
}
|
||||
|
||||
+67
-25
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -341,6 +342,12 @@ public class Presenter implements IPlugInPort {
|
||||
view.addMenuAction(action, menuName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectSubmenu(String name, Icon icon, String parentMenuName) {
|
||||
LOG.info(String.format("injectSubmenu(%s, icon, %s)", name, parentMenuName));
|
||||
view.addSubmenu(name, icon, parentMenuName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all components whose areas include the specified {@link Point}.
|
||||
* Point is <b>not</b> scaled by the zoom factor.
|
||||
@@ -394,9 +401,11 @@ public class Presenter implements IPlugInPort {
|
||||
selectedComponents.addAll(findAllGroupedComponents(component));
|
||||
}
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
}
|
||||
@@ -458,9 +467,11 @@ public class Presenter implements IPlugInPort {
|
||||
public void selectAll() {
|
||||
LOG.info("selectAll()");
|
||||
this.selectedComponents = new ComponentSelection(currentProject.getComponents());
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@@ -486,16 +497,20 @@ public class Presenter implements IPlugInPort {
|
||||
// If we're dragging control points reset selection.
|
||||
selectedComponents.clear();
|
||||
selectedComponents.addAll(controlPointMap.keySet());
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else if (components.isEmpty()) {
|
||||
// If there are no components are under the cursor, reset selection.
|
||||
selectedComponents.clear();
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else {
|
||||
// Take the last component, i.e. the top order component.
|
||||
@@ -505,9 +520,11 @@ public class Presenter implements IPlugInPort {
|
||||
if (!selectedComponents.contains(component)) {
|
||||
selectedComponents.clear();
|
||||
selectedComponents.addAll(findAllGroupedComponents(component));
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
// If there aren't any control points, try to add all the selected
|
||||
@@ -659,9 +676,10 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
selectionRect = null;
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
}
|
||||
// There is selection, so we need to finalize the drag&drop
|
||||
// operation.
|
||||
@@ -670,6 +688,7 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, preDragProject, cloner
|
||||
.deepClone(currentProject), "Move");
|
||||
}
|
||||
fireSelectionChanged();
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
dragInProgress = false;
|
||||
}
|
||||
@@ -749,9 +768,10 @@ public class Presenter implements IPlugInPort {
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
// First remove the selected components from other groups.
|
||||
ungroupComponents(selectedComponents);
|
||||
// Then group them together
|
||||
// Then group them together.
|
||||
currentProject.getGroups().add(new HashSet<IDIYComponent<?>>(selectedComponents));
|
||||
// Notify the listeners.
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Group");
|
||||
@@ -764,12 +784,29 @@ public class Presenter implements IPlugInPort {
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
ungroupComponents(selectedComponents);
|
||||
// Notify the listeners.
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Group");
|
||||
}
|
||||
}
|
||||
|
||||
private void fireSelectionChanged() {
|
||||
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||
for (IDIYComponent<?> component : selectedComponents) {
|
||||
Set<Integer> indices = new HashSet<Integer>();
|
||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||
indices.add(i);
|
||||
}
|
||||
controlPointMap.put(component, indices);
|
||||
}
|
||||
includeStuckComponents(controlPointMap);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents,
|
||||
controlPointMap.keySet());
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the groups that contain at least one of the specified
|
||||
* components.
|
||||
@@ -926,9 +963,12 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Add " + componentType.getName());
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@@ -965,9 +1005,11 @@ public class Presenter implements IPlugInPort {
|
||||
: componentType.getName()));
|
||||
this.componentSlot = componentType;
|
||||
selectedComponents.clear();
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
fireSelectionChanged();
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentSlot);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user