List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:edu.ku.brc.specify.dbsupport.SpecifySchemaUpdateService.java
/** * Changes all the contents of the Geography 'Name' field from the geonames 'name' to 'acsiiname' to * get rid of the unprintable ascii characters. *///w ww. jav a 2 s. com public void updateGeographyNames() { final String FIXED_GEO = "FIXED.GEOGRAPHY"; if (AppPreferences.getGlobalPrefs().getBoolean(FIXED_GEO, false)) { //return; } String sql = String.format( "SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = 'geoname'", DBConnection.getInstance().getDatabaseName()); if (BasicSQLUtils.getCount(sql) == 0) { AppPreferences.getGlobalPrefs().putBoolean(FIXED_GEO, true); return; } final int numRecs = BasicSQLUtils.getCountAsInt( "SELECT COUNT(*) FROM geoname ge INNER JOIN geography g ON ge.name = g.Name WHERE ge.Name <> ge.asciiname"); if (BasicSQLUtils.getCount(sql) == 0) { AppPreferences.getGlobalPrefs().putBoolean(FIXED_GEO, true); return; } final ProgressFrame prefProgFrame = new ProgressFrame(getResourceString("UPDATE_SCHEMA_TITLE")); prefProgFrame.adjustProgressFrame(); prefProgFrame.getCloseBtn().setVisible(false); prefProgFrame.getProcessProgress().setIndeterminate(true); prefProgFrame.setDesc(UIRegistry.getLocalizedMessage("UPDATE_GEO")); UIHelper.centerAndShow(prefProgFrame); prefProgFrame.setProcess(0, 100); SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() { @Override protected Boolean doInBackground() throws Exception { Statement stmt = null; PreparedStatement pStmt = null; try { Connection currDBConn = DBConnection.getInstance().getConnection(); pStmt = currDBConn.prepareStatement("UPDATE geography SET Name=? WHERE GeographyID=?"); stmt = currDBConn.createStatement(); int cnt = 0; String sqlStr = "SELECT ge.asciiname, g.GeographyID FROM geoname ge INNER JOIN geography g ON ge.name = g.Name WHERE ge.Name <> ge.asciiname"; ResultSet rs = stmt.executeQuery(sqlStr); while (rs.next()) { pStmt.setString(1, rs.getString(1)); pStmt.setInt(2, rs.getInt(2)); if (pStmt.executeUpdate() != 1) { } cnt++; if (prefProgFrame != null && cnt % 100 == 0) { setProgress((int) (cnt / numRecs * 100.0)); } } rs.close(); if (prefProgFrame != null) { prefProgFrame.setProcess(numRecs); } AppPreferences.getGlobalPrefs().putBoolean(FIXED_GEO, true); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildFromGeonames.class, ex); } finally { try { if (stmt != null) { stmt.close(); } if (pStmt != null) { pStmt.close(); } } catch (Exception ex) { ex.printStackTrace(); } } return true; } /* (non-Javadoc) * @see javax.swing.SwingWorker#done() */ @Override protected void done() { super.done(); prefProgFrame.setVisible(false); prefProgFrame.dispose(); } }; worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { prefProgFrame.setProcess((Integer) evt.getNewValue()); } } }); worker.execute(); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java
/** * Implemented as specified by the {@link TreeViewer} interface. * @see TreeViewer#handleSplitImage(Map, Object, int) *//*www. j av a 2 s .c o m*/ public void handleSplitImage(ImageCheckerResult result, final Object action, ImageCheckerType index) { if (!CollectionUtils.isEmpty(result.getMifResults())) { //Indicate what do depending on the index. MIFNotificationDialog dialog = new MIFNotificationDialog(view, result.getMifResults(), action, index, TreeViewerAgent.getAvailableUserGroups()); dialog.addPropertyChangeListener(new PropertyChangeListener() { /** * Moves the data. */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (MIFNotificationDialog.MOVE_ALL_PROPERTY.equals(name)) { moveObject((ChgrpObject) evt.getNewValue()); } } }); UIUtilities.centerAndShow(dialog); return; } // show a warning if the images to be deleted are linked to multiple datasets: if (ImageCheckerType.DELETE.equals(index) && !result.getMultiLinkedImages().isEmpty()) { LinkNotificationDialog dialog = new LinkNotificationDialog(view, result); dialog.addPropertyChangeListener(new PropertyChangeListener() { /** * Removes the data */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (LinkNotificationDialog.DELETE_PROPERTY.equals(name)) { delete((List) action); } } }); UIUtilities.centerAndShow(dialog); return; } if (ImageCheckerType.DELETE.equals(index)) { delete((List) action); } else if (ImageCheckerType.CHGRP.equals(index)) { moveObject((ChgrpObject) action); } }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java
/** * Moves the object.// w w w . j ava2s . c o m * * @param object The object to move. */ private void moveObject(ChgrpObject object) { GroupData group = object.getGroupData(); SecurityContext ctx = new SecurityContext(group.getId()); long userID = object.getUserID(); if (userID >= 0) { ExperimenterData exp = model.getExperimenter(); if (userID == exp.getId()) { Class<?> type = object.getDataType(); if (ImageData.class.equals(type) || DatasetData.class.equals(type)) type = ProjectData.class; else if (ProjectData.class.equals(type)) type = null; else if (PlateData.class.equals(type)) type = ScreenData.class; else if (ScreenData.class.equals(type)) type = null; else if (GroupData.class.equals(type) || ExperimenterData.class.equals(type)) type = null; if (type != null) { MoveGroupSelectionDialog dialog = new MoveGroupSelectionDialog(view, userID, object, true); dialog.addPropertyChangeListener(new PropertyChangeListener() { /** * Transfers the data. */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (MoveGroupSelectionDialog.TRANSFER_PROPERTY.equals(name)) { ChgrpObject v = (ChgrpObject) evt.getNewValue(); GroupData group = v.getGroupData(); SecurityContext ctx = new SecurityContext(group.getId()); moveData(ctx, v.getTarget(), v.getTransferable()); } } }); model.fireMoveDataLoading(ctx, dialog, type, userID); UIUtilities.centerAndShow(dialog); } } else moveData(ctx, object.getTarget(), object.getTransferable()); } else { moveData(ctx, object.getTarget(), object.getTransferable()); } }
From source file:org.nuclos.client.ui.collect.CollectController.java
protected void initTab() { // prevent that the frame is closed when changes are pending: getTab().addVetoableChangeListener(new VetoableChangeListener() { @Override//from w w w . ja va 2 s . co m public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { if (evt.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY)) { final Boolean bOldValue = (Boolean) evt.getOldValue(); final Boolean bNewValue = (Boolean) evt.getNewValue(); if (bOldValue == Boolean.FALSE && bNewValue == Boolean.TRUE) { // We need bFrameMayBeClosed as a member variable here, as it is set in // cmdFrameClosing and must be checked here. // JInternalFrame.setClosed() first sends a frame closing event, then a vetoable change event. // Note that this is totally weird. See JInternalFrame.setClosed() if (!CollectController.this.bFrameMayBeClosed) { throw new PropertyVetoException("do not close", evt); } } } } }); // override close behavior: getTab().addMainFrameTabListener(new MainFrameTabAdapter() { @Override public void tabSelected(MainFrameTab tab) { setDefaultButton(); } @Override public void tabClosing(MainFrameTab tab, final ResultListener<Boolean> rl) { askAndSaveIfNecessary(new ResultListener<Boolean>() { @Override public void done(Boolean result) { rl.done(Boolean.TRUE.equals(result)); } }); } @Override public void tabClosed(MainFrameTab tab) { CollectController.this.close(); tab.removeMainFrameTabListener(this); } }); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
/** * //from www. j ava 2s.c o m * Added by Ben. 14/10/2013. */ private void setMultipleRootFromFolders_startThread() { BuildIEWorker buildIE = new BuildIEWorker("SetMultipleRootFromFolders"); buildIE.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name.equals("progress")) { int progress = (Integer) evt.getNewValue(); manualDepositFrame.setProgressLevel(progress); } } }); buildIE.execute(); return; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
/** * //from w w w. j a v a 2 s .c om * Added by Ben. 14/10/2013. */ private void setMultipleRoot_startThread() { BuildIEWorker buildIE = new BuildIEWorker("SetMultipleRoot"); buildIE.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name.equals("progress")) { int progress = (Integer) evt.getNewValue(); manualDepositFrame.setProgressLevel(progress); } } }); buildIE.execute(); return; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
/** * /*from w ww. j a va 2 s. c o m*/ * Added by Ben. 14/10/2013. */ private void setRoot_startThread(String entityName, String filePrefix, boolean updateScreen, boolean childrenLoaded) { BuildIEWorker buildIE = new BuildIEWorker("SetRoot", entityName, filePrefix, updateScreen, childrenLoaded); buildIE.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name.equals("progress")) { int progress = (Integer) evt.getNewValue(); manualDepositFrame.setProgressLevel(progress); } } }); buildIE.execute(); return; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
/** * //from ww w . j ava 2s . com * Added by Ben. 14/10/2013. */ private void dragFromFileSystemTree_startThread(List<FileGroupCollection> entities, FileSystemObject rootNode, boolean recursive, boolean isEditingEntity) { BuildIEWorker buildIE = new BuildIEWorker("dragFromFileSystemTree", entities, rootNode, recursive, isEditingEntity); buildIE.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name.equals("progress")) { int progress = (Integer) evt.getNewValue(); manualDepositFrame.setProgressLevel(progress); } } }); buildIE.execute(); return; }