add usage tips

This commit is contained in:
Branislav Stojkovic
2018-12-17 00:18:14 +01:00
parent 2bf7de07f3
commit d8b7e99044
9 changed files with 1667 additions and 1569 deletions
@@ -62,7 +62,7 @@ public enum IconLoader {
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png"), DocumentsGear(
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png");
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png");
protected String name;
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

File diff suppressed because it is too large Load Diff
@@ -1,214 +1,217 @@
/*
*
* 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.gui;
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
import java.awt.Window;
import java.io.File;
import java.util.List;
This file is part of DIYLC.
import javax.swing.Icon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;
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.
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.plugins.cloud.model.UserEntity;
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
import org.diylc.swing.gui.editor.InfoDialog;
import org.diylc.swing.gui.editor.PropertyEditorDialog;
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
import org.diylc.swing.plugins.cloud.view.LoginDialog;
import org.diylc.swing.plugins.cloud.view.UploadDialog;
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
import org.diylc.swing.plugins.file.BomDialog;
import org.diylc.swingframework.AboutDialog;
import org.diylc.swingframework.IFileChooserAccessory;
import org.diylc.swingframework.ProgressDialog;
import org.diylc.utils.BomEntry;
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.
public class DialogFactory {
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
private static DialogFactory instance;
*/
package org.diylc.swing.gui;
import java.awt.Window;
import java.io.File;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.plugins.cloud.model.UserEntity;
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
import org.diylc.swing.gui.editor.PropertyEditorDialog;
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
import org.diylc.swing.plugins.cloud.view.LoginDialog;
import org.diylc.swing.plugins.cloud.view.UploadDialog;
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
import org.diylc.swing.plugins.file.BomDialog;
import org.diylc.swingframework.AboutDialog;
import org.diylc.swingframework.IFileChooserAccessory;
import org.diylc.swingframework.ProgressDialog;
import org.diylc.utils.BomEntry;
public class DialogFactory {
private static DialogFactory instance;
private static final String PATH_KEY = "lastPath";
public static DialogFactory getInstance() {
if (instance == null) {
instance = new DialogFactory();
}
return instance;
}
private JFrame mainFrame;
private File lastDirectory;
private DialogFactory() {}
/**
* Sets the frame to be used as dialog parent. This should be called prior to any other methods in
* this class.
*
* @param mainFrame
*/
public void initialize(JFrame mainFrame) {
this.mainFrame = mainFrame;
String lastDirectoryPath = (String) ConfigurationManager.getInstance().readString(PATH_KEY, null);
if (lastDirectoryPath != null) {
lastDirectory = new File(lastDirectoryPath);
}
}
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title, boolean saveDefaults) {
return createPropertyEditorDialog(mainFrame, properties, title, saveDefaults);
}
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title, boolean saveDefaults) {
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title, saveDefaults);
return editor;
}
public BomDialog createBomDialog(List<BomEntry> bom) {
BomDialog dialog = new BomDialog(mainFrame, bom);
return dialog;
}
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = openFileChooser.showOpenDialog(mainFrame);
return processFileChooserResult(result, openFileChooser, defaultExtension);
}
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory, JFrame ownerFrame) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = openFileChooser.showOpenDialog(ownerFrame);
return processFileChooserResult(result, openFileChooser, defaultExtension);
}
public File[] showOpenMultiDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory, JFrame ownerFrame) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, true);
int result = openFileChooser.showOpenDialog(ownerFrame);
return processFileMultiChooserResult(result, openFileChooser, defaultExtension);
}
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory) {
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = saveFileChooser.showSaveDialog(owner);
return processFileChooserResult(result, saveFileChooser, defaultExtension);
}
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter, File initialFile,
String defaultExtension, IFileChooserAccessory accessory, boolean allowMultiSelect) {
if (accessory != null) {
accessory.install(fileChooser);
}
for (FileFilter filter : fileChooser.getChoosableFileFilters()) {
fileChooser.removeChoosableFileFilter(filter);
}
if (fileChooser instanceof OverwritePromptFileChooser) {
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
} else {
fileChooser.setFileFilter(fileFilter);
}
if (lastDirectory != null) {
fileChooser.setCurrentDirectory(lastDirectory);
}
fileChooser.setSelectedFile(initialFile);
if (allowMultiSelect)
fileChooser.setMultiSelectionEnabled(true);
}
private File processFileChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
fileChooser.setAccessory(null);
if (result == JFileChooser.APPROVE_OPTION) {
lastDirectory = fileChooser.getCurrentDirectory();
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
if (fileChooser.getSelectedFile().getName().contains(".")) {
return fileChooser.getSelectedFile();
} else {
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "." + defaultExtension);
}
} else {
return null;
}
}
private File[] processFileMultiChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
fileChooser.setAccessory(null);
if (result == JFileChooser.APPROVE_OPTION) {
lastDirectory = fileChooser.getCurrentDirectory();
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
return fileChooser.getSelectedFiles();
} else {
return null;
}
}
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author, String url,
String mail, String htmlContent) {
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail, htmlContent);
return dialog;
}
public UserEditDialog createUserEditDialog(UserEntity existingUser) {
UserEditDialog dialog = new UserEditDialog(mainFrame, existingUser);
return dialog;
}
public LoginDialog createLoginDialog() {
LoginDialog dialog = new LoginDialog(mainFrame);
return dialog;
}
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories,
boolean isUpdate) {
UploadDialog dialog = new UploadDialog(ownerFrame, plugInPort, categories, isUpdate);
return dialog;
}
public ChangePasswordDialog createChangePasswordDialog() {
ChangePasswordDialog dialog = new ChangePasswordDialog(mainFrame);
return dialog;
}
public ProgressDialog createProgressDialog(String title, String[] buttonCaptions, String description,
boolean useProgress) {
ProgressDialog dialog = new ProgressDialog(mainFrame, title, buttonCaptions, description, useProgress);
return dialog;
}
}
private static final String PATH_KEY = "lastPath";
public static DialogFactory getInstance() {
if (instance == null) {
instance = new DialogFactory();
}
return instance;
}
private JFrame mainFrame;
private File lastDirectory;
private DialogFactory() {}
/**
* Sets the frame to be used as dialog parent. This should be called prior to any other methods in
* this class.
*
* @param mainFrame
*/
public void initialize(JFrame mainFrame) {
this.mainFrame = mainFrame;
String lastDirectoryPath = (String) ConfigurationManager.getInstance().readString(PATH_KEY, null);
if (lastDirectoryPath != null) {
lastDirectory = new File(lastDirectoryPath);
}
}
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title,
boolean saveDefaults) {
return createPropertyEditorDialog(mainFrame, properties, title, saveDefaults);
}
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title,
boolean saveDefaults) {
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title, saveDefaults);
return editor;
}
public InfoDialog createInfoDialog(String tipKey) {
return new InfoDialog(mainFrame, tipKey);
}
public BomDialog createBomDialog(List<BomEntry> bom) {
BomDialog dialog = new BomDialog(mainFrame, bom);
return dialog;
}
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = openFileChooser.showOpenDialog(mainFrame);
return processFileChooserResult(result, openFileChooser, defaultExtension);
}
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory, JFrame ownerFrame) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = openFileChooser.showOpenDialog(ownerFrame);
return processFileChooserResult(result, openFileChooser, defaultExtension);
}
public File[] showOpenMultiDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory, JFrame ownerFrame) {
JFileChooser openFileChooser = new JFileChooser();
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, true);
int result = openFileChooser.showOpenDialog(ownerFrame);
return processFileMultiChooserResult(result, openFileChooser, defaultExtension);
}
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
IFileChooserAccessory accessory) {
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
int result = saveFileChooser.showSaveDialog(owner);
return processFileChooserResult(result, saveFileChooser, defaultExtension);
}
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter, File initialFile,
String defaultExtension, IFileChooserAccessory accessory, boolean allowMultiSelect) {
if (accessory != null) {
accessory.install(fileChooser);
}
for (FileFilter filter : fileChooser.getChoosableFileFilters()) {
fileChooser.removeChoosableFileFilter(filter);
}
if (fileChooser instanceof OverwritePromptFileChooser) {
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
} else {
fileChooser.setFileFilter(fileFilter);
}
if (lastDirectory != null) {
fileChooser.setCurrentDirectory(lastDirectory);
}
fileChooser.setSelectedFile(initialFile);
if (allowMultiSelect)
fileChooser.setMultiSelectionEnabled(true);
}
private File processFileChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
fileChooser.setAccessory(null);
if (result == JFileChooser.APPROVE_OPTION) {
lastDirectory = fileChooser.getCurrentDirectory();
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
if (fileChooser.getSelectedFile().getName().contains(".")) {
return fileChooser.getSelectedFile();
} else {
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "." + defaultExtension);
}
} else {
return null;
}
}
private File[] processFileMultiChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
fileChooser.setAccessory(null);
if (result == JFileChooser.APPROVE_OPTION) {
lastDirectory = fileChooser.getCurrentDirectory();
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
return fileChooser.getSelectedFiles();
} else {
return null;
}
}
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author, String url,
String mail, String htmlContent) {
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail, htmlContent);
return dialog;
}
public UserEditDialog createUserEditDialog(UserEntity existingUser) {
UserEditDialog dialog = new UserEditDialog(mainFrame, existingUser);
return dialog;
}
public LoginDialog createLoginDialog() {
LoginDialog dialog = new LoginDialog(mainFrame);
return dialog;
}
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories,
boolean isUpdate) {
UploadDialog dialog = new UploadDialog(ownerFrame, plugInPort, categories, isUpdate);
return dialog;
}
public ChangePasswordDialog createChangePasswordDialog() {
ChangePasswordDialog dialog = new ChangePasswordDialog(mainFrame);
return dialog;
}
public ProgressDialog createProgressDialog(String title, String[] buttonCaptions, String description,
boolean useProgress) {
ProgressDialog dialog = new ProgressDialog(mainFrame, title, buttonCaptions, description, useProgress);
return dialog;
}
}
@@ -0,0 +1,72 @@
/*
*
* 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.gui.editor;
import java.awt.Dimension;
import java.util.Arrays;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.images.IconLoader;
import org.diylc.swingframework.ButtonDialog;
public class InfoDialog extends ButtonDialog {
private static final long serialVersionUID = 1L;
private String message;
private String tipKey;
public InfoDialog(JFrame owner, String tipKey) {
super(owner, "Usage Tip", new String[] {"OK", "Dismiss"});
this.tipKey = tipKey;
int index = Arrays.asList(tipKeys).indexOf(tipKey);
this.message = messages[index];
setMinimumSize(new Dimension(240, 40));
layoutGui();
setLocationRelativeTo(owner);
}
@Override
protected JComponent getMainComponent() {
JLabel label = new JLabel("<html>" + message + "</html>");
label.setIcon(IconLoader.Help.getIcon());
label.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
label.setIconTextGap(8);
return label;
}
@Override
public void setVisible(boolean b) {
if (!b && getSelectedButtonCaption() == "Dismiss")
ConfigurationManager.getInstance().writeValue(tipKey + ".dismissed", true);
super.setVisible(b);
}
private static String[] tipKeys = new String[] {IPlugInPort.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."};
}
@@ -1,140 +1,136 @@
/*
*
* 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.config;
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.EnumSet;
This file is part of DIYLC.
import org.apache.log4j.Logger;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.components.autocreate.SolderPadAutoCreator;
import org.diylc.core.Theme;
import org.diylc.images.IconLoader;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
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.
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
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.
/**
* Controls configuration menu.
*
* @author Branislav Stojkovic
*/
public class ConfigPlugin implements IPlugIn {
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
private static final Logger LOG = Logger.getLogger(ConfigPlugin.class);
*/
package org.diylc.swing.plugins.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.EnumSet;
import org.apache.log4j.Logger;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.components.autocreate.SolderPadAutoCreator;
import org.diylc.core.Theme;
import org.diylc.images.IconLoader;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
/**
* Controls configuration menu.
*
* @author Branislav Stojkovic
*/
public class ConfigPlugin implements IPlugIn {
private static final Logger LOG = Logger.getLogger(ConfigPlugin.class);
private static final String CONFIG_MENU = "Config";
private static final String THEME_MENU = "Theme";
private static final String COMPONENT_BROWSER_MENU = "Toolbox";
public static final String COMPONENT_BROWSER = "componentBrowser";
public static final String SEARCHABLE_TREE = "Searchable Tree";
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
private ISwingUI swingUI;
public ConfigPlugin(ISwingUI swingUI) {
super();
this.swingUI = swingUI;
}
@Override
public void connect(IPlugInPort plugInPort) {
swingUI.injectMenuAction(
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Anti-Aliasing", IPlugInPort.ANTI_ALIASING_KEY, true), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Create Pads",
SolderPadAutoCreator.AUTO_PADS_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Edit Mode", IPlugInPort.AUTO_EDIT_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Continuous Creation",
IPlugInPort.CONTINUOUS_CREATION_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Show Rulers", IPlugInPort.SHOW_RULERS_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Show Grid", IPlugInPort.SHOW_GRID_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Export Grid", IPlugInPort.EXPORT_GRID_KEY, false),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Hi-Quality Rendering",
IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY,
false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Outline Mode", IPlugInPort.OUTLINE_KEY, false),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
private static final String CONFIG_MENU = "Config";
private static final String THEME_MENU = "Theme";
private static final String COMPONENT_BROWSER_MENU = "Toolbox";
public static final String COMPONENT_BROWSER = "componentBrowser";
public static final String SEARCHABLE_TREE = "Searchable Tree";
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
private ISwingUI swingUI;
public ConfigPlugin(ISwingUI swingUI) {
super();
this.swingUI = swingUI;
}
@Override
public void connect(IPlugInPort plugInPort) {
swingUI.injectMenuAction(
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Highlight Connected Areas", IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, false), CONFIG_MENU);
File themeDir = new File("themes");
if (themeDir.exists()) {
XStream xStream = new XStream(new DomDriver());
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
for (File file : themeDir.listFiles()) {
if (file.getName().toLowerCase().endsWith(".xml")) {
try {
InputStream in = new FileInputStream(file);
Theme theme = (Theme) xStream.fromXML(in);
LOG.debug("Found theme: " + theme.getName());
swingUI.injectMenuAction(ActionFactory.getInstance().createThemeAction(plugInPort, theme), THEME_MENU);
} catch (Exception e) {
LOG.error("Could not load theme file " + file.getName(), e);
}
}
}
}
swingUI.injectSubmenu(COMPONENT_BROWSER_MENU, IconLoader.Hammer.getIcon(), CONFIG_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(SEARCHABLE_TREE),
COMPONENT_BROWSER_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
COMPONENT_BROWSER_MENU);
}
@Override
public EnumSet<EventType> getSubscribedEventTypes() {
return EnumSet.noneOf(EventType.class);
}
@Override
public void processMessage(EventType eventType, Object... params) {}
}
.createConfigAction(plugInPort, "Anti-Aliasing", IPlugInPort.ANTI_ALIASING_KEY, true), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Create Pads",
SolderPadAutoCreator.AUTO_PADS_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Edit Mode", IPlugInPort.AUTO_EDIT_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Continuous Creation",
IPlugInPort.CONTINUOUS_CREATION_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Show Rulers", IPlugInPort.SHOW_RULERS_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Show Grid", IPlugInPort.SHOW_GRID_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Export Grid", IPlugInPort.EXPORT_GRID_KEY, false),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Hi-Quality Rendering",
IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY,
false), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Outline Mode", IPlugInPort.OUTLINE_KEY, false),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true),
CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
swingUI.injectMenuAction(
ActionFactory.getInstance().createConfigAction(plugInPort, "Highlight Connected Areas",
IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, false, IPlugInPort.HIGHLIGHT_CONTINUITY_AREA), CONFIG_MENU);
File themeDir = new File("themes");
if (themeDir.exists()) {
XStream xStream = new XStream(new DomDriver());
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
for (File file : themeDir.listFiles()) {
if (file.getName().toLowerCase().endsWith(".xml")) {
try {
InputStream in = new FileInputStream(file);
Theme theme = (Theme) xStream.fromXML(in);
LOG.debug("Found theme: " + theme.getName());
swingUI.injectMenuAction(ActionFactory.getInstance().createThemeAction(plugInPort, theme), THEME_MENU);
} catch (Exception e) {
LOG.error("Could not load theme file " + file.getName(), e);
}
}
}
}
swingUI.injectSubmenu(COMPONENT_BROWSER_MENU, IconLoader.Hammer.getIcon(), CONFIG_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(SEARCHABLE_TREE),
COMPONENT_BROWSER_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
COMPONENT_BROWSER_MENU);
}
@Override
public EnumSet<EventType> getSubscribedEventTypes() {
return EnumSet.noneOf(EventType.class);
}
@Override
public void processMessage(EventType eventType, Object... params) {}
}