This commit is contained in:
Bane Stojkovic
2022-12-08 23:00:05 +01:00
parent bc0fc4d3b9
commit 82d4b9ebfc
9 changed files with 54 additions and 26 deletions
@@ -71,7 +71,7 @@ public class TemplateDialog extends JDialog {
private IPlugInPort plugInPort;
private JList fileList;
private JList<File> fileList;
private JPanel canvasPanel;
private Presenter presenter;
private List<File> files;
@@ -213,16 +213,16 @@ public class TemplateDialog extends JDialog {
return infoPanel;
}
public JList getFileList() {
public JList<File> getFileList() {
if (fileList == null) {
fileList = new JList(getFiles().toArray());
fileList = new JList<File>(getFiles().toArray(new File[0]));
fileList.setPreferredSize(new Dimension(128, -1));
fileList.setCellRenderer(new DefaultListCellRenderer() {
private static final long serialVersionUID = 1L;
@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) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof File) {
@@ -33,7 +33,7 @@ import org.diylc.common.PropertyWrapper;
import org.diylc.lang.LangUtil;
import org.diylc.utils.Constants;
public class EnumEditor extends JComboBox {
public class EnumEditor extends JComboBox<Object> {
private static final long serialVersionUID = 1L;
@@ -46,7 +46,7 @@ public class EnumEditor extends JComboBox {
Object[] values = property.getType().getEnumConstants();
if (property.isReadOnly())
setEnabled(false);
setModel(new DefaultComboBoxModel(values));
setModel(new DefaultComboBoxModel<Object>(values));
setRenderer(new DefaultListCellRenderer() {
private static final long serialVersionUID = 1L;
@@ -50,7 +50,7 @@ public class MeasureArrayEditor extends Container {
private Color oldBg;
private DoubleArrayTextField valueField;
private JComboBox unitBox;
private JComboBox<Object> unitBox;
public MeasureArrayEditor(final PropertyWrapper property) {
setLayout(new BorderLayout());
@@ -100,7 +100,7 @@ public class MeasureArrayEditor extends Container {
Type type = ((ParameterizedType) property.getType().getComponentType()
.getGenericSuperclass()).getActualTypeArguments()[0];
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
: measure[0].getUnit());
unitBox.addActionListener(new ActionListener() {
@@ -49,7 +49,7 @@ public class MeasureEditor extends Container {
private Color oldBg;
private DoubleTextField valueField;
private JComboBox unitBox;
private JComboBox<Object> unitBox;
@SuppressWarnings("unchecked")
public MeasureEditor(final PropertyWrapper property) {
@@ -78,7 +78,7 @@ public class MeasureEditor extends Container {
try {
Type type = ((ParameterizedType) property.getType().getGenericSuperclass()).getActualTypeArguments()[0];
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.addActionListener(new ActionListener() {
@@ -31,7 +31,7 @@ import org.diylc.common.PropertyWrapper;
import org.diylc.core.annotations.DynamicList;
import org.diylc.utils.Constants;
public class StringListEditor extends JComboBox {
public class StringListEditor extends JComboBox<Object> {
private static final long serialVersionUID = 1L;
@@ -46,7 +46,7 @@ public class StringListEditor extends JComboBox {
String listFunctionName = property.getGetter().getAnnotation(DynamicList.class).availableValueFunction();
Method function = property.getOwnerObject().getClass().getMethod(listFunctionName);
Object[] values = (Object[]) function.invoke(property.getOwnerObject());
setModel(new DefaultComboBoxModel(values));
setModel(new DefaultComboBoxModel<Object>(values));
setSelectedItem(property.getValue());
addItemListener(new ItemListener() {
@@ -83,7 +83,7 @@ public class LoadlineEditorFrame extends JFrame implements IView {
private JPanel controlPanel;
private CanvasPanel canvasPanel;
private Presenter plugInPort;
private IConfigurationManager configManager;
private IConfigurationManager<?> configManager;
private JTextField nameEditor;
private DoubleTextField vEditor;
@@ -38,8 +38,8 @@ public class SearchHeaderPanel extends JPanel {
private static final long serialVersionUID = 1L;
private JTextField searchField;
private JComboBox categoryBox;
private JComboBox sortBox;
private JComboBox<String> categoryBox;
private JComboBox<String> sortBox;
private JButton goButton;
private boolean initialized = false;
@@ -87,8 +87,8 @@ public class SearchHeaderPanel extends JPanel {
}
public void initializeLists(String[] categories, String[] sortings) {
getCategoryBox().setModel(new DefaultComboBoxModel(categories));
getSortBox().setModel(new DefaultComboBoxModel(sortings));
getCategoryBox().setModel(new DefaultComboBoxModel<String>(categories));
getSortBox().setModel(new DefaultComboBoxModel<String>(sortings));
initialized = true;
}
@@ -103,16 +103,16 @@ public class SearchHeaderPanel extends JPanel {
return searchField;
}
private JComboBox getCategoryBox() {
private JComboBox<String> getCategoryBox() {
if (categoryBox == null) {
categoryBox = new JComboBox();
categoryBox = new JComboBox<String>();
}
return categoryBox;
}
private JComboBox getSortBox() {
private JComboBox<String> getSortBox() {
if (sortBox == null) {
sortBox = new JComboBox();
sortBox = new JComboBox<String>();
}
return sortBox;
}
@@ -1,6 +1,5 @@
package org.diylc.swing.plugins.explorer;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
@@ -30,10 +29,10 @@ import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.apache.log4j.Logger;
import org.diylc.common.ComponentType;
import org.diylc.common.IPlugInPort;
import org.diylc.core.IDIYComponent;
@@ -51,13 +50,12 @@ public class ExplorerPane extends JPanel {
private static final String REORDERING_NOT_POSSIBLE = LangUtil.translate(
"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);
private ISwingUI swingUI;
private IPlugInPort plugInPort;
private JLabel titleLabel;
private JTextField searchField;
private JScrollPane componentScrollPane;
private ComponentListModel componentListModel;
@@ -80,6 +78,10 @@ public class ExplorerPane extends JPanel {
gbc.weighty = 0;
gbc.gridwidth = 1;
// add(getTitleLabel(), gbc);
//
// gbc.gridy++;
add(getSearchField(), gbc);
gbc.gridy++;
@@ -101,6 +103,15 @@ public class ExplorerPane extends JPanel {
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() {
if (searchField == null) {
searchField = new SearchTextField(true, 'X', text -> {
@@ -35,6 +35,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
@@ -43,6 +44,7 @@ import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.event.PopupMenuEvent;
@@ -81,6 +83,7 @@ public class TreePanel extends JPanel {
public static final String COMPONENT_SHORTCUT_KEY = "componentShortcuts";
private JLabel titleLabel;
private CustomTreeModel treeModel;
private JTree tree;
private JScrollPane treeScroll;
@@ -107,6 +110,10 @@ public class TreePanel extends JPanel {
gbc.weighty = 0;
gbc.gridwidth = 1;
// add(getTitleLabel(), gbc);
//
// gbc.gridy++;
add(getSearchField(), gbc);
gbc.gridy++;
@@ -150,6 +157,16 @@ public class TreePanel extends JPanel {
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() {
if (treeScroll == null) {
treeScroll = new JScrollPane(getTree());