List of usage examples for javax.swing ListSelectionModel addSelectionInterval
void addSelectionInterval(int index0, int index1);
From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java
/** * Inverts the current selection status of the table containing the process * instances. This means that instances that have been selected will result * being unselected and the other way round. */// w ww. j a v a 2s . c o m private void invertSelectionStatus() { ListSelectionModel selectionModel = processInstanceIDsTable.getSelectionModel(); // step through the table for (int index = 0; index < extendedLog.getSizeOfLog(); index++) { if (selectionModel.isSelectedIndex(index) == true) { // if entry is currently selected --> deselect selectionModel.removeSelectionInterval(index, index); } else { // if entry is currently not selected --> select selectionModel.addSelectionInterval(index, index); } } hideAllMetrics(); updateResults(); }
From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Updates both the visualization and the performance metrics by taking only * the selected instances into account. If all instances have been selected, * the result corresponds to the initial state. *//*from ww w. j a va2 s . c om*/ private void updateResults() { try { // check if selection is empty --> if so select whole log ListSelectionModel selectionModel = processInstanceIDsTable.getSelectionModel(); if (selectionModel.isSelectionEmpty()) { selectionModel.addSelectionInterval(0, extendedLog.getSizeOfLog() - 1); } // invoke redraw of vizualization for selected process instances only.. ArrayList selectedInstanceIDs = getSelectedInstanceIDs(); ArrayList selectedInstances = getSelectedInstances(); grappaPanel = replayResult.getVisualization(selectedInstanceIDs); grappaPanel.addGrappaListener(new ExtendedGrappaAdapter()); mapping = new HashMap(); buildGraphMapping(mapping, grappaPanel.getSubgraph()); modelContainer = new JScrollPane(grappaPanel); centerPanel.removeAll(); centerPanel.add(modelContainer, BorderLayout.CENTER); centerPanel.validate(); centerPanel.repaint(); //update process metrics and display them displayProcessMetrics(selectedInstances); //calculate the values for the simulation model calculateValuesForSimulationModel(getSelectedInstances(), getSelectedInstanceIDs()); // update the provided object (visualization might have changed) extendedPetriNet = (ExtendedPetriNet) replayResult.replayedPetriNet; //Make sure that what was selected before the update, is now //selected again. if (elt1 instanceof ExtendedTransition) { //transition was selected, select it again in sb1 ExtendedTransition trans = (ExtendedTransition) elt1; sb1.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " " + trans.getLogEvent().getEventType()); if (elt2 instanceof ExtendedTransition) { //another transition was selected too, select it again in sb2 trans = (ExtendedTransition) elt2; sb2.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " " + trans.getLogEvent().getEventType()); } } else if (elt1 instanceof ExtendedPlace) { //place was selected, select it in sb1 ExtendedPlace place = (ExtendedPlace) elt1; sb1.setSelectedItem("Place - " + place.getIdentifier()); } else { //nothing selected, set sb1 and sb2 to index 0 sb1.setSelectedIndex(0); sb2.setSelectedIndex(0); } } catch (Exception ex) { JOptionPane.showMessageDialog(this, "An internal error occured while\nupdating the visualization."); Message.add("Probably not found.\n" + ex.toString(), 2); ex.printStackTrace(); } }
From source file:org.wings.SList.java
/** * Select some cells./*from w w w . j a v a 2 s. c o m*/ * * @param indices The indices of the cells to select * @see ListSelectionModel#addSelectionInterval * @see #isSelectedIndex * @see #addListSelectionListener */ public void setSelectedIndices(int[] indices) { ListSelectionModel sm = getSelectionModel(); int[] oldVal = this.getSelectedIndices(); sm.clearSelection(); for (int i = 0; i < indices.length; i++) { sm.addSelectionInterval(indices[i], indices[i]); } propertyChangeSupport.firePropertyChange("selectedIndices", oldVal, this.getSelectedIndices()); }