List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
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// w ww . ja va2s .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:org.photovault.swingui.framework.AbstractController.java
/** * Register an action that can be executed by this controller. * * @param source The source component, this method sets action command and registers the controller as listener. * @param actionCommand The action command, used as a key when registering and executing actions. * @param action An actual action implementation. *//*from w ww . j av a2 s . c o m*/ public void registerAction(AbstractButton source, String actionCommand, DefaultAction action) { source.setActionCommand(actionCommand); source.addActionListener(this); this.actions.put(actionCommand, action); final String cmd = actionCommand; final AbstractController ctrl = this; // TODO: Is this really needed??? action.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("enabled")) { fireEvent(new ActionStateChangeEvent(ctrl, cmd, (Boolean) evt.getNewValue())); } } }); }
From source file:org.rdv.viz.dial.DialPanel.java
private void initModelListener() { model.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName().equals("value")) { Number value = (Number) pce.getNewValue(); dataset.setValue(value); } else if (pce.getPropertyName().equals("name")) { String name = (String) pce.getNewValue(); dialValueIndicator.setVisible(name != null); if (name != null) { dialTextAnnotation.setLabel(name); }/*from w w w .java2 s . c om*/ } else if (pce.getPropertyName().equals("unit")) { String unit = (String) pce.getNewValue(); engineeringFormatWithUnit.setUnit(unit); } else if (pce.getPropertyName().equals("range")) { updateRange(); } else if (pce.getPropertyName().equals("warningThreshold") || pce.getPropertyName().equals("criticalThreshold")) { updateThresholdRanges(); } } }); }
From source file:org.ngrinder.recorder.proxy.ScriptRecorderProxy.java
/** * Start proxy./*from w w w .j a va 2 s. co m*/ * * This tries to create a proxy on the given ports. However if it's failed, it creates a proxy * with the randomly selected port. * * @param defaultPort * default port which will be used to try to make a socket. * @return real setup proxy info. */ public ProxyEndPointPair startProxy(int defaultPort) { // #recorder.additional.headers=header names to be recorded System.setProperty("DHTTPPlugin.additionalHeaders", recorderConfig.getProperty("recorder.additional.headers", "")); LOG.info("Initilize proxy.."); m_filterContainer = new DefaultPicoContainer(new Caching()); m_filterContainer.addComponent(LOG); UpdatableCommentSource commentSource = new CommentSourceImplementation(); m_filterContainer.addComponent(commentSource); final FilterChain requestFilterChain = new FilterChain(); final FilterChain responseFilterChain = new FilterChain(); requestFilterChain.add(SwitchableRequestTcpProxyFilter.class); responseFilterChain.add(SwitchableResponseTcpProxyFilter.class); m_filterContainer.addComponent(SwitchableRequestTcpProxyFilter.class); m_filterContainer.addComponent(SwitchableResponseTcpProxyFilter.class); m_filterContainer.addComponent(NullFilter.class); m_filterContainer.addComponent(ConnectionAwareNullRequestFilter.class); m_filterContainer.addComponent(FileTypeFilterImpl.class); m_filterContainer.as(Characteristics.USE_NAMES).addComponent(HTTPResponseFilter.class); m_filterContainer.as(Characteristics.USE_NAMES).addComponent(HTTPRequestFilter.class); m_filterContainer.addComponent(SwitchableTcpProxyFilter.class); m_filterContainer.addComponent(AttributeStringParserImplementation.class); m_filterContainer.addComponent("eventListener", ConnectedHostHTTPFilterEventListener.class); m_filterContainer.addComponent("connectionCache", ConnectionCache.class); m_filterContainer.addComponent(ConnectionHandlerFactoryImplEx.class); m_filterContainer.addComponent(ParametersFromProperties.class); m_filterContainer.addComponent(HTTPRecordingImplEx.class); m_filterContainer.addComponent(ProcessHTTPRecordingWithFreeMarker.class); m_filterContainer.addComponent(ConnectionFilterImpl.class); m_filterContainer.addComponent(RegularExpressionsImplementation.class); m_filterContainer.addComponent(URIParserImplementation.class); m_filterContainer.addComponent(SimpleStringEscaper.class); m_filterContainer.addComponent(recorderConfig); m_filterContainer.start(); LOG.info("Pico container initiated.."); final SwitchableResponseTcpProxyFilter switchableResponseFilter = m_filterContainer .getComponent(SwitchableResponseTcpProxyFilter.class); final SwitchableRequestTcpProxyFilter switchableRequestFilter = m_filterContainer .getComponent(SwitchableRequestTcpProxyFilter.class); final HTTPResponseFilter httpResponseFilter = m_filterContainer.getComponent(HTTPResponseFilter.class); final HTTPRequestFilter httpRequestFilter = m_filterContainer.getComponent(HTTPRequestFilter.class); final NullFilter nullFilter = m_filterContainer.getComponent(NullFilter.class); final ConnectionAwareNullRequestFilter connectionAwareNullRequestFilter = m_filterContainer .getComponent(ConnectionAwareNullRequestFilter.class); final FileTypeFilterImpl fileTypeFilter = m_filterContainer.getComponent(FileTypeFilterImpl.class); final HTTPRecordingImplEx httpRecording = m_filterContainer.getComponent(HTTPRecordingImplEx.class); final ConnectedHostHTTPFilterEventListener connectionCache = m_filterContainer .getComponent(ConnectedHostHTTPFilterEventListener.class); final MessageBus messageBus = MessageBus.getInstance(); MessageBusConnection connect = messageBus.connect(); LOG.info("Register event handler.."); connect.subscribe(Topics.START_RECORDING, new PropertyChangeListener() { @Override @SuppressWarnings("unchecked") public void propertyChange(PropertyChangeEvent evt) { initFileTypeFilter(fileTypeFilter, (List<FileTypeCategory>) evt.getNewValue()); switchableResponseFilter.setTcpProxyFilter(httpResponseFilter); switchableRequestFilter.setTcpProxyFilter(httpRequestFilter); } }); connect.subscribe(Topics.STOP_RECORDING, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { switchableResponseFilter.setTcpProxyFilter(nullFilter); switchableRequestFilter.setTcpProxyFilter(connectionAwareNullRequestFilter); Pair<List<FileTypeCategory>, Set<GenerationOption>> pair = cast(evt.getNewValue()); initFileTypeFilter(fileTypeFilter, pair.getFirst()); ProcessHTTPRecordingWithFreeMarker httpOutput = m_filterContainer .getComponent(ProcessHTTPRecordingWithFreeMarker.class); HTTPRecordingImplEx recoding = m_filterContainer.getComponent(HTTPRecordingImplEx.class); StringWriter writer = new StringWriter(); Set<GenerationOption> second = (Set<GenerationOption>) pair.getSecond(); httpOutput.setGenerationOptions(second); httpOutput.setWriter(writer); recoding.generate(); Language lang = Language.Jython; for (GenerationOption each : second) { if (StringUtils.equals("Language", each.getGroup())) { lang = Language.valueOf(each.name()); break; } } Pair<Language, String> result = Pair.of(lang, writer.toString()); messageBus.getPublisher(Topics.SHOW_SCRIPT) .propertyChange(new PropertyChangeEvent(this, "Show Script", null, result)); } }); connect.subscribe(Topics.START_USER_PAGE, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { httpRecording.setNewPageRequested(); } }); connect.subscribe(Topics.RESET, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { connectionCache.dispose(); httpRecording.reset(); } }); LOG.info("Try to start proxy.."); InetAddress localHostAddress = NetworkUtil.getLocalHostAddress(); int proxyPort = getAvailablePort(localHostAddress, defaultPort); LOG.info("Recorder port is HTTP:{} / HTTPS:{}", proxyPort, proxyPort); final EndPoint localHttpEndPoint = new EndPoint(localHostAddress.getHostAddress(), proxyPort); final EndPoint localHttpsEndPoint = new EndPoint(localHostAddress.getHostAddress(), proxyPort); ProxyEndPointPair proxyEndPointPair = new ProxyEndPointPair(localHttpEndPoint, localHttpsEndPoint); final TCPProxyFilter requestFilter = requestFilterChain.resolveFilter(); final TCPProxyFilter responseFilter = responseFilterChain.resolveFilter(); try { TCPProxySSLSocketFactory sslSocketFactory = ceateTCPProxySSlSocketFactory(); m_httpProxyEngine = new HTTPProxyTCPProxyEngineEx(sslSocketFactory, requestFilter, responseFilter, LOG, localHttpEndPoint, null, null); Thread httpProxyThread = new Thread(m_httpProxyEngine); httpProxyThread.start(); LOG.info("Finish proxy initailization."); } catch (Exception e) { throw new NGrinderRuntimeException("Failed to start the tcp proxy engine.", e); } return proxyEndPointPair; }
From source file:org.jcurl.demo.tactics.sg.BroomPromptScenario.java
public void propertyChange(final PropertyChangeEvent evt) { if (evt.getSource() == model) { if ("idx16".equals(evt.getPropertyName())) syncIndexM2V((Integer) evt.getNewValue(), pie); else if ("outTurn".equals(evt.getPropertyName())) syncHandleM2V((Boolean) evt.getNewValue(), handle); else if ("broom".equals(evt.getPropertyName())) syncBroomM2V((Point2D) evt.getNewValue(), scene); else if ("splitTimeMillis".equals(evt.getPropertyName())) { final BoundedRangeModel os = (BoundedRangeModel) evt.getOldValue(); if (os != null) os.removeChangeListener(this); final BoundedRangeModel ns = (BoundedRangeModel) evt.getNewValue(); if (ns != null) ns.addChangeListener(this); syncSpeedM2V(ns);//from w w w. j av a 2 s . c om } else log.info(evt.getPropertyName() + " " + evt.getSource()); } else log.warn("Unconsumed event from " + evt.getSource()); }
From source file:org.jcurl.core.helpers.PropertyChangeSupport.java
/** * Fire a property change event to all of the listeners. * <p>/*ww w . j av a 2 s . com*/ * 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:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java
private void trainNetwork() { if (!training) { // Set training flag and disable button training = true;/*from ww w. j a v a 2 s .c om*/ 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:EnrollFingerprint.Verify.java
/** * Creates new form Enroll/* w w w.j ava 2s . c o m*/ */ public Verify() { initComponents(); //updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Verify.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }
From source file:de.fhg.igd.swingrcp.ActionAdapter.java
/** * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) *///from ww w .j a v a 2 s . c om @Override public void propertyChange(final PropertyChangeEvent evt) { // propagate property change event // -> enabled if (evt.getPropertyName().equals("enabled")) display.asyncExec(new Runnable() { @Override public void run() { firePropertyChange(Action.ENABLED, evt.getOldValue(), evt.getNewValue()); } }); }
From source file:org.cubictest.ui.sections.ParameterisationSection.java
public void propertyChange(PropertyChangeEvent event) { if (event.getOldValue() instanceof ParameterList) { ((ParameterList) event.getOldValue()).removePropertyChangeListener(this); }/*ww w . j a v a 2 s . c om*/ if (event.getNewValue() instanceof ParameterList) { ((ParameterList) event.getNewValue()).removePropertyChangeListener(this); } refresh(); }