mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Extract 'Analyze' menu, move 'Highlight Connected Areas' feature from 'Config' menu to 'Analyze' menu
This commit is contained in:
@@ -78,7 +78,6 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
public static final String RECENT_FILES_KEY = "recentFiles";
|
||||
public static final String SHOW_RULERS_KEY = "showRulers";
|
||||
public static final String SHOW_GRID_KEY = "showGrid";
|
||||
public static final String HIGHLIGHT_CONTINUITY_AREA = "highlightContinuityArea";
|
||||
public static final String HARDWARE_ACCELERATION = "hardwareAcceleration";
|
||||
public static final String EXTRA_SPACE_KEY = "extraSpace";
|
||||
public static final String FAVORITES_KEY = "favorites";
|
||||
@@ -400,4 +399,16 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
* @param threshold
|
||||
*/
|
||||
List<Area> checkContinuityAreaProximity(Size threshold);
|
||||
|
||||
/**
|
||||
* @return the current operation mode of the application
|
||||
*/
|
||||
OperationMode getOperationMode();
|
||||
|
||||
/**
|
||||
* Updates the current operation mode of the application
|
||||
*
|
||||
* @param operationMode
|
||||
*/
|
||||
void setOperationMode(OperationMode operationMode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.diylc.common;
|
||||
|
||||
public enum OperationMode {
|
||||
EDIT, HIGHLIGHT_CONNECTED_AREAS
|
||||
}
|
||||
@@ -59,17 +59,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentFilter;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
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.*;
|
||||
import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDatasheetSupport;
|
||||
@@ -99,7 +89,7 @@ import org.diylc.utils.ReflectionUtils;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class Presenter implements IPlugInPort, IConfigListener {
|
||||
public class Presenter implements IPlugInPort {
|
||||
|
||||
private static final String REACHED_BOTTOM =
|
||||
LangUtil.translate("Selected component(s) have reached the bottom of their layer. Do you want to force the selection to the back?");
|
||||
@@ -183,6 +173,8 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
|
||||
private DIYTest test = null;
|
||||
|
||||
private OperationMode operationMode;
|
||||
|
||||
public Presenter(IView view, IConfigurationManager<?> configManager) {
|
||||
this(view, configManager, false);
|
||||
}
|
||||
@@ -212,8 +204,6 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
variantManager.importDefaultVariants();
|
||||
buildingBlockManager.importDefaultBlocks();
|
||||
}
|
||||
|
||||
this.configManager.addConfigListener(HIGHLIGHT_CONTINUITY_AREA, this);
|
||||
}
|
||||
|
||||
public void installPlugin(Supplier<IPlugIn> plugInSupplier) {
|
||||
@@ -258,7 +248,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
@Override
|
||||
public Cursor getCursorAt(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||
// Only change the cursor if we're not making a new component.
|
||||
if (configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false) || altDown)
|
||||
if (operationMode == OperationMode.HIGHLIGHT_CONNECTED_AREAS || altDown)
|
||||
return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
|
||||
if (instantiationManager.getComponentTypeSlot() == null) {
|
||||
// Scale point to remove zoom factor.
|
||||
@@ -268,7 +258,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
}
|
||||
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
||||
if (!isComponentLocked(component) && isComponentVisible(component)
|
||||
&& !configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false)) {
|
||||
&& operationMode != OperationMode.HIGHLIGHT_CONNECTED_AREAS) {
|
||||
ComponentArea area = drawingManager.getComponentArea(component);
|
||||
if (area != null && area.getOutlineArea() != null && scaledPoint != null && area.getOutlineArea().contains(scaledPoint)) {
|
||||
return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
|
||||
@@ -610,7 +600,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
default:
|
||||
LOG.error("Unknown creation method: " + componentTypeSlot.getCreationMethod());
|
||||
}
|
||||
} else if (configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false) || altDown) {
|
||||
} else if (operationMode == OperationMode.HIGHLIGHT_CONNECTED_AREAS || altDown) {
|
||||
drawingManager.findContinuityAreaAtPoint(scaledPoint);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else {
|
||||
@@ -1084,8 +1074,8 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
dragAction == DnDConstants.ACTION_LINK, dragAction == DnDConstants.ACTION_MOVE, 1);
|
||||
return;
|
||||
}
|
||||
if (configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false)) {
|
||||
LOG.debug("Cannot start drag in hightlight continuity mode.");
|
||||
if (operationMode == OperationMode.HIGHLIGHT_CONNECTED_AREAS) {
|
||||
LOG.debug("Cannot start drag in highlight continuity mode.");
|
||||
return;
|
||||
}
|
||||
this.dragInProgress = true;
|
||||
@@ -1243,7 +1233,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
test.addStep(DIYTest.DRAG_OVER, params);
|
||||
}
|
||||
|
||||
if (point == null || configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false)) {
|
||||
if (point == null || operationMode == OperationMode.HIGHLIGHT_CONNECTED_AREAS) {
|
||||
return false;
|
||||
}
|
||||
Point2D scaledPoint = scalePoint(point);
|
||||
@@ -1558,7 +1548,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
new Point((int)previousDragPoint.getX(), (int)previousDragPoint.getY()));;
|
||||
}
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
|
||||
if (!configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false))
|
||||
if (operationMode != OperationMode.HIGHLIGHT_CONNECTED_AREAS)
|
||||
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
||||
if (!isComponentLocked(component) && isComponentVisible(component)) {
|
||||
ComponentArea area = drawingManager.getComponentArea(component);
|
||||
@@ -2748,7 +2738,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<INetlistAnalyzer>() {
|
||||
result.sort(new Comparator<INetlistAnalyzer>() {
|
||||
|
||||
@Override
|
||||
public int compare(INetlistAnalyzer o1, INetlistAnalyzer o2) {
|
||||
@@ -2804,17 +2794,20 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
return drawingManager.getContinuityAreaProximity((float)threshold.convertToPixels());
|
||||
}
|
||||
|
||||
// IConfigListener
|
||||
@Override
|
||||
public OperationMode getOperationMode() {
|
||||
return operationMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(String configKey, Object value) {
|
||||
if (HIGHLIGHT_CONTINUITY_AREA.equalsIgnoreCase(configKey)) {
|
||||
drawingManager.clearContinuityArea();
|
||||
if (Boolean.TRUE.equals(value)) {
|
||||
drawingManager.clearComponentAreaMap();
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
public void setOperationMode(OperationMode operationMode) {
|
||||
this.operationMode = operationMode;
|
||||
drawingManager.clearContinuityArea();
|
||||
if (OperationMode.HIGHLIGHT_CONNECTED_AREAS == operationMode) {
|
||||
drawingManager.clearComponentAreaMap();
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
messageDispatcher.dispatchMessage(EventType.STATUS_MESSAGE_CHANGED);
|
||||
}
|
||||
|
||||
protected MessageDispatcher<EventType> getMessageDispatcher() {
|
||||
|
||||
@@ -317,6 +317,14 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added Windows zip file distribution in addition to the installer.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Moved 'Analyze' functions from 'File' menu to their own menu for faster access</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Moved 'Highlight Connected Areas' feature from 'Config' menu to 'Analyze' menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Fully configurable colors for 'Mini Toggle Switch' components</description>
|
||||
|
||||
@@ -117,9 +117,6 @@ public class DIYLCStarter {
|
||||
LOG.info("Running in export mode with params: " + String.join(", ", args));
|
||||
}
|
||||
|
||||
// disable HIGHLIGHT_CONTINUITY_AREA config, keep it transient
|
||||
ConfigurationManager.getInstance().writeValue(IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, false);
|
||||
|
||||
LOG.info("Loading languages...");
|
||||
|
||||
LangUtil.configure();
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import javax.swing.Icon;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.swing.actions.analyze.HighlightConnectedAreasAction;
|
||||
import org.diylc.swingframework.IDrawingProvider;
|
||||
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
@@ -34,9 +35,9 @@ import org.diylc.swing.actions.ExportGerberAction;
|
||||
import org.diylc.swing.actions.ExportPNGAction;
|
||||
import org.diylc.swing.actions.FindAction;
|
||||
import org.diylc.swing.actions.FlexibleLeadsAction;
|
||||
import org.diylc.swing.actions.GenerateNetlistAction;
|
||||
import org.diylc.swing.actions.analyze.GenerateNetlistAction;
|
||||
import org.diylc.swing.actions.RenumberAction;
|
||||
import org.diylc.swing.actions.SummarizeNetlistAction;
|
||||
import org.diylc.swing.actions.analyze.SummarizeNetlistAction;
|
||||
import org.diylc.swing.actions.ThemeAction;
|
||||
import org.diylc.swing.actions.ToggleAction;
|
||||
import org.diylc.swing.actions.edit.BringToFrontAction;
|
||||
@@ -247,11 +248,6 @@ public class ActionFactory {
|
||||
return new ConfigAction(plugInPort, title, configKey, defaultValue);
|
||||
}
|
||||
|
||||
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) {
|
||||
return new ToggleAction(title, configKey, groupName, defaultValue, null);
|
||||
@@ -287,4 +283,8 @@ public class ActionFactory {
|
||||
public CheckProximityAction createCheckProximityAction(IPlugInPort plugInPort, ISwingUI swingUI) {
|
||||
return new CheckProximityAction(plugInPort, swingUI);
|
||||
}
|
||||
|
||||
public HighlightConnectedAreasAction createHighlightConnectedAreasAction(IPlugInPort plugInPort) {
|
||||
return new HighlightConnectedAreasAction(plugInPort);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.diylc.swing.actions;
|
||||
package org.diylc.swing.actions.analyze;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package org.diylc.swing.actions.analyze;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.OperationMode;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.utils.IconLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class HighlightConnectedAreasAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final IPlugInPort plugInPort;
|
||||
|
||||
public HighlightConnectedAreasAction(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
|
||||
putValue(AbstractAction.NAME, "Highlight Connected Areas");
|
||||
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||
putValue(AbstractAction.SELECTED_KEY,
|
||||
plugInPort.getOperationMode() == OperationMode.HIGHLIGHT_CONNECTED_AREAS);
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.LaserPointer.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (Boolean.TRUE.equals(getValue(AbstractAction.SELECTED_KEY))) {
|
||||
plugInPort.setOperationMode(OperationMode.HIGHLIGHT_CONNECTED_AREAS);
|
||||
} else {
|
||||
plugInPort.setOperationMode(OperationMode.EDIT);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshState() {
|
||||
putValue(AbstractAction.SELECTED_KEY,
|
||||
plugInPort.getOperationMode() == OperationMode.HIGHLIGHT_CONNECTED_AREAS);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.diylc.swing.actions;
|
||||
package org.diylc.swing.actions.analyze;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -68,7 +68,7 @@ public class InfoDialog extends ButtonDialog {
|
||||
super.setVisible(b);
|
||||
}
|
||||
|
||||
private static String[] tipKeys = new String[] {IPlugInPort.HIGHLIGHT_CONTINUITY_AREA};
|
||||
private static String[] tipKeys = new String[] {"HIGHLIGHT_CONTINUITY_AREA"};
|
||||
private static String[] messages =
|
||||
new String[] {"Click on a component to highlight continuity area directly or indirectly connected to it.<br>In this mode components cannot be moved or edited. In order to continue editing,<br>this mode needs to be switched OFF."};
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.swing.IDynamicSubmenuHandler;
|
||||
import org.diylc.swing.plugins.analyze.AnalyzeMenuPlugin;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
import org.diylc.common.BadPositionException;
|
||||
@@ -126,6 +127,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
||||
|
||||
presenter.installPlugin(() -> new ToolBox(this));
|
||||
presenter.installPlugin(() -> new FileMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new AnalyzeMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new EditMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new ConfigPlugin(this));
|
||||
presenter.installPlugin(() -> new LayersMenuPlugin(this));
|
||||
|
||||
+19
-11
@@ -29,6 +29,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@@ -38,11 +39,7 @@ import javax.swing.SwingUtilities;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.*;
|
||||
import org.diylc.lang.LangUtil;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
@@ -68,6 +65,7 @@ public class ActionBarPlugin implements IPlugIn {
|
||||
|
||||
private static final String DONATE_HTML = LangUtil.translate("Enjoying DIYLC? Click here to buy me a coffee :)");
|
||||
private static final String DONATE_HTML_SHORT = LangUtil.translate("Donate");
|
||||
private Consumer<Boolean> highlightConnectedAreasUpdateAction;
|
||||
|
||||
public ActionBarPlugin(ISwingUI swingUI) {
|
||||
this.swingUI = swingUI;
|
||||
@@ -165,7 +163,14 @@ public class ActionBarPlugin implements IPlugIn {
|
||||
configToolbar.add(new JLabel(" "));
|
||||
|
||||
configToolbar.add(LangUtil.translate("Continuous Creation"), IPlugInPort.CONTINUOUS_CREATION_KEY, IconLoader.Elements.getIcon(), false);
|
||||
configToolbar.add(LangUtil.translate("Highlight Connected Areas") + " (Alt)", IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, IconLoader.LaserPointer.getIcon(), false);
|
||||
highlightConnectedAreasUpdateAction =
|
||||
configToolbar.add(LangUtil.translate("Highlight Connected Areas") + " (Alt)",
|
||||
IconLoader.LaserPointer.getIcon(),
|
||||
plugInPort.getOperationMode() == OperationMode.HIGHLIGHT_CONNECTED_AREAS,
|
||||
() -> plugInPort.setOperationMode(
|
||||
plugInPort.getOperationMode() == OperationMode.EDIT ?
|
||||
OperationMode.HIGHLIGHT_CONNECTED_AREAS :
|
||||
OperationMode.EDIT));
|
||||
configToolbar.add(LangUtil.translate("Sticky Points") + " (Ctrl)", IPlugInPort.STICKY_POINTS_KEY, IconLoader.GraphNodes.getIcon(), true);
|
||||
}
|
||||
return configToolbar;
|
||||
@@ -207,14 +212,17 @@ public class ActionBarPlugin implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED);
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED, EventType.STATUS_MESSAGE_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processMessage(EventType eventType, Object... params) {
|
||||
if (eventType != EventType.SELECTION_CHANGED)
|
||||
return;
|
||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||
getContextActionToolbar().setEnabled(enabled);
|
||||
if (eventType == EventType.SELECTION_CHANGED) {
|
||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||
getContextActionToolbar().setEnabled(enabled);
|
||||
} else if (eventType == EventType.STATUS_MESSAGE_CHANGED) {
|
||||
highlightConnectedAreasUpdateAction.accept(plugInPort.getOperationMode() ==
|
||||
OperationMode.HIGHLIGHT_CONNECTED_AREAS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
@@ -33,6 +36,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
public class ConfigToolbar extends JPanel {
|
||||
|
||||
@@ -74,6 +78,32 @@ public class ConfigToolbar extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public Consumer<Boolean> add(String title, Icon icon, boolean defaultState, Runnable toggleAction) {
|
||||
final JLabel label = new JLabel();
|
||||
label.setText(defaultState ? CHECK : UNCHECK);
|
||||
label.setIcon(icon);
|
||||
label.setToolTipText(title);
|
||||
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
toggleAction.run();
|
||||
}
|
||||
});
|
||||
add(label);
|
||||
|
||||
// ConfigurationManager.getInstance().addConfigListener(configKey, new IConfigListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void valueChanged(String key, Object value) {
|
||||
// boolean checked = (boolean) value;
|
||||
// label.setText(checked ? CHECK : UNCHECK);
|
||||
// }
|
||||
// });
|
||||
return (checked) -> label.setText(checked ? CHECK : UNCHECK);
|
||||
}
|
||||
|
||||
public void addToggleLabel(String text, String configKey, String defaultValue, List<ToggleItem> items) {
|
||||
ToggleConfigLabel label = new ToggleConfigLabel(text, configKey, defaultValue, items);
|
||||
add(label);
|
||||
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
*
|
||||
* 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.swing.plugins.analyze;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.*;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.IDynamicSubmenuHandler;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.actions.analyze.HighlightConnectedAreasAction;
|
||||
import org.diylc.swing.loadline.LoadlineEditorFrame;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
import org.diylc.swing.plugins.file.TraceMaskDrawingProvider;
|
||||
import org.diylc.utils.IconLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entry point class for Analyze toors.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class AnalyzeMenuPlugin implements IPlugIn {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(AnalyzeMenuPlugin.class);
|
||||
|
||||
private static final String ANALYZE_TITLE = "Analyze";
|
||||
private static final String EXPORT_TITLE = "Export";
|
||||
|
||||
private ISwingUI swingUI;
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
private HighlightConnectedAreasAction highlightConnectedAreasAction;
|
||||
|
||||
public AnalyzeMenuPlugin(ISwingUI swingUI) {
|
||||
super();
|
||||
this.swingUI = swingUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
|
||||
ActionFactory actionFactory = ActionFactory.getInstance();
|
||||
List<Action> menuActions = new ArrayList<>();
|
||||
|
||||
// Add all menu actions to the list
|
||||
menuActions.add(actionFactory.createCheckProximityAction(plugInPort, swingUI));
|
||||
menuActions.add(actionFactory.createBomAction(plugInPort));
|
||||
menuActions.add(actionFactory.createGenerateNetlistAction(plugInPort, swingUI, false));
|
||||
menuActions.add(actionFactory.createGenerateNetlistAction(plugInPort, swingUI, true));
|
||||
highlightConnectedAreasAction =
|
||||
actionFactory.createHighlightConnectedAreasAction(plugInPort);
|
||||
menuActions.add(highlightConnectedAreasAction);
|
||||
|
||||
List<INetlistAnalyzer> summarizers = plugInPort.getNetlistAnalyzers();
|
||||
if (summarizers != null) {
|
||||
for (INetlistAnalyzer summarizer : summarizers) {
|
||||
if (summarizer.getSwitchPreference().contains(NetlistSwitchPreference.WITH)) {
|
||||
menuActions.add(actionFactory.createSummarizeNetlistAction(plugInPort, swingUI, summarizer, true));
|
||||
}
|
||||
if (summarizer.getSwitchPreference().contains(NetlistSwitchPreference.WITHOUT)) {
|
||||
menuActions.add(actionFactory.createSummarizeNetlistAction(plugInPort, swingUI, summarizer, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort actions by name
|
||||
menuActions.sort((a1, a2) -> {
|
||||
String name1 = (String) a1.getValue(Action.NAME);
|
||||
String name2 = (String) a2.getValue(Action.NAME);
|
||||
return name1.compareTo(name2);
|
||||
});
|
||||
|
||||
// Inject sorted actions
|
||||
for (Action action : menuActions) {
|
||||
swingUI.injectMenuAction(action, ANALYZE_TITLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.STATUS_MESSAGE_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processMessage(EventType eventType, Object... params) {
|
||||
if (eventType == EventType.STATUS_MESSAGE_CHANGED) {
|
||||
highlightConnectedAreasAction.refreshState();;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,15 +187,6 @@ public class CanvasPlugin implements IPlugIn{
|
||||
}
|
||||
});
|
||||
|
||||
configManager.addConfigListener(IPlugInPort.HIGHLIGHT_CONTINUITY_AREA,
|
||||
new IConfigListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
canvasPanel.repaint();
|
||||
}
|
||||
});
|
||||
|
||||
getScrollPane().getViewport().setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,13 +107,10 @@ public class ConfigPlugin implements IPlugIn {
|
||||
swingUI.injectMenuAction(
|
||||
ActionFactory.getInstance().createConfigAction(plugInPort, "Hi-Quality Rendering",
|
||||
IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
||||
swingUI.injectMenuAction(
|
||||
ActionFactory.getInstance().createConfigAction(plugInPort, "Highlight Connected Areas", IPlugInPort.HIGHLIGHT_CONTINUITY_AREA,
|
||||
false), CONFIG_MENU);
|
||||
|
||||
try {
|
||||
List<Language> languages = LangUtil.getAvailableLanguages();
|
||||
if (languages != null && languages.size() > 0) {
|
||||
if (languages != null && !languages.isEmpty()) {
|
||||
swingUI.injectSubmenu(LANGUAGE_MENU, IconLoader.Earth.getIcon(), CONFIG_MENU);
|
||||
for(Language language : languages) {
|
||||
Icon icon = null;
|
||||
|
||||
@@ -44,7 +44,6 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
|
||||
private static final String FILE_TITLE = "File";
|
||||
private static final String TRACE_MASK_TITLE = "Trace Mask";
|
||||
private static final String INTEGRATION_TITLE = "Integration";
|
||||
private static final String ANALYZE_TITLE = "Analyze";
|
||||
private static final String EXPORT_TITLE = "Export";
|
||||
|
||||
private ProjectDrawingProvider drawingProvider;
|
||||
@@ -93,31 +92,6 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() | KeyEvent.SHIFT_DOWN_MASK),
|
||||
TRACE_MASK_TITLE);
|
||||
|
||||
swingUI.injectSubmenu(ANALYZE_TITLE, IconLoader.Scientist.getIcon(), FILE_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createCheckProximityAction(plugInPort, swingUI),
|
||||
ANALYZE_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createBomAction(plugInPort), ANALYZE_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createGenerateNetlistAction(plugInPort, swingUI, false),
|
||||
ANALYZE_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createGenerateNetlistAction(plugInPort, swingUI, true),
|
||||
ANALYZE_TITLE);
|
||||
|
||||
List<INetlistAnalyzer> summarizers = plugInPort.getNetlistAnalyzers();
|
||||
if (summarizers != null) {
|
||||
for (INetlistAnalyzer summarizer : summarizers) {
|
||||
if (summarizer.getSwitchPreference().contains(NetlistSwitchPreference.WITH)) {
|
||||
swingUI.injectMenuAction(
|
||||
actionFactory.createSummarizeNetlistAction(plugInPort, swingUI, summarizer, true),
|
||||
ANALYZE_TITLE);
|
||||
}
|
||||
if (summarizer.getSwitchPreference().contains(NetlistSwitchPreference.WITHOUT)) {
|
||||
swingUI.injectMenuAction(
|
||||
actionFactory.createSummarizeNetlistAction(plugInPort, swingUI, summarizer, false),
|
||||
ANALYZE_TITLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
swingUI.injectMenuAction(null, FILE_TITLE);
|
||||
swingUI.injectSubmenu(INTEGRATION_TITLE, IconLoader.Node.getIcon(), FILE_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createImportBlocksAction(swingUI, plugInPort),
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.appframework.update.UpdateChecker;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.common.*;
|
||||
import org.diylc.swingframework.MemoryBar;
|
||||
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
||||
import org.diylc.swingframework.update.UpdateDialog;
|
||||
@@ -61,12 +62,6 @@ import org.diylc.swingframework.update.UpdateLabel;
|
||||
import net.java.balloontip.BalloonTip;
|
||||
import net.java.balloontip.styles.EdgedBalloonStyle;
|
||||
import org.diylc.announcements.AnnouncementProvider;
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.lang.LangUtil;
|
||||
@@ -192,14 +187,6 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
refreshPosition((Boolean)value);
|
||||
}
|
||||
});
|
||||
|
||||
ConfigurationManager.getInstance().addConfigListener(IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, new IConfigListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
refreshStatusText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JComboBox<Double> getZoomBox() {
|
||||
@@ -494,7 +481,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
refreshStatusText();
|
||||
break;
|
||||
case STATUS_MESSAGE_CHANGED:
|
||||
statusMessage = (String) params[0];
|
||||
statusMessage = params.length > 0 ? (String) params[0] : null;
|
||||
refreshStatusText();
|
||||
break;
|
||||
case MOUSE_MOVED:
|
||||
@@ -569,8 +556,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
}
|
||||
|
||||
// override any other status with this when in highlight mode, as we cannot do anything else
|
||||
Boolean highlightConnectedAreasMode = ConfigurationManager.getInstance().readBoolean(IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, false);
|
||||
if (highlightConnectedAreasMode)
|
||||
if (plugInPort.getOperationMode() == OperationMode.HIGHLIGHT_CONNECTED_AREAS)
|
||||
statusText = HIGHLIGHT_CONNECTED_TIP;
|
||||
|
||||
final String finalStatus = statusText;
|
||||
|
||||
Reference in New Issue
Block a user