List of usage examples for java.beans PropertyChangeEvent getPropertyName
public String getPropertyName()
From source file:org.polymap.core.mapeditor.tooling.edit.BaseVectorLayer.java
/** * Listen to feature selection changes from {@link LayerFeatureSelectionManager}. *//*from www . ja v a 2s. c o m*/ @Override @EventHandler public void propertyChange(PropertyChangeEvent ev) { if (fsm == ev.getSource()) { //select if (ev.getPropertyName().equals(LayerFeatureSelectionManager.PROP_FILTER)) { selectFeatures(fsm.getFeatureCollection()); } // // hover // else if (ev.getPropertyName().equals( LayerFeatureSelectionManager.PROP_HOVER )) { // selectControl.unselectAll(); // selectControl.selectFids( Collections.singletonList( (String)ev.getNewValue() ) ); // } } }
From source file:org.orbisgis.mapeditorapi.MapElement.java
/** * Set this element as modified/* w w w .jav a2s. com*/ */ public void onMapUpdate(PropertyChangeEvent evt) { if (!ignoredModificationEvents.contains(evt.getPropertyName())) { setModified(true); } }
From source file:com.github.alexfalappa.nbspringboot.projects.service.spi.SpringBootServiceImpl.java
private void init() { if (mvnPrj == null) { return;/*from ww w.j a v a2s . co m*/ } logger.info("Initializing SpringBoot service"); // check maven project has a dependency starting with 'spring-boot' logger.fine("Checking maven project has a spring boot dependency"); springBootAvailable = dependencyArtifactIdContains(mvnPrj.getProjectWatcher(), "spring-boot"); // early exit if no spring boot dependency detected if (!springBootAvailable) { return; } logger.log(INFO, "Initializing SpringBootService for project {0}", new Object[] { mvnPrj.toString() }); // set up a reference to the execute classpath object Sources srcs = ProjectUtils.getSources(mvnPrj); SourceGroup[] srcGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); boolean srcGroupFound = false; for (SourceGroup group : srcGroups) { if (group.getName().toLowerCase().contains("source")) { srcGroupFound = true; cpExec = ClassPath.getClassPath(group.getRootFolder(), ClassPath.EXECUTE); break; } } if (!srcGroupFound) { logger.log(WARNING, "No sources found for project: {0}", new Object[] { mvnPrj.toString() }); } if (cpExec != null) { // check if completion of configuration properties is possible try { logger.fine( "Checking spring boot ConfigurationProperties class is on the project execution classpath"); cpExec.getClassLoader(false) .loadClass("org.springframework.boot.context.properties.ConfigurationProperties"); } catch (ClassNotFoundException ex) { // no completion } // listen for pom changes logger.info("Adding maven pom listener..."); mvnPrj.getProjectWatcher().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { final String propertyName = String.valueOf(evt.getPropertyName()); logger.log(FINE, "Maven pom change ({0})", propertyName); if (propertyName.equals("MavenProject")) { refresh(); } } }); // build configuration properties maps updateConfigRepo(); } }
From source file:org.jcurl.core.helpers.PropertyChangeSupport.java
/** * Fire a property change event to all of the listeners. * <p>//from w w w. j ava 2 s. c o m * This method is called by all the fire methods to perform the firing of * the events. * </p> * <p> * The firing will go to the listeners that are registered for the specific * property as well as general purpose listeners. * </p> * <p> * If the old and new values for the event are the same, by the * <tt>equals()</tt> method, the event will not be fired. * </p> * * @param event * The event to fire to the listeners. */ public void firePropertyChange(final PropertyChangeEvent event) { validateNamedProperty(event.getPropertyName()); { final Object a = event.getOldValue(); final Object b = event.getNewValue(); if (a != null && a.equals(b) || a == null && b == null) return; } // if (event.getOldValue() == null) { // if (event.getOldValue() == null) { // return; // } // } else if (event.getOldValue().equals(event.getNewValue())) { // return; // } // validated that an event must be thrown; now throw it. synchronized (listenerMap) { // First gets the list of listeners and stores them in strong // references by copying them into a new set. final Set<PropertyChangeListener> targets = new HashSet<PropertyChangeListener>( listenerMap.get(ALL_PROPERTIES)); targets.addAll(listenerMap.get(event.getPropertyName())); for (final PropertyChangeListener element : targets) element.propertyChange(event); } }
From source file:net.chaosserver.timelord.data.TimelordDayView.java
/** * listens for property changes for hours or the task list to * update the view.//from w ww . j av a 2 s . c om * * @param evt the trigger event */ public void propertyChange(PropertyChangeEvent evt) { if (log.isDebugEnabled()) { log.debug("Got propertyChangeEvent [" + evt.getPropertyName() + "]"); } if ("hours".equals(evt.getPropertyName())) { propertyChangeSupport.firePropertyChange("totalTimeToday", 0, 1); } else if ("taskCollection".equals(evt.getPropertyName())) { buildTaskCollection(); } }
From source file:org.apache.sling.ide.eclipse.ui.internal.InstallEditorSection.java
public void init(IEditorSite site, IEditorInput input) { super.init(site, input); serverListener = new PropertyChangeListener() { @Override/*from w w w.j ava 2s . c o m*/ public void propertyChange(PropertyChangeEvent evt) { if (ISlingLaunchpadServer.PROP_INSTALL_LOCALLY.equals(evt.getPropertyName())) { quickLocalInstallButton.setSelection((Boolean) evt.getNewValue()); bundleLocalInstallButton.setSelection(!(Boolean) evt.getNewValue()); } else if (evt.getPropertyName() .equals(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT, EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME))) { Version launchpadVersion = new Version((String) evt.getNewValue()); Version embeddedVersion = new Version(artifactLocator.loadToolingSupportBundle().getVersion()); updateActionArea(launchpadVersion, embeddedVersion); } } }; server.addPropertyChangeListener(serverListener); launchpadServer = (ISlingLaunchpadServer) server.getAdapter(ISlingLaunchpadServer.class); if (launchpadServer == null) { // TODO progress monitor launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class, new NullProgressMonitor()); } artifactLocator = Activator.getDefault().getArtifactLocator(); osgiClientFactory = Activator.getDefault().getOsgiClientFactory(); }
From source file:com.emr.schemas.SchemerMapper.java
/** * Constructor//ww w . j a v a 2s. com * @param emrConn {@link Connection} Connection to the EMR database * @param emrDbName {@link String} Database name */ public SchemerMapper(Connection emrConn, String emrDbName) { this.emrConn = emrConn; this.emrDbName = emrDbName; listModel = new DefaultListModel<String>(); initComponents(); this.setClosable(true); SourceTablesListener listSelectionListener = new SourceTablesListener(txtSelectedTables, listOfTables); sourceTablesList.setCellRenderer(new CheckboxListCellRenderer()); sourceTablesList.addListSelectionListener(listSelectionListener); sourceTablesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); sourceTablesList.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if (isSelectedIndex(index0)) super.removeSelectionInterval(index0, index1); else super.addSelectionInterval(index0, index1); } }); //getDatabaseMetaData(); final ListUpdater lu = new ListUpdater(); lu.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getPropertyName()) { case "progress": System.out.println("Fetching data from db"); break; case "state": switch ((SwingWorker.StateValue) event.getNewValue()) { case DONE: try { listModel = lu.get(); sourceTablesList.setModel(listModel); } catch (final CancellationException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } break; } break; } } }); lu.execute(); }
From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java
private void trainNetwork() { if (!training) { // Set training flag and disable button training = true;//from w w w. j a v a 2 s. co m trainButton.setEnabled(false); final ProgressMonitor progressMonitor = new ProgressMonitor(frame, "Training Network...", "", 0, 100); progressMonitor.setMillisToDecideToPopup(100); progressMonitor.setMillisToPopup(400); @SuppressWarnings("unchecked") final ArrayList<XYDataItem> data = new ArrayList<>(outputGraphDataSeries.getItems()); final int maxProgress = iterations * data.size(); final SwingWorker<Void, Void> trainingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { // Reset the neural network to default values synchronized (this) { network.reset(); network.setEta(eta); network.setMomentum(momentum); } outer: for (int j = 0; j < iterations; j++) { for (int i = 0; i < data.size(); i++) { if (!isCancelled()) { XYDataItem d = data.get(i); double error = convertAngleToInput(d.getXValue()); double output = d.getYValue(); synchronized (this) { network.feedForward(error); network.backPropagation(output); } int jl = j; int il = i; int progress = (int) (((float) (data.size() * jl + il + 1) / maxProgress) * 100); setProgress(progress); } else { break outer; } } } displayNetwork(); return null; } @Override protected void done() { training = false; trainButton.setEnabled(true); progressMonitor.close(); } }; trainingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { progressMonitor.setProgress((int) evt.getNewValue()); } if (progressMonitor.isCanceled()) { trainingWorker.cancel(true); } } }); trainingWorker.execute(); } }
From source file:EditorDropTarget4.java
public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (propertyName.equals("enabled")) { // Enable the drop target if the JEditorPane is enabled // and vice versa. dropTarget.setActive(pane.isEnabled()); } else if (!changingBackground && propertyName.equals("background")) { backgroundColor = pane.getBackground(); }/* w w w.j a v a2 s . com*/ }
From source file:org.springframework.beans.AbstractVetoableChangeListener.java
/** * Implementation of VetoableChangeListener. * Will attempt to locate the appropriate validator method and invoke it. * Will do nothing if there is no validation method for this property. *///from www . j a va 2 s . c o m public final void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { if (logger.isDebugEnabled()) logger.debug( "VetoableChangeEvent: old value=[" + e.getOldValue() + "] new value=[" + e.getNewValue() + "]"); Method method = (Method) validationMethodHash.get(e.getPropertyName()); if (method != null) { try { logger.debug("Using validator method: " + method); Object val = e.getNewValue(); method.invoke(this, new Object[] { val, e }); } catch (IllegalAccessException ex) { logger.warn("Can't validate: Method isn't accessible"); } catch (InvocationTargetException ex) { // This is what we're looking for: the subclass's // validator method vetoed the property change event // We know that the exception must be of the correct type (unless // it's a runtime exception) as we checked the declared exceptions of the // validator method in this class's constructor. // If it IS a runtime exception, we just rethrow it, to encourage the // author of the subclass to write robust code... if (ex.getTargetException() instanceof RuntimeException) throw (RuntimeException) ex.getTargetException(); PropertyVetoException pex = (PropertyVetoException) ex.getTargetException(); throw pex; } } // if there was a validator method for this property else { logger.debug("No validation method for property: " + e.getPropertyName()); } }