use of javax.swing.DefaultCellEditor in project vcell by virtualcell.
the class RateRulesSummaryTableModel method updateSubdomainComboBox.
private void updateSubdomainComboBox() {
if (steComboBox == null) {
steComboBox = new JComboBox<>();
}
if (simulationContext == null) {
return;
}
SpeciesContext[] scs = simulationContext.getModel().getSpeciesContexts();
ModelParameter[] mps = simulationContext.getModel().getModelParameters();
DefaultComboBoxModel<String> aModel = new DefaultComboBoxModel<>();
for (SpeciesContext sc : scs) {
aModel.addElement(sc.getName());
}
for (ModelParameter mp : mps) {
aModel.addElement(mp.getName());
}
steComboBox.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseClicked(java.awt.event.MouseEvent evt) {
}
@Override
public void mouseEntered(java.awt.event.MouseEvent evt) {
}
});
steComboBox.addFocusListener(new java.awt.event.FocusAdapter() {
@Override
public void focusGained(java.awt.event.FocusEvent evt) {
DefaultComboBoxModel<String> aModel = (DefaultComboBoxModel<String>) steComboBox.getModel();
SpeciesContext[] scs = simulationContext.getModel().getSpeciesContexts();
ModelParameter[] mps = simulationContext.getModel().getModelParameters();
for (SpeciesContext sc : scs) {
int position = aModel.getIndexOf(sc.getName());
if (position == -1) {
// element is missing, add it
aModel.addElement(sc.getName());
}
}
for (ModelParameter mp : mps) {
int position = aModel.getIndexOf(mp.getName());
if (position == -1) {
aModel.addElement(mp.getName());
}
}
Set<String> elementsToRemove = new HashSet<>();
for (int i = 0; i < aModel.getSize(); i++) {
String candidate = aModel.getElementAt(i);
SpeciesContext sc = simulationContext.getModel().getSpeciesContext(candidate);
ModelParameter mp = simulationContext.getModel().getModelParameter(candidate);
if (sc == null && mp == null) {
elementsToRemove.add(candidate);
}
if (sc != null && simulationContext.getAssignmentRule(sc) != null) {
elementsToRemove.add(candidate);
continue;
}
if (mp != null && simulationContext.getAssignmentRule(mp) != null) {
elementsToRemove.add(candidate);
continue;
}
}
for (String candidate : elementsToRemove) {
aModel.removeElement(candidate);
}
}
});
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_RATERULE_VAR).setCellEditor(new DefaultCellEditor(steComboBox));
}
use of javax.swing.DefaultCellEditor in project vcell by virtualcell.
the class OutputFunctionsListTableModel method setAvailableDomains.
public void setAvailableDomains(GeometryClass[] availableGeometryClasses) {
this.availableGeometryClasses = availableGeometryClasses;
if (ownerTable.getColumnModel().getColumnCount() > COLUMN_OUTPUTFN_VARIABLETYPE) {
TableColumn varTypeCol = ownerTable.getColumnModel().getColumn(COLUMN_OUTPUTFN_VARIABLETYPE);
JComboBox<String> varTypesCB = new JComboBox<>();
for (int i = 0; availableGeometryClasses != null && i < availableGeometryClasses.length; i++) {
varTypesCB.addItem(availableGeometryClasses[i].getName());
}
varTypeCol.setCellEditor(new DefaultCellEditor(varTypesCB));
}
}
use of javax.swing.DefaultCellEditor in project vcell by virtualcell.
the class SimulationListPanel method initConnections.
/**
* Initializes connections
* @exception java.lang.Exception The exception description.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
// user code begin {1}
// user code end
getNewButton().addActionListener(ivjEventHandler);
getEditButton().addActionListener(ivjEventHandler);
getDeleteButton().addActionListener(ivjEventHandler);
getRunButton().addActionListener(ivjEventHandler);
getMassConservationModelReductionCheckBox().addActionListener(ivjEventHandler);
getMassConservationModelReductionHelpButton().addActionListener(ivjEventHandler);
// getPythonResultsButton().addActionListener(ivjEventHandler);
getNativeResultsButton().addActionListener(ivjEventHandler);
getMoreActionsButton().addActionListener(ivjEventHandler);
getScrollPaneTable().addPropertyChangeListener(ivjEventHandler);
getOutputFunctionsPanel().addPropertyChangeListener(ivjEventHandler);
getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
DefaultScrollTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof OutputTimeSpec) {
SimulationWorkspace sw = getSimulationWorkspace();
SimulationOwner so = sw.getSimulationOwner();
UnitInfo unitInfo = so.getUnitInfo();
Objects.requireNonNull(unitInfo);
OutputTimeSpec ots = (OutputTimeSpec) value;
String text = ots.describe(unitInfo);
setText(text);
} else if (value instanceof Double) {
setText(value + "");
}
boolean bFinitVolumeRerun = false;
if (value instanceof SolverDescription) {
SolverDescription solverDescription = (SolverDescription) value;
try {
if (FINITEVOLUME_CUTTOFF != null && solverDescription.equals(SolverDescription.FiniteVolume)) /*Compiled Solver*/
{
SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(getSimulationListTableModel1().getValueAt(row));
if (simStatus.getHasData()) {
int statusIndex = 0;
while (simStatus.getJobStatus(statusIndex) != null) {
if (simStatus.getJobStatus(statusIndex).getEndDate().compareTo(FINITEVOLUME_CUTTOFF) > 0) {
bFinitVolumeRerun = true;
break;
}
statusIndex++;
}
}
}
} catch (Exception e) {
// ignore, let table cell render anyway
e.printStackTrace();
}
setText(solverDescription.getShortDisplayLabel());
setToolTipText(solverDescription.getDisplayLabel());
} else {
setToolTipText(getText());
}
if (bFinitVolumeRerun) {
setText(getText() + (bFinitVolumeRerun ? "(*)" : ""));
setToolTipText(getToolTipText() + (bFinitVolumeRerun ? " (data regenerated using FiniteVolumeStandalone)" : ""));
}
return this;
}
};
getScrollPaneTable().setDefaultRenderer(OutputTimeSpec.class, renderer);
getScrollPaneTable().setDefaultRenderer(Double.class, renderer);
getScrollPaneTable().setDefaultRenderer(String.class, renderer);
getScrollPaneTable().setDefaultRenderer(SolverDescription.class, renderer);
getScrollPaneTable().setDefaultEditor(OutputTimeSpec.class, new DefaultCellEditor(new JTextField()));
getScrollPaneTable().setDefaultRenderer(SimulationStatus.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Object obj = getSimulationStatusDisplay(row);
if (obj instanceof JProgressBar) {
return (JProgressBar) obj;
}
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof SimulationStatus) {
setText(obj.toString());
String details = ((SimulationStatus) value).getDetails();
setToolTipText(details);
}
return this;
}
});
}
use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.
the class PolicyPassiveScanPanel method getTableTest.
/**
* This method initializes tableTest
*
* @return javax.swing.JTable
*/
private JTable getTableTest() {
if (tableTest == null) {
tableTest = new JTable();
tableTest.setModel(getPassiveScanTableModel());
tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
tableTest.setAutoCreateRowSorter(true);
//Default sort by name (column 0)
List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
tableTest.getRowSorter().setSortKeys(sortKeys);
for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
TableColumn column = tableTest.getColumnModel().getColumn(i);
column.setPreferredWidth(width[i]);
}
JComboBox<String> jcb1 = new JComboBox<>();
for (AlertThreshold level : AlertThreshold.values()) {
jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
}
tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
}
return tableTest;
}
use of javax.swing.DefaultCellEditor in project ACS by ACS-Community.
the class CDBTable method setUpStringEditor.
public void setUpStringEditor() {
// , this);
final StringField stringField = new StringField("", 3);
DefaultCellEditor stringEditor = new DefaultCellEditor(stringField) {
public Object getCellEditorValue() {
return stringField.getValue();
}
};
setDefaultEditor(String.class, stringEditor);
}
Aggregations