List of usage examples for java.beans PropertyChangeEvent getPropertyName
public String getPropertyName()
From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java
/** * Listens to property fired by the Editor dialog. * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) *//*from w w w. j a v a 2 s .c om*/ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) { //reset text and tooltip String text = ""; String description = ""; AnnotationData annotation = null; if (data instanceof TagAnnotationData || data instanceof TermAnnotationData || data instanceof XMLAnnotationData) { annotation = (AnnotationData) data; text = annotation.getContentAsString(); } description = model.getAnnotationDescription(annotation); if (annotation == null) return; label.setText(text); label.setToolTipText(formatToolTip(annotation, null)); originalName = text; originalDescription = description; firePropertyChange(AnnotationUI.EDIT_TAG_PROPERTY, null, this); } else if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { if (data == null) return; FileAnnotationData fa = (FileAnnotationData) data; OriginalFile f = (OriginalFile) fa.getContent(); File folder; Object o = evt.getNewValue(); if (o instanceof String) { String path = (String) o; if (!path.endsWith(File.separator)) { path += File.separator; } path += fa.getFileName(); folder = new File(path); } else { File[] files = (File[]) o; folder = files[0]; } if (folder == null) folder = UIUtilities.getDefaultFolder(); UserNotifier un = EditorAgent.getRegistry().getUserNotifier(); IconManager icons = IconManager.getInstance(); DownloadActivityParam activity = new DownloadActivityParam(f, folder, icons.getIcon(IconManager.DOWNLOAD_22)); //Check Name space activity.setLegend(fa.getDescription()); un.notifyActivity(model.getSecurityContext(), activity); } }
From source file:DragDropTreeExample.java
public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (propertyName.equals("enabled")) { // Enable the drop target if the FileTree is enabled // and vice versa. dropTarget.setActive(tree.isEnabled()); }/* www. j av a 2 s . c om*/ }
From source file:org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.java
@Override public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(HashDb.Event.INDEXING_DONE.name())) { HashDb hashDb = (HashDb) event.getNewValue(); if (null != hashDb) { try { String indexPath = hashDb.getIndexPath(); if (!indexPath.equals("None")) { //NON-NLS hashSetPaths.add(indexPath); }/*from w w w . ja va2 s . c o m*/ } catch (TskCoreException ex) { Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error getting index path of " + hashDb.getHashSetName() + " hash database after indexing", ex); //NON-NLS } } } }
From source file:com.jaspersoft.studio.property.section.style.inerithance.StylesListSection.java
/** * Override of the property change handler, check if the last event received was already notified *//*from ww w . j a v a 2 s .c om*/ public void propertyChange(PropertyChangeEvent evt) { if (!evt.getPropertyName().equals(ExternalStylesManager.STYLE_FOUND_EVENT)) { updatePanelJob.cancel(); updatePanelJob.schedule(UPDATE_DELAY); } }
From source file:org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage.java
public void propertyChange(PropertyChangeEvent evt) { if (PluginConstant.ISDIRTY_PROPERTY.equals(evt.getPropertyName())) { ((AnalysisEditor) currentEditor).firePropertyChange(IEditorPart.PROP_DIRTY); } else if (PluginConstant.DATAFILTER_PROPERTY.equals(evt.getPropertyName())) { this.columnSetAnalysisHandler.setStringDataFilter((String) evt.getNewValue()); }/*from w w w. jav a 2 s. com*/ }
From source file:ca.sqlpower.dao.SPPersisterListener.java
public void propertyChanged(PropertyChangeEvent evt) { SPObject source = (SPObject) evt.getSource(); String uuid = source.getUUID(); String propertyName = evt.getPropertyName(); Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); try {/*from w w w. j a va 2s. co m*/ if (!PersisterHelperFinder.findPersister(source.getClass()).getPersistedProperties() .contains(propertyName)) { logger.debug( "Tried to persist a property that shouldn't be. Ignoring the property: " + propertyName); return; } } catch (Exception e) { throw new RuntimeException(e); } if (!((SPObject) evt.getSource()).getRunnableDispatcher().isForegroundThread()) { throw new RuntimeException("Property change " + evt + " not fired on the foreground."); } Object oldBasicType = converter.convertToBasicType(oldValue); Object newBasicType = converter.convertToBasicType(newValue); PersistedSPOProperty property = null; for (PersistedSPOProperty p : persistedProperties.get(uuid)) { if (p.getPropertyName().equals(propertyName)) { property = p; break; } } if (property != null) { boolean valuesMatch; if (property.getNewValue() == null) { valuesMatch = oldBasicType == null; } else { // Check that the old property's new value is equal to the new change's old value. // Also, accept the change if it is the same as the last one. valuesMatch = property.getNewValue().equals(oldBasicType) || (property.getOldValue().equals(oldBasicType) && property.getNewValue().equals(newBasicType)); } if (!valuesMatch) { try { throw new RuntimeException("Multiple property changes do not follow after each other properly. " + "Property " + property.getPropertyName() + ", on object " + source + " of type " + source.getClass() + ", Old " + oldBasicType + ", new " + property.getNewValue()); } finally { this.rollback(); } } } if (wouldEcho()) { //The persisted property was changed by a persist call received from the server. //The property is removed from the persist calls as it now matchs what is //in the server. persistedProperties.remove(uuid, property); return; } transactionStarted(TransactionEvent.createStartTransactionEvent(this, "Creating start transaction event from propertyChange on object " + evt.getSource().getClass().getSimpleName() + " and property name " + evt.getPropertyName())); //Not persisting non-settable properties. //TODO A method in the persister helpers would make more sense than //using reflection here. PropertyDescriptor propertyDescriptor; try { propertyDescriptor = PropertyUtils.getPropertyDescriptor(source, propertyName); } catch (Exception ex) { this.rollback(); throw new RuntimeException(ex); } if (propertyDescriptor == null || propertyDescriptor.getWriteMethod() == null) { transactionEnded(TransactionEvent.createEndTransactionEvent(this)); return; } DataType typeForClass = PersisterUtils.getDataType(newValue == null ? Void.class : newValue.getClass()); boolean unconditional = false; if (property != null) { // Hang on to the old value oldBasicType = property.getOldValue(); // If an object was created, and unconditional properties are being sent, // this will maintain that flag in the event of additional property changes // to the same property in the same transaction. unconditional = property.isUnconditional(); persistedProperties.remove(uuid, property); } logger.debug("persistProperty(" + uuid + ", " + propertyName + ", " + typeForClass.name() + ", " + oldValue + ", " + newValue + ")"); persistedProperties.put(uuid, new PersistedSPOProperty(uuid, propertyName, typeForClass, oldBasicType, newBasicType, unconditional)); this.transactionEnded(TransactionEvent.createEndTransactionEvent(this)); }
From source file:com.rubenlaguna.en4j.mainmodule.NoteListTopComponent.java
@Override public synchronized void propertyChange(final PropertyChangeEvent evt) { LOG.info("change in noterepository / index"); if (updateAllNotesTask == null) { updateAllNotesTask = createUpdateAllNotesTask(); }/* www. j av a 2 s .com*/ if (refreshTask == null) { Runnable runnable = new Runnable() { @Override public void run() { NoteListTopComponent.this.refresh(); } }; refreshTask = new RepeatableTask(runnable, 4000); } if ("notes".equals(evt.getPropertyName())) { LOG.log(Level.INFO, "Event {0} received updating allNotes", evt.getPropertyName()); updateAllNotesTask.schedule(); } else { LOG.log(Level.INFO, "Event {0} doesn't require update of allNotes", evt.getPropertyName()); } refreshTask.schedule(); }
From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java
/** * //from www.jav a2 s .co m */ public void createDB() { getValues(properties); final String databaseName = dbNameTxt.getText(); final String dbUserName = usernameTxt.getText(); final String dbPwd = passwordTxt.getText(); final String hostName = hostNameTxt.getText(); if (isMobile()) { DBConnection.clearMobileMachineDir(); File tmpDir = DBConnection.getMobileMachineDir(databaseName); setEmbeddedDBPath(tmpDir.getAbsolutePath()); } final DatabaseDriverInfo driverInfo = (DatabaseDriverInfo) drivers.getSelectedItem(); String connStrInitial = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName, databaseName, dbUserName, dbPwd, driverInfo.getName()); //System.err.println(connStrInitial); DBConnection.checkForEmbeddedDir("createDB - " + connStrInitial); DBConnection.getInstance().setDriverName(driverInfo.getName()); DBConnection.getInstance().setServerName(hostName); VerifyStatus status = verifyDatabase(properties); if ((isOK == null || !isOK) && status == VerifyStatus.OK) { progressBar.setIndeterminate(true); progressBar.setVisible(true); label.setText(getResourceString("CONN_DB")); setUIEnabled(false); DatabasePanel.this.label.setForeground(Color.BLACK); SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { /* (non-Javadoc) * @see javax.swing.SwingWorker#doInBackground() */ @Override protected Object doInBackground() throws Exception { isOK = false; DBMSUserMgr mgr = DBMSUserMgr.getInstance(); boolean dbmsOK = false; if (driverInfo.isEmbedded()) { if (checkForProcesses) { SpecifyDBSecurityWizardFrame.checkForMySQLProcesses(); checkForProcesses = false; } if (isMobile()) { File mobileTmpDir = DBConnection.getMobileMachineDir(); if (!mobileTmpDir.exists()) { if (!mobileTmpDir.mkdirs()) { System.err.println( "Dir[" + mobileTmpDir.getAbsolutePath() + "] didn't get created!"); // throw exception } DBConnection.setCopiedToMachineDisk(true); } } String newConnStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName, databaseName, dbUserName, dbPwd, driverInfo.getName()); if (driverInfo.isEmbedded()) { //System.err.println(newConnStr); try { Class.forName(driverInfo.getDriverClassName()); // This call will create the database if it doesn't exist DBConnection testDB = DBConnection.createInstance(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), databaseName, newConnStr, dbUserName, dbPwd); testDB.getConnection(); // Opens the connection if (testDB != null) { testDB.close(); } dbmsOK = true; } catch (Exception ex) { ex.printStackTrace(); } DBConnection.getInstance().setDatabaseName(null); } } else if (mgr.connectToDBMS(dbUserName, dbPwd, hostName)) { mgr.close(); dbmsOK = true; } if (dbmsOK) { firePropertyChange(PROPNAME, 0, 1); try { SpecifySchemaGenerator.generateSchema(driverInfo, hostName, databaseName, dbUserName, dbPwd); // false means create new database, true means update String connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Create, hostName, databaseName); if (connStr == null) { connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName, databaseName); } firePropertyChange(PROPNAME, 0, 2); // tryLogin sets up DBConnection if (UIHelper.tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), dbNameTxt.getText(), connStr, dbUserName, dbPwd)) { if (!checkEngineCharSet(properties)) { return false; } isOK = true; firePropertyChange(PROPNAME, 0, 3); Thumbnailer thumb = Thumbnailer.getInstance(); File thumbFile = XMLHelper.getConfigDir("thumbnail_generators.xml"); thumb.registerThumbnailers(thumbFile); thumb.setQuality(.5f); thumb.setMaxSize(128, 128); File attLoc = getAppDataSubDir("AttachmentStorage", true); AttachmentManagerIface attachMgr = new FileStoreAttachmentManager(attLoc); AttachmentUtils.setAttachmentManager(attachMgr); AttachmentUtils.setThumbnailer(thumb); } else { errorKey = "NO_LOGIN_ROOT"; } } catch (Exception ex) { errorKey = "DB_UNRECOVERABLE"; } } else { errorKey = "NO_CONN_ROOT"; mgr.close(); } return null; } /* (non-Javadoc) * @see javax.swing.SwingWorker#done() */ @Override protected void done() { super.done(); setUIEnabled(true); progressBar.setIndeterminate(false); progressBar.setVisible(false); updateBtnUI(); if (isOK) { label.setText(getResourceString("DB_CREATED")); setUIEnabled(false); } else { label.setText(getResourceString(errorKey != null ? errorKey : "ERR_CRE_DB")); showLocalizedError(errorKey != null ? errorKey : "ERR_CRE_DB"); } } }; worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (PROPNAME.equals(evt.getPropertyName())) { String key = null; switch ((Integer) evt.getNewValue()) { case 1: key = "BLD_SCHEMA"; break; case 2: key = "DB_FRST_LOGIN"; break; case 3: key = "BLD_CACHE"; break; default: break; } if (key != null) { DatabasePanel.this.label.setText(getResourceString(key)); } } } }); worker.execute(); } else if (status == VerifyStatus.ERROR) { errorKey = "NO_LOGIN_ROOT"; DatabasePanel.this.label.setText(getResourceString(errorKey)); DatabasePanel.this.label.setForeground(Color.RED); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getTopWindow().pack(); } }); } }
From source file:au.org.ala.delta.editor.DeltaEditor.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (_activeController == null) { return;//from w ww. j a va 2 s . c o m } if (evt.getSource() == _activeController.getModel()) { if ("modified".equals(evt.getPropertyName())) { setSaveEnabled((Boolean) evt.getNewValue()); } } }
From source file:org.jitsi.videobridge.VideoChannel.java
@Override public void propertyChange(PropertyChangeEvent ev) { super.propertyChange(ev); String propertyName = ev.getPropertyName(); if (Endpoint.PINNED_ENDPOINTS_PROPERTY_NAME.equals(propertyName)) { lastNController.setPinnedEndpointIds((List<String>) ev.getNewValue()); } else if (Content.CHANNEL_MODIFIED_PROPERTY_NAME.equals(propertyName)) { // Another channel in this content has been modified ( // added/removed/modified source group, same with payload types, etc) // This has implications in SSRC rewriting, we need to update our // engine. logger.debug("Handling CHANNEL_MODIFIED_PROPERTY_NAME"); VideoChannel videoChannel = (VideoChannel) ev.getNewValue(); updateTranslatedVideoChannel(videoChannel); }//from w ww .ja v a 2 s .c o m }