List of usage examples for javax.swing.event ChangeEvent ChangeEvent
public ChangeEvent(Object source)
From source file:edu.ku.brc.af.ui.forms.validation.ValComboBox.java
/** * @param makeEditable//from www.ja v a2 s . c o m */ public void init(final boolean makeEditable) { if (makeEditable) { Java2sAutoComboBox cbx = (Java2sAutoComboBox) comboBox; textEditor = cbx.getAutoTextFieldEditor().getAutoTextFieldEditor(); textEditor.addKeyListener(getTextKeyAdapter()); addPopupMenu(textEditor); comboBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { comboBox.setSelectedIndex(-1); } notifyChangeListeners(new ChangeEvent(ValComboBox.this)); } @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { comboBox.setSelectedIndex(-1); } super.keyReleased(e); } /* (non-Javadoc) * @see java.awt.event.KeyAdapter#keyTyped(java.awt.event.KeyEvent) */ @Override public void keyTyped(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { comboBox.setSelectedIndex(-1); } super.keyTyped(e); } }); } setOpaque(false); if (defaultTextBGColor == null) { defaultTextBGColor = (new JTextField()).getBackground(); } setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g", "p:g:f"), this); CellConstraints cc = new CellConstraints(); builder.add(comboBox, cc.xy(1, 1)); comboBox.getModel().addListDataListener(this); if (valTextColor == null || requiredFieldColor == null) { valTextColor = AppPrefsCache.getColorWrapper("ui", "formatting", "valtextcolor"); requiredFieldColor = AppPrefsCache.getColorWrapper("ui", "formatting", "requiredfieldcolor"); } if (valTextColor != null) { AppPrefsCache.addChangeListener("ui.formatting.valtextcolor", this); AppPrefsCache.addChangeListener("ui.formatting.requiredfieldcolor", this); } }
From source file:AncestorTree.java
public boolean stopCellEditing() { if (m_item != null) m_item.m_data = m_editor.getText(); ChangeEvent e = new ChangeEvent(this); for (int k = 0; k < m_listeners.size(); k++) { CellEditorListener l = (CellEditorListener) m_listeners.elementAt(k); l.editingStopped(e);/* w w w. ja v a2 s . c om*/ } removeEditor(); return true; }
From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVChart.java
protected void fireStateChanged() { if (changeListeners != null) { List<ChangeListener> listeners = new ArrayList<ChangeListener>(changeListeners); ChangeEvent evt = new ChangeEvent(this); for (ChangeListener l : listeners) l.stateChanged(evt);/*from ww w . j a v a 2s .c o m*/ } }
From source file:AncestorTree.java
public void cancelCellEditing() { ChangeEvent e = new ChangeEvent(this); for (int k = 0; k < m_listeners.size(); k++) { CellEditorListener l = (CellEditorListener) m_listeners.elementAt(k); l.editingCanceled(e);/*from w w w. j a v a 2s .co m*/ } removeEditor(); }
From source file:UndoExample5.java
protected void fireChangeEvent() { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChangeListener.class) { if (changeEvent == null) { changeEvent = new ChangeEvent(this); }/*from w ww .j a v a 2 s.c o m*/ ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent); } } }
From source file:edu.ku.brc.specify.ui.db.PickListTableAdapter.java
@Override public PickListItemIFace addItem(final String title, final String value) { // this should never happen! if (pickList.getType() != PickListDBAdapterIFace.Type.TableField.value()) { throw new RuntimeException("This type of PickList cannot be added to"); }// ww w. j ava2 s . c o m int sizeLimit = 50; // arbitrary size could be a pref (XXX PREF) Integer sizeLimitInt = pickList.getSizeLimit(); if (sizeLimitInt != null) { sizeLimit = sizeLimitInt.intValue(); } searchablePLI.setTitle(title); int index = Collections.binarySearch(items, searchablePLI); if (index < 0) { // find oldest item and remove it if (items.size() >= sizeLimit && sizeLimit > 0) { PickListItemIFace oldest = null; for (PickListItemIFace pli : items) { if (oldest == null || pli.getTimestampCreated().getTime() < oldest.getTimestampCreated().getTime()) { oldest = pli; } } items.remove(oldest); pickList.removeItem(oldest); } PickListItem item = new PickListItem(title, value, new Timestamp(System.currentTimeMillis())); items.add(item); if (pickList != null) { pickList.addItem(item); item.setPickList(pickList); pickList.reorder(); } Collections.sort(items); super.fireContentsChanged(this, 0, items.size() - 1); for (ChangeListener cl : changeListeners) { cl.stateChanged(new ChangeEvent(this)); } return item; } // else return items.elementAt(index); }
From source file:edu.ku.brc.specify.plugins.CollectionRelOneToManyPlugin.java
/** * /*from w w w. j a va2 s . c o m*/ */ private void showSearch() { ViewBasedSearchDialogIFace srchDlg = getViewbasedFactory().createSearchDialog(null, "CollectionObjectSearch"); //$NON-NLS-1$ if (srchDlg != null) { srchDlg.registerQueryBuilder( CollectionRelPlugin.createSearchQueryBuilder(isLeftSide, leftSideCol, rightSideCol)); srchDlg.setTitle(DBTableIdMgr.getInstance().getTitleForId(CollectionObject.getClassTableId())); srchDlg.getDialog().setVisible(true); if (!srchDlg.isCancelled()) { CollectionObject colObj = (CollectionObject) srchDlg.getSelectedObject(); if (colObj != null) { // Make sure this no one is already pointing at it. if (CollectionRelPlugin.isColObjAlreadyUsed(colRelType.getId(), rightSideCol.getId(), colObj.getCatalogNumber(), catNumFormatter)) { return; } if (!existsInCollectionRel(currentColObj.getLeftSideRels(), colObj)) { CollectionRelationship collectionRel = new CollectionRelationship(); collectionRel.initialize(); collectionRel.setCollectionRelType(colRelType); //colRelType.getRelationships().add(collectionRel); collectionRel.setLeftSide(currentColObj); collectionRel.setRightSide(colObj); currentColObj.getLeftSideRels().add(collectionRel); colObjs.add(collectionRel); DataProviderSessionIFace tmpSession = null; try { tmpSession = DataProviderFactory.getInstance().createSession(); tmpSession.attach(colObj); colObj.getCollection().getId(); // force load colObj.getRightSideRels().add(collectionRel); } catch (Exception ex) { ex.printStackTrace(); } finally { if (tmpSession != null) tmpSession.close(); } model.fireTableDataChanged(); notifyChangeListeners(new ChangeEvent(this)); } } } } }
From source file:edu.ku.brc.af.ui.forms.validation.ValComboBox.java
/** * @return//from ww w. jav a2 s . c o m */ private KeyAdapter getTextKeyAdapter() { return new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); notifyChangeListeners(new ChangeEvent(ValComboBox.this)); } @Override public void keyReleased(KeyEvent e) { super.keyReleased(e); } }; }
From source file:fungus.UtilizationObserver.java
public static void notifyChangeListeners() { for (ChangeListener cl : changeListeners) { cl.stateChanged(new ChangeEvent(UtilizationObserver.class)); }/*from w ww .ja v a 2s . c o m*/ }
From source file:fungus.JungObserver.java
public boolean execute() { MycoCast mycocast = (MycoCast) Network.get(0).getProtocol(mycocastPid); int bio = mycocast.countBiomass(); int bul = mycocast.countBulwark(); int ext = mycocast.countExtending(); int bra = mycocast.countBranching(); int imm = mycocast.countImmobile(); // Need to wipe existing graph (reimplement with some intelligence) //for (String v : graph.getVertices()) { // System.out.println("womble"); // graph.removeVertex(v); // }// w w w . j a v a 2 s. com // Update vertices Set<MycoNode> activeNodes = new HashSet<MycoNode>(); for (int i = 0; i < Network.size(); i++) { MycoNode n = (MycoNode) Network.get(i); activeNodes.add(n); HyphaData data = n.getHyphaData(); //if (data.isBiomass()) { continue; } if (graph.containsVertex(n)) { graph.removeVertex(n); } if (!graph.containsVertex(n)) { graph.addVertex(n); } } Set<MycoNode> visualizerNodes = new HashSet<MycoNode>(graph.getVertices()); visualizerNodes.removeAll(activeNodes); for (MycoNode n : visualizerNodes) { graph.removeVertex(n); } // Update edges for (int i = 0; i < Network.size(); i++) { MycoNode n = (MycoNode) Network.get(i); HyphaData data = n.getHyphaData(); HyphaLink link = n.getHyphaLink(); MycoList neighbors = link.getHyphae(); Collection<MycoNode> jungNeighbors = graph.getNeighbors(n); for (MycoNode o : jungNeighbors) { if (!neighbors.contains(o)) { String edge = graph.findEdge(n, o); if (edge != null) { graph.removeEdge(edge); } /*String edgeName; if (n.getID() < o.getID()) { edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); } else { edgeName = Long.toString(o.getID()) + "-" + Long.toString(n.getID()); } graph.removeEdge(edgeName);*/ } } for (MycoNode o : neighbors) { String edgeName; edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); if (!graph.containsEdge(edgeName)) { graph.addEdge(edgeName, n, o, EdgeType.DIRECTED); } /* String edgeName; if (n.getID() < o.getID()) { edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); } else { edgeName = Long.toString(o.getID()) + "-" + Long.toString(n.getID()); } if (!graph.containsEdge(edgeName)) { graph.addEdge(edgeName, n, o, EdgeType.UNDIRECTED); }*/ } } visualizer.stateChanged(new ChangeEvent(graph)); try { while (stepBlocked && !noBlock) { synchronized (this) { wait(); } } } catch (InterruptedException e) { stepBlocked = true; } stepBlocked = true; //System.out.println(graph.toString()); return false; }