use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.
the class OutputSpeciesResultsPanel method initialize.
private void initialize() {
try {
setName("ViewGeneratedSpeciesPanel");
setLayout(new GridBagLayout());
shapePanel = new LargeShapePanel() {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spls != null) {
spls.paintSelf(g);
}
}
@Override
public DisplayMode getDisplayMode() {
return DisplayMode.other;
}
@Override
public RuleAnalysisChanged hasStateChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleAnalysisChanged hasStateChanged(MolecularComponentPattern molecularComponentPattern) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleAnalysisChanged hasBondChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleAnalysisChanged hasBondChanged(MolecularComponentPattern molecularComponentPattern) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleAnalysisChanged hasNoMatch(String reactionRuleName, MolecularTypePattern mtp) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleAnalysisChanged hasNoMatch(MolecularTypePattern molecularTypePattern) {
return RuleAnalysisChanged.UNCHANGED;
}
@Override
public RuleParticipantSignature getSignature() {
return null;
}
@Override
public GroupingCriteria getCriteria() {
return null;
}
@Override
public boolean isViewSingleRow() {
return true;
}
};
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
shapePanel.setLayout(new GridBagLayout());
shapePanel.setBackground(Color.white);
// not really editable but we don't want the brown contours here
shapePanel.setEditable(true);
shapePanel.setShowMoleculeColor(true);
shapePanel.setShowNonTrivialOnly(true);
JScrollPane scrollPane = new JScrollPane(shapePanel);
scrollPane.setBorder(loweredBevelBorder);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new GridBagLayout());
getZoomSmallerButton().setEnabled(true);
getZoomLargerButton().setEnabled(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 0, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomLargerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(2, 0, 4, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomSmallerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1;
// fake cell used for filling all the vertical empty space
gbc.weighty = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(4, 4, 4, 10);
optionsPanel.add(new JLabel(""), gbc);
JPanel containerOfScrollPanel = new JPanel();
containerOfScrollPanel.setLayout(new BorderLayout());
containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
Dimension dim = new Dimension(500, 135);
// dimension of shape panel
containerOfScrollPanel.setPreferredSize(dim);
containerOfScrollPanel.setMinimumSize(dim);
containerOfScrollPanel.setMaximumSize(dim);
// ------------------------------------------------------------------------
table = new EditorScrollTable();
tableModel = new OutputSpeciesResultsTableModel();
table.setModel(tableModel);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
int gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
table.setPreferredScrollableViewportSize(new Dimension(400, 200));
add(table.getEnclosingScrollPane(), gbc);
// add toolTipText for each table cell
table.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 4, 4, 4);
add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
add(textFieldSearch, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
add(totalSpeciesLabel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
// gbc.weightx = 1.0;
gbc.gridwidth = 8;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
add(containerOfScrollPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
add(getSpeciesFileLocationPanel(), gbc);
// // button to copy to clipboard the content of the JTextField.
// // TODO: do not delete! this is how it's done
// JButton buttonCopy = new JButton("Copy");
// buttonCopy.setToolTipText("Copy to clipboard the species file path");
// buttonCopy.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent le) {
// if(speciesFileLocationTextField.getSelectionStart() == speciesFileLocationTextField.getSelectionEnd()) {
// speciesFileLocationTextField.setSelectionStart(0);
// speciesFileLocationTextField.setSelectionEnd(speciesFileLocationTextField.getText().length());
// }
// speciesFileLocationTextField.copy();
// speciesFileLocationTextField.setSelectionStart(0);
// speciesFileLocationTextField.setSelectionEnd(0);
// }
// });
// gbc = new GridBagConstraints();
// gbc.gridx = 4;
// gbc.gridy = gridy;
// gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4,4,4,4);
// add(buttonCopy, gbc);
// rendering the small shapes of the flattened species in the Depiction column of this viewer table)
DefaultScrollTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
SpeciesPatternSmallShape spss = null;
@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 (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == tableModel) {
selectedObject = tableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof GeneratedSpeciesTableRow) {
SpeciesContext sc = ((GeneratedSpeciesTableRow) selectedObject).species;
if (sc == null || sc.getSpeciesPattern() == null) {
spss = null;
} else {
SpeciesPattern sp = sc.getSpeciesPattern();
Graphics panelContext = table.getGraphics();
spss = new SpeciesPatternSmallShape(4, 2, sp, panelContext, sc, isSelected, issueManager);
}
}
} else {
spss = null;
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spss != null) {
spss.paintSelf(g);
}
}
};
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setPreferredWidth(400);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setMinWidth(400);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDefinition).setPreferredWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.
the class WorkflowObjectsPanel method initialize.
private void initialize() {
showButton = new JButton("show data");
showButton.addActionListener(eventHandler);
deleteButton = new JButton("Delete Task(s)");
deleteButton.setEnabled(false);
deleteButton.addActionListener(eventHandler);
runButton = new JButton("Run");
runButton.addActionListener(eventHandler);
textFieldSearch = new JTextField(10);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
parametersFunctionsTable = new EditorScrollTable();
parametersFunctionsTableModel = new WorkflowObjectsTableModel(parametersFunctionsTable);
parametersFunctionsTable.setModel(parametersFunctionsTableModel);
tasksCheckBox = new JCheckBox("Tasks");
tasksCheckBox.setSelected(true);
tasksCheckBox.addActionListener(eventHandler);
parametersCheckBox = new JCheckBox("parameters");
parametersCheckBox.setSelected(true);
parametersCheckBox.addActionListener(eventHandler);
taskInputsCheckBox = new JCheckBox("Task inputs");
taskInputsCheckBox.setSelected(true);
taskInputsCheckBox.addActionListener(eventHandler);
taskOutputsCheckBox = new JCheckBox("Task outputs");
taskOutputsCheckBox.setSelected(true);
taskOutputsCheckBox.addActionListener(eventHandler);
JPanel buttonPanel = new JPanel(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(showButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(deleteButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(runButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 50, 4, 4);
buttonPanel.add(new JLabel("Search"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
buttonPanel.add(textFieldSearch, gbc);
setLayout(new BorderLayout());
add(getParametersFunctionsPanel(), BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
parametersFunctionsTable.setDefaultRenderer(NameScope.class, 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 NameScope) {
NameScope nameScope = (NameScope) value;
setText(nameScope.getPathDescription());
}
return this;
}
});
}
use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.
the class ViewJobsPanel method initialize.
private void initialize() {
try {
setName("ViewSimulationJobsPanel");
getRefreshAllButton().addActionListener(eventHandler);
// ----------------------------------------------------------------------------------
// filters, buttons
JPanel top = new JPanel();
// table with results
JPanel bottom = new JPanel();
Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Filters ");
titleTop.setTitleJustification(TitledBorder.LEFT);
titleTop.setTitlePosition(TitledBorder.TOP);
TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Results ");
titleBottom.setTitleJustification(TitledBorder.LEFT);
titleBottom.setTitlePosition(TitledBorder.TOP);
top.setBorder(titleTop);
bottom.setBorder(titleBottom);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
// top, left, bottom, right
gbc.insets = new Insets(5, 2, 2, 3);
add(top, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
add(bottom, gbc);
// --------------------------------------- top panel (filters, button) --------------
// filters
JPanel left = new JPanel();
JPanel center = new SeparatedJPanel();
// buttons
JPanel right = new SeparatedJPanel();
top.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(left, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(center, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(right, gbc);
// ------------------------------------ left panel (of top panel) -------------
left.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getWaitingButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
JLabel label = new JLabel(waitingIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 0);
left.add(getQueuedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(queuedIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getDispatchedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(dispatchedIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 0);
left.add(getRunningButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(runningIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getCompletedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(completedIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 3);
left.add(getFailedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(failedIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getStoppedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 3;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(stoppedIcon);
left.add(label, gbc);
// ---------------------------------------- center panel (of top panel) ------------
center.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 15, 4, 4);
center.add(new JLabel("Max # of results "), gbc);
textFieldJobsLimit = new JTextField();
textFieldJobsLimit.addActionListener(eventHandler);
// textFieldJobsLimit.getDocument().addDocumentListener(eventHandler);
textFieldJobsLimit.setText(maxRows + "");
Dimension d = textFieldJobsLimit.getPreferredSize();
d.width = 80;
textFieldJobsLimit.setPreferredSize(d);
textFieldJobsLimit.setMaximumSize(d);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 0, 4, 4);
center.add(textFieldJobsLimit, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 3);
center.add(getOrphanedButton(), gbc);
// gbc = new GridBagConstraints();
// gbc.weighty = 1.0;
// gbc.gridx = 0;
// gbc.gridy = 2;
// // gbc.gridheight = GridBagConstraints.REMAINDER;
// gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = java.awt.GridBagConstraints.VERTICAL;
// gbc.insets = new Insets(4,4,4,4);
// center.add(new JLabel("---"), gbc); // fake vertical
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 11, 4, 4);
center.add(getSubmitDatePanel(), gbc);
gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 3;
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
// fake horizontal
center.add(new JLabel("-"), gbc);
// ---------------------------------------- right panel (of top panel) -------------
right.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.weighty = 1.0;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.VERTICAL;
// fake vertical
right.add(new JLabel(""), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 12, 4, 8);
right.add(getRefreshAllButton(), gbc);
getCompletedButton().setSelected(false);
getDispatchedButton().setSelected(true);
getFailedButton().setSelected(true);
getQueuedButton().setSelected(true);
getRunningButton().setSelected(true);
getStoppedButton().setSelected(true);
getWaitingButton().setSelected(true);
getOrphanedButton().setSelected(false);
getSubmitBetweenButton().setSelected(false);
// ----------------------------------------- bottom panel (the table) -------------------
table = new EditorScrollTable();
model = new SimulationJobsTableModel(table, this);
table.setModel(model);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
table.addMouseMotionListener(new // add toolTipText for each table cell
MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
bottom.setLayout(new GridBagLayout());
int gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
// table.setPreferredScrollableViewportSize(new Dimension(700,350)); // apparently useless
bottom.add(table.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 4, 4, 4);
bottom.add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
bottom.add(textFieldSearch, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
bottom.add(countLabel, gbc);
// renderer for the status icon; the tooltip gives the text
DefaultScrollTableCellRenderer statusCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus js = (SimpleJobStatus) selectedObject;
SchedulerStatus ss1 = js.jobStatus.getSchedulerStatus();
switch(ss1) {
case WAITING:
setIcon(waitingIcon);
break;
case QUEUED:
setIcon(queuedIcon);
break;
case DISPATCHED:
setIcon(dispatchedIcon);
break;
case RUNNING:
setIcon(runningIcon);
break;
case COMPLETED:
setIcon(completedIcon);
break;
case STOPPED:
setIcon(stoppedIcon);
break;
case FAILED:
setIcon(failedIcon);
break;
default:
setIcon(failedIcon);
break;
}
// setText("");
setToolTipText(ss1.getDescription());
setHorizontalTextPosition(SwingConstants.RIGHT);
}
}
return this;
}
};
// statusCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
DefaultScrollTableCellRenderer dateTimeCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
DateFormat df = new SimpleDateFormat("MM.dd.yyyy HH:MM:SS");
Date date = sjs.jobStatus.getStartDate();
String str = df.format(date);
setToolTipText(str);
}
}
return this;
}
};
DefaultScrollTableCellRenderer hasDataCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
if (sjs.jobStatus.hasData()) {
setIcon(dataYesIcon);
} else {
setIcon(dataNoIcon);
}
}
}
return this;
}
};
table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setCellRenderer(statusCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColSubmitDate).setCellRenderer(dateTimeCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColHasData).setCellRenderer(hasDataCellRenderer);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColDepiction).setMinWidth(400);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setPreferredWidth(30);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setMaxWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
refreshInterface();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.
the class BioModelEditorApplicationRightSidePanel method initialize.
private void initialize() {
addNewButton = new JButton("New");
deleteButton = new JButton("Delete Selected");
textFieldSearch = new JTextField(10);
textFieldSearch.putClientProperty("JTextField.variant", "search");
table = new EditorScrollTable();
tableModel = createTableModel();
table.setModel(tableModel);
addNewButton.addActionListener(eventHandler);
deleteButton.addActionListener(eventHandler);
// disable 'add new' button for rate rules temporarily
if (this instanceof RateRulesDisplayPanel) {
addNewButton.setEnabled(false);
}
deleteButton.setEnabled(false);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
table.getSelectionModel().addListSelectionListener(eventHandler);
}
use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.
the class ViewGeneratedReactionsPanel method initialize.
private void initialize() {
try {
setName("ViewGeneratedReactionsPanel");
setLayout(new GridBagLayout());
shapePanel = new RulesShapePanel() {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (AbstractComponentShape stls : reactantPatternShapeList) {
stls.paintSelf(g);
}
for (AbstractComponentShape stls : productPatternShapeList) {
stls.paintSelf(g);
}
}
};
Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
shapePanel.setLayout(new GridBagLayout());
shapePanel.setBackground(Color.white);
// don't show the brown contour even though it's not editable
shapePanel.setEditable(true);
shapePanel.setShowMoleculeColor(true);
shapePanel.setShowNonTrivialOnly(true);
JScrollPane scrollPane = new JScrollPane(shapePanel);
scrollPane.setBorder(loweredBevelBorder);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new GridBagLayout());
getZoomSmallerButton().setEnabled(true);
getZoomLargerButton().setEnabled(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 0, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomLargerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(2, 0, 4, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomSmallerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1;
// fake cell used for filling all the vertical empty space
gbc.weighty = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(4, 4, 4, 10);
optionsPanel.add(new JLabel(""), gbc);
JPanel containerOfScrollPanel = new JPanel();
containerOfScrollPanel.setLayout(new BorderLayout());
containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
Dimension dim = new Dimension(500, 140);
// dimension of shape panel
containerOfScrollPanel.setPreferredSize(dim);
containerOfScrollPanel.setMinimumSize(dim);
containerOfScrollPanel.setMaximumSize(dim);
// -----------------------------------------------------------------------------
table = new EditorScrollTable();
tableModel = new GeneratedReactionTableModel(table, owner);
table.setModel(tableModel);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
// table.getColumnModel().getColumn(GeneratedReactionTableModel.iColIndex).setCellRenderer(rightRenderer); // right align first table column
// table.getColumnModel().getColumn(GeneratedReactionTableModel.iColIndex).setMaxWidth(60); // left column wide enough for 6-7 digits
int gridy = 0;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
// table.setPreferredScrollableViewportSize(new Dimension(400,200));
add(table.getEnclosingScrollPane(), gbc);
// add toolTipText for each table cell
table.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 4, 4, 4);
add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
add(textFieldSearch, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
add(totalReactionsLabel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
// gbc.weightx = 1.0;
// gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
add(containerOfScrollPanel, gbc);
// rendering the small shapes of a fake rule in the Depiction column of this viewer table)
// TODO: this renderer is almost identical with the one in BioModelEditorModelPanel (which paints the small shapes
// of a rule in the Depiction column of the reaction table)
DefaultScrollTableCellRenderer rbmReactionShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
List<SpeciesPatternSmallShape> spssList = new ArrayList<SpeciesPatternSmallShape>();
SpeciesPatternSmallShape spss = null;
@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 (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == tableModel) {
selectedObject = tableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof GeneratedReactionTableRow) {
ReactionRule rr = ((GeneratedReactionTableRow) selectedObject).getReactionRule();
Graphics panelContext = table.getGraphics();
BioModel bioModel = owner.getSimulationContext().getBioModel();
spssList.clear();
List<ReactantPattern> rpList = rr.getReactantPatterns();
int xPos = 4;
for (int i = 0; i < rpList.size(); i++) {
SpeciesPattern sp = rr.getReactantPattern(i).getSpeciesPattern();
spss = new SpeciesPatternSmallShape(xPos, 2, sp, null, panelContext, rr, isSelected, issueManager);
if (i < rpList.size() - 1) {
spss.addEndText("+");
} else {
if (rr.isReversible()) {
spss.addEndText("<->");
xPos += 7;
} else {
spss.addEndText("->");
}
}
xPos += spss.getWidth() + 14;
spssList.add(spss);
}
List<ProductPattern> ppList = rr.getProductPatterns();
xPos += 7;
for (int i = 0; i < ppList.size(); i++) {
SpeciesPattern sp = rr.getProductPattern(i).getSpeciesPattern();
spss = new SpeciesPatternSmallShape(xPos, 2, sp, null, panelContext, rr, isSelected, issueManager);
if (i < ppList.size() - 1) {
spss.addEndText("+");
}
xPos += spss.getWidth() + 14;
spssList.add(spss);
}
}
} else {
spssList.clear();
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (SpeciesPatternSmallShape spss : spssList) {
if (spss == null) {
continue;
}
spss.paintSelf(g);
}
}
};
table.getColumnModel().getColumn(GeneratedReactionTableModel.iColDepiction).setCellRenderer(rbmReactionShapeDepictionCellRenderer);
table.getColumnModel().getColumn(GeneratedReactionTableModel.iColDepiction).setPreferredWidth(400);
table.getColumnModel().getColumn(GeneratedReactionTableModel.iColDepiction).setMinWidth(400);
table.getColumnModel().getColumn(GeneratedReactionTableModel.iColDefinition).setPreferredWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
Aggregations