mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
add usage tips
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<property name="jar.dir" value="${build.dir}/jar" />
|
<property name="jar.dir" value="${build.dir}/jar" />
|
||||||
<property name="report.dir" value="${build.dir}/junitreport" />
|
<property name="report.dir" value="${build.dir}/junitreport" />
|
||||||
<property name="main.class" value="org.diylc.DIYLCStarter" />
|
<property name="main.class" value="org.diylc.DIYLCStarter" />
|
||||||
<property name="diylc.version" value="3.42.0" />
|
<property name="diylc.version" value="3.42.1" />
|
||||||
|
|
||||||
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
|
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
|
||||||
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
|
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
|
||||||
|
|||||||
Binary file not shown.
@@ -62,7 +62,7 @@ public enum IconLoader {
|
|||||||
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
|
"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(
|
"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(
|
"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;
|
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).
|
import java.awt.Window;
|
||||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
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
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
it under the terms of the GNU General Public License as published by
|
import org.diylc.common.IPlugInPort;
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
import org.diylc.common.PropertyWrapper;
|
||||||
(at your option) any later version.
|
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,
|
public class DialogFactory {
|
||||||
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
|
private static DialogFactory instance;
|
||||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
private static final String PATH_KEY = "lastPath";
|
||||||
package org.diylc.swing.gui;
|
|
||||||
|
public static DialogFactory getInstance() {
|
||||||
import java.awt.Window;
|
if (instance == null) {
|
||||||
import java.io.File;
|
instance = new DialogFactory();
|
||||||
import java.util.List;
|
}
|
||||||
|
return instance;
|
||||||
import javax.swing.Icon;
|
}
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JFrame;
|
private JFrame mainFrame;
|
||||||
import javax.swing.filechooser.FileFilter;
|
private File lastDirectory;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
private DialogFactory() {}
|
||||||
import org.diylc.common.IPlugInPort;
|
|
||||||
import org.diylc.common.PropertyWrapper;
|
/**
|
||||||
import org.diylc.plugins.cloud.model.UserEntity;
|
* Sets the frame to be used as dialog parent. This should be called prior to any other methods in
|
||||||
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
|
* this class.
|
||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
*
|
||||||
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
* @param mainFrame
|
||||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
*/
|
||||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
public void initialize(JFrame mainFrame) {
|
||||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
this.mainFrame = mainFrame;
|
||||||
import org.diylc.swing.plugins.file.BomDialog;
|
String lastDirectoryPath = (String) ConfigurationManager.getInstance().readString(PATH_KEY, null);
|
||||||
import org.diylc.swingframework.AboutDialog;
|
if (lastDirectoryPath != null) {
|
||||||
import org.diylc.swingframework.IFileChooserAccessory;
|
lastDirectory = new File(lastDirectoryPath);
|
||||||
import org.diylc.swingframework.ProgressDialog;
|
}
|
||||||
import org.diylc.utils.BomEntry;
|
}
|
||||||
|
|
||||||
public class DialogFactory {
|
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title,
|
||||||
|
boolean saveDefaults) {
|
||||||
private static DialogFactory instance;
|
return createPropertyEditorDialog(mainFrame, properties, title, saveDefaults);
|
||||||
|
}
|
||||||
private static final String PATH_KEY = "lastPath";
|
|
||||||
|
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title,
|
||||||
public static DialogFactory getInstance() {
|
boolean saveDefaults) {
|
||||||
if (instance == null) {
|
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title, saveDefaults);
|
||||||
instance = new DialogFactory();
|
return editor;
|
||||||
}
|
}
|
||||||
return instance;
|
|
||||||
}
|
public InfoDialog createInfoDialog(String tipKey) {
|
||||||
|
return new InfoDialog(mainFrame, tipKey);
|
||||||
private JFrame mainFrame;
|
}
|
||||||
private File lastDirectory;
|
|
||||||
|
public BomDialog createBomDialog(List<BomEntry> bom) {
|
||||||
private DialogFactory() {}
|
BomDialog dialog = new BomDialog(mainFrame, bom);
|
||||||
|
return dialog;
|
||||||
/**
|
}
|
||||||
* Sets the frame to be used as dialog parent. This should be called prior to any other methods in
|
|
||||||
* this class.
|
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
*
|
IFileChooserAccessory accessory) {
|
||||||
* @param mainFrame
|
JFileChooser openFileChooser = new JFileChooser();
|
||||||
*/
|
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
||||||
public void initialize(JFrame mainFrame) {
|
|
||||||
this.mainFrame = mainFrame;
|
int result = openFileChooser.showOpenDialog(mainFrame);
|
||||||
String lastDirectoryPath = (String) ConfigurationManager.getInstance().readString(PATH_KEY, null);
|
|
||||||
if (lastDirectoryPath != null) {
|
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
||||||
lastDirectory = new File(lastDirectoryPath);
|
}
|
||||||
}
|
|
||||||
}
|
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
|
IFileChooserAccessory accessory, JFrame ownerFrame) {
|
||||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
JFileChooser openFileChooser = new JFileChooser();
|
||||||
return createPropertyEditorDialog(mainFrame, properties, title, saveDefaults);
|
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
||||||
}
|
|
||||||
|
int result = openFileChooser.showOpenDialog(ownerFrame);
|
||||||
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
|
||||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title, saveDefaults);
|
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
||||||
return editor;
|
}
|
||||||
}
|
|
||||||
|
public File[] showOpenMultiDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
public BomDialog createBomDialog(List<BomEntry> bom) {
|
IFileChooserAccessory accessory, JFrame ownerFrame) {
|
||||||
BomDialog dialog = new BomDialog(mainFrame, bom);
|
JFileChooser openFileChooser = new JFileChooser();
|
||||||
return dialog;
|
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, true);
|
||||||
}
|
|
||||||
|
int result = openFileChooser.showOpenDialog(ownerFrame);
|
||||||
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
|
||||||
IFileChooserAccessory accessory) {
|
return processFileMultiChooserResult(result, openFileChooser, defaultExtension);
|
||||||
JFileChooser openFileChooser = new JFileChooser();
|
}
|
||||||
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
|
||||||
|
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
int result = openFileChooser.showOpenDialog(mainFrame);
|
IFileChooserAccessory accessory) {
|
||||||
|
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
||||||
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
||||||
}
|
|
||||||
|
int result = saveFileChooser.showSaveDialog(owner);
|
||||||
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
|
||||||
IFileChooserAccessory accessory, JFrame ownerFrame) {
|
return processFileChooserResult(result, saveFileChooser, defaultExtension);
|
||||||
JFileChooser openFileChooser = new JFileChooser();
|
}
|
||||||
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
|
||||||
|
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter, File initialFile,
|
||||||
int result = openFileChooser.showOpenDialog(ownerFrame);
|
String defaultExtension, IFileChooserAccessory accessory, boolean allowMultiSelect) {
|
||||||
|
if (accessory != null) {
|
||||||
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
accessory.install(fileChooser);
|
||||||
}
|
}
|
||||||
|
for (FileFilter filter : fileChooser.getChoosableFileFilters()) {
|
||||||
public File[] showOpenMultiDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
fileChooser.removeChoosableFileFilter(filter);
|
||||||
IFileChooserAccessory accessory, JFrame ownerFrame) {
|
}
|
||||||
JFileChooser openFileChooser = new JFileChooser();
|
if (fileChooser instanceof OverwritePromptFileChooser) {
|
||||||
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory, true);
|
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
|
||||||
|
} else {
|
||||||
int result = openFileChooser.showOpenDialog(ownerFrame);
|
fileChooser.setFileFilter(fileFilter);
|
||||||
|
}
|
||||||
return processFileMultiChooserResult(result, openFileChooser, defaultExtension);
|
if (lastDirectory != null) {
|
||||||
}
|
fileChooser.setCurrentDirectory(lastDirectory);
|
||||||
|
}
|
||||||
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
|
fileChooser.setSelectedFile(initialFile);
|
||||||
IFileChooserAccessory accessory) {
|
if (allowMultiSelect)
|
||||||
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
fileChooser.setMultiSelectionEnabled(true);
|
||||||
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory, false);
|
}
|
||||||
|
|
||||||
int result = saveFileChooser.showSaveDialog(owner);
|
private File processFileChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
|
||||||
|
fileChooser.setAccessory(null);
|
||||||
return processFileChooserResult(result, saveFileChooser, defaultExtension);
|
if (result == JFileChooser.APPROVE_OPTION) {
|
||||||
}
|
lastDirectory = fileChooser.getCurrentDirectory();
|
||||||
|
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
|
||||||
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter, File initialFile,
|
if (fileChooser.getSelectedFile().getName().contains(".")) {
|
||||||
String defaultExtension, IFileChooserAccessory accessory, boolean allowMultiSelect) {
|
return fileChooser.getSelectedFile();
|
||||||
if (accessory != null) {
|
} else {
|
||||||
accessory.install(fileChooser);
|
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "." + defaultExtension);
|
||||||
}
|
}
|
||||||
for (FileFilter filter : fileChooser.getChoosableFileFilters()) {
|
} else {
|
||||||
fileChooser.removeChoosableFileFilter(filter);
|
return null;
|
||||||
}
|
}
|
||||||
if (fileChooser instanceof OverwritePromptFileChooser) {
|
}
|
||||||
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
|
|
||||||
} else {
|
private File[] processFileMultiChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
|
||||||
fileChooser.setFileFilter(fileFilter);
|
fileChooser.setAccessory(null);
|
||||||
}
|
if (result == JFileChooser.APPROVE_OPTION) {
|
||||||
if (lastDirectory != null) {
|
lastDirectory = fileChooser.getCurrentDirectory();
|
||||||
fileChooser.setCurrentDirectory(lastDirectory);
|
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
|
||||||
}
|
return fileChooser.getSelectedFiles();
|
||||||
fileChooser.setSelectedFile(initialFile);
|
} else {
|
||||||
if (allowMultiSelect)
|
return null;
|
||||||
fileChooser.setMultiSelectionEnabled(true);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File processFileChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
|
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author, String url,
|
||||||
fileChooser.setAccessory(null);
|
String mail, String htmlContent) {
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail, htmlContent);
|
||||||
lastDirectory = fileChooser.getCurrentDirectory();
|
return dialog;
|
||||||
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
|
}
|
||||||
if (fileChooser.getSelectedFile().getName().contains(".")) {
|
|
||||||
return fileChooser.getSelectedFile();
|
public UserEditDialog createUserEditDialog(UserEntity existingUser) {
|
||||||
} else {
|
UserEditDialog dialog = new UserEditDialog(mainFrame, existingUser);
|
||||||
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "." + defaultExtension);
|
return dialog;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return null;
|
public LoginDialog createLoginDialog() {
|
||||||
}
|
LoginDialog dialog = new LoginDialog(mainFrame);
|
||||||
}
|
return dialog;
|
||||||
|
}
|
||||||
private File[] processFileMultiChooserResult(int result, JFileChooser fileChooser, String defaultExtension) {
|
|
||||||
fileChooser.setAccessory(null);
|
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories,
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
boolean isUpdate) {
|
||||||
lastDirectory = fileChooser.getCurrentDirectory();
|
UploadDialog dialog = new UploadDialog(ownerFrame, plugInPort, categories, isUpdate);
|
||||||
ConfigurationManager.getInstance().writeValue(PATH_KEY, lastDirectory.getAbsolutePath());
|
return dialog;
|
||||||
return fileChooser.getSelectedFiles();
|
}
|
||||||
} else {
|
|
||||||
return null;
|
public ChangePasswordDialog createChangePasswordDialog() {
|
||||||
}
|
ChangePasswordDialog dialog = new ChangePasswordDialog(mainFrame);
|
||||||
}
|
return dialog;
|
||||||
|
}
|
||||||
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author, String url,
|
|
||||||
String mail, String htmlContent) {
|
public ProgressDialog createProgressDialog(String title, String[] buttonCaptions, String description,
|
||||||
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail, htmlContent);
|
boolean useProgress) {
|
||||||
return dialog;
|
ProgressDialog dialog = new ProgressDialog(mainFrame, title, buttonCaptions, description, useProgress);
|
||||||
}
|
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).
|
import java.io.File;
|
||||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
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
|
import com.thoughtworks.xstream.XStream;
|
||||||
it under the terms of the GNU General Public License as published by
|
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||||
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
|
* Controls configuration menu.
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
*
|
||||||
GNU General Public License for more details.
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
public class ConfigPlugin implements IPlugIn {
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
private static final Logger LOG = Logger.getLogger(ConfigPlugin.class);
|
||||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
private static final String CONFIG_MENU = "Config";
|
||||||
package org.diylc.swing.plugins.config;
|
private static final String THEME_MENU = "Theme";
|
||||||
|
private static final String COMPONENT_BROWSER_MENU = "Toolbox";
|
||||||
import java.io.File;
|
public static final String COMPONENT_BROWSER = "componentBrowser";
|
||||||
import java.io.FileInputStream;
|
public static final String SEARCHABLE_TREE = "Searchable Tree";
|
||||||
import java.io.InputStream;
|
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
|
||||||
import java.util.EnumSet;
|
|
||||||
|
private ISwingUI swingUI;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.diylc.common.EventType;
|
public ConfigPlugin(ISwingUI swingUI) {
|
||||||
import org.diylc.common.IPlugIn;
|
super();
|
||||||
import org.diylc.common.IPlugInPort;
|
this.swingUI = swingUI;
|
||||||
import org.diylc.components.autocreate.SolderPadAutoCreator;
|
}
|
||||||
import org.diylc.core.Theme;
|
|
||||||
import org.diylc.images.IconLoader;
|
@Override
|
||||||
import org.diylc.swing.ActionFactory;
|
public void connect(IPlugInPort plugInPort) {
|
||||||
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);
|
|
||||||
swingUI.injectMenuAction(
|
swingUI.injectMenuAction(
|
||||||
ActionFactory.getInstance()
|
ActionFactory.getInstance()
|
||||||
.createConfigAction(plugInPort, "Highlight Connected Areas", IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, false), CONFIG_MENU);
|
.createConfigAction(plugInPort, "Anti-Aliasing", IPlugInPort.ANTI_ALIASING_KEY, true), CONFIG_MENU);
|
||||||
|
swingUI.injectMenuAction(
|
||||||
File themeDir = new File("themes");
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Create Pads",
|
||||||
if (themeDir.exists()) {
|
SolderPadAutoCreator.AUTO_PADS_KEY, false), CONFIG_MENU);
|
||||||
XStream xStream = new XStream(new DomDriver());
|
swingUI.injectMenuAction(
|
||||||
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Auto-Edit Mode", IPlugInPort.AUTO_EDIT_KEY, true),
|
||||||
for (File file : themeDir.listFiles()) {
|
CONFIG_MENU);
|
||||||
if (file.getName().toLowerCase().endsWith(".xml")) {
|
swingUI.injectMenuAction(
|
||||||
try {
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Continuous Creation",
|
||||||
InputStream in = new FileInputStream(file);
|
IPlugInPort.CONTINUOUS_CREATION_KEY, false), CONFIG_MENU);
|
||||||
Theme theme = (Theme) xStream.fromXML(in);
|
swingUI.injectMenuAction(
|
||||||
LOG.debug("Found theme: " + theme.getName());
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Show Rulers", IPlugInPort.SHOW_RULERS_KEY, true),
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createThemeAction(plugInPort, theme), THEME_MENU);
|
CONFIG_MENU);
|
||||||
} catch (Exception e) {
|
swingUI.injectMenuAction(
|
||||||
LOG.error("Could not load theme file " + file.getName(), e);
|
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(
|
||||||
swingUI.injectSubmenu(COMPONENT_BROWSER_MENU, IconLoader.Hammer.getIcon(), CONFIG_MENU);
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Hi-Quality Rendering",
|
||||||
|
IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(SEARCHABLE_TREE),
|
swingUI.injectMenuAction(
|
||||||
COMPONENT_BROWSER_MENU);
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY,
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
|
false), CONFIG_MENU);
|
||||||
COMPONENT_BROWSER_MENU);
|
swingUI.injectMenuAction(
|
||||||
}
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Outline Mode", IPlugInPort.OUTLINE_KEY, false),
|
||||||
|
CONFIG_MENU);
|
||||||
@Override
|
swingUI.injectMenuAction(
|
||||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
ActionFactory.getInstance().createConfigAction(plugInPort, "Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true),
|
||||||
return EnumSet.noneOf(EventType.class);
|
CONFIG_MENU);
|
||||||
}
|
swingUI.injectMenuAction(
|
||||||
|
ActionFactory.getInstance()
|
||||||
@Override
|
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
||||||
public void processMessage(EventType eventType, Object... params) {}
|
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) {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1912,6 +1912,22 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
|
</org.diylc.appframework.update.Version>
|
||||||
|
<org.diylc.appframework.update.Version>
|
||||||
|
<versionNumber>
|
||||||
|
<major>3</major>
|
||||||
|
<minor>42</minor>
|
||||||
|
<build>1</build>
|
||||||
|
</versionNumber>
|
||||||
|
<releaseDate>2018-12-16 00:00:00.000 CET</releaseDate>
|
||||||
|
<name></name>
|
||||||
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Added usage hints for new functionality</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
</changes>
|
||||||
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
</a>
|
</a>
|
||||||
</java.util.Arrays_-ArrayList>
|
</java.util.Arrays_-ArrayList>
|
||||||
|
|||||||
Reference in New Issue
Block a user