List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:org.tinymediamanager.ui.tvshows.TvShowExtendedSearchPanel.java
public TvShowExtendedSearchPanel(TvShowTreeModel model, JTree tree) { super();// w w w . jav a2 s.c om setOpaque(false); shadowAlpha = 100; arcs = new Dimension(10, 10); this.tvShowTreeModel = model; this.tree = tree; // add a dummy mouse listener to prevent clicking through addMouseListener(new MouseAdapter() { }); listCheckListener = new ListCheckListener() { @Override public void removeCheck(ListEvent event) { actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked")); } @Override public void addCheck(ListEvent event) { actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked")); } }; setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, })); JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$ setComponentFont(lblFilterBy); add(lblFilterBy, "2, 2, 3, 1"); cbFilterNewEpisodes = new JCheckBox(""); cbFilterNewEpisodes.setAction(actionFilter); add(cbFilterNewEpisodes, "2, 4"); JLabel lblNewEpisodes = new JLabel(BUNDLE.getString("movieextendedsearch.newepisodes")); //$NON-NLS-1$ setComponentFont(lblNewEpisodes); add(lblNewEpisodes, "4, 4, right, default"); cbFilterWatched = new JCheckBox(""); cbFilterWatched.setAction(actionFilter); cbFilterWatched.setUI(CHECKBOX_UI); // $hide$ add(cbFilterWatched, "2, 5"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ setComponentFont(lblWatched); add(lblWatched, "4, 5, right, default"); cbWatched = new SmallComboBox(WatchedFlag.values()); setComponentFont(cbWatched); cbWatched.setAction(actionFilter); add(cbWatched, "6, 5, fill, default"); cbFilterGenres = new JCheckBox(""); cbFilterGenres.setAction(actionFilter); cbFilterGenres.setUI(CHECKBOX_UI); // $hide$ add(cbFilterGenres, "2, 6"); JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ setComponentFont(lblGenres); add(lblGenres, "4, 6, right, default"); cbGenres = new SmallComboBox(MediaGenres.values()); setComponentFont(cbGenres); cbGenres.setAction(actionFilter); add(cbGenres, "6, 6, fill, default"); cbFilterCast = new JCheckBox(""); cbFilterCast.setAction(actionFilter); cbFilterCast.setUI(CHECKBOX_UI); // $hide$ add(cbFilterCast, "2, 7"); JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$ setComponentFont(lblCastMember); add(lblCastMember, "4, 7, right, default"); tfCastMember = new JTextField(); setComponentFont(tfCastMember); tfCastMember.setBorder(new SmallTextFieldBorder()); add(tfCastMember, "6, 7, fill, default"); tfCastMember.setColumns(10); tfCastMember.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } @Override public void insertUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } @Override public void removeUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } }); cbFilterTag = new JCheckBox(""); cbFilterTag.setAction(actionFilter); cbFilterTag.setUI(CHECKBOX_UI); // $hide$ add(cbFilterTag, "2, 8"); JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$ setComponentFont(lblTag); add(lblTag, "4, 8, right, default"); cbTag = new SmallCheckComboBox(); cbTag.setTextFor(CheckComboBox.NONE, BUNDLE.getString("movieextendedsearch.tags.selected.none")); //$NON-NLS-1$ cbTag.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("movieextendedsearch.tags.selected.multiple")); //$NON-NLS-1$ cbTag.setTextFor(CheckComboBox.ALL, BUNDLE.getString("movieextendedsearch.tags.selected.all")); //$NON-NLS-1$ cbTag.getModel().addListCheckListener(listCheckListener); add(cbTag, "6, 8, fill, default"); cbFilterVideoFormat = new JCheckBox(""); cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$ cbFilterVideoFormat.setAction(actionFilter); add(cbFilterVideoFormat, "2, 9"); JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$ setComponentFont(lblVideoFormat); add(lblVideoFormat, "4, 9, right, default"); cbVideoFormat = new SmallComboBox(getVideoFormats()); setComponentFont(cbVideoFormat); cbVideoFormat.setAction(actionFilter); add(cbVideoFormat, "6, 9, fill, default"); cbFilterVideoCodec = new JCheckBox(""); cbFilterVideoCodec.setAction(actionFilter); cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$ add(cbFilterVideoCodec, "2, 10"); JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$ setComponentFont(lblVideoCodec); add(lblVideoCodec, "4, 10, right, default"); cbVideoCodec = new SmallComboBox(); setComponentFont(cbVideoCodec); cbVideoCodec.setAction(actionFilter); add(cbVideoCodec, "6, 10, fill, default"); cbFilterAudioCodec = new JCheckBox(""); cbFilterAudioCodec.setAction(actionFilter); cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$ add(cbFilterAudioCodec, "2, 11"); JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$ setComponentFont(lblAudioCodec); add(lblAudioCodec, "4, 11, right, default"); cbAudioCodec = new SmallComboBox(); setComponentFont(cbAudioCodec); cbAudioCodec.setAction(actionFilter); add(cbAudioCodec, "6, 11, fill, default"); cbFilterDatasource = new JCheckBox(""); cbFilterDatasource.setAction(actionFilter); cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$ add(cbFilterDatasource, "2, 12"); JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$ setComponentFont(lblDatasource); add(lblDatasource, "4, 12, right, default"); cbDatasource = new SmallCheckComboBox(); cbDatasource.setTextFor(CheckComboBox.NONE, BUNDLE.getString("checkcombobox.selected.none")); //$NON-NLS-1$ cbDatasource.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("checkcombobox.selected.multiple")); //$NON-NLS-1$ cbDatasource.setTextFor(CheckComboBox.ALL, BUNDLE.getString("checkcombobox.selected.all")); //$NON-NLS-1$ cbDatasource.getModel().addListCheckListener(listCheckListener); add(cbDatasource, "6, 12, fill, default"); cbFilterMediaSource = new JCheckBox(""); cbFilterMediaSource.setAction(actionFilter); cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMediaSource, "2, 13"); lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ setComponentFont(lblMediaSource); add(lblMediaSource, "4, 13, right, default"); cbMediaSource = new SmallComboBox(MediaSource.values()); setComponentFont(cbMediaSource); cbMediaSource.setAction(actionFilter); add(cbMediaSource, "6, 13, fill, default"); cbFilterMissingMetadata = new JCheckBox(""); cbFilterMissingMetadata.setAction(actionFilter); cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingMetadata, "2, 14"); JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$ setComponentFont(lblMissingMetadata); add(lblMissingMetadata, "4, 14, right, default"); cbFilterMissingArtwork = new JCheckBox(""); cbFilterMissingArtwork.setAction(actionFilter); cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingArtwork, "2, 15"); JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$ setComponentFont(lblMissingArtwork); add(lblMissingArtwork, "4, 15, right, default"); cbFilterMissingSubtitles = new JCheckBox(""); cbFilterMissingSubtitles.setAction(actionFilter); cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingSubtitles, "2, 16"); JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$ setComponentFont(lblMissingSubtitles); add(lblMissingSubtitles, "4, 16, right, default"); cbFilterNewEpisodes.setUI(CHECKBOX_UI); // $hide$ PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof TvShowSettings && "tvShowDataSource".equals(evt.getPropertyName())) { buildAndInstallDatasourceArray(); } if (evt.getSource() instanceof TvShowList && "tag".equals(evt.getPropertyName())) { buildAndInstallTagsArray(); } if (evt.getSource() instanceof TvShowList && ("audioCodec".equals(evt.getPropertyName()) || "videoCodec".equals(evt.getPropertyName()))) { buildAndInstallCodecArray(); } } }; tvShowList.addPropertyChangeListener(propertyChangeListener); TvShowModuleManager.SETTINGS.addPropertyChangeListener(propertyChangeListener); buildAndInstallDatasourceArray(); buildAndInstallTagsArray(); buildAndInstallCodecArray(); }
From source file:blue.automation.AutomationManager.java
private AutomationManager() { parameterActionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { if (data == null || selectedSoundLayer == null) { return; }/*from w ww . j av a2s. c o m*/ JMenuItem menuItem = (JMenuItem) ae.getSource(); Parameter param = (Parameter) menuItem.getClientProperty("param"); parameterSelected(selectedSoundLayer, param); selectedSoundLayer = null; } }; renderTimeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getSource() == data) { if (pce.getPropertyName().equals("renderStartTime")) { updateValuesFromAutomations(); } } } }; }
From source file:com.github.fritaly.dualcommander.DualCommander.java
@Override public void propertyChange(PropertyChangeEvent e) { if (e.getSource() == preferences) { if (logger.isDebugEnabled()) { logger.debug(String.format("User preference '%s' changed: '%s' -> '%s'", e.getPropertyName(), e.getOldValue(), e.getNewValue())); }/* w w w.j a v a 2s. c om*/ // The 'show hidden' property changed, need to refresh the active // directory browsers // TODO Set a flag for the inactive directory browsers to refresh // when they get the focus this.leftPane.getActiveBrowser().refresh(); this.rightPane.getActiveBrowser().refresh(); } }
From source file:dk.dma.epd.shore.gui.views.SendRouteDialog.java
/** * Called when one of the arrival and departure pickers changes value * //from w w w. ja v a 2 s . c om * @param evt * the event */ @Override public void propertyChange(PropertyChangeEvent evt) { if (loading || route == null) { return; } if (evt.getSource() == departurePicker) { Date date = combineDateTime(departurePicker.getDate(), (Date) departureSpinner.getValue()); route.setStarttime(date); updateRouteFields(route, RouteFields.ARRIVAL); } else if (evt.getSource() == arrivalPicker) { Date date = combineDateTime(arrivalPicker.getDate(), (Date) arrivalSpinner.getValue()); recalculateSpeeds(date, route); } }
From source file:biz.wolschon.fileformats.gnucash.jwsdpimpl.GnucashAccountWritingImpl.java
/** * same as getBalance(new Date()).<br/> * ignores transactions after the current date+time<br/> * This implementation caches the result.<br/> * We assume that time does never move backwards * @see #getBalance(Date)//from w ww . ja v a 2 s . c om */ @Override public FixedPointNumber getBalance() { if (myBalanceCached != null) { return myBalanceCached; } Collection<GnucashTransactionSplit> after = new LinkedList<GnucashTransactionSplit>(); FixedPointNumber balance = getBalance(new Date(), after); if (after.isEmpty()) { myBalanceCached = balance; // add a listener to keep the cache up to date if (myBalanceCachedInvalidtor != null) { myBalanceCachedInvalidtor = new PropertyChangeListener() { private final Collection<GnucashTransactionSplit> splitsWeAreAddedTo = new HashSet<GnucashTransactionSplit>(); public void propertyChange(final PropertyChangeEvent evt) { myBalanceCached = null; // we don't handle the case of removing an account // because that happenes seldomly enough if (evt.getPropertyName().equals("account") && evt.getSource() instanceof GnucashWritableTransactionSplit) { GnucashWritableTransactionSplit splitw = (GnucashWritableTransactionSplit) evt .getSource(); if (splitw.getAccount() != GnucashAccountWritingImpl.this) { splitw.removePropertyChangeListener("account", this); splitw.removePropertyChangeListener("quantity", this); splitw.getTransaction().removePropertyChangeListener("datePosted", this); splitsWeAreAddedTo.remove(splitw); } } if (evt.getPropertyName().equals("transactionSplits")) { Collection<GnucashTransactionSplit> splits = (Collection<GnucashTransactionSplit>) evt .getNewValue(); for (GnucashTransactionSplit split : splits) { if (!(split instanceof GnucashWritableTransactionSplit) || splitsWeAreAddedTo.contains(split)) { continue; } GnucashWritableTransactionSplit splitw = (GnucashWritableTransactionSplit) split; splitw.addPropertyChangeListener("account", this); splitw.addPropertyChangeListener("quantity", this); splitw.getTransaction().addPropertyChangeListener("datePosted", this); splitsWeAreAddedTo.add(splitw); } } } }; addPropertyChangeListener("currencyID", myBalanceCachedInvalidtor); addPropertyChangeListener("currencyNameSpace", myBalanceCachedInvalidtor); addPropertyChangeListener("transactionSplits", myBalanceCachedInvalidtor); } } return balance; }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaSideMenu.java
@SuppressWarnings("unchecked") protected void menuItemPropertyChanged(PropertyChangeEvent event) { if (event.getPropertyName() == null) { return;/*from ww w. j a v a 2s. c o m*/ } if (!structureChanged && MENU_ITEM_BADGE_TEXT.equals(event.getPropertyName())) { badgeUpdates.add((MenuItem) event.getSource()); markAsDirty(); } if (MENU_ITEM_CHILDREN.equals(event.getPropertyName())) { List<MenuItem> oldItems = (List<MenuItem>) event.getOldValue(); List<MenuItem> newItems = (List<MenuItem>) event.getNewValue(); if (oldItems != null) { for (MenuItem oldItem : oldItems) { oldItem.removePropertyChangeListener(itemsPropertyChangeListener); } } if (newItems != null) { for (MenuItem newItem : newItems) { newItem.addPropertyChangeListener(itemsPropertyChangeListener); } } } switch (event.getPropertyName()) { case MENU_ITEM_CAPTION: case MENU_ITEM_DESCRIPTION: case MENU_ITEM_ICON: case MENU_ITEM_CHILDREN: case MENU_ITEM_STYLE_NAME: case MENU_ITEM_VISIBLE: case MENU_ITEM_ENABLED: case MENU_ITEM_CAPTION_AS_HTML: case MENU_ITEM_CUBA_ID: case MENU_ITEM_EXPANDED: markMenuStructureAsDirty(); break; } }
From source file:org.tinymediamanager.core.tvshow.TvShowList.java
/** * Instantiates a new TvShowList./*from w w w . ja v a 2 s .c om*/ */ 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: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 ww w . j a v a 2 s . 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:org.apache.catalina.cluster.session.DeltaManager.java
/** * Process property change events from our associated Context. * * @param event The property change event that has occurred *//*from w ww .j a va 2 s.com*/ public void propertyChange(PropertyChangeEvent event) { // Validate the source of this event if (!(event.getSource() instanceof Context)) return; Context context = (Context) event.getSource(); // Process a relevant property change if (event.getPropertyName().equals("sessionTimeout")) { try { setMaxInactiveInterval(((Integer) event.getNewValue()).intValue() * 60); } catch (NumberFormatException e) { log.error(sm.getString("standardManager.sessionTimeout", event.getNewValue().toString())); } } }
From source file:au.org.ala.delta.editor.DeltaEditor.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (_activeController == null) { return;/*ww w.ja v a 2 s . co m*/ } if (evt.getSource() == _activeController.getModel()) { if ("modified".equals(evt.getPropertyName())) { setSaveEnabled((Boolean) evt.getNewValue()); } } }