List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
private void doSelectedFilesChanged(PropertyChangeEvent e) { FileObject[] files = (FileObject[]) e.getNewValue(); VFSJFileChooser fc = getFileChooser(); if ((files != null) && (files.length > 0) && ((files.length > 1) || fc.isDirectorySelectionEnabled() || !VFSUtils.isDirectory(files[0]))) { setFileName(fileNameString(files)); }/*from w w w . j ava 2 s . c om*/ }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Creates, activates, and then shows the Chainsaw GUI, optionally showing * the splash screen, and using the passed shutdown action when the user * requests to exit the application (if null, then Chainsaw will exit the vm) * * @param model//w ww. j av a 2 s. c o m * @param newShutdownAction * DOCUMENT ME! */ public static void createChainsawGUI(ApplicationPreferenceModel model, Action newShutdownAction) { if (model.isOkToRemoveSecurityManager()) { MessageCenter.getInstance() .addMessage("User has authorised removal of Java Security Manager via preferences"); System.setSecurityManager(null); // this SHOULD set the Policy/Permission stuff for any // code loaded from our custom classloader. // crossing fingers... Policy.setPolicy(new Policy() { public void refresh() { } public PermissionCollection getPermissions(CodeSource codesource) { Permissions perms = new Permissions(); perms.add(new AllPermission()); return (perms); } }); } final LogUI logUI = new LogUI(); logUI.applicationPreferenceModel = model; if (model.isShowSplash()) { showSplash(logUI); } logUI.cyclicBufferSize = model.getCyclicBufferSize(); logUI.pluginRegistry = repositoryExImpl.getPluginRegistry(); logUI.handler = new ChainsawAppenderHandler(); logUI.handler.addEventBatchListener(logUI.new NewTabEventBatchReceiver()); /** * TODO until we work out how JoranConfigurator might be able to have * configurable class loader, if at all. For now we temporarily replace the * TCCL so that Plugins that need access to resources in * the Plugins directory can find them (this is particularly * important for the Web start version of Chainsaw */ //configuration initialized here logUI.ensureChainsawAppenderHandlerAdded(); logger = LogManager.getLogger(LogUI.class); //set hostname, application and group properties which will cause Chainsaw and other apache-generated //logging events to route (by default) to a tab named 'chainsaw-log' PropertyRewritePolicy policy = new PropertyRewritePolicy(); policy.setProperties("hostname=chainsaw,application=log,group=chainsaw"); RewriteAppender rewriteAppender = new RewriteAppender(); rewriteAppender.setRewritePolicy(policy); Enumeration appenders = Logger.getLogger("org.apache").getAllAppenders(); if (!appenders.hasMoreElements()) { appenders = Logger.getRootLogger().getAllAppenders(); } while (appenders.hasMoreElements()) { Appender nextAppender = (Appender) appenders.nextElement(); rewriteAppender.addAppender(nextAppender); } Logger.getLogger("org.apache").removeAllAppenders(); Logger.getLogger("org.apache").addAppender(rewriteAppender); Logger.getLogger("org.apache").setAdditivity(false); //commons-vfs uses httpclient for http filesystem support, route this to the chainsaw-log tab as well appenders = Logger.getLogger("httpclient").getAllAppenders(); if (!appenders.hasMoreElements()) { appenders = Logger.getRootLogger().getAllAppenders(); } while (appenders.hasMoreElements()) { Appender nextAppender = (Appender) appenders.nextElement(); rewriteAppender.addAppender(nextAppender); } Logger.getLogger("httpclient").removeAllAppenders(); Logger.getLogger("httpclient").addAppender(rewriteAppender); Logger.getLogger("httpclient").setAdditivity(false); //set the commons.vfs.cache logger to info, since it can contain password information Logger.getLogger("org.apache.commons.vfs.cache").setLevel(Level.INFO); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { e.printStackTrace(); logger.error("Uncaught exception in thread " + t, e); } }); String config = configurationURLAppArg; if (config != null) { logger.info("Command-line configuration arg provided (overriding auto-configuration URL) - using: " + config); } else { config = model.getConfigurationURL(); } if (config != null && (!config.trim().equals(""))) { config = config.trim(); try { URL configURL = new URL(config); logger.info("Using '" + config + "' for auto-configuration"); logUI.loadConfigurationUsingPluginClassLoader(configURL); } catch (MalformedURLException e) { logger.error("Initial configuration - failed to convert config string to url", e); } catch (IOException e) { logger.error("Unable to access auto-configuration URL: " + config); } } //register a listener to load the configuration when it changes (avoid having to restart Chainsaw when applying a new configuration) //this doesn't remove receivers from receivers panel, it just triggers DOMConfigurator.configure. model.addPropertyChangeListener("configurationURL", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String newConfiguration = evt.getNewValue().toString(); if (newConfiguration != null && !(newConfiguration.trim().equals(""))) { newConfiguration = newConfiguration.trim(); try { logger.info("loading updated configuration: " + newConfiguration); URL newConfigurationURL = new URL(newConfiguration); File file = new File(newConfigurationURL.toURI()); if (file.exists()) { logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL); } else { logger.info("Updated configuration but file does not exist"); } } catch (MalformedURLException e) { logger.error("Updated configuration - failed to convert config string to URL", e); } catch (URISyntaxException e) { logger.error("Updated configuration - failed to convert config string to URL", e); } } } }); LogManager.getRootLogger().setLevel(Level.TRACE); EventQueue.invokeLater(new Runnable() { public void run() { logUI.activateViewer(); } }); logger.info("SecurityManager is now: " + System.getSecurityManager()); if (newShutdownAction != null) { logUI.setShutdownAction(newShutdownAction); } else { logUI.setShutdownAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } }
From source file:org.talend.designer.runprocess.ui.MemoryRuntimeComposite.java
private void runProcessContextChanged(final PropertyChangeEvent evt) { if (isDisposed()) { return;/*from w w w . j av a2 s . co m*/ } String propName = evt.getPropertyName(); if (RunProcessContext.MEMORY_MONITOR.equals(propName)) { getDisplay().asyncExec(new Runnable() { @Override public void run() { if (isDisposed()) { return; } boolean monitoring = ((Boolean) evt.getNewValue()).booleanValue(); if (runtimeButton != null && !runtimeButton.isDisposed()) { setRuntimeButtonByStatus(processContext != null && processContext.isRunning()); if (processContext == null) { setRuntimeButtonByStatus(false); } else if (processContext.isRunning()) { setRuntimeButtonByStatus(false); } else { disconnectJVM(); setRuntimeButtonByStatus(true); processContext.setMonitoring(false); if (AbstractRuntimeGraphcsComposite.isMonitoring()) { AbstractRuntimeGraphcsComposite.setMonitoring(false); String content = getExecutionInfo("End"); //$NON-NLS-1$ messageManager.setEndMessage(content, getDisplay().getSystemColor(SWT.COLOR_BLUE), getDisplay().getSystemColor(SWT.COLOR_WHITE)); } ((RuntimeGraphcsComposite) chartComposite).displayReportField(); lock = false; } } if (!monitoring && chartComposite != null && chartComposite.isDisposed()) { viewPart.setSelection(null); refreshMonitorComposite(); } } }); } }
From source file:org.opencastproject.ingest.impl.IngestServiceImpl.java
private URI addContentToRepo(MediaPackage mp, String elementId, String filename, InputStream file) throws IOException { ProgressInputStream progressInputStream = new ProgressInputStream(file); progressInputStream.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w w w. j av a 2 s. c o m public void propertyChange(PropertyChangeEvent evt) { long totalNumBytesRead = (Long) evt.getNewValue(); long oldTotalNumBytesRead = (Long) evt.getOldValue(); ingestStatistics.add(totalNumBytesRead - oldTotalNumBytesRead); } }); return workingFileRepository.put(mp.getIdentifier().compact(), elementId, filename, progressInputStream); }
From source file:edu.ku.brc.specify.config.init.DatabasePanel.java
/** * /* w ww. j a va2s. c o 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 (UIRegistry.isMobile()) { DBConnection.clearMobileMachineDir(); File tmpDir = DBConnection.getMobileMachineDir(databaseName); UIRegistry.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(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")); createDBBtn.setVisible(false); setUIEnabled(false); DatabasePanel.this.label.setForeground(Color.BLACK); SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { isOK = false; DBMSUserMgr mgr = DBMSUserMgr.getInstance(); List<PermissionInfo> perms = null; boolean dbmsOK = false; if (driverInfo.isEmbedded()) { if (checkForProcesses) { ProcessListUtil.checkForMySQLProcesses(null); checkForProcesses = false; } if (UIRegistry.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)) { perms = mgr.getPermissionsForCurrentUser(); Pair<List<PermissionInfo>, List<PermissionInfo>> missingPerms = PermissionInfo .getMissingPerms(perms, createDBPerms, databaseName); if (missingPerms.getFirst().size() > 0) { final String missingPermStr = PermissionInfo.getMissingPermissionString(mgr, missingPerms.getFirst(), databaseName); SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { UIRegistry.showLocalizedError("SEC_MISSING_PERMS", dbUserName, missingPermStr); } }); dbmsOK = false; } else { dbmsOK = true; } mgr.close(); } if (dbmsOK) { properties.put(DB_SKIP_CREATE, false); if (perms != null) { properties.put(DBUSERPERMS, perms); } 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(0.5f); thumb.setMaxSize(128, 128); File attLoc = UIRegistry.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(); createDBBtn.setVisible(!isOK); if (isOK) { label.setText(UIRegistry.getResourceString("DB_CREATED")); setUIEnabled(false); } else { label.setText(UIRegistry.getResourceString(errorKey != null ? errorKey : "ERR_CRE_DB")); UIRegistry.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(UIRegistry.getResourceString(key)); } } } }); worker.execute(); } else if (status == VerifyStatus.ERROR) { errorKey = "NO_LOGIN_ROOT"; DatabasePanel.this.label.setText(UIRegistry.getResourceString(errorKey)); DatabasePanel.this.label.setForeground(Color.RED); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { UIRegistry.getTopWindow().pack(); } }); } }
From source file:edu.ku.brc.specify.ui.DBObjSearchPanel.java
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("selection")) { Integer numRowsSelected = (Integer) evt.getOldValue(); if (numRowsSelected > 0) { idList = etrb.getListOfIds(false); } else {/*w w w .ja v a 2 s. c o m*/ idList = null; } updateUIControls(); } else if (evt.getPropertyName().equals("doubleClick")) { okBtn.doClick(); } else if (evt.getPropertyName().equals("loaded")) { // If there is only one returned, then select it and focus the OK defult btn if (evt.getNewValue() != null && ((Integer) evt.getNewValue()) == 1) { ESResultsTablePanel etrbPanel = (ESResultsTablePanel) etrb; etrbPanel.getTable().setRowSelectionInterval(0, 0); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { okBtn.requestFocus(); } }); } } }
From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java
@Override public void propertyChange(PropertyChangeEvent event) { if ((calibration_step == CALIBRATION_STEP.CALIBRATION || calibration_step == CALIBRATION_STEP.WARMUP) && AudioProcess.PROP_DELAYED_STANDART_PROCESSING.equals(event.getPropertyName())) { // New leq AudioProcess.AudioMeasureResult measure = (AudioProcess.AudioMeasureResult) event.getNewValue(); final double leq; // Use global dB value or only the selected frequency band leq = measure.getGlobaldBaValue(); if (calibration_step == CALIBRATION_STEP.CALIBRATION) { leqStats.addLeq(leq);/*from ww w . j av a2 s . c om*/ if (!freqLeqStats.isEmpty() && splBackroundNoise != 0) { freqLeqStats.get(freqLeqStats.size() - 1).pushMeasure(measure.getResult()); } } runOnUiThread(new Runnable() { @Override public void run() { double leqToShow; if (calibration_step == CALIBRATION_STEP.CALIBRATION) { leqToShow = leqStats.getLeqMean(); } else { leqToShow = leq; } textDeviceLevel.setText(String.format(Locale.getDefault(), "%.1f", leqToShow)); } }); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorUI.java
/** * Removes the tags./*ww w.j a va2 s .c o m*/ * * @param src The mouse clicked location. * @param location The location of the mouse pressed. */ void removeTags(JComponent src, Point location) { if (!generalPane.hasTagsToUnlink()) return; if (model.isGroupLeader() || model.isAdministrator()) { if (tagMenu == null) { tagMenu = new PermissionMenu(PermissionMenu.REMOVE, "Tags"); tagMenu.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String n = evt.getPropertyName(); if (PermissionMenu.SELECTED_LEVEL_PROPERTY.equals(n)) { removeLinks((Integer) evt.getNewValue(), model.getAllTags()); } } }); } tagMenu.show(src, location.x, location.y); return; } SwingUtilities.convertPointToScreen(location, src); MessageBox box = new MessageBox(model.getRefFrame(), "Remove All Your Tags", "Are you sure you want to remove all your Tags?"); Dimension d = box.getPreferredSize(); Point p = new Point(location.x - d.width / 2, location.y); if (box.showMsgBox(p) == MessageBox.YES_OPTION) { List<TagAnnotationData> list = generalPane.removeTags(); if (list.size() > 0) saveData(true); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorUI.java
/** * Removes the other annotations./*from w w w . jav a 2s .c o m*/ * * @param src The mouse clicked location. * @param location The location of the mouse pressed. */ void removeOtherAnnotations(JComponent src, Point location) { if (!generalPane.hasOtherAnnotationsToUnlink()) return; if (model.isGroupLeader() || model.isAdministrator()) { if (otherAnnotationMenu == null) { otherAnnotationMenu = new PermissionMenu(PermissionMenu.REMOVE, "Other annotations"); otherAnnotationMenu.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String n = evt.getPropertyName(); if (PermissionMenu.SELECTED_LEVEL_PROPERTY.equals(n)) { removeLinks((Integer) evt.getNewValue(), model.getAllOtherAnnotations()); } } }); } otherAnnotationMenu.show(src, location.x, location.y); return; } SwingUtilities.convertPointToScreen(location, src); MessageBox box = new MessageBox(model.getRefFrame(), "Remove All Your Other Annotations", "Are you sure you want to remove all your other annotations?"); Dimension d = box.getPreferredSize(); Point p = new Point(location.x - d.width / 2, location.y); if (box.showMsgBox(p) == MessageBox.YES_OPTION) { List<AnnotationData> list = generalPane.removeOtherAnnotations(); if (list.size() > 0) saveData(true); } }
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 . ja va 2 s.co m }