List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.DownloadAction.java
/** * Downloads the selected files./*from w w w .j av a2 s .com*/ * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) */ public void actionPerformed(ActionEvent e) { Browser browser = model.getSelectedBrowser(); if (browser == null) return; TreeImageDisplay node = browser.getLastSelectedDisplay(); if (node == null) return; JFrame f = TreeViewerAgent.getRegistry().getTaskBar().getFrame(); List<DataObject> list = browser.getSelectedDataObjects(); int type = FileChooser.SAVE; List<String> paths = new ArrayList<String>(); if (list != null && list.size() > 1) { type = FileChooser.FOLDER_CHOOSER; Iterator<DataObject> i = list.iterator(); DataObject data; while (i.hasNext()) { data = i.next(); if (data instanceof ImageData) { paths.add(FilenameUtils.getName(((ImageData) data).getName())); } } } FileChooser chooser = new FileChooser(f, type, FileChooser.DOWNLOAD_TEXT, FileChooser.DOWNLOAD_DESCRIPTION, null, true); try { File file = UIUtilities.getDefaultFolder(); if (file != null) chooser.setCurrentDirectory(file); } catch (Exception ex) { } String text = ""; Object ho = node.getUserObject(); if (ho instanceof ImageData) text = ((ImageData) ho).getName(); else if (ho instanceof FileAnnotationData) text = ((FileAnnotationData) ho).getFileName(); chooser.setSelectedFileFull(text); chooser.setCheckOverride(true); chooser.setSelectedFiles(paths); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.setApproveButtonText(FileChooser.DOWNLOAD_TEXT); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); FileChooser src = (FileChooser) evt.getSource(); File path = null; if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { if (src.getChooserType() == FileChooser.FOLDER_CHOOSER) { path = new File((String) evt.getNewValue()); } else { File[] files = (File[]) evt.getNewValue(); if (files == null || files.length == 0) return; path = files[0]; } if (path == null) { path = UIUtilities.getDefaultFolder(); } model.download(path, src.isOverride()); } } }); chooser.centerDialog(); }
From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java
/** * Create the application.// w w w. jav a 2 s. co m */ public TestPanelWindow(Controller theController) { myController = theController; myMessageDescriptionListener = new MyMessageDescriptionListener(); new SwingLogAppender(); initialize(); initializeLocal(); initWindowPosition(); if (myController.getLeftSelectedItem() instanceof Hl7V2MessageCollection) { myMessagesList.setSelectedValue(myController.getLeftSelectedItem(), true); } else if (myController.getLeftSelectedItem() instanceof InboundConnection) { myInboundConnectionsList.setSelectedValue(myController.getLeftSelectedItem(), true); } else if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myOutboundConnectionsList.setSelectedValue(myController.getLeftSelectedItem(), true); } else { ourLog.warn("Unknown type is selected: {}", myController.getLeftSelectedItem()); } myPanelTitleListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { updateWindowTitle(); } }; }
From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java
public void createGUI() { // header image add(UIHelper.wrapComponentInPanel(new JLabel(panelHeader, SwingConstants.RIGHT)), BorderLayout.NORTH); // add a checkable jtree with investigations & studies... JPanel availableSubmissionsContainer = new JPanel(new BorderLayout()); availableSubmissionsContainer.setOpaque(false); JPanel optionsContainer = new JPanel(); optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.LINE_AXIS)); optionsContainer.setOpaque(false);// w ww . j ava 2 s . c o m JPanel optionsAndInformationPanel = new JPanel(); optionsAndInformationPanel.setLayout(new BoxLayout(optionsAndInformationPanel, BoxLayout.PAGE_AXIS)); optionsAndInformationPanel.setOpaque(false); JLabel fileInformation = UIHelper.createLabel("<html><i>where</i> to save the isatab files?</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); fileInformation.setVerticalAlignment(JLabel.TOP); JPanel fileLocationOptionContainer = new JPanel(); fileLocationOptionContainer.setLayout(new BoxLayout(fileLocationOptionContainer, BoxLayout.PAGE_AXIS)); fileLocationOptionContainer.setOpaque(false); // add component for selection of output to repository or output to folder... fileLocationOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true); fileLocationOptionGroup.addOptionItem("BII repository", true); fileLocationOptionGroup.addOptionItem("Local file system"); localDirectoryLocation = new FileSelectionUtil("select output directory", createFileChooser(), UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR); localDirectoryLocation.setVisible(false); localDirectoryLocation.setPreferredSize(new Dimension(150, 20)); fileLocationOptionGroup.addPropertyChangeListener("optionSelectionChange", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { localDirectoryLocation .setVisible(fileLocationOptionGroup.getSelectedItem().equals("Local file system")); revalidate(); } }); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileInformation)); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileLocationOptionGroup)); fileLocationOptionContainer.add(Box.createVerticalStrut(5)); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(localDirectoryLocation)); optionsContainer.add(fileLocationOptionContainer); JPanel dataFileExportOptionContainer = new JPanel(); dataFileExportOptionContainer.setLayout(new BoxLayout(dataFileExportOptionContainer, BoxLayout.PAGE_AXIS)); dataFileExportOptionContainer.setOpaque(false); JLabel dataFileExportInformation = UIHelper.createLabel("<html>export data files?</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); dataFileExportInformation.setVerticalAlignment(JLabel.TOP); dataFileExportOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true); dataFileExportOptionGroup.addOptionItem("yes", true); dataFileExportOptionGroup.addOptionItem("no"); dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportInformation)); dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportOptionGroup)); dataFileExportOptionContainer.add(Box.createVerticalStrut(25)); optionsContainer.add(dataFileExportOptionContainer); optionsAndInformationPanel.add(Box.createVerticalStrut(5)); optionsAndInformationPanel.add(optionsContainer); optionsAndInformationPanel.add(Box.createVerticalStrut(10)); JLabel information = UIHelper.createLabel( "<html>please <i>select</i> the submissions to be exported...</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); information.setVerticalAlignment(JLabel.TOP); optionsAndInformationPanel.add(UIHelper.wrapComponentInPanel(information)); optionsAndInformationPanel.add(Box.createVerticalStrut(5)); availableSubmissionsContainer.add(optionsAndInformationPanel, BorderLayout.NORTH); retrieveAndProcessStudyInformation(); JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroller.getViewport().setOpaque(false); treeScroller.setOpaque(false); treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1)); treeScroller.setPreferredSize(new Dimension(380, 250)); availableSubmissionsContainer.add(treeScroller, BorderLayout.CENTER); add(availableSubmissionsContainer, BorderLayout.CENTER); add(createSouthPanel(), BorderLayout.SOUTH); }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java
/** Initializes the components composing the display. */ private void initComponents() { usersBox = new JComboBox(); groupsBox = createGroupBox();/* ww w .ja v a 2 s .c o m*/ scopes = new HashMap<Integer, JCheckBox>(model.getNodes().size()); types = new HashMap<Integer, JCheckBox>(model.getTypes().size()); IconManager icons = IconManager.getInstance(); fromDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT); fromDate.setBackground(UIUtilities.BACKGROUND_COLOR); fromDate.addPropertyChangeListener("date", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Date d = (Date) evt.getNewValue(); if (d != null) { if (d.after(new Date())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Selecting a future 'From' date doesn't make any sense."); fromDate.setDate(null); } if (toDate.getDate() != null && d.after(toDate.getDate())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Cannot set a 'From' date which is more recent than the 'To' date."); fromDate.setDate(null); } } } }); fromDate.setToolTipText(DATE_TOOLTIP); toDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT); toDate.setBackground(UIUtilities.BACKGROUND_COLOR); toDate.setToolTipText(DATE_TOOLTIP); toDate.addPropertyChangeListener("date", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Date d = (Date) evt.getNewValue(); if (d != null) { if (fromDate.getDate() != null && d.before(fromDate.getDate())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Cannot set a 'To' date which is prior to the 'From' date."); toDate.setDate(null); } } } }); clearDate = new JButton(icons.getIcon(IconManager.CLOSE)); clearDate.setToolTipText("Reset the dates"); UIUtilities.unifiedButtonLookAndFeel(clearDate); clearDate.setBackground(UIUtilities.BACKGROUND_COLOR); clearDate.setActionCommand("" + SearchComponent.RESET_DATE); clearDate.addActionListener(model); fullTextArea = new JTextField(AREA_COLUMNS); fullTextArea.addKeyListener(new KeyAdapter() { /** Finds the phrase. */ public void keyPressed(KeyEvent e) { Object source = e.getSource(); if (source != fullTextArea) return; switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: model.search(); } } }); helpBasicButton = new JButton(icons.getIcon(IconManager.HELP)); helpBasicButton.setToolTipText("Search Tips."); helpBasicButton.setBackground(UIUtilities.BACKGROUND_COLOR); UIUtilities.unifiedButtonLookAndFeel(helpBasicButton); helpBasicButton.addActionListener(model); helpBasicButton.setActionCommand("" + SearchComponent.HELP); SearchContext ctx = model.getSearchContext(); if (ctx == null) return; }
From source file:org.netflux.core.task.AbstractTask.java
/** * Creates a new task with the given name, and initializes its input and output ports using the given names. * //from w w w.j a v a2 s. c o m * @param name the name of the task to be created. * @param inputPortNames the name of the input ports this task will use to read records. * @param outputPortNames the name of the output ports this task will use to write records. */ protected AbstractTask(String name, Set<String> inputPortNames, Set<String> outputPortNames) { this.name = name; Iterator<String> inputPortNamesIterator = inputPortNames.iterator(); while (inputPortNamesIterator.hasNext()) { String inputPortName = inputPortNamesIterator.next(); InputPort currentInputPort = new SimpleInputPort(this.name + ":" + inputPortName); this.inputPorts.put(inputPortName, currentInputPort); currentInputPort.addPropertyChangeListener("metadata", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { AbstractTask.this.updateMetadata((InputPort) event.getSource(), (RecordMetadata) event.getNewValue()); } }); } Iterator<String> outputPortNamesIterator = outputPortNames.iterator(); while (outputPortNamesIterator.hasNext()) { String outputPortName = outputPortNamesIterator.next(); this.outputPorts.put(outputPortName, new SimpleOutputPort(this.name + ":" + outputPortName)); } }
From source file:Provider.GoogleMapsStatic.TestUI.SampleApp.java
private SwingUIHookAdapter _initHook(SwingUIHookAdapter hook) { hook.enableRecieveStatusNotification(checkboxRecvStatus.isSelected()); hook.enableSendStatusNotification(checkboxSendStatus.isSelected()); hook.setProgressMessage(ttfProgressMsg.getText()); PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SwingUIHookAdapter.PropertyList type = ProgressMonitorUtils.parseTypeFrom(evt); int progress = ProgressMonitorUtils.parsePercentFrom(evt); String msg = ProgressMonitorUtils.parseMessageFrom(evt); progressBar.setValue(progress); progressBar.setString(type.toString()); sout(msg);/*from www . j av a 2s.c om*/ } }; hook.addRecieveStatusListener(listener); hook.addSendStatusListener(listener); hook.addUnderlyingIOStreamInterruptedOrClosed(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { sout(evt.getPropertyName() + " fired!!!"); } }); return hook; }
From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java
public void createGUI() { HUDTitleBar titlePanel = new HUDTitleBar(null, null, true); add(titlePanel, BorderLayout.NORTH); titlePanel.installListeners();//w w w . ja v a 2s .c om titlePanel.addPropertyChangeListener("windowClosed", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { firePropertyChange("ontologyClosed", "", "closed"); } }); // create left panel with list of selected ontology terms and Expandable panel createOntologySelectionPanel(); // create right panel containing tree showing the entirety of the ontology selected from the left pane. JPanel ontologySelectionPanel = new JPanel(new BorderLayout()); ontologyViewContainer = new JPanel(new BorderLayout()); ontologyViewContainer.setPreferredSize(new Dimension(500, 300)); // add placeholder panel by default with some image describing what to do setOntologySelectionPanelPlaceholder(infoImage); ontologyViewContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "browse ontology", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); ontologySelectionPanel.add(ontologyViewContainer, BorderLayout.CENTER); ontologySelectionPanel.add(Box.createVerticalStrut(20), BorderLayout.SOUTH); add(ontologySelectionPanel, BorderLayout.CENTER); JPanel functionWrapper = new JPanel(new BorderLayout()); searchAndTermDefinitionViewer = new SearchAndDefinitionUI(); searchAndTermDefinitionViewer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "functions", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); functionWrapper.add(searchAndTermDefinitionViewer); functionWrapper.add(createButtonPanel(), BorderLayout.SOUTH); add(functionWrapper, BorderLayout.EAST); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent componentEvent) { if (currentlyActiveBrowser != null && currentlyActiveBrowser.isShowing()) { ontologyViewContainer.setPreferredSize(getMaxBrowserSize()); currentlyActiveBrowser.setBrowserSize(getMaxBrowserSize()); ontologyViewContainer.repaint(); currentlyActiveBrowser.repaint(); } } }); FooterPanel footer = new FooterPanel(this); add(footer, BorderLayout.SOUTH); pack(); setVisible(true); }
From source file:org.ngrinder.infra.config.Config.java
private void addChangeConfigListenerForStatistics() { addSystemConfListener(new PropertyChangeListener() { @Override/*from w w w . ja v a2 s. com*/ public void propertyChange(PropertyChangeEvent evt) { updateCacheStatisticsSupports(); } }); }
From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java
/** * This method initializes jButton// w ww .j ava 2s . c o m * * @return javax.swing.JButton */ private JButton getJButtonFillGraphic() { if (jButtonFillGraphic == null) { jButtonFillGraphic = new JButton(); boolean enabled = false; if (symbolizer.getFill() != null) { Graphic graphicFill = symbolizer.getFill().getGraphicFill(); enabled = (graphicFill != null); } jButtonFillGraphic.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (symbolizer.getFill() == null) { symbolizer.setFill(StylingUtil.STYLE_BUILDER.createFill((Color) null, (Color) null, 1., StylingUtil.STYLE_BUILDER.createGraphic())); } JDialog editFillGraphicJDialog = new GraphicEditGUIinDialog(asv, SwingUtil.getParentWindow(PolygonSymbolEditGUI.this), symbolizer.getFill()); editFillGraphicJDialog.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(AbstractStyleEditGUI.PROPERTY_UPDATED)) { PolygonSymbolEditGUI.this.firePropertyChange(AbstractStyleEditGUI.PROPERTY_UPDATED, null, null); // Update the Button Icon jButtonFillGraphic.setIcon(new ImageIcon(ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } }); SwingUtil.setRelativeFramePosition(editFillGraphicJDialog, PolygonSymbolEditGUI.this, SwingUtil.BOUNDS_OUTER, SwingUtil.NORTHEAST); editFillGraphicJDialog.setVisible(true); } }); // Initialize correctly jLabelFillGraphic.setEnabled(enabled); jButtonFillGraphic.setEnabled(enabled); if (enabled) { jButtonFillGraphic.setIcon(new ImageIcon( ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } return jButtonFillGraphic; }
From source file:org.openvpms.web.workspace.reporting.statement.CustomerBalanceQuery.java
/** * Lays out the component in a container, and sets focus on the instance * name./*from w w w. ja v a 2 s.c o m*/ * * @param container the container */ @Override protected void doLayout(Component container) { Grid grid = GridFactory.create(6); accountType = LookupFieldFactory.create(new ArchetypeLookupQuery("lookup.customerAccountType"), true); accountType.setSelected((Lookup) null); accountType.setCellRenderer(LookupListCellRenderer.INSTANCE); Label accountTypeLabel = LabelFactory.create("reporting.statements.accountType"); date = DateFieldFactory.create(); date.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { } }); Label dateLabel = LabelFactory.create("reporting.statements.date"); balanceType = SelectFieldFactory.create(balanceTypeItems); balanceType.setCellRenderer(new BalanceTypeListCellRenderer()); balanceType.addActionListener(new ActionListener() { public void onAction(ActionEvent e) { onBalanceTypeChanged(); } }); Label balanceTypeLabel = LabelFactory.create("reporting.statements.balancetypes"); grid.add(accountTypeLabel); grid.add(accountType); grid.add(dateLabel); grid.add(date); grid.add(balanceTypeLabel); grid.add(balanceType); periodFromLabel = LabelFactory.create("reporting.statements.periodFrom"); periodFrom = TextComponentFactory.create(); periodFrom.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { } }); periodToLabel = LabelFactory.create("reporting.statements.periodTo"); periodTo = TextComponentFactory.create(); periodTo.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { } }); excludeCredit = CheckBoxFactory.create("reporting.statements.excludeCredit", true); grid.add(periodFromLabel); grid.add(periodFrom); grid.add(periodToLabel); grid.add(periodTo); grid.add(excludeCredit); grid.add(LabelFactory.create()); Label customerFromLabel = LabelFactory.create("reporting.statements.customerFrom"); customerFrom = TextComponentFactory.create(); customerFrom.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { } }); Label customerToLabel = LabelFactory.create("reporting.statements.customerTo"); customerTo = TextComponentFactory.create(); customerTo.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { } }); grid.add(customerFromLabel); grid.add(customerFrom); grid.add(customerToLabel); grid.add(customerTo); grid.add(LabelFactory.create("reporting.customer.location")); locationSelector = new LocationSelectField(); grid.add(locationSelector); container.add(grid); FocusGroup group = getFocusGroup(); group.add(accountType); group.add(date); group.add(balanceType); group.add(periodFrom); group.add(periodTo); group.add(excludeCredit); group.add(customerFrom); group.add(customerTo); group.add(locationSelector); FocusHelper.setFocus(getSearchField()); }