mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Cleanup
This commit is contained in:
@@ -71,7 +71,7 @@ public class TemplateDialog extends JDialog {
|
|||||||
|
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
|
|
||||||
private JList fileList;
|
private JList<File> fileList;
|
||||||
private JPanel canvasPanel;
|
private JPanel canvasPanel;
|
||||||
private Presenter presenter;
|
private Presenter presenter;
|
||||||
private List<File> files;
|
private List<File> files;
|
||||||
@@ -213,16 +213,16 @@ public class TemplateDialog extends JDialog {
|
|||||||
return infoPanel;
|
return infoPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JList getFileList() {
|
public JList<File> getFileList() {
|
||||||
if (fileList == null) {
|
if (fileList == null) {
|
||||||
fileList = new JList(getFiles().toArray());
|
fileList = new JList<File>(getFiles().toArray(new File[0]));
|
||||||
fileList.setPreferredSize(new Dimension(128, -1));
|
fileList.setPreferredSize(new Dimension(128, -1));
|
||||||
fileList.setCellRenderer(new DefaultListCellRenderer() {
|
fileList.setCellRenderer(new DefaultListCellRenderer() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
|
||||||
boolean cellHasFocus) {
|
boolean cellHasFocus) {
|
||||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
if (value instanceof File) {
|
if (value instanceof File) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.diylc.common.PropertyWrapper;
|
|||||||
import org.diylc.lang.LangUtil;
|
import org.diylc.lang.LangUtil;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
public class EnumEditor extends JComboBox {
|
public class EnumEditor extends JComboBox<Object> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class EnumEditor extends JComboBox {
|
|||||||
Object[] values = property.getType().getEnumConstants();
|
Object[] values = property.getType().getEnumConstants();
|
||||||
if (property.isReadOnly())
|
if (property.isReadOnly())
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
setModel(new DefaultComboBoxModel(values));
|
setModel(new DefaultComboBoxModel<Object>(values));
|
||||||
setRenderer(new DefaultListCellRenderer() {
|
setRenderer(new DefaultListCellRenderer() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class MeasureArrayEditor extends Container {
|
|||||||
|
|
||||||
private Color oldBg;
|
private Color oldBg;
|
||||||
private DoubleArrayTextField valueField;
|
private DoubleArrayTextField valueField;
|
||||||
private JComboBox unitBox;
|
private JComboBox<Object> unitBox;
|
||||||
|
|
||||||
public MeasureArrayEditor(final PropertyWrapper property) {
|
public MeasureArrayEditor(final PropertyWrapper property) {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
@@ -100,7 +100,7 @@ public class MeasureArrayEditor extends Container {
|
|||||||
Type type = ((ParameterizedType) property.getType().getComponentType()
|
Type type = ((ParameterizedType) property.getType().getComponentType()
|
||||||
.getGenericSuperclass()).getActualTypeArguments()[0];
|
.getGenericSuperclass()).getActualTypeArguments()[0];
|
||||||
Method method = ((Class<?>) type).getMethod("values");
|
Method method = ((Class<?>) type).getMethod("values");
|
||||||
unitBox = new JComboBox((Object[]) method.invoke(null));
|
unitBox = new JComboBox<Object>((Object[]) method.invoke(null));
|
||||||
unitBox.setSelectedItem(measure == null || measure.length == 0 || measure[0] == null ? null
|
unitBox.setSelectedItem(measure == null || measure.length == 0 || measure[0] == null ? null
|
||||||
: measure[0].getUnit());
|
: measure[0].getUnit());
|
||||||
unitBox.addActionListener(new ActionListener() {
|
unitBox.addActionListener(new ActionListener() {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MeasureEditor extends Container {
|
|||||||
|
|
||||||
private Color oldBg;
|
private Color oldBg;
|
||||||
private DoubleTextField valueField;
|
private DoubleTextField valueField;
|
||||||
private JComboBox unitBox;
|
private JComboBox<Object> unitBox;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public MeasureEditor(final PropertyWrapper property) {
|
public MeasureEditor(final PropertyWrapper property) {
|
||||||
@@ -78,7 +78,7 @@ public class MeasureEditor extends Container {
|
|||||||
try {
|
try {
|
||||||
Type type = ((ParameterizedType) property.getType().getGenericSuperclass()).getActualTypeArguments()[0];
|
Type type = ((ParameterizedType) property.getType().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||||
Method method = ((Class<?>) type).getMethod("values");
|
Method method = ((Class<?>) type).getMethod("values");
|
||||||
unitBox = new JComboBox((Object[]) method.invoke(null));
|
unitBox = new JComboBox<Object>((Object[]) method.invoke(null));
|
||||||
unitBox.setSelectedItem(measure == null ? null : measure.getUnit());
|
unitBox.setSelectedItem(measure == null ? null : measure.getUnit());
|
||||||
unitBox.addActionListener(new ActionListener() {
|
unitBox.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.diylc.common.PropertyWrapper;
|
|||||||
import org.diylc.core.annotations.DynamicList;
|
import org.diylc.core.annotations.DynamicList;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
public class StringListEditor extends JComboBox {
|
public class StringListEditor extends JComboBox<Object> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class StringListEditor extends JComboBox {
|
|||||||
String listFunctionName = property.getGetter().getAnnotation(DynamicList.class).availableValueFunction();
|
String listFunctionName = property.getGetter().getAnnotation(DynamicList.class).availableValueFunction();
|
||||||
Method function = property.getOwnerObject().getClass().getMethod(listFunctionName);
|
Method function = property.getOwnerObject().getClass().getMethod(listFunctionName);
|
||||||
Object[] values = (Object[]) function.invoke(property.getOwnerObject());
|
Object[] values = (Object[]) function.invoke(property.getOwnerObject());
|
||||||
setModel(new DefaultComboBoxModel(values));
|
setModel(new DefaultComboBoxModel<Object>(values));
|
||||||
setSelectedItem(property.getValue());
|
setSelectedItem(property.getValue());
|
||||||
addItemListener(new ItemListener() {
|
addItemListener(new ItemListener() {
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class LoadlineEditorFrame extends JFrame implements IView {
|
|||||||
private JPanel controlPanel;
|
private JPanel controlPanel;
|
||||||
private CanvasPanel canvasPanel;
|
private CanvasPanel canvasPanel;
|
||||||
private Presenter plugInPort;
|
private Presenter plugInPort;
|
||||||
private IConfigurationManager configManager;
|
private IConfigurationManager<?> configManager;
|
||||||
|
|
||||||
private JTextField nameEditor;
|
private JTextField nameEditor;
|
||||||
private DoubleTextField vEditor;
|
private DoubleTextField vEditor;
|
||||||
|
|||||||
+8
-8
@@ -38,8 +38,8 @@ public class SearchHeaderPanel extends JPanel {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private JTextField searchField;
|
private JTextField searchField;
|
||||||
private JComboBox categoryBox;
|
private JComboBox<String> categoryBox;
|
||||||
private JComboBox sortBox;
|
private JComboBox<String> sortBox;
|
||||||
private JButton goButton;
|
private JButton goButton;
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
@@ -87,8 +87,8 @@ public class SearchHeaderPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initializeLists(String[] categories, String[] sortings) {
|
public void initializeLists(String[] categories, String[] sortings) {
|
||||||
getCategoryBox().setModel(new DefaultComboBoxModel(categories));
|
getCategoryBox().setModel(new DefaultComboBoxModel<String>(categories));
|
||||||
getSortBox().setModel(new DefaultComboBoxModel(sortings));
|
getSortBox().setModel(new DefaultComboBoxModel<String>(sortings));
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,16 +103,16 @@ public class SearchHeaderPanel extends JPanel {
|
|||||||
return searchField;
|
return searchField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox getCategoryBox() {
|
private JComboBox<String> getCategoryBox() {
|
||||||
if (categoryBox == null) {
|
if (categoryBox == null) {
|
||||||
categoryBox = new JComboBox();
|
categoryBox = new JComboBox<String>();
|
||||||
}
|
}
|
||||||
return categoryBox;
|
return categoryBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox getSortBox() {
|
private JComboBox<String> getSortBox() {
|
||||||
if (sortBox == null) {
|
if (sortBox == null) {
|
||||||
sortBox = new JComboBox();
|
sortBox = new JComboBox<String>();
|
||||||
}
|
}
|
||||||
return sortBox;
|
return sortBox;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.diylc.swing.plugins.explorer;
|
package org.diylc.swing.plugins.explorer;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@@ -30,10 +29,10 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.ListCellRenderer;
|
import javax.swing.ListCellRenderer;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
@@ -51,13 +50,12 @@ public class ExplorerPane extends JPanel {
|
|||||||
private static final String REORDERING_NOT_POSSIBLE = LangUtil.translate(
|
private static final String REORDERING_NOT_POSSIBLE = LangUtil.translate(
|
||||||
"Component reordering is possible only when Project Explorer is sorted by z-index.");
|
"Component reordering is possible only when Project Explorer is sorted by z-index.");
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(ExplorerPane.class);
|
|
||||||
|
|
||||||
public static Font DEFAULT_FONT = new Font("Square721 BT", Font.PLAIN, 12);
|
public static Font DEFAULT_FONT = new Font("Square721 BT", Font.PLAIN, 12);
|
||||||
|
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
|
|
||||||
|
private JLabel titleLabel;
|
||||||
private JTextField searchField;
|
private JTextField searchField;
|
||||||
private JScrollPane componentScrollPane;
|
private JScrollPane componentScrollPane;
|
||||||
private ComponentListModel componentListModel;
|
private ComponentListModel componentListModel;
|
||||||
@@ -80,6 +78,10 @@ public class ExplorerPane extends JPanel {
|
|||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.gridwidth = 1;
|
gbc.gridwidth = 1;
|
||||||
|
|
||||||
|
// add(getTitleLabel(), gbc);
|
||||||
|
//
|
||||||
|
// gbc.gridy++;
|
||||||
|
|
||||||
add(getSearchField(), gbc);
|
add(getSearchField(), gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
@@ -101,6 +103,15 @@ public class ExplorerPane extends JPanel {
|
|||||||
setPreferredSize(new Dimension(180, 200));
|
setPreferredSize(new Dimension(180, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JLabel getTitleLabel() {
|
||||||
|
if (titleLabel == null) {
|
||||||
|
titleLabel = new JLabel(getName());
|
||||||
|
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
|
||||||
|
}
|
||||||
|
return titleLabel;
|
||||||
|
}
|
||||||
|
|
||||||
public JTextField getSearchField() {
|
public JTextField getSearchField() {
|
||||||
if (searchField == null) {
|
if (searchField == null) {
|
||||||
searchField = new SearchTextField(true, 'X', text -> {
|
searchField = new SearchTextField(true, 'X', text -> {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -43,6 +44,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.ToolTipManager;
|
import javax.swing.ToolTipManager;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
@@ -81,6 +83,7 @@ public class TreePanel extends JPanel {
|
|||||||
|
|
||||||
public static final String COMPONENT_SHORTCUT_KEY = "componentShortcuts";
|
public static final String COMPONENT_SHORTCUT_KEY = "componentShortcuts";
|
||||||
|
|
||||||
|
private JLabel titleLabel;
|
||||||
private CustomTreeModel treeModel;
|
private CustomTreeModel treeModel;
|
||||||
private JTree tree;
|
private JTree tree;
|
||||||
private JScrollPane treeScroll;
|
private JScrollPane treeScroll;
|
||||||
@@ -107,6 +110,10 @@ public class TreePanel extends JPanel {
|
|||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.gridwidth = 1;
|
gbc.gridwidth = 1;
|
||||||
|
|
||||||
|
// add(getTitleLabel(), gbc);
|
||||||
|
//
|
||||||
|
// gbc.gridy++;
|
||||||
|
|
||||||
add(getSearchField(), gbc);
|
add(getSearchField(), gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
@@ -150,6 +157,16 @@ public class TreePanel extends JPanel {
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JLabel getTitleLabel() {
|
||||||
|
if (titleLabel == null) {
|
||||||
|
titleLabel = new JLabel(getName());
|
||||||
|
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
// titleLabel.setBorder(BorderFactory.createEtchedBorder());
|
||||||
|
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
|
||||||
|
}
|
||||||
|
return titleLabel;
|
||||||
|
}
|
||||||
|
|
||||||
public JScrollPane getTreeScroll() {
|
public JScrollPane getTreeScroll() {
|
||||||
if (treeScroll == null) {
|
if (treeScroll == null) {
|
||||||
treeScroll = new JScrollPane(getTree());
|
treeScroll = new JScrollPane(getTree());
|
||||||
|
|||||||
Reference in New Issue
Block a user