mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 09:42:08 +10:00
add flexible leads to some components through the menu
This commit is contained in:
@@ -376,4 +376,11 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
* @return size of extra space around the canvas
|
||||
*/
|
||||
double getExtraSpace();
|
||||
|
||||
/**
|
||||
* Applies changes to the current project as specified by the provided {@link IProjectEditor}.
|
||||
*
|
||||
* @param editor
|
||||
*/
|
||||
void applyEditor(IProjectEditor editor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
public interface IProjectEditor {
|
||||
|
||||
Set<IDIYComponent<?>> edit(Project project, Set<IDIYComponent<?>> selection);
|
||||
|
||||
String getEditAction();
|
||||
}
|
||||
@@ -66,6 +66,7 @@ import org.diylc.common.IKeyProcessor;
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.IProjectEditor;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.common.VariantPackage;
|
||||
import org.diylc.core.ExpansionMode;
|
||||
@@ -2289,6 +2290,29 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEditor(IProjectEditor editor) {
|
||||
LOG.debug(String.format("applyEditor(%s)", editor.getEditAction()));
|
||||
Project oldProject = currentProject.clone();
|
||||
try {
|
||||
Set<IDIYComponent<?>> newSelection = editor.edit(currentProject, selectedComponents);
|
||||
if (newSelection != null)
|
||||
updateSelection(newSelection);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not apply editor", e);
|
||||
view.showMessage("Could not apply " + editor.getEditAction() + ". Check the log for details.", "Error", IView.ERROR_MESSAGE);
|
||||
} finally {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
||||
editor.getEditAction());
|
||||
drawingManager.clearContinuityArea();
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
drawingManager.fireZoomChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentType getNewComponentTypeSlot() {
|
||||
return instantiationManager.getComponentTypeSlot();
|
||||
|
||||
Binary file not shown.
@@ -69,6 +69,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
public static Color LEAD_COLOR_ICON = LEAD_COLOR.darker().darker();
|
||||
public static Size LEAD_THICKNESS = new Size(0.6d, SizeUnit.mm);
|
||||
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
|
||||
private static final int LEAD_RENDER_THRESHOLD = 2;
|
||||
|
||||
protected Size length;
|
||||
protected Size width;
|
||||
@@ -203,32 +204,35 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
float leadThickness = getLeadThickness();
|
||||
double leadLength = (distance - calculatePinSpacing(shapeRect)) / 2;
|
||||
|
||||
if (shouldShadeLeads()) {
|
||||
Stroke leadStroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness - 1);
|
||||
Color leadColor = getLeadColorForPainting(componentState);
|
||||
// only draw leads longer than threshold
|
||||
if (leadLength > LEAD_RENDER_THRESHOLD) {
|
||||
if (shouldShadeLeads()) {
|
||||
Stroke leadStroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness - 1);
|
||||
Color leadColor = getLeadColorForPainting(componentState);
|
||||
|
||||
Area leadArea = new Area();
|
||||
Area leadArea = new Area();
|
||||
|
||||
int endX = (int) (getPoints()[0].x + Math.cos(theta) * leadLength);
|
||||
int endY = (int) (getPoints()[0].y + Math.sin(theta) * leadLength);
|
||||
Line2D line = new Line2D.Double(getPoints()[0].x, getPoints()[0].y, endX, endY);
|
||||
leadArea.add(new Area(leadStroke.createStrokedShape(line)));
|
||||
int endX = (int) (getPoints()[0].x + Math.cos(theta) * leadLength);
|
||||
int endY = (int) (getPoints()[0].y + Math.sin(theta) * leadLength);
|
||||
Line2D line = new Line2D.Double(getPoints()[0].x, getPoints()[0].y, endX, endY);
|
||||
leadArea.add(new Area(leadStroke.createStrokedShape(line)));
|
||||
|
||||
endX = (int) (getPoints()[1].x + Math.cos(theta - Math.PI) * leadLength);
|
||||
endY = (int) (getPoints()[1].y + Math.sin(theta - Math.PI) * leadLength);
|
||||
line = new Line2D.Double(getPoints()[1].x, getPoints()[1].y, endX, endY);
|
||||
leadArea.add(new Area(leadStroke.createStrokedShape(line)));
|
||||
endX = (int) (getPoints()[1].x + Math.cos(theta - Math.PI) * leadLength);
|
||||
endY = (int) (getPoints()[1].y + Math.sin(theta - Math.PI) * leadLength);
|
||||
line = new Line2D.Double(getPoints()[1].x, getPoints()[1].y, endX, endY);
|
||||
leadArea.add(new Area(leadStroke.createStrokedShape(line)));
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
g2d.setColor(leadColor);
|
||||
g2d.fill(leadArea);
|
||||
g2d.setColor(leadColor.darker());
|
||||
g2d.draw(leadArea);
|
||||
} else {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
|
||||
Color leadColor = getLeadColorForPainting(componentState);
|
||||
g2d.setColor(leadColor);
|
||||
drawLeads(g2d, theta, leadLength);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
g2d.setColor(leadColor);
|
||||
g2d.fill(leadArea);
|
||||
g2d.setColor(leadColor.darker());
|
||||
g2d.draw(leadArea);
|
||||
} else {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
|
||||
Color leadColor = getLeadColorForPainting(componentState);
|
||||
g2d.setColor(leadColor);
|
||||
drawLeads(g2d, theta, leadLength);
|
||||
}
|
||||
}
|
||||
// g2d.setTransform(textTransform);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.diylc.editor;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.common.IProjectEditor;
|
||||
import org.diylc.components.AbstractCurvedComponent.PointCount;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.components.connectivity.AWG;
|
||||
import org.diylc.components.connectivity.HookupWire;
|
||||
import org.diylc.components.semiconductors.AbstractTransistorPackage;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.presenter.InstantiationManager;
|
||||
|
||||
public class FlexibleLeadsEditor implements IProjectEditor {
|
||||
|
||||
private InstantiationManager instantiationManager;
|
||||
|
||||
@Override
|
||||
public Set<IDIYComponent<?>> edit(Project project, Set<IDIYComponent<?>> selection) {
|
||||
Set<IDIYComponent<?>> newSelection = new HashSet<IDIYComponent<?>>(selection);
|
||||
for (IDIYComponent<?> c : selection) {
|
||||
if (c instanceof AbstractLeadedComponent<?>)
|
||||
addLeads((AbstractLeadedComponent<?>) c, project, newSelection);
|
||||
}
|
||||
|
||||
return newSelection;
|
||||
}
|
||||
|
||||
private void addLeads(AbstractLeadedComponent<?> c, Project project, Set<IDIYComponent<?>> newSelection) {
|
||||
AbstractLeadedComponent<?> leaded = (AbstractLeadedComponent<?>)c;
|
||||
Size l = leaded.getLength();
|
||||
// do not apply to jumpers, etc
|
||||
if (l == null)
|
||||
return;
|
||||
|
||||
Point p1 = new Point(leaded.getControlPoint(0));
|
||||
Point p2 = new Point(leaded.getControlPoint(1));
|
||||
double d = p1.distance(p2);
|
||||
double len = l.convertToPixels() + 2;
|
||||
|
||||
double diff = (d - len) / 2;
|
||||
|
||||
if (diff < 20)
|
||||
return;
|
||||
|
||||
// find the center and angle
|
||||
double centerX = (p1.x + p2.x) / 2.0;
|
||||
double centerY = (p1.y + p2.y) / 2.0;
|
||||
double theta = Math.atan2(p2.y - p1.y, p2.x - p1.x);
|
||||
// shorten the component to match the size of the body
|
||||
Point newP1 = new Point((int)Math.round(centerX - Math.cos(theta) * len / 2), (int)Math.round(centerY - Math.sin(theta) * len / 2));
|
||||
Point newP2 = new Point((int)Math.round(centerX + Math.cos(theta) * len / 2), (int)Math.round(centerY + Math.sin(theta) * len / 2));
|
||||
leaded.setControlPoint(newP1, 0);
|
||||
leaded.setControlPoint(newP2, 1);
|
||||
|
||||
// create leads
|
||||
HookupWire w1 = new HookupWire();
|
||||
w1.setGauge(AWG._26);
|
||||
w1.setLeadColor(leaded.getLeadColor());
|
||||
w1.setPointCount(PointCount.THREE);
|
||||
w1.setControlPoint(p1, 0);
|
||||
w1.setControlPoint(new Point((int)Math.round(centerX - Math.cos(theta) * (len / 2 + diff / 2)), (int)Math.round(centerY - Math.sin(theta) * (len / 2 + diff / 2))), 1);
|
||||
w1.setControlPoint(newP1, 2);
|
||||
newSelection.add(w1);
|
||||
|
||||
HookupWire w2 = new HookupWire();
|
||||
w2.setGauge(AWG._26);
|
||||
w2.setLeadColor(leaded.getLeadColor());
|
||||
w2.setPointCount(PointCount.THREE);
|
||||
w2.setControlPoint(p2, 0);
|
||||
w2.setControlPoint(new Point((int)Math.round(centerX + Math.cos(theta) * (len / 2 + diff / 2)), (int)Math.round(centerY + Math.sin(theta) * (len / 2 + diff / 2))), 1);
|
||||
w2.setControlPoint(newP2, 2);
|
||||
newSelection.add(w2);
|
||||
|
||||
// inject leads right before the component
|
||||
int index = project.getComponents().indexOf(c);
|
||||
project.getComponents().add(index, w1);
|
||||
project.getComponents().add(index, w2);
|
||||
}
|
||||
|
||||
private void addLeads(AbstractTransistorPackage c, Project project, Set<IDIYComponent<?>> newSelection) {
|
||||
if (c.getFolded()) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEditAction() {
|
||||
return "Add Flexible Leads";
|
||||
}
|
||||
|
||||
public InstantiationManager getInstantiationManager() {
|
||||
if (instantiationManager == null)
|
||||
instantiationManager = new InstantiationManager();
|
||||
return instantiationManager;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -65,7 +65,7 @@ public enum IconLoader {
|
||||
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png"),
|
||||
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
|
||||
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
|
||||
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png");
|
||||
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -64,6 +64,7 @@ import org.diylc.core.Theme;
|
||||
import org.diylc.core.measures.Nudge;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.editor.FlexibleLeadsEditor;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.netlist.Group;
|
||||
import org.diylc.netlist.Netlist;
|
||||
@@ -127,11 +128,13 @@ public class ActionFactory {
|
||||
return new CreateBomAction(plugInPort);
|
||||
}
|
||||
|
||||
public ExportPDFAction createExportPDFAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
public ExportPDFAction createExportPDFAction(IPlugInPort plugInPort,
|
||||
IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
return new ExportPDFAction(plugInPort, drawingProvider, swingUI, defaultSuffix);
|
||||
}
|
||||
|
||||
public ExportPNGAction createExportPNGAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
public ExportPNGAction createExportPNGAction(IPlugInPort plugInPort,
|
||||
IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
return new ExportPNGAction(plugInPort, drawingProvider, swingUI, defaultSuffix);
|
||||
}
|
||||
|
||||
@@ -161,11 +164,13 @@ public class ActionFactory {
|
||||
|
||||
// Edit menu actions.
|
||||
|
||||
public CutAction createCutAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
public CutAction createCutAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
return new CutAction(plugInPort, clipboard, clipboardOwner);
|
||||
}
|
||||
|
||||
public CopyAction createCopyAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
public CopyAction createCopyAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
return new CopyAction(plugInPort, clipboard, clipboardOwner);
|
||||
}
|
||||
|
||||
@@ -209,7 +214,8 @@ public class ActionFactory {
|
||||
return new SaveAsBlockAction(plugInPort);
|
||||
}
|
||||
|
||||
public ExpandSelectionAction createExpandSelectionAction(IPlugInPort plugInPort, ExpansionMode expansionMode) {
|
||||
public ExpandSelectionAction createExpandSelectionAction(IPlugInPort plugInPort,
|
||||
ExpansionMode expansionMode) {
|
||||
return new ExpandSelectionAction(plugInPort, expansionMode);
|
||||
}
|
||||
|
||||
@@ -237,18 +243,24 @@ public class ActionFactory {
|
||||
return new FindAction(plugInPort, swingUI);
|
||||
}
|
||||
|
||||
public FlexibleLeadsAction createFlexibleLeadsAction(IPlugInPort plugInPort) {
|
||||
return new FlexibleLeadsAction(plugInPort);
|
||||
}
|
||||
|
||||
// Config actions.
|
||||
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue) {
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue) {
|
||||
return new ConfigAction(plugInPort, title, configKey, defaultValue);
|
||||
}
|
||||
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue,
|
||||
String tipKey) {
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue, String tipKey) {
|
||||
return new ConfigAction(plugInPort, title, configKey, defaultValue, tipKey);
|
||||
}
|
||||
|
||||
public ToggleAction createToggleAction(String title, String configKey, String groupName, String defaultValue) {
|
||||
public ToggleAction createToggleAction(String title, String configKey, String groupName,
|
||||
String defaultValue) {
|
||||
return new ToggleAction(title, configKey, groupName, defaultValue);
|
||||
}
|
||||
|
||||
@@ -264,11 +276,13 @@ public class ActionFactory {
|
||||
return new RenumberAction(plugInPort, xAxisFirst);
|
||||
}
|
||||
|
||||
public GenerateNetlistAction createGenerateNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI) {
|
||||
public GenerateNetlistAction createGenerateNetlistAction(IPlugInPort plugInPort,
|
||||
ISwingUI swingUI) {
|
||||
return new GenerateNetlistAction(plugInPort, swingUI);
|
||||
}
|
||||
|
||||
public SummarizeNetlistAction createSummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistAnalyzer summarizer) {
|
||||
public SummarizeNetlistAction createSummarizeNetlistAction(IPlugInPort plugInPort,
|
||||
ISwingUI swingUI, INetlistAnalyzer summarizer) {
|
||||
return new SummarizeNetlistAction(plugInPort, swingUI, summarizer);
|
||||
}
|
||||
|
||||
@@ -284,8 +298,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "New");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentPlain.getIcon());
|
||||
}
|
||||
|
||||
@@ -306,7 +320,8 @@ public class ActionFactory {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(), property.getValue());
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(),
|
||||
property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,8 +339,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Open");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FolderOut.getIcon());
|
||||
}
|
||||
|
||||
@@ -335,9 +350,8 @@ public class ActionFactory {
|
||||
if (!plugInPort.allowFileAction()) {
|
||||
return;
|
||||
}
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(),
|
||||
null, FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -353,7 +367,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not open file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not open file. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -375,7 +390,8 @@ public class ActionFactory {
|
||||
this.presenter = new Presenter(new IView() {
|
||||
|
||||
@Override
|
||||
public int showConfirmDialog(String message, String title, int optionType, int messageType) {
|
||||
public int showConfirmDialog(String message, String title, int optionType,
|
||||
int messageType) {
|
||||
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
|
||||
}
|
||||
|
||||
@@ -390,13 +406,14 @@ public class ActionFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties) {
|
||||
public boolean editProperties(List<PropertyWrapper> properties,
|
||||
Set<PropertyWrapper> defaultedProperties) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
putValue(AbstractAction.NAME, "Import");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_I,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.ElementInto.getIcon());
|
||||
}
|
||||
|
||||
@@ -404,9 +421,8 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("ImportAction triggered");
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(),
|
||||
null, FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -430,7 +446,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not open file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not open file. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -449,8 +466,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Save");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DiskBlue.getIcon());
|
||||
}
|
||||
|
||||
@@ -458,9 +475,8 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("SaveAction triggered");
|
||||
if (plugInPort.getCurrentFileName() == null) {
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.DIY.getFilter(), null, FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -476,7 +492,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -495,7 +512,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -514,19 +532,16 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Save As");
|
||||
putValue(
|
||||
AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
|
||||
| ActionEvent.SHIFT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DiskBlue.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("SaveAsAction triggered");
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.DIY.getFilter(), null, FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -542,7 +557,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -565,8 +581,8 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("CreateBomAction triggered");
|
||||
List<BomEntry> bom =
|
||||
org.diylc.utils.BomMaker.getInstance().createBom(plugInPort.getCurrentProject().getComponents());
|
||||
List<BomEntry> bom = org.diylc.utils.BomMaker.getInstance()
|
||||
.createBom(plugInPort.getCurrentProject().getComponents());
|
||||
|
||||
String initialFileName = null;
|
||||
String currentFile = plugInPort.getCurrentFileName();
|
||||
@@ -589,7 +605,8 @@ public class ActionFactory {
|
||||
private IPlugInPort plugInPort;
|
||||
private String defaultSuffix;
|
||||
|
||||
public ExportPDFAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
public ExportPDFAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider,
|
||||
ISwingUI swingUI, String defaultSuffix) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.drawingProvider = drawingProvider;
|
||||
@@ -607,12 +624,12 @@ public class ActionFactory {
|
||||
String currentFile = plugInPort.getCurrentFileName();
|
||||
if (currentFile != null) {
|
||||
File cFile = new File(currentFile);
|
||||
initialFile = new File(cFile.getName().replaceAll("(?i)\\.diy", "") + defaultSuffix + ".pdf");
|
||||
initialFile =
|
||||
new File(cFile.getName().replaceAll("(?i)\\.diy", "") + defaultSuffix + ".pdf");
|
||||
}
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.PDF.getFilter(), initialFile,
|
||||
FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.PDF.getFilter(), initialFile, FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -628,7 +645,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export to PDF. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export to PDF. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -644,7 +662,8 @@ public class ActionFactory {
|
||||
private IPlugInPort plugInPort;
|
||||
private String defaultSuffix;
|
||||
|
||||
public ExportPNGAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider, ISwingUI swingUI, String defaultSuffix) {
|
||||
public ExportPNGAction(IPlugInPort plugInPort, IDrawingProvider drawingProvider,
|
||||
ISwingUI swingUI, String defaultSuffix) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.drawingProvider = drawingProvider;
|
||||
@@ -662,12 +681,12 @@ public class ActionFactory {
|
||||
String currentFile = plugInPort.getCurrentFileName();
|
||||
if (currentFile != null) {
|
||||
File cFile = new File(currentFile);
|
||||
initialFile = new File(cFile.getName().replaceAll("(?i)\\.diy", "") + defaultSuffix + ".png");
|
||||
initialFile =
|
||||
new File(cFile.getName().replaceAll("(?i)\\.diy", "") + defaultSuffix + ".png");
|
||||
}
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.PNG.getFilter(), initialFile,
|
||||
FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.PNG.getFilter(), initialFile, FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -683,7 +702,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export to PNG. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export to PNG. " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -721,7 +741,8 @@ public class ActionFactory {
|
||||
|
||||
private ISwingUI swingUI;
|
||||
|
||||
private Map<String, ComponentType> typeMap = new TreeMap<String, ComponentType>(String.CASE_INSENSITIVE_ORDER);
|
||||
private Map<String, ComponentType> typeMap =
|
||||
new TreeMap<String, ComponentType>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
public ExportVariantsAction(ISwingUI swingUI, IPlugInPort plugInPort) {
|
||||
super();
|
||||
@@ -743,8 +764,8 @@ public class ActionFactory {
|
||||
Map<String, List<Template>> selectedVariants;
|
||||
|
||||
try {
|
||||
Map<String, List<Template>> variantMap =
|
||||
(Map<String, List<Template>>) ConfigurationManager.getInstance().readObject(IPlugInPort.TEMPLATES_KEY, null);
|
||||
Map<String, List<Template>> variantMap = (Map<String, List<Template>>) ConfigurationManager
|
||||
.getInstance().readObject(IPlugInPort.TEMPLATES_KEY, null);
|
||||
if (variantMap == null || variantMap.isEmpty()) {
|
||||
swingUI.showMessage("No variants found to export.", "Error", IView.ERROR_MESSAGE);
|
||||
return;
|
||||
@@ -764,9 +785,11 @@ public class ActionFactory {
|
||||
@Override
|
||||
public int compare(ComponentType o1, ComponentType o2) {
|
||||
return o1.toString().compareToIgnoreCase(o2.toString());
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
CheckBoxListDialog dialog = new CheckBoxListDialog(swingUI.getOwnerFrame(), "Export Variants", types.toArray());
|
||||
CheckBoxListDialog dialog =
|
||||
new CheckBoxListDialog(swingUI.getOwnerFrame(), "Export Variants", types.toArray());
|
||||
|
||||
dialog.setVisible(true);
|
||||
|
||||
@@ -790,19 +813,19 @@ public class ActionFactory {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Error preparing variants for export", ex);
|
||||
swingUI.showMessage("Could not export variants. Please check the log for details", "Export Variants", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export variants. Please check the log for details",
|
||||
"Export Variants", ISwingUI.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
final VariantPackage variantPkg = new VariantPackage(selectedVariants, System.getProperty("user.name"));
|
||||
final VariantPackage variantPkg =
|
||||
new VariantPackage(selectedVariants, System.getProperty("user.name"));
|
||||
|
||||
File initialFile =
|
||||
new File(variantPkg.getOwner() == null ? "variants.xml" : ("variants by "
|
||||
+ variantPkg.getOwner().toLowerCase() + ".xml"));
|
||||
File initialFile = new File(variantPkg.getOwner() == null ? "variants.xml"
|
||||
: ("variants by " + variantPkg.getOwner().toLowerCase() + ".xml"));
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.XML.getFilter(),
|
||||
initialFile, FileFilterEnum.XML.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.XML.getFilter(), initialFile, FileFilterEnum.XML.getExtensions()[0], null);
|
||||
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
@@ -832,7 +855,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export variants: " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export variants: " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -857,9 +881,8 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("ImportVariantsAction triggered");
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.XML.getFilter(),
|
||||
null, FileFilterEnum.XML.getExtensions()[0], null, swingUI.getOwnerFrame());
|
||||
final File file = DialogFactory.getInstance().showOpenDialog(FileFilterEnum.XML.getFilter(),
|
||||
null, FileFilterEnum.XML.getExtensions()[0], null, swingUI.getOwnerFrame());
|
||||
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Integer>() {
|
||||
@@ -871,13 +894,14 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void complete(Integer result) {
|
||||
swingUI.showMessage(result + " variant(s) imported from \"" + file.getName() + "\".", "Success",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage(result + " variant(s) imported from \"" + file.getName() + "\".",
|
||||
"Success", ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not import variants: " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not import variants: " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -906,7 +930,8 @@ public class ActionFactory {
|
||||
|
||||
try {
|
||||
Map<String, List<IDIYComponent<?>>> blocks =
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(IPlugInPort.BLOCKS_KEY, null);
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance()
|
||||
.readObject(IPlugInPort.BLOCKS_KEY, null);
|
||||
if (blocks == null || blocks.isEmpty()) {
|
||||
swingUI.showMessage("No building blocks found to export.", "Error", IView.ERROR_MESSAGE);
|
||||
return;
|
||||
@@ -919,9 +944,11 @@ public class ActionFactory {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareToIgnoreCase(o2);
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
CheckBoxListDialog dialog = new CheckBoxListDialog(swingUI.getOwnerFrame(), "Export Building Blocks", options);
|
||||
CheckBoxListDialog dialog =
|
||||
new CheckBoxListDialog(swingUI.getOwnerFrame(), "Export Building Blocks", options);
|
||||
|
||||
dialog.setVisible(true);
|
||||
|
||||
@@ -931,7 +958,8 @@ public class ActionFactory {
|
||||
Object[] selected = dialog.getSelectedOptions();
|
||||
|
||||
if (selected.length == 0) {
|
||||
swingUI.showMessage("No building blocks selected for export.", "Error", IView.ERROR_MESSAGE);
|
||||
swingUI.showMessage("No building blocks selected for export.", "Error",
|
||||
IView.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -941,19 +969,19 @@ public class ActionFactory {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Error preparing building blocks for export", ex);
|
||||
swingUI.showMessage("Could not export building blocks. Please check the log for details", "Export Building Blocks", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export building blocks. Please check the log for details",
|
||||
"Export Building Blocks", ISwingUI.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
final BuildingBlockPackage variantPkg = new BuildingBlockPackage(selectedBlocks, System.getProperty("user.name"));
|
||||
final BuildingBlockPackage variantPkg =
|
||||
new BuildingBlockPackage(selectedBlocks, System.getProperty("user.name"));
|
||||
|
||||
File initialFile =
|
||||
new File(variantPkg.getOwner() == null ? "building blocks.xml" : ("building blocks by "
|
||||
+ variantPkg.getOwner().toLowerCase() + ".xml"));
|
||||
File initialFile = new File(variantPkg.getOwner() == null ? "building blocks.xml"
|
||||
: ("building blocks by " + variantPkg.getOwner().toLowerCase() + ".xml"));
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(), FileFilterEnum.XML.getFilter(),
|
||||
initialFile, FileFilterEnum.XML.getExtensions()[0], null);
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||
FileFilterEnum.XML.getFilter(), initialFile, FileFilterEnum.XML.getExtensions()[0], null);
|
||||
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
@@ -977,13 +1005,14 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void complete(Void result) {
|
||||
swingUI.showMessage("Building blocks exported to \"" + file.getName() + "\".", "Success",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage("Building blocks exported to \"" + file.getName() + "\".",
|
||||
"Success", ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export building blocks: " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not export building blocks: " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -1009,9 +1038,8 @@ public class ActionFactory {
|
||||
LOG.info("ImportBlocksAction triggered");
|
||||
|
||||
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.XML.getFilter(),
|
||||
null, FileFilterEnum.XML.getExtensions()[0], null, swingUI.getOwnerFrame());
|
||||
final File file = DialogFactory.getInstance().showOpenDialog(FileFilterEnum.XML.getFilter(),
|
||||
null, FileFilterEnum.XML.getExtensions()[0], null, swingUI.getOwnerFrame());
|
||||
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Integer>() {
|
||||
@@ -1023,13 +1051,15 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void complete(Integer result) {
|
||||
swingUI.showMessage(result + " building block(s) imported from \"" + file.getName() + "\".", "Success",
|
||||
swingUI.showMessage(
|
||||
result + " building block(s) imported from \"" + file.getName() + "\".", "Success",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not import building blocks: " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not import building blocks: " + e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -1074,15 +1104,16 @@ public class ActionFactory {
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Cut");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Cut.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Cut triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboard.setContents(
|
||||
new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
plugInPort.deleteSelectedComponents();
|
||||
}
|
||||
@@ -1100,8 +1131,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
putValue(AbstractAction.NAME, "Paste");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Paste.getIcon());
|
||||
}
|
||||
|
||||
@@ -1112,7 +1143,8 @@ public class ActionFactory {
|
||||
try {
|
||||
List<IDIYComponent<?>> components =
|
||||
(List<IDIYComponent<?>>) clipboard.getData(ComponentTransferable.listFlavor);
|
||||
plugInPort.pasteComponents(cloneComponents(components), false, ConfigurationManager.getInstance().readBoolean(Presenter.RENUMBER_ON_PASTE_KEY, true));
|
||||
plugInPort.pasteComponents(cloneComponents(components), false,
|
||||
ConfigurationManager.getInstance().readBoolean(Presenter.RENUMBER_ON_PASTE_KEY, true));
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Coule not paste.", ex);
|
||||
}
|
||||
@@ -1133,15 +1165,16 @@ public class ActionFactory {
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Copy");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Copy.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboard.setContents(
|
||||
new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
}
|
||||
}
|
||||
@@ -1157,8 +1190,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Duplicate");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_D,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentsGear.getIcon());
|
||||
}
|
||||
|
||||
@@ -1195,8 +1228,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Select All");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Selection.getIcon());
|
||||
}
|
||||
|
||||
@@ -1217,8 +1250,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Group Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Group.getIcon());
|
||||
}
|
||||
|
||||
@@ -1239,8 +1272,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Ungroup Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Ungroup.getIcon());
|
||||
}
|
||||
|
||||
@@ -1277,7 +1310,8 @@ public class ActionFactory {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(), property.getValue());
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(),
|
||||
property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1294,8 +1328,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Nudge");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FitToSize.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1311,8 +1345,8 @@ public class ActionFactory {
|
||||
n.setyOffset(new Size(0d, SizeUnit.in));
|
||||
}
|
||||
List<PropertyWrapper> properties = plugInPort.getProperties(n);
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(properties, "Nudge Selection", false);
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance()
|
||||
.createPropertyEditorDialog(properties, "Nudge Selection", false);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyProperties(n, properties);
|
||||
@@ -1331,8 +1365,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Edit Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.EditComponent.getIcon());
|
||||
}
|
||||
|
||||
@@ -1385,8 +1419,8 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Save as template triggered");
|
||||
String templateName =
|
||||
JOptionPane.showInputDialog(null, "Variant name:", "Save as Variant", JOptionPane.PLAIN_MESSAGE);
|
||||
String templateName = JOptionPane.showInputDialog(null, "Variant name:", "Save as Variant",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
if (templateName != null && !templateName.trim().isEmpty()) {
|
||||
plugInPort.saveSelectedComponentAsVariant(templateName);
|
||||
}
|
||||
@@ -1409,8 +1443,8 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Save as building block triggered");
|
||||
String templateName =
|
||||
JOptionPane.showInputDialog(null, "Block name:", "Save as Building Block", JOptionPane.PLAIN_MESSAGE);
|
||||
String templateName = JOptionPane.showInputDialog(null, "Block name:",
|
||||
"Save as Building Block", JOptionPane.PLAIN_MESSAGE);
|
||||
if (templateName != null && !templateName.trim().isEmpty()) {
|
||||
plugInPort.saveSelectionAsBlock(templateName);
|
||||
}
|
||||
@@ -1465,11 +1499,13 @@ public class ActionFactory {
|
||||
if (direction > 0) {
|
||||
putValue(AbstractAction.NAME, "Rotate Clockwise");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.RotateCW.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK));
|
||||
} else {
|
||||
putValue(AbstractAction.NAME, "Rotate Counterclockwise");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.RotateCCW.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1494,11 +1530,13 @@ public class ActionFactory {
|
||||
if (direction == IComponentTransformer.HORIZONTAL) {
|
||||
putValue(AbstractAction.NAME, "Mirror Horizontally");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));
|
||||
} else {
|
||||
putValue(AbstractAction.NAME, "Mirror Vertically");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipVertical.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.ALT_MASK));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1520,7 +1558,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Send Backward");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Back.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.ALT_MASK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1541,7 +1580,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Bring Forward");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Front.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.ALT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.ALT_MASK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1564,7 +1604,8 @@ public class ActionFactory {
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Find");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.SearchBox.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1577,12 +1618,33 @@ public class ActionFactory {
|
||||
String criteria = dialog.getCriteria();
|
||||
plugInPort.selectMatching(criteria);
|
||||
if (plugInPort.getSelectedComponents().size() == 0) {
|
||||
swingUI.showMessage("No matching components found.", "Find", ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage("No matching components found.", "Find",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FlexibleLeadsAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
public FlexibleLeadsAction(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Add Flexible Leads");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlexibleLeads.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Add Flexible Leads triggered");
|
||||
plugInPort.applyEditor(new FlexibleLeadsEditor());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfigAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -1591,31 +1653,35 @@ public class ActionFactory {
|
||||
private String configKey;
|
||||
private String tipKey;
|
||||
|
||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue, String tipKey) {
|
||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue, String tipKey) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.configKey = configKey;
|
||||
this.tipKey = tipKey;
|
||||
putValue(AbstractAction.NAME, title);
|
||||
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readBoolean(configKey, defaultValue));
|
||||
putValue(AbstractAction.SELECTED_KEY,
|
||||
ConfigurationManager.getInstance().readBoolean(configKey, defaultValue));
|
||||
ConfigurationManager.getInstance().addConfigListener(configKey, new IConfigListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
putValue(AbstractAction.SELECTED_KEY, (Boolean)value);
|
||||
putValue(AbstractAction.SELECTED_KEY, (Boolean) value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue) {
|
||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue) {
|
||||
this(plugInPort, title, configKey, defaultValue, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info(getValue(AbstractAction.NAME) + " triggered");
|
||||
ConfigurationManager.getInstance().writeValue(configKey, getValue(AbstractAction.SELECTED_KEY));
|
||||
ConfigurationManager.getInstance().writeValue(configKey,
|
||||
getValue(AbstractAction.SELECTED_KEY));
|
||||
if ((Boolean) getValue(AbstractAction.SELECTED_KEY) && tipKey != null
|
||||
&& !ConfigurationManager.getInstance().readBoolean(tipKey + ".dismissed", false)) {
|
||||
DialogFactory.getInstance().createInfoDialog(tipKey).setVisible(true);
|
||||
@@ -1628,14 +1694,15 @@ public class ActionFactory {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String configKey;
|
||||
private String configKey;
|
||||
|
||||
public ToggleAction(String title, String configKey, String groupName, String defaultValue) {
|
||||
super();
|
||||
this.configKey = configKey;
|
||||
putValue(AbstractAction.NAME, title);
|
||||
putValue(IView.RADIO_BUTTON_GROUP_KEY, groupName);
|
||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readString(configKey, defaultValue).equalsIgnoreCase(title));
|
||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance()
|
||||
.readString(configKey, defaultValue).equalsIgnoreCase(title));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1658,7 +1725,8 @@ public class ActionFactory {
|
||||
this.theme = theme;
|
||||
putValue(AbstractAction.NAME, theme.getName());
|
||||
putValue(IView.RADIO_BUTTON_GROUP_KEY, "theme");
|
||||
putValue(AbstractAction.SELECTED_KEY, plugInPort.getSelectedTheme().getName().equals(theme.getName()));
|
||||
putValue(AbstractAction.SELECTED_KEY,
|
||||
plugInPort.getSelectedTheme().getName().equals(theme.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1680,10 +1748,8 @@ public class ActionFactory {
|
||||
putValue(AbstractAction.NAME, browserType);
|
||||
putValue(IView.RADIO_BUTTON_GROUP_KEY, "componentBrowser");
|
||||
|
||||
putValue(
|
||||
AbstractAction.SELECTED_KEY,
|
||||
browserType.equals(ConfigurationManager.getInstance().readString(ConfigPlugin.COMPONENT_BROWSER,
|
||||
ConfigPlugin.SEARCHABLE_TREE)));
|
||||
putValue(AbstractAction.SELECTED_KEY, browserType.equals(ConfigurationManager.getInstance()
|
||||
.readString(ConfigPlugin.COMPONENT_BROWSER, ConfigPlugin.SEARCHABLE_TREE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1741,27 +1807,31 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Failed to generate the netlist: " + e.getMessage(), "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage("Failed to generate the netlist: " + e.getMessage(), "DIYLC Netlist",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(List<Netlist> res) {
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated netlist is empty, nothing to show.", "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage("The generated netlist is empty, nothing to show.", "DIYLC Netlist",
|
||||
ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Netlist netlist : res) {
|
||||
sb.append("<p style=\"font-family: " + new JLabel().getFont().getName() + "; font-size: 9px\"><b>Switch configuration: ").
|
||||
append(netlist.getSwitchSetup()).append("</b><br><br>Connected node groups:<br>");
|
||||
sb.append("<p style=\"font-family: " + new JLabel().getFont().getName()
|
||||
+ "; font-size: 9px\"><b>Switch configuration: ").append(netlist.getSwitchSetup())
|
||||
.append("</b><br><br>Connected node groups:<br>");
|
||||
for (Group v : netlist.getSortedGroups()) {
|
||||
sb.append(" ").append(v.getSortedNodes()).append("<br>");
|
||||
}
|
||||
sb.append("</p><br><hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "DIYLC Netlist", new Dimension(800, 600)).setVisible(true);
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "DIYLC Netlist",
|
||||
new Dimension(800, 600)).setVisible(true);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -1775,13 +1845,15 @@ public class ActionFactory {
|
||||
private ISwingUI swingUI;
|
||||
private INetlistAnalyzer summarizer;
|
||||
|
||||
public SummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistAnalyzer summarizer) {
|
||||
public SummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI,
|
||||
INetlistAnalyzer summarizer) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
this.summarizer = summarizer;
|
||||
putValue(AbstractAction.NAME, summarizer.getName());
|
||||
putValue(AbstractAction.SMALL_ICON, Enum.valueOf(IconLoader.class, summarizer.getIconName()).getIcon());
|
||||
putValue(AbstractAction.SMALL_ICON,
|
||||
Enum.valueOf(IconLoader.class, summarizer.getIconName()).getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1807,20 +1879,19 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void complete(List<Summary> res) {
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated summary is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
swingUI.showMessage("The generated summary is empty, nothing to show.",
|
||||
summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Summary summary : res) {
|
||||
sb.append("<p style=\"font-family: ").
|
||||
append(summarizer.getFontName()).
|
||||
append("; font-size: 9px\">");
|
||||
sb.append("<p style=\"font-family: ").append(summarizer.getFontName())
|
||||
.append("; font-size: 9px\">");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<b>Switch configuration: ").
|
||||
append(summary.getNetlist().getSwitchSetup()).
|
||||
append("</b><br><br>");
|
||||
sb.append("<b>Switch configuration: ").append(summary.getNetlist().getSwitchSetup())
|
||||
.append("</b><br><br>");
|
||||
|
||||
sb.append(summary.getSummary());
|
||||
|
||||
@@ -1830,7 +1901,8 @@ public class ActionFactory {
|
||||
sb.append("<hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(), new Dimension(800, 600)).setVisible(true);
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(),
|
||||
new Dimension(800, 600)).setVisible(true);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.RotateSelectionAction rotateCounterclockwiseAction;
|
||||
private ActionFactory.MirrorSelectionAction mirrorHorizontallyAction;
|
||||
private ActionFactory.MirrorSelectionAction mirrorVerticallyAction;
|
||||
private ActionFactory.FlexibleLeadsAction flexibleLeadsAction;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private ISwingUI swingUI;
|
||||
@@ -289,6 +290,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
getRotateCounterclockwiseAction().setEnabled(enabled);
|
||||
getMirrorHorizontallyAction().setEnabled(enabled);
|
||||
getMirrorVerticallyAction().setEnabled(enabled);
|
||||
getFlexibleLeadsAction().setEnabled(enabled);
|
||||
|
||||
getSaveAsTemplateAction()
|
||||
.setEnabled(plugInPort.getSelectedComponents().size() == 1);
|
||||
@@ -453,6 +455,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
popupMenu.add(getSaveAsBlockAction());
|
||||
popupMenu.add(getExpandMenu());
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(getFlexibleLeadsAction());
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(ActionFactory.getInstance().createEditProjectAction(plugInPort));
|
||||
}
|
||||
return popupMenu;
|
||||
@@ -631,6 +635,12 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
return mirrorVerticallyAction;
|
||||
}
|
||||
|
||||
public ActionFactory.FlexibleLeadsAction getFlexibleLeadsAction() {
|
||||
if (flexibleLeadsAction == null)
|
||||
flexibleLeadsAction = ActionFactory.getInstance().createFlexibleLeadsAction(plugInPort);
|
||||
return flexibleLeadsAction;
|
||||
}
|
||||
|
||||
public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() {
|
||||
if (saveAsTemplateAction == null) {
|
||||
saveAsTemplateAction = ActionFactory.getInstance().createSaveAsTemplateAction(plugInPort);
|
||||
|
||||
@@ -76,6 +76,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.MirrorSelectionAction mirrorHorizontallyAction;
|
||||
private ActionFactory.MirrorSelectionAction mirrorVerticallyAction;
|
||||
private ActionFactory.FindAction findAction;
|
||||
private ActionFactory.FlexibleLeadsAction flexibleLeadsAction;
|
||||
|
||||
private UndoHandler<Project> undoHandler;
|
||||
|
||||
@@ -270,6 +271,12 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
return findAction;
|
||||
}
|
||||
|
||||
public ActionFactory.FlexibleLeadsAction getFlexibleLeadsAction() {
|
||||
if (flexibleLeadsAction == null)
|
||||
flexibleLeadsAction = ActionFactory.getInstance().createFlexibleLeadsAction(plugInPort);
|
||||
return flexibleLeadsAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
@@ -312,6 +319,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(getExpandSelectionImmediateAction(), EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionSameTypeAction(), EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getFlexibleLeadsAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createEditProjectAction(plugInPort), EDIT_TITLE);
|
||||
|
||||
refreshActions();
|
||||
@@ -365,6 +374,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
getMirrorVerticallyAction().setEnabled(enabled);
|
||||
getSaveAsTemplateAction().setEnabled(enabled);
|
||||
getSaveAsBlockAction().setEnabled(enabled);
|
||||
getFlexibleLeadsAction().setEnabled(enabled);
|
||||
}
|
||||
|
||||
// ClipboardOwner
|
||||
|
||||
Reference in New Issue
Block a user