List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:ca.sqlpower.wabit.dao.session.WorkspacePersisterListener.java
public void propertyChanged(PropertyChangeEvent evt) { if (wouldEcho()) return;/*www .j av a2s.c o m*/ this.transactionStarted(TransactionEvent.createStartTransactionEvent(this, "Creating start transaction event from propertyChange on object " + evt.getSource().getClass().getSimpleName() + " and property name " + evt.getPropertyName())); SPObject source = (SPObject) evt.getSource(); String uuid = source.getUUID(); String propertyName = evt.getPropertyName(); Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); PropertyDescriptor propertyDescriptor; try { propertyDescriptor = PropertyUtils.getPropertyDescriptor(source, propertyName); } catch (Exception ex) { this.rollback(); throw new RuntimeException(ex); } //Not persisting non-settable properties if (propertyDescriptor == null || propertyDescriptor.getWriteMethod() == null) { this.transactionEnded(TransactionEvent.createEndTransactionEvent(this)); return; } for (PropertyToIgnore ignoreProperty : ignoreList) { if (ignoreProperty.getPropertyName().equals(propertyName) && ignoreProperty.getClassType().isAssignableFrom(source.getClass())) { this.transactionEnded(TransactionEvent.createEndTransactionEvent(this)); return; } } //XXX special case that I want to remove even though I'm implementing it List<Object> additionalParams = new ArrayList<Object>(); if (source instanceof OlapQuery && propertyName.equals("currentCube")) { additionalParams.add(((OlapQuery) source).getOlapDataSource()); } DataType typeForClass = PersisterUtils.getDataType(newValue == null ? Void.class : newValue.getClass()); Object oldBasicType; Object newBasicType; oldBasicType = converter.convertToBasicType(oldValue, additionalParams.toArray()); newBasicType = converter.convertToBasicType(newValue, additionalParams.toArray()); logger.debug("Calling persistProperty on propertyChange"); this.persistProperty(uuid, propertyName, typeForClass, oldBasicType, newBasicType); this.transactionEnded(TransactionEvent.createEndTransactionEvent(this)); }
From source file:ome.formats.importer.gui.GuiImporter.java
public void update(IObservable importLibrary, ImportEvent event) { // Keep alive has failed, call logout if (event instanceof ImportEvent.LOGGED_OUT) { logout();/*from www .ja v a 2 s . c om*/ showLogoutMessage(); } if (event instanceof ImportEvent.LOADING_IMAGE) { ImportEvent.LOADING_IMAGE ev = (ImportEvent.LOADING_IMAGE) event; getStatusBar().setProgress(true, -1, "Loading file " + ev.numDone + " of " + ev.total); appendToOutput("> [" + ev.index + "] Loading image \"" + ev.shortName + "\"...\n"); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Prepping file \"" + ev.shortName); } else if (event instanceof ImportEvent.LOADED_IMAGE) { ImportEvent.LOADED_IMAGE ev = (ImportEvent.LOADED_IMAGE) event; getStatusBar().setProgress(true, -1, "Analyzing file " + ev.numDone + " of " + ev.total); appendToOutput(" Succesfully loaded.\n"); appendToOutput("> [" + ev.index + "] Importing metadata for " + "image \"" + ev.shortName + "\"... "); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Analyzing the metadata for file \"" + ev.shortName); } else if (event instanceof ImportEvent.BEGIN_SAVE_TO_DB) { ImportEvent.BEGIN_SAVE_TO_DB ev = (ImportEvent.BEGIN_SAVE_TO_DB) event; appendToOutput("> [" + ev.index + "] Saving metadata for " + "image \"" + ev.filename + "\"... "); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Saving metadata for file \"" + ev.filename); } else if (event instanceof ImportEvent.DATASET_STORED) { ImportEvent.DATASET_STORED ev = (ImportEvent.DATASET_STORED) event; int num = ev.numDone; int tot = ev.total; int pro = num - 1; appendToOutputLn("Successfully stored to " + ev.target.getClass().getSimpleName() + " \"" + ev.filename + "\" with id \"" + ev.target.getId().getValue() + "\"."); appendToOutputLn( "> [" + ev.series + "] Importing pixel data for " + "image \"" + ev.filename + "\"... "); getStatusBar().setProgress(true, 0, "Importing file " + num + " of " + tot); getStatusBar().setProgressValue(pro); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Importing the pixel data for file \"" + ev.filename); appendToOutput("> Importing plane: "); } else if (event instanceof ImportEvent.DATA_STORED) { ImportEvent.DATA_STORED ev = (ImportEvent.DATA_STORED) event; appendToOutputLn("> Successfully stored with pixels id \"" + ev.pixId + "\"."); appendToOutputLn("> [" + ev.filename + "] Image imported successfully!"); } else if (event instanceof FILE_EXCEPTION) { FILE_EXCEPTION ev = (FILE_EXCEPTION) event; if (IOException.class.isAssignableFrom(ev.exception.getClass())) { final JOptionPane optionPane = new JOptionPane( "The importer cannot retrieve one of your images in a timely manner.\n" + "The file in question is:\n'" + ev.filename + "'\n\n" + "There are a number of reasons you may see this error:\n" + " - The file has been deleted.\n" + " - There was a networking error retrieving a remotely saved file.\n" + " - An archived file has not been fully retrieved from backup.\n\n" + "The importer should now continue with the remainer of your imports.\n", JOptionPane.ERROR_MESSAGE); final JDialog dialog = new JDialog(this, "IO Error"); dialog.setAlwaysOnTop(true); dialog.setContentPane(optionPane); dialog.pack(); dialog.setVisible(true); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.dispose(); } } }); } } else if (event instanceof EXCEPTION_EVENT) { EXCEPTION_EVENT ev = (EXCEPTION_EVENT) event; log.error("EXCEPTION_EVENT", ev.exception); } else if (event instanceof INTERNAL_EXCEPTION) { INTERNAL_EXCEPTION e = (INTERNAL_EXCEPTION) event; log.error("INTERNAL_EXCEPTION", e.exception); // What else should we do here? Why are EXCEPTION_EVENTs being // handled here? } else if (event instanceof ImportEvent.ERRORS_PENDING) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON_ANIM)); errors_pending = true; error_notification = true; } else if (event instanceof ImportEvent.ERRORS_COMPLETE) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON)); error_notification = false; } else if (event instanceof ImportEvent.ERRORS_COMPLETE) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON)); error_notification = false; } else if (event instanceof ImportEvent.ERRORS_FAILED) { sendingErrorsFailed(this); } else if (event instanceof ImportEvent.IMPORT_QUEUE_DONE && errors_pending == true) { errors_pending = false; importErrorsCollected(this); } }
From source file:org.tinymediamanager.core.movie.MovieList.java
/** * Instantiates a new movie list.// www . j ava2s. com */ private MovieList() { // create all lists tagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); videoCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); audioCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>()); certificationsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<Certification>()); // the tag listener: its used to always have a full list of all tags used in tmm tagListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // listen to changes of tags if ("tag".equals(evt.getPropertyName())) { Movie movie = (Movie) evt.getSource(); updateTags(movie); } if (MEDIA_FILES.equals(evt.getPropertyName()) || MEDIA_INFORMATION.equals(evt.getPropertyName())) { Movie movie = (Movie) evt.getSource(); updateMediaInformationLists(movie); } if (CERTIFICATION.equals(evt.getPropertyName())) { Movie movie = (Movie) evt.getSource(); updateCertifications(movie); } } }; movieSettings = MovieModuleManager.MOVIE_SETTINGS; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java
/** Brings up the folder chooser. */ private void export() { DowngradeChooser chooser = new DowngradeChooser(new RefWindow(), FileChooser.SAVE, "Export", "Select where to export the image as OME-TIFF.", exportFilters); try {//from w w w .j a v a 2s .com String path = MetadataViewerAgent.getRegistry().getTaskBar() .getLibFileRelative(TransformsParser.SPECIFICATION + ".jar"); chooser.parseData(path); } catch (Exception e) { LogMessage msg = new LogMessage(); msg.print(e); MetadataViewerAgent.getRegistry().getLogger().debug(this, msg); } String s = UIUtilities.removeFileExtension(view.getRefObjectName()); chooser.setSelectedFileFull(s); chooser.setCheckOverride(true); chooser.setApproveButtonText("Export"); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.EXPORT_AS_OMETIFF_48)); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { File[] files = (File[]) evt.getNewValue(); File folder = files[0]; if (folder == null) folder = UIUtilities.getDefaultFolder(); Object src = evt.getSource(); Target target = null; if (src instanceof DowngradeChooser) { ((FileChooser) src).setVisible(false); ((FileChooser) src).dispose(); target = ((DowngradeChooser) src).getSelectedSchema(); } model.exportImageAsOMETIFF(folder, target); } else if (DowngradeChooser.HELP_DOWNGRADE_PROPERTY.equals(name)) { Registry reg = MetadataViewerAgent.getRegistry(); String url = (String) reg.lookup("HelpDowngrade"); reg.getTaskBar().openURL(url); } } }); chooser.centerDialog(); }
From source file:org.openmicroscopy.shoola.agents.metadata.view.MetadataViewerComponent.java
/** * Implemented as specified by the {@link MetadataViewer} interface. * @see MetadataViewer#makeMovie(int, Color) */// w w w .j a va 2 s . c om public void makeMovie(int scaleBar, Color overlayColor) { Object refObject = model.getRefObject(); if (refObject instanceof WellSampleData) { WellSampleData wsd = (WellSampleData) refObject; refObject = wsd.getImage(); } if (!(refObject instanceof ImageData)) return; PixelsData data = null; ImageData img = (ImageData) refObject; try { data = ((ImageData) refObject).getDefaultPixels(); } catch (Exception e) { } if (data == null) return; int maxT = data.getSizeT(); int maxZ = data.getSizeZ(); int defaultZ = maxZ; int defaultT = maxT; Object value = data.getSizeC(); if (model.getEditor().getChannelData() != null) value = model.getEditor().getChannelData(); String name = EditorUtil.getPartialName(img.getName()); JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); MovieExportDialog dialog = new MovieExportDialog(f, name, maxT, maxZ, defaultZ, defaultT, value); dialog.setBinaryAvailable(MetadataViewerAgent.isBinaryAvailable()); dialog.setScaleBarDefault(scaleBar, overlayColor); dialog.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (MovieExportDialog.CREATE_MOVIE_PROPERTY.equals(name)) { Object src = evt.getSource(); if (src instanceof MovieExportDialog) { MovieExportDialog d = (MovieExportDialog) src; createMovie(d.getParameters()); } } } }); dialog.centerDialog(); }
From source file:org.jitsi.videobridge.Conference.java
/** * Notifies this instance that there was a change in the value of a property * of an object in which this instance is interested. * * @param ev a <tt>PropertyChangeEvent</tt> which specifies the object of * interest, the name of the property and the old and new values of that * property/*from w w w. j a v a 2 s . co m*/ */ @Override public void propertyChange(PropertyChangeEvent ev) { Object source = ev.getSource(); if (isExpired()) { // An expired Conference is to be treated like a null Conference // i.e. it does not handle any PropertyChangeEvents. If possible, // make sure that no further PropertyChangeEvents will be delivered // to this Conference. if (source instanceof PropertyChangeNotifier) { ((PropertyChangeNotifier) source).removePropertyChangeListener(propertyChangeListener); } } else if (source == speechActivity) { speechActivityPropertyChange(ev); } else if (source instanceof Endpoint) { // We care about PropertyChangeEvents from Endpoint but only if the // Endpoint in question is still participating in this Conference. Endpoint endpoint = getEndpoint(((Endpoint) source).getID()); if (endpoint != null) endpointPropertyChange(endpoint, ev); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java
/** Brings up the folder chooser to select where to save the files. * /*from w ww. j a va 2 s. co m*/ * @param format One of the formats defined by <code>FigureParam</code>. * @see org.openmicroscopy.shoola.env.data.model.FigureParam */ void saveAs(final int format) { String v = FigureParam.FORMATS.get(format); JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); List<FileFilter> filters = new ArrayList<FileFilter>(); switch (format) { case FigureParam.JPEG: filters.add(new JPEGFilter()); break; case FigureParam.PNG: filters.add(new PNGFilter()); break; case FigureParam.TIFF: filters.add(new TIFFFilter()); } FileChooser chooser = new FileChooser(f, FileChooser.FOLDER_CHOOSER, "Save As", "Select where to save locally the images as " + v, filters); try { File file = UIUtilities.getDefaultFolder(); if (file != null) chooser.setCurrentDirectory(file); } catch (Exception ex) { } String s = UIUtilities.removeFileExtension(view.getRefObjectName()); if (s != null && s.trim().length() > 0) chooser.setSelectedFile(s); chooser.setApproveButtonText("Save"); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.SAVE_AS_48)); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { String value = (String) evt.getNewValue(); File folder = null; if (StringUtils.isEmpty(value)) folder = UIUtilities.getDefaultFolder(); else folder = new File(value); Object src = evt.getSource(); if (src instanceof FileChooser) { ((FileChooser) src).setVisible(false); ((FileChooser) src).dispose(); } model.saveAs(folder, format); } } }); chooser.centerDialog(); }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private void createCards() { introPanel = new StandaloneLicensePanel(); content.add(introPanel, CARD_INTRO); playCard = new JPanel(new BorderLayout()); content.add(playCard, CARD_PLAY);//from w w w. java 2 s.c om JPanel confirm = new JPanel(new GridBagLayout()); JOptionPane option = new JOptionPane("A game is in open. End this game?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_PLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_PLAY); currentCard = CARD_PLAY; playButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); GridBagConstraints cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_PLAY_END); content.add(new StandaloneModeselectPanel(), CARD_MODESELECT); netplayCard = new JPanel(new BorderLayout()); netplayCard.add(netLobby, BorderLayout.SOUTH); content.add(netplayCard, CARD_NETPLAY); confirm = new JPanel(new GridBagLayout()); option = new JOptionPane("A netplay game is open. End this game and disconnect?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_NETPLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } netLobby.disconnect(); contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_NETPLAY); currentCard = CARD_NETPLAY; netplayButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_NETPLAY_END); StandaloneKeyConfig kc = new StandaloneKeyConfig(this); kc.load(0); content.add(kc, CARD_KEYS_1P); kc = new StandaloneKeyConfig(this); kc.load(1); content.add(kc, CARD_KEYS_2P); StandaloneGameTuningPanel gt = new StandaloneGameTuningPanel(); gt.load(0); content.add(gt, CARD_TUNING_1P); gt = new StandaloneGameTuningPanel(); gt.load(1); content.add(gt, CARD_TUNING_2P); StandaloneAISelectPanel ai = new StandaloneAISelectPanel(); ai.load(0); content.add(ai, CARD_AI_1P); ai = new StandaloneAISelectPanel(); ai.load(1); content.add(ai, CARD_AI_2P); StandaloneGeneralConfigPanel gc = new StandaloneGeneralConfigPanel(); gc.load(); content.add(gc, CARD_GENERAL); final JFileChooser fc = FileSystemViews.get().fileChooser("replay/"); fc.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Zeromeaner Replay Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().endsWith(".zrep"); } }); fc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) return; JFileChooser fc = (JFileChooser) e.getSource(); String path = fc.getSelectedFile().getPath(); if (!path.contains("replay/")) path = "replay/" + path; startReplayGame(path); } }); fc.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { fc.rescanCurrentDirectory(); } }); content.add(fc, CARD_OPEN); content.add(new StandaloneFeedbackPanel(), CARD_FEEDBACK); }
From source file:org.tinymediamanager.core.tvshow.entities.TvShow.java
/** * Instantiates a tv show. To initialize the propertychangesupport after loading *//* www . j a v a2 s . c o m*/ public TvShow() { // register for dirty flag listener super(); // give tag events from episodes up to the TvShowList propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShowEpisode) { firePropertyChange(evt); } } }; }
From source file:org.apache.catalina.mbeans.ServerLifecycleListener.java
/** * Handle a <code>PropertyChangeEvent</code> from one of the Containers * we are interested in.// w w w .j av a 2 s. c om * * @param event The event that has occurred */ public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof Container) { try { processContainerPropertyChange((Container) event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); } catch (Exception e) { log.error("Exception handling Container property change", e); } } else if (event.getSource() instanceof DefaultContext) { try { processDefaultContextPropertyChange((DefaultContext) event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); } catch (Exception e) { log.error("Exception handling DefaultContext property change", e); } } else if (event.getSource() instanceof NamingResources) { try { processNamingResourcesPropertyChange((NamingResources) event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); } catch (Exception e) { log.error("Exception handling NamingResources property change", e); } } else if (event.getSource() instanceof Server) { try { processServerPropertyChange((Server) event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); } catch (Exception e) { log.error("Exception handing Server property change", e); } } else if (event.getSource() instanceof Service) { try { processServicePropertyChange((Service) event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); } catch (Exception e) { log.error("Exception handing Service property change", e); } } }