List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:hermes.browser.components.ClasspathGroupTable.java
private void init() { final JPopupMenu popupMenu = new JPopupMenu(); final JMenuItem addItem = new JMenuItem("Add Group"); final JMenuItem removeItem = new JMenuItem("Remove Group"); final JMenuItem renameItem = new JMenuItem("Rename"); popupMenu.add(addItem);// w w w . j a v a 2 s . c om popupMenu.add(removeItem); popupMenu.add(renameItem); addItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { doAddGroup(); dialog.setDirty(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } } }); removeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (getSelectedRowCount() > 0) { for (int row : getSelectedRows()) { getClasspathGroupTableModel().removeRow(row); } dialog.setDirty(); } } }); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (getSelectedRow() != -1) { doRename(); } } }); mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { removeItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); renameItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }; addMouseListener(mouseAdapter); getTableHeader().addMouseListener(mouseAdapter); if (dialog != null) { addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // // Think this is ok, seems 2 do the job. if (evt.getPropertyName().equals("tableCellEditor")) { dialog.setDirty(); } } }); } }
From source file:org.mule.module.launcher.DeploymentDirectoryWatcher.java
public DeploymentDirectoryWatcher(final ArchiveDeployer<Domain> domainArchiveDeployer, final ArchiveDeployer<Application> applicationArchiveDeployer, ObservableList<Domain> domains, ObservableList<Application> applications, final ReentrantLock deploymentLock) { this.appsDir = applicationArchiveDeployer.getDeploymentDirectory(); this.domainsDir = domainArchiveDeployer.getDeploymentDirectory(); this.deploymentLock = deploymentLock; this.domainArchiveDeployer = domainArchiveDeployer; this.applicationArchiveDeployer = applicationArchiveDeployer; this.applications = applications; this.domains = domains; applications.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e instanceof ElementAddedEvent || e instanceof ElementRemovedEvent) { if (logger.isDebugEnabled()) { logger.debug("Deployed applications set has been modified, flushing state."); }/*from w w w .j a va2 s.c o m*/ dirty = true; } } }); domains.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e instanceof ElementAddedEvent || e instanceof ElementRemovedEvent) { if (logger.isDebugEnabled()) { logger.debug("Deployed applications set has been modified, flushing state."); } dirty = true; } } }); this.applicationTimestampListener = new ArtifactTimestampListener(applications); this.domainTimestampListener = new ArtifactTimestampListener(domains); }
From source file:ec.ui.view.DistributionView.java
private void enableProperties() { addPropertyChangeListener(new PropertyChangeListener() { @Override/*w w w . j a va2 s . com*/ public void propertyChange(PropertyChangeEvent evt) { switch (evt.getPropertyName()) { case L_BOUND_PROPERTY: onDataChange(); break; case R_BOUND_PROPERTY: onDataChange(); break; case DISTRIBUTION_PROPERTY: onDataChange(); break; case ADJUST_DISTRIBUTION_PROPERTY: onDataChange(); break; case H_COUNT_PROPERTY: onDataChange(); break; case DATA_PROPERTY: onDataChange(); break; case "componentPopupMenu": onComponentPopupMenuChange(); break; } } }); }
From source file:org.tinymediamanager.core.tvshow.TvShowList.java
/** * Instantiates a new TvShowList.//from w ww .j a va2 s . c o m */ private TvShowList() { // create the lists tvShowTagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); episodeTagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); videoCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); audioCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); // the tag listener: its used to always have a full list of all tags used in tmm propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // listen to changes of tags if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShow) { TvShow tvShow = (TvShow) evt.getSource(); updateTvShowTags(tvShow); } if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShowEpisode) { TvShowEpisode episode = (TvShowEpisode) evt.getSource(); updateEpisodeTags(episode); } if ((MEDIA_FILES.equals(evt.getPropertyName()) || MEDIA_INFORMATION.equals(evt.getPropertyName())) && evt.getSource() instanceof TvShowEpisode) { TvShowEpisode episode = (TvShowEpisode) evt.getSource(); updateMediaInformationLists(episode); } if (EPISODE_COUNT.equals(evt.getPropertyName())) { firePropertyChange(EPISODE_COUNT, 0, 1); } } }; }
From source file:TrackFocusDemo.java
public TrackFocusDemo() { super(new BorderLayout()); JPanel mugshots = new JPanel(new GridLayout(2, 3)); pic1 = new Picture(createImageIcon("images/" + mayaString + ".jpg", mayaString).getImage()); pic1.setName("1"); mugshots.add(pic1);// w w w .j a va 2 s . c o m pic2 = new Picture(createImageIcon("images/" + anyaString + ".jpg", anyaString).getImage()); pic2.setName("2"); mugshots.add(pic2); pic3 = new Picture(createImageIcon("images/" + laineString + ".jpg", laineString).getImage()); pic3.setName("3"); mugshots.add(pic3); pic4 = new Picture(createImageIcon("images/" + cosmoString + ".jpg", cosmoString).getImage()); pic4.setName("4"); mugshots.add(pic4); pic5 = new Picture(createImageIcon("images/" + adeleString + ".jpg", adeleString).getImage()); pic5.setName("5"); mugshots.add(pic5); pic6 = new Picture(createImageIcon("images/" + alexiString + ".jpg", alexiString).getImage()); pic6.setName("6"); mugshots.add(pic6); info = new JLabel("Nothing selected"); setPreferredSize(new Dimension(450, 350)); add(mugshots, BorderLayout.CENTER); add(info, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (("focusOwner".equals(prop)) && (e.getNewValue() != null) && ((e.getNewValue()) instanceof Picture)) { Component comp = (Component) e.getNewValue(); String name = comp.getName(); Integer num = new Integer(name); int index = num.intValue(); if (index < 0 || index > comments.length) { index = 0; } info.setText(comments[index]); } } }); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.ProfileSection.java
public ProfileSection(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding) { super(parent, SWT.NONE); m_data = data;/*from ww w .ja v a 2s. c om*/ toolkit.adapt(this); GridLayoutFactory.fillDefaults().margins(0, 0).spacing(0, 0).applyTo(this); createControls(toolkit, this, data, binding); ControlUtils.addDisposeListener(this); data.addPropertyChangeListener(ChannelEditData.PROPERTY_ACTIVE_PROFILE, new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { onProfileChanged(data.getActiveProfile()); } }); onProfileChanged(data.getActiveProfile()); }
From source file:net.sourceforge.vulcan.core.support.StateManagerImpl.java
public void start() throws StoreException { try {//from w ww. ja va 2s . c o m writeLock.lock(); config = configurationStore.loadConfiguration(); applyPluginConfigurations(); final BuildManagerConfigDto buildManagerConfig = config.getBuildManagerConfig(); buildManagerConfig.addPropertyChangeListener("enabled", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { final Object newValue = evt.getNewValue(); if (!evt.getOldValue().equals(newValue)) { if (Boolean.TRUE.equals(newValue)) { startSchedulers(); } else { stopSchedulers(); } } } }); buildManager.init(buildManagerConfig); running = true; if (buildManagerConfig.isEnabled()) { startSchedulers(); } startBuildDaemons(); eventHandler.reportEvent(new InfoEvent(this, "messages.startup")); } finally { writeLock.unlock(); } }
From source file:Provider.GoogleMapsStatic.TestUI.SampleApp.java
/** create a test task and wire it up with a task handler that dumps output to the textarea */ @SuppressWarnings("unchecked") private void _setupTask() { TaskExecutorIF<ByteBuffer> functor = new TaskExecutorAdapter<ByteBuffer>() { public ByteBuffer doInBackground(Future<ByteBuffer> swingWorker, SwingUIHookAdapter hook) throws Exception { _initHook(hook);// w w w.j a v a 2 s.c o m // set the license key MapLookup.setLicenseKey(ttfLicense.getText()); // get the uri for the static map String uri = MapLookup.getMap(Double.parseDouble(ttfLat.getText()), Double.parseDouble(ttfLon.getText()), Integer.parseInt(ttfSizeW.getText()), Integer.parseInt(ttfSizeH.getText()), Integer.parseInt(ttfZoom.getText())); sout("Google Maps URI=" + uri); // get the map from Google GetMethod get = new GetMethod(uri); new HttpClient().executeMethod(get); ByteBuffer data = HttpUtils.getMonitoredResponse(hook, get); try { _img = ImageUtils.toCompatibleImage(ImageIO.read(data.getInputStream())); sout("converted downloaded data to image..."); } catch (Exception e) { _img = null; sout("The URI is not an image. Data is downloaded, can't display it as an image."); _respStr = new String(data.getBytes()); } return data; } @Override public String getName() { return _task.getName(); } }; _task = new SimpleTask(new TaskManager(), functor, "HTTP GET Task", "Download an image from a URL", AutoShutdownSignals.Daemon); _task.addStatusListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { sout(":: task status change - " + ProgressMonitorUtils.parseStatusMessageFrom(evt)); lblProgressStatus.setText(ProgressMonitorUtils.parseStatusMessageFrom(evt)); } }); _task.setTaskHandler(new SimpleTaskHandler<ByteBuffer>() { @Override public void beforeStart(AbstractTask task) { sout(":: taskHandler - beforeStart"); } @Override public void started(AbstractTask task) { sout(":: taskHandler - started "); } /** {@link SampleApp#_initHook} adds the task status listener, which is removed here */ @Override public void stopped(long time, AbstractTask task) { sout(":: taskHandler [" + task.getName() + "]- stopped"); sout(":: time = " + time / 1000f + "sec"); task.getUIHook().clearAllStatusListeners(); } @Override public void interrupted(Throwable e, AbstractTask task) { sout(":: taskHandler [" + task.getName() + "]- interrupted - " + e.toString()); } @Override public void ok(ByteBuffer value, long time, AbstractTask task) { sout(":: taskHandler [" + task.getName() + "]- ok - size=" + (value == null ? "null" : value.toString())); if (_img != null) { _displayImgInFrame(); } else _displayRespStrInFrame(); } @Override public void error(Throwable e, long time, AbstractTask task) { sout(":: taskHandler [" + task.getName() + "]- error - " + e.toString()); } @Override public void cancelled(long time, AbstractTask task) { sout(" :: taskHandler [" + task.getName() + "]- cancelled"); } }); }
From source file:uk.ac.lkl.cram.ui.chart.LearningExperienceChartMaker.java
/** * Create a dataset from the module//from www. jav a 2 s. c om * @return a category dataset that is used to produce a stacked bar chart */ @Override protected CategoryDataset createDataSet() { //Create the dataset to hold the data final DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); //Populate the dataset with the data populateDataset(categoryDataset, module); //Create a listener, which repopulates the dataset when anything changes final PropertyChangeListener learningExperienceListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //LOGGER.info("property change: " + pce); populateDataset(categoryDataset, module); } }; //Add the listener to each of the module's tlaLineItems, as well as to each //tlaLineItem's activity //This means that whenever a tlaLineItem changes, or its activity changes, the listener is triggered //Causing the dataset to be repopulated for (TLALineItem lineItem : module.getTLALineItems()) { //LOGGER.info("adding listeners to : " + lineItem.getName()); lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.addPropertyChangeListener(learningExperienceListener); } //Add a listener to the module, listening for changes where a tlaLineItem is added or removed module.addPropertyChangeListener(Module.PROP_TLA_LINEITEM, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //A tlaLineItem has been added or removed if (pce instanceof IndexedPropertyChangeEvent) { //LOGGER.info("indexed change: " + pce); if (pce.getOldValue() != null) { //This has been removed TLALineItem lineItem = (TLALineItem) pce.getOldValue(); //So remove the listener from it and its activity //LOGGER.info("removing listeners from: " + lineItem.getName()); lineItem.getActivity().removePropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.removePropertyChangeListener(learningExperienceListener); } if (pce.getNewValue() != null) { //This has been added TLALineItem lineItem = (TLALineItem) pce.getNewValue(); //So add a listener to it and its activity //LOGGER.info("adding listeners to: " + lineItem); lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.addPropertyChangeListener(learningExperienceListener); } } //Assume the dataset is now out of date, so repopulate it populateDataset(categoryDataset, module); } }); return categoryDataset; }
From source file:org.openconcerto.sql.view.listview.ListSQLView.java
protected final ListItemSQLView addNewItem() { final ListItemSQLView newItem = new ListItemSQLView(this, this.getPool().getNewItem()); this.items.add(newItem); newItem.getRowItemView().addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { ListSQLView.this.supp.firePropertyChange("value", null, null); }//from ww w . java 2 s . com }); this.readd(newItem); return newItem; }