List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:org.rdv.viz.image.HighResImageViz.java
private void initImagePanel() { imagePanel = new ImagePanel(); imagePanel.setBackground(Color.black); imagePanel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { String propertyName = pce.getPropertyName(); if (propertyName.equals(ImagePanel.AUTO_SCALING_PROPERTY)) { boolean autoScaling = (Boolean) pce.getNewValue(); //autoScaleMenuItem.setSelected(autoScaling); if (autoScaling) { properties.setProperty(DATA_PANEL_PROPERTY_AUTOSCALE, "true"); properties.remove(DATA_PANEL_PROPERTY_SCALE); properties.remove(DATA_PANEL_PROPERTY_ORIGIN); } else { properties.setProperty(DATA_PANEL_PROPERTY_SCALE, Double.toString(imagePanel.getScale())); properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, pointToString(imagePanel.getOrigin())); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); }//from w w w . j ava 2 s . c om } else if (propertyName.equals(ImagePanel.SCALE_PROPERTY) && !imagePanel.isAutoScaling()) { properties.setProperty(DATA_PANEL_PROPERTY_SCALE, pce.getNewValue().toString()); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); } else if (propertyName.equals(ImagePanel.ORIGIN_PROPERTY) && !imagePanel.isAutoScaling()) { Point origin = (Point) pce.getNewValue(); String originString = pointToString(origin); properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, originString); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); } else if (propertyName.equals(ImagePanel.NAVIGATION_IMAGE_ENABLED_PROPERTY)) { boolean showNavigationImage = (Boolean) pce.getNewValue(); //showNavigationImageMenuItem.setSelected(showNavigationImage); if (showNavigationImage) { properties.setProperty(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE, "true"); } else { properties.remove(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE); } } } }); panel.add(imagePanel, BorderLayout.CENTER); }
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
public void propertyChange(final PropertyChangeEvent evt) { // This gets called when all the results have been loaded rowCount = (Integer) evt.getNewValue(); if (rowCount > 0) { synchronized (getTreeLock()) { setTitleBar();/*ww w .j av a 2 s .com*/ esrPane.addTable(ESResultsTablePanel.this); } if (propChangeListener != null) { propChangeListener.propertyChange(new PropertyChangeEvent(this, "loaded", rowCount, rowCount)); } autoResizeColWidth(table, (DefaultTableModel) table.getModel()); } }
From source file:org.orbisgis.mapeditor.map.MapEditor.java
/** * The user update the scale field/* w w w . ja v a 2 s . co m*/ * @param pce update event * @throws PropertyVetoException If the property entered is incorrect */ public void onUserSetScaleDenominator(PropertyChangeEvent pce) throws PropertyVetoException { long newScale = (Long) pce.getNewValue(); if (newScale < 1) { throw new PropertyVetoException( I18N.tr("The value of the scale denominator must be equal or greater than 1"), pce); } mapControl.getMapTransform().setScaleDenominator(newScale); }
From source file:au.org.ala.delta.editor.DeltaEditor.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (_activeController == null) { return;/* w w w.j a v a 2 s . com*/ } if (evt.getSource() == _activeController.getModel()) { if ("modified".equals(evt.getPropertyName())) { setSaveEnabled((Boolean) evt.getNewValue()); } } }
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 w w w . jav 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.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.java
@Override public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(HashDb.Event.INDEXING_DONE.name())) { HashDb hashDb = (HashDb) event.getNewValue(); if (null != hashDb) { try { String indexPath = hashDb.getIndexPath(); if (!indexPath.equals("None")) { //NON-NLS hashSetPaths.add(indexPath); }/*from w w w .j a v a2 s .c o m*/ } catch (TskCoreException ex) { Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error getting index path of " + hashDb.getHashSetName() + " hash database after indexing", ex); //NON-NLS } } } }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Instantiates a new tv show panel.//from w w w .j a v a 2 s. com */ public TvShowPanel() { super(); treeModel = new TvShowTreeModel(tvShowList.getTvShows()); tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel(); tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel(); // build menu menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$ JFrame mainFrame = MainWindow.getFrame(); JMenuBar menuBar = mainFrame.getJMenuBar(); menuBar.add(menu); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JSplitPane splitPane = new JSplitPane(); splitPane.setContinuousLayout(true); add(splitPane, "2, 2, fill, fill"); JPanel panelTvShowTree = new JPanel(); splitPane.setLeftComponent(panelTvShowTree); panelTvShowTree.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); textField = EnhancedTextField.createSearchTextField(); panelTvShowTree.add(textField, "4, 1, right, bottom"); textField.setColumns(12); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { applyFilter(); } @Override public void removeUpdate(final DocumentEvent e) { applyFilter(); } @Override public void changedUpdate(final DocumentEvent e) { applyFilter(); } public void applyFilter() { TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel(); if (StringUtils.isNotBlank(textField.getText())) { filteredModel.setFilter(SearchOptions.TEXT, textField.getText()); } else { filteredModel.removeFilter(SearchOptions.TEXT); } filteredModel.filter(tree); } }); final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ panelTvShowTree.add(btnFilter, "6, 1, default, bottom"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill"); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); toolBar.setOpaque(false); panelTvShowTree.add(toolBar, "2, 1"); // toolBar.add(actionUpdateDatasources); final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH); // temp fix for size of the button buttonUpdateDatasource.setText(" "); buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonUpdateDatasource.setSplitWidth(18); buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionUpdateDatasources.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { // build the popupmenu on the fly buttonUpdateDatasource.getPopupMenu().removeAll(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2)); buttonUpdateDatasource.getPopupMenu().addSeparator(); for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) { buttonUpdateDatasource.getPopupMenu() .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds))); } buttonUpdateDatasource.getPopupMenu().addSeparator(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow)); buttonUpdateDatasource.getPopupMenu().pack(); } }); JPopupMenu popup = new JPopupMenu("popup"); buttonUpdateDatasource.setPopupMenu(popup); toolBar.add(buttonUpdateDatasource); JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH); // temp fix for size of the button buttonScrape.setText(" "); buttonScrape.setHorizontalAlignment(JButton.LEFT); buttonScrape.setSplitWidth(18); buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$ // register for listener buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() { @Override public void buttonClicked(ActionEvent e) { actionScrape.actionPerformed(e); } @Override public void splitButtonClicked(ActionEvent e) { } }); popup = new JPopupMenu("popup"); JMenuItem item = new JMenuItem(actionScrape2); popup.add(item); // item = new JMenuItem(actionScrapeUnscraped); // popup.add(item); item = new JMenuItem(actionScrapeSelected); popup.add(item); item = new JMenuItem(actionScrapeNewItems); popup.add(item); buttonScrape.setPopupMenu(popup); toolBar.add(buttonScrape); toolBar.add(actionEdit); JButton btnMediaInformation = new JButton(); btnMediaInformation.setAction(actionMediaInformation); toolBar.add(btnMediaInformation); // install drawing of full with tree = new ZebraJTree(treeModel) { private static final long serialVersionUID = 2422163883324014637L; @Override public void paintComponent(Graphics g) { width = this.getWidth(); super.paintComponent(g); } }; tvShowSelectionModel = new TvShowSelectionModel(tree); TreeUI ui = new TreeUI() { @Override protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { bounds.width = width - bounds.x; super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } }; tree.setUI(ui); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setCellRenderer(new TvShowTreeCellRenderer()); tree.setRowHeight(0); scrollPane.setViewportView(tree); JPanel panelHeader = new JPanel() { private static final long serialVersionUID = -6914183798172482157L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, getWidth(), getHeight()); } }; scrollPane.setColumnHeaderView(panelHeader); panelHeader.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$ lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER); panelHeader.add(lblTvShowsColumn, "2, 1"); JLabel lblNfoColumn = new JLabel(""); lblNfoColumn.setHorizontalAlignment(JLabel.CENTER); lblNfoColumn.setIcon(IconManager.INFO); lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$ panelHeader.add(lblNfoColumn, "4, 1"); JLabel lblImageColumn = new JLabel(""); lblImageColumn.setHorizontalAlignment(JLabel.CENTER); lblImageColumn.setIcon(IconManager.IMAGE); lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$ panelHeader.add(lblImageColumn, "5, 1"); JLabel lblSubtitleColumn = new JLabel(""); lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER); lblSubtitleColumn.setIcon(IconManager.SUBTITLE); lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$ panelHeader.add(lblSubtitleColumn, "6, 1"); JPanel panel = new JPanel(); panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$ panel.add(lblTvShowsT, "1, 2, fill, fill"); lblTvShows = new JLabel(""); panel.add(lblTvShows, "3, 2"); JLabel labelSlash = new JLabel("/"); panel.add(labelSlash, "5, 2"); JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$ panel.add(lblEpisodesT, "7, 2"); lblEpisodes = new JLabel(""); panel.add(lblEpisodes, "9, 2"); JLayeredPane layeredPaneRight = new JLayeredPane(); layeredPaneRight.setLayout( new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") }, new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") })); panelRight = new JPanel(); layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill"); layeredPaneRight.setLayer(panelRight, 0); // glass pane final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree); panelExtendedSearch.setVisible(false); // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill"); btnFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (panelExtendedSearch.isVisible() == true) { panelExtendedSearch.setVisible(false); } else { panelExtendedSearch.setVisible(true); } } }); // add a propertychangelistener which reacts on setting a filter tree.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("filterChanged".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { btnFilter.setIcon(IconManager.FILTER_ACTIVE); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$ } else { btnFilter.setIcon(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ } } } }); layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill"); layeredPaneRight.setLayer(panelExtendedSearch, 1); splitPane.setRightComponent(layeredPaneRight); panelRight.setLayout(new CardLayout(0, 0)); JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel); panelRight.add(panelTvShow, "tvShow"); JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel); panelRight.add(panelTvShowSeason, "tvShowSeason"); JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel); panelRight.add(panelTvShowEpisode, "tvShowEpisode"); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { // click on a tv show if (node.getUserObject() instanceof TvShow) { TvShow tvShow = (TvShow) node.getUserObject(); tvShowSelectionModel.setSelectedTvShow(tvShow); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShow"); } // click on a season if (node.getUserObject() instanceof TvShowSeason) { TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject(); tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowSeason"); } // click on an episode if (node.getUserObject() instanceof TvShowEpisode) { TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject(); tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowEpisode"); } } else { // check if there is at least one tv show in the model TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot(); if (root.getChildCount() == 0) { // sets an inital show tvShowSelectionModel.setSelectedTvShow(null); } } } }); addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { menu.setVisible(false); super.componentHidden(e); } @Override public void componentShown(ComponentEvent e) { menu.setVisible(true); super.componentHidden(e); } }); // further initializations init(); initDataBindings(); // selecting first TV show at startup if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) { DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel() .getRoot()).getFirstChild(); tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath())); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java
/** Download the original metadata.*/ private void downloadMetadata() { JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); FileChooser chooser = new FileChooser(f, FileChooser.SAVE, "Download Metadata", "Download the metadata file.", null, true); chooser.setSelectedFileFull(FileAnnotationData.ORIGINAL_METADATA_NAME); chooser.setCheckOverride(true);/*from ww w . j a va2 s. co m*/ FileAnnotationData data = view.getOriginalMetadata(); String name = ""; if (data != null) name = data.getFileName(); else { ImageData img = view.getImage(); name = FilenameUtils.removeExtension(img.getName()); } chooser.setSelectedFileFull(name); chooser.setApproveButtonText("Download"); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.addPropertyChangeListener(new PropertyChangeListener() { /** * Handles the download of the original files */ 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(); UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier(); ImageData img = view.getImage(); if (img == null) return; IconManager icons = IconManager.getInstance(); DownloadActivityParam activity = new DownloadActivityParam(img.getId(), DownloadActivityParam.METADATA_FROM_IMAGE, folder, icons.getIcon(IconManager.DOWNLOAD_22)); un.notifyActivity(model.getSecurityContext(), activity); } } }); chooser.centerDialog(); }
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 {// ww w . j av a 2s. c o m 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:e3fraud.gui.MainWindow.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //parse file this.baseModel = FileParser.parseFile(file); log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline); } else {//from www . j a v a2s . co m log.append(currentTime.currentTime() + " Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); //handle Generate button } else if (e.getSource() == generateButton) { if (this.baseModel != null) { //have the user indicate the ToA via pop-up JFrame frame1 = new JFrame("Select Target of Assessment"); Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); String selectedActorString = (String) JOptionPane.showInputDialog(frame1, "Which actor's perspective are you taking?", "Choose main actor", JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(), actorsMap.keySet().toArray()[0]); if (selectedActorString == null) { log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline); } else { lastSelectedActorString = selectedActorString; //have the user select a need via pop-up JFrame frame2 = new JFrame("Select graph parameter"); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); String selectedNeedString = (String) JOptionPane.showInputDialog(frame2, "What do you want to use as parameter?", "Choose need to parametrize", JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(), needsMap.keySet().toArray()[0]); if (selectedNeedString == null) { log.append("Attack generation cancelled!" + newline); } else { lastSelectedNeedString = selectedNeedString; //have the user select occurence interval via pop-up JTextField xField = new JTextField("1", 4); JTextField yField = new JTextField("500", 4); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Mininum occurences:")); myPanel.add(xField); myPanel.add(Box.createHorizontalStrut(15)); // a spacer myPanel.add(new JLabel("Maximum occurences:")); myPanel.add(yField); int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { log.append("Attack generation cancelled!" + newline); } else if (result == JOptionPane.OK_OPTION) { startValue = Integer.parseInt(xField.getText()); endValue = Integer.parseInt(yField.getText()); selectedNeed = needsMap.get(selectedNeedString); selectedActor = actorsMap.get(selectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString, selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); System.err.println("I made it invisible"); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } } } } else { log.append("Load a model file first!" + newline); } } //handle the refresh button else if (e.getSource() == refreshButton) { if (lastSelectedNeedString != null && lastSelectedActorString != null) { Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); selectedNeed = needsMap.get(lastSelectedNeedString); selectedActor = actorsMap.get(lastSelectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString, selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Most likely out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } else { log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline); } } //handle show ideal graph button else if (e.getSource() == idealGraphButton) { if (this.baseModel != null) { graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1); chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartframe1.pack(); chartframe1.setLocationByPlatform(true); chartframe1.setVisible(true); } else { log.append(currentTime.currentTime() + " Load a model file first!" + newline); } } //Handle the graph extend button//Handle the graph extend button else if (e.getSource() == expandButton) { //make sure there is a graph to show if (graph2 == null) { log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline); } else { //this makes sure both graphs have the same y axis: // double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound()); // double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound()); // graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); // graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); chartPane.removeAll(); chartPanel = new ChartPanel(graph2); chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartPane.add(chartPanel); chartPane.add(collapseButton); extended = true; this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight())); JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } } //Handle the graph collapse button//Handle the graph collapse button else if (e.getSource() == collapseButton) { System.out.println("resizing by -" + CHART_WIDTH); chartPane.removeAll(); chartPane.add(expandButton); this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight())); chartPane.repaint(); chartPane.revalidate(); extended = false; JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } }