use of javax.swing.DefaultListCellRenderer in project n2a by frothga.
the class SettingsBackend method getPanel.
@SuppressWarnings("serial")
@Override
public Component getPanel() {
if (scrollPane != null)
return scrollPane;
JPanel view = new JPanel();
scrollPane = new JScrollPane(view);
for (Host h : Host.getHosts()) model.addElement(h);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
Host h = (Host) list.getSelectedValue();
if (h == null)
return;
bind(h.config.childOrCreate("backend", key));
}
});
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Host h = (Host) value;
String name = h.name;
if (h.config.get("backend", key).equals("0"))
name = "<html><s>" + name + "</s></html>";
return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
}
});
InputMap inputMap = list.getInputMap();
inputMap.put(KeyStroke.getKeyStroke("DELETE"), "toggleEnable");
inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), "toggleEnable");
inputMap.put(KeyStroke.getKeyStroke("SPACE"), "toggleEnable");
ActionMap actionMap = list.getActionMap();
actionMap.put("toggleEnable", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Host h = (Host) list.getSelectedValue();
if (h == null)
return;
boolean disabled = h.config.get("backend", key).equals("0");
if (disabled)
h.config.set(null, "backend", key);
else
h.config.set("0", "backend", key);
list.repaint();
}
});
JPanel panelList = Lay.BL("C", list, "pref=[100,200]");
panelList.setBorder(LineBorder.createBlackLineBorder());
panelList = (JPanel) Lay.eb(Lay.BL("C", panelList), "5");
editor = getEditor();
Lay.BLtg(view, "N", Lay.BL("W", Lay.BxL("H", Lay.BL("N", panelList), Box.createHorizontalStrut(5), Lay.BL("N", editor))));
if (list.getModel().getSize() > 0)
list.setSelectedIndex(0);
return scrollPane;
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class EventAssignmentsTableModel method updateSteComboBox.
private void updateSteComboBox() {
if (fieldSimContext == null) {
return;
}
if (steComboBox == null) {
steComboBox = new JComboBox<>();
}
populateVariableComboBoxModel(aModel, fieldSimContext);
// steComboBox.addFocusListener(new java.awt.event.FocusAdapter() {
// @Override
// public void focusGained(java.awt.event.FocusEvent evt) {
//
// DefaultComboBoxModel<String> aModel = (DefaultComboBoxModel<String>) steComboBox.getModel();
// ArrayList<String> varNameList = EventPanel.filterEventAssignmentVariables(fieldSimContext);
// // TODO: repopulate aModel
// }
// });
steComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setHorizontalTextPosition(SwingConstants.LEFT);
if (value == null) {
setText("");
} else if (value instanceof String) {
setText((String) value);
} else {
setText(value.toString());
System.out.println("not String");
}
return this;
}
});
steComboBox.setModel(aModel);
ownerTable.getColumnModel().getColumn(COLUMN_EVENTASSGN_VARNAME).setCellEditor(new DefaultCellEditor(steComboBox));
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class DBReactionWizardPanel method getParameterNamesJList.
/**
* Return the ParameterNamesJList property value.
* @return javax.swing.JList
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private JList<MapStringToObject> getParameterNamesJList() {
if (ivjParameterNamesJList == null) {
try {
ivjParameterNamesJList = new JList<MapStringToObject>();
ivjParameterNamesJList.setName("ParameterNamesJList");
ivjParameterNamesJList.setBounds(0, 0, 160, 120);
ivjParameterNamesJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
ivjParameterNamesJList.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
comp.setEnabled(((MapStringToObject) value).isEnabled());
return comp;
}
});
ivjParameterNamesJList.setSelectionModel(new DefaultListSelectionModel() {
@Override
public void setSelectionInterval(int index0, int index1) {
if (ivjParameterNamesJList.getModel().getElementAt(index0).isEnabled())
super.setSelectionInterval(index0, index1);
}
});
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjParameterNamesJList;
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class StructurePropertiesPanel method initialize.
/**
* Initialize the class.
*/
private void initialize() {
try {
setName(this.getClass().getName());
setLayout(new GridBagLayout());
nameTextField = new JTextField();
nameTextField.setEditable(false);
nameTextField.addActionListener(eventHandler);
sizeTextField = new JTextField();
sizeTextField.setEditable(false);
voltageLabel = new JLabel("Voltage Variable Name");
voltageTextField = new JTextField();
voltageTextField.setEditable(false);
electrophysiologyLabel = new JLabel("<html><u>Electrophysiology</u></html>");
electrophysiologyExplanationLabel = new JLabel();
positiveFeatureLabel = new JLabel("Positive (inside feature)");
positiveFeatureComboBox = new JComboBox<String>();
negativeFeatureLabel = new JLabel("Negative (outside feature)");
negativeFeatureComboBox = new JComboBox<String>();
// annotationTextArea = new javax.swing.JTextArea("", 1, 30);
// annotationTextArea.setLineWrap(true);
// annotationTextArea.setWrapStyleWord(true);
// annotationTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
// annotationTextArea.setEditable(false);
int gridy = 0;
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel label = new JLabel("<html><u>Select only one structure to edit properties</u></html>");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(label.getFont().deriveFont(Font.BOLD));
add(label, gbc);
// name
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
label = new JLabel("Structure Name");
add(label, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
add(nameTextField, gbc);
// size
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
label = new JLabel("Size Variable Name");
add(label, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
add(sizeTextField, gbc);
// electrophysiology
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
electrophysiologyLabel.setHorizontalAlignment(SwingConstants.CENTER);
electrophysiologyLabel.setFont(label.getFont().deriveFont(Font.BOLD));
add(electrophysiologyLabel, gbc);
// voltage
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(voltageLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
voltageTextField.setForeground(Color.blue);
add(voltageTextField, gbc);
// positive (feature) voltage
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(positiveFeatureLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
positiveFeatureComboBox.setForeground(Color.blue);
add(positiveFeatureComboBox, gbc);
// negative (feature) voltage
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(negativeFeatureLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
negativeFeatureComboBox.setForeground(Color.blue);
add(negativeFeatureComboBox, gbc);
// electrophysiology
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
electrophysiologyExplanationLabel.setHorizontalAlignment(SwingConstants.CENTER);
// electrophysiologyExplanationLabel.setFont(label.getFont().deriveFont(Font.BOLD));
add(electrophysiologyExplanationLabel, gbc);
// // annotation
// gridy ++;
// gbc = new java.awt.GridBagConstraints();
// gbc.gridx = 0;
// gbc.gridy = gridy;
// gbc.insets = new Insets(9, 8, 4, 6);
// gbc.anchor = GridBagConstraints.FIRST_LINE_END;
// add(new JLabel("Annotation "), gbc);
//
// javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.weighty = 1;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
// empty space filling
add(new JLabel(), gbc);
DefaultListCellRenderer comboBoxListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Feature) {
setText(((Structure) value).getName());
}
return this;
}
};
positiveFeatureComboBox.setRenderer(comboBoxListCellRenderer);
negativeFeatureComboBox.setRenderer(comboBoxListCellRenderer);
setBackground(Color.white);
initConnections();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ElectricalStimulusPanel method getJPanel1.
/**
* Return the JPanel1 property value.
* @return javax.swing.JPanel
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJPanel1() {
if (ivjJPanel1 == null) {
try {
ivjJPanel1 = new javax.swing.JPanel();
ivjJPanel1.setName("JPanel1");
ivjJPanel1.setLayout(new BoxLayout(ivjJPanel1, BoxLayout.X_AXIS));
JLabel label = new javax.swing.JLabel();
label.setText("Electrical Stimulus:");
label.setFont(label.getFont().deriveFont(Font.BOLD));
ivjJPanel1.add(label);
clampComboBox = new JComboBox();
for (Clamp clamp : Clamp.values()) {
clampComboBox.addItem(clamp);
}
clampComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Clamp) {
setText(((Clamp) value).title);
}
return this;
}
});
ivjJPanel1.add(Box.createHorizontalStrut(4));
ivjJPanel1.add(clampComboBox);
ivjJPanel1.add(Box.createHorizontalGlue());
ivjJPanel1.add(getBtnGraphElectricalStimulus());
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
return ivjJPanel1;
}
Aggregations