List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:VASSAL.build.module.map.LOS_Thread.java
/** * Expects to be added to a {@link Map}. Adds a button to the map * window's toolbar. Pushing the button pushes a MouseListener * onto the Map that draws the thread. Adds some entries to * preferences/*from w w w .ja v a2 s . com*/ * * @see Map#pushMouseListener*/ public void addTo(Buildable b) { idMgr.add(this); map = (Map) b; map.getView().addMouseMotionListener(this); map.addDrawComponent(this); map.getToolBar().add(launch); GameModule.getGameModule().addCommandEncoder(this); GameModule.getGameModule().getPrefs().addOption(getConfigureName(), new BooleanConfigurer(SNAP_LOS, Resources.getString("LOS_Thread.snap_thread_preference"))); if (fixedColor == null) { ColorConfigurer config = new ColorConfigurer(LOS_COLOR, Resources.getString("LOS_Thread.thread_color_preference")); GameModule.getGameModule().getPrefs().addOption(getConfigureName(), config); threadColor = (Color) GameModule.getGameModule().getPrefs().getValue(LOS_COLOR); config.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { threadColor = (Color) evt.getNewValue(); } }); config.fireUpdate(); } }
From source file:org.fhcrc.cpl.viewer.gui.SpectrumComponent.java
public void selectedPoint_propertyChange(PropertyChangeEvent e) { Spectrum.Peak p = (Spectrum.Peak) e.getNewValue(); if (null == p) { _selectedMZ = -1;/*from ww w. j a v a 2 s . c o m*/ _selectedScanNum = -1; clearChart(); return; } if (_selectedMZ == p.mz && _selectedScanNum == p.scan) return; _selectedMZ = p.mz; _selectedScanNum = p.scan; _log.debug("_selectedMZ = " + _selectedMZ); _log.debug("_selectedScanNum = " + _selectedScanNum); updateChart(false); }
From source file:org.openvpms.web.component.im.edit.IMTableCollectionEditor.java
/** * Invoked when the editor changes components. * * @param event the property change event */// w w w . j av a2s. c o m protected void onComponentChange(PropertyChangeEvent event) { Component oldValue = (Component) event.getOldValue(); Component newValue = (Component) event.getNewValue(); editBox.remove(oldValue); editBox.add(newValue); changeFocusGroup(getCurrentEditor()); }
From source file:org.squidy.designer.model.PipeShape.java
public void initialize() { if (pipe == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not initialize PipeShape without a pipe instance. Removing from parent."); }//from w w w .j av a 2s. c o m return; } visualization = new VisualizationShape(this); visualization.setScale(0.5); addChild(visualization); // ShapeUtils.setApparent(visualization, false); pipe.addProcessingFeedback(visualization); flowIncoming = new DataTypeShape(pipe.getInputTypes()); flowIncoming.setScale(0.1); addChild(flowIncoming); // ShapeUtils.setApparent(flowIncoming, false); flowOutgoing = new DataTypeShape(pipe.getOutputTypes()); flowOutgoing.setScale(0.1); addChild(flowOutgoing); // ShapeUtils.setApparent(flowOutgoing, false); final PropertyChangeListener changeListener = new PropertyChangeListener() { /* * (non-Javadoc) * * * @seejava.beans.PropertyChangeListener#propertyChange(java. * beans. PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() != null) { setBounds(computeBounds()); positionVisualization(); } } }; addPropertyChangeListener(PNode.PROPERTY_PARENT, changeListener); source.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); target.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); pipe.addStatusChangeListener(Processable.STATUS_PROCESSABLE_DELETED, new PropertyChangeListener() { /* * (non-Javadoc) * * @see * java.beans.PropertyChangeListener#propertyChange(java * .beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (source != null) { source.removePropertyChangeListener(changeListener); } if (target != null) { target.removePropertyChangeListener(changeListener); } removeFromParent(); } }); addInputEventListener(new PBasicInputEventHandler() { /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseEntered * (edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseEntered(PInputEvent event) { super.mouseEntered(event); // ShapeUtils.setApparent(visualization, true); // ShapeUtils.setApparent(flowIncoming, true); // ShapeUtils.setApparent(flowOutgoing, true); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseExited( * edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseExited(PInputEvent event) { super.mouseExited(event); // ShapeUtils.setApparent(visualization, false); // ShapeUtils.setApparent(flowIncoming, false); // ShapeUtils.setApparent(flowOutgoing, false); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mousePressed * (edu.umd.cs.piccolo. event.PInputEvent) */ @Override public void mousePressed(PInputEvent event) { super.mousePressed(event); if (!event.isHandled()) { Point2D p = event.getPosition(); double x = p.getX(); double y = p.getY(); // Check intersection based on mouse position (5 pixel // around // position) // Rectangle2D rectangle = globalToLocal(new // Rectangle2D.Double(x, y, 100 * getGlobalScale(), // 100 * getGlobalScale())); // if (shape.intersects(rectangle)) { event.getInputManager().setKeyboardFocus(event.getPath()); // // if (event.isRightMouseButton()) { // globalToLocal(p); // System.out.println("Do you wan't to create a bendpoint at x=" // + p.getX() + " / y=" // + p.getY() + "?"); // } event.setHandled(true); // } } // PNode nextNode = event.getPath().nextPickedNode(); // if (nextNode != null) { // EventListenerList listenerList = nextNode.getListenerList(); // // if (listenerList != null) { // PBasicInputEventHandler[] listeners = // listenerList.getListeners(PBasicInputEventHandler.class); // for (PBasicInputEventHandler listener : listeners) { // listener.mousePressed(event); // } // } // } } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusGained * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusGained(PInputEvent event) { super.keyboardFocusGained(event); selected = true; moveToFront(); invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusLost * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusLost(PInputEvent event) { super.keyboardFocusLost(event); selected = false; invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyPressed(edu * .umd.cs.piccolo.event .PInputEvent) */ @Override public void keyPressed(PInputEvent event) { super.keyPressed(event); if (KeyEvent.VK_DELETE == event.getKeyCode()) { // DrawingArea drawingArea = (DrawingArea) // event.getCamera().getComponent(); // drawingArea.removeEdge(Edge.this); if (LOG.isDebugEnabled()) { LOG.debug("Backspace has been pressed. Trigger deletion of edge?"); } pipe.delete(); Manager.get().notify(getPipe(), Action.DELETE); } } }); }
From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java
private JPanel createOptionsPanel() { final JLabel numBinsLabel = new JLabel("#Bins:"); JTextField numBinsField = new JTextField(Integer.toString(NUM_BINS_DEFAULT)); numBinsField.setPreferredSize(new Dimension(50, numBinsField.getPreferredSize().height)); final JCheckBox histoLogCheck = new JCheckBox("Log10 scaled bins"); histoLogCheck.addActionListener(configChangeListener); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS) .setDescription("Set the number of bins in the histogram"); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS) .setValueRange(new ValueRange(2.0, 2048.0)); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS).setDefaultValue(NUM_BINS_DEFAULT); bindingContext.bind(PROPERTY_NAME_NUM_BINS, numBinsField); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM) .setDescription("Use log-10 scaled values for computation of histogram"); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM).setDefaultValue(false); bindingContext.bind(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, histoLogCheck); log10HistEnablement = bindingContext.bindEnabledState(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, true, new Enablement.Condition() { @Override/*from w w w . ja va 2 s. c o m*/ public boolean evaluate(BindingContext bindingContext) { return getRaster() != null && getRaster().getStx().getMaximum() > 0; } }); PropertyChangeListener logChangeListener = new AxisControlChangeListener(); xAxisRangeControl.getBindingContext().addPropertyChangeListener(logChangeListener); xAxisRangeControl.getBindingContext().getPropertySet() .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM)); xAxisRangeControl.getBindingContext().getPropertySet() .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOG_SCALED)); xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED) .setDescription("Toggle whether to use a logarithmic x-axis"); log10AxisEnablement = xAxisRangeControl.getBindingContext().bindEnabledState(PROPERTY_NAME_LOG_SCALED, true, new Enablement.Condition() { @Override public boolean evaluate(BindingContext bindingContext) { HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig(); boolean hasStx = model.hasStx(currentConfig); // log10 xAxis is enabled when current histogram exists and is NOT log10 scaled return dataset != null && hasStx && !model.getStx(currentConfig).isLogHistogram(); } }); JPanel dataSourceOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints dataSourceOptionsConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2"); GridBagUtils.addToPanel(dataSourceOptionsPanel, new JLabel(" "), dataSourceOptionsConstraints, "gridwidth=2,gridy=0,gridx=0,weightx=0"); GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsLabel, dataSourceOptionsConstraints, "insets.top=2,insets.left=4,gridwidth=1,gridy=1,gridx=0,weightx=1"); GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsField, dataSourceOptionsConstraints, "insets.top=0,insets.left=0,insets.right=2,gridwidth=1,gridy=1,gridx=1"); GridBagUtils.addToPanel(dataSourceOptionsPanel, histoLogCheck, dataSourceOptionsConstraints, "insets.right=0,gridwidth=2,gridy=2,gridx=0"); xAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled")); xAxisRangeControl.getBindingContext().addPropertyChangeListener(PROPERTY_NAME_LOG_SCALED, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { ValueAxis oldAxis = chart.getXYPlot().getDomainAxis(); ValueAxis newAxis = StatisticChartStyling.updateScalingOfAxis((Boolean) evt.getNewValue(), oldAxis, true); chart.getXYPlot().setDomainAxis(newAxis); } }); JPanel displayOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints displayOptionsConstraints = GridBagUtils .createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1"); GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=2"); JPanel optionsPanel = GridBagUtils.createPanel(); GridBagConstraints gbc = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1"); GridBagUtils.addToPanel(optionsPanel, dataSourceOptionsPanel, gbc, "gridy=0"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=1,fill=VERTICAL,weighty=1"); GridBagUtils.addToPanel(optionsPanel, displayOptionsPanel, gbc, "gridy=2,fill=HORIZONTAL,weighty=0"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=3,fill=VERTICAL,weighty=1"); GridBagUtils.addToPanel(optionsPanel, xAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getComponents()[0], gbc, "gridy=4"); return optionsPanel; }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * /*from ww w .j a va 2s . c om*/ */ protected void buildUI() { SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr); localizableIO = slxh; localizableIO.load(false); //stripToSingleLocale("pt", slxh); LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() { public LocalizableStrIFace create() { SpLocaleItemStr str = new SpLocaleItemStr(); str.initialize(); return str; } public LocalizableStrIFace create(String text, Locale locale) { return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor } }; LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory); SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory); schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, webLinkMgrCache, schemaType); schemaLocPanel.setLocalizableIO(localizableIO); schemaLocPanel.setStatusBar(statusBar); boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false); schemaLocPanel.setUseDisciplines(useDisciplines); // rods - for now //schemaLocPanel.setIncludeHiddenUI(true); schemaLocPanel.buildUI(); schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad()); statusBar.setSectionText(1, schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$ : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$ UIRegistry.setStatusBar(statusBar); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); String title = "File"; //$NON-NLS-1$ String mneu = "F"; //$NON-NLS-1$ JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "Save"; //$NON-NLS-1$ mneu = "S"; //$NON-NLS-1$ JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$ new ActionListener() { public void actionPerformed(ActionEvent e) { write(); } }); saveMenuItem.setEnabled(false); title = "Export"; //$NON-NLS-1$ mneu = "E"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { export(); } }); title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$ mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { exportSingleLocale(); } }); title = "Exit"; //$NON-NLS-1$ mneu = "x"; //$NON-NLS-1$ if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } /* JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T"); UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener() { public void actionPerformed(ActionEvent e) { createResourceFiles(); } }); */ menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$ { schemaLocPanel.localeChanged((Locale) evt.getNewValue()); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); } } })); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setSize(800, 600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(schemaLocPanel, BorderLayout.CENTER); mainPanel.add(statusBar, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setContentPane(mainPanel); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); schemaLocPanel.setSaveMenuItem(saveMenuItem); schemaLocPanel.getContainerList().setEnabled(true); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.loadColorAndFormatPrefs(); if (localizableIO.didModelChangeDuringLoad()) { saveMenuItem.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); tp.setContentType("text/html"); tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer()); frame.setContentPane(js); frame.pack(); frame.setSize(400, 500); frame.setVisible(true); } }); } }
From source file:org.yccheok.jstock.gui.portfolio.DividendSummaryJDialog.java
@Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { if (progressMonitor == null) { return; }//from ww w . java2s .c o m int progress = (Integer) evt.getNewValue(); progressMonitor.setProgress(progress); int total = transactionSummaries.size(); int progressPercentage = total == 0 ? 0 : (int) (progress / (double) total * 100.); String template = GUIBundle.getString("DividendSummaryJDialog_Completed_template"); String message = MessageFormat.format(template, progressPercentage); progressMonitor.setNote(message); if (progressMonitor.isCanceled() || autoDividendTask.isDone()) { if (progressMonitor.isCanceled()) { autoDividendTask.cancel(true); } else { } jButton5.setEnabled(true); } } }
From source file:org.jspresso.framework.application.frontend.action.lov.LovAction.java
/** * Feed context with dialog./*from w ww . ja v a 2 s . co m*/ * * @param erqDescriptor * the erq descriptor * @param queryComponent * the query component * @param lovView * the lov view * @param actionHandler * the action handler * @param context * the context */ protected void feedContextWithDialog(IReferencePropertyDescriptor<IComponent> erqDescriptor, IQueryComponent queryComponent, IView<E> lovView, final IActionHandler actionHandler, final Map<String, Object> context) { getViewConnector(context).setConnectorValue(getViewConnector(context).getConnectorValue()); if (!context.containsKey(ModalDialogAction.DIALOG_ACTIONS)) { List<IDisplayableAction> actions = new ArrayList<>(); actions.add(getOkAction()); if (getCreateAction() != null) { actions.add(getCreateAction()); } actions.add(getFindAction()); actions.add(getCancelAction()); context.put(ModalDialogAction.DIALOG_ACTIONS, actions); } context.put(ModalDialogAction.DIALOG_TITLE, getI18nName(getTranslationProvider(context), getLocale(context)) + " : " + erqDescriptor.getReferencedDescriptor().getI18nName(getTranslationProvider(context), getLocale(context))); context.put(ModalDialogAction.DIALOG_VIEW, lovView); if (lovView instanceof ICompositeView<?>) { context.put(ModalDialogAction.DIALOG_FOCUSED_COMPONENT, ((ICompositeView<E>) lovView).getChildren().get(1).getPeer()); } if (pagingAction != null) { PropertyChangeListener paginationListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getOldValue() != null && evt.getNewValue() != null) { try { context.put(AbstractQbeAction.PAGINATE, null); actionHandler.execute(pagingAction, context); } finally { context.remove(AbstractQbeAction.PAGINATE); } } } }; queryComponent.addPropertyChangeListener(IPageable.PAGE, paginationListener); } }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java
/** * Creates a new dataset./* ww w.ja v a 2 s . c om*/ * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (CreateFolderDialog.CREATE_FOLDER_PROPERTY.equals(name)) { String folderName = (String) evt.getNewValue(); if (folderName != null && folderName.trim().length() > 0) createDataset(folderName); } }
From source file:ome.formats.importer.gui.LoginHandler.java
public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); if (!NEW_LOGIN) { if (prop.equals(LOGIN)) { tryLogin();//from w w w .j a v a2 s. c om } if (prop.equals(LOGIN_CANCELLED)) { loginCancelled(); } } else { if (prop.equals(ScreenLogin.LOGIN_PROPERTY)) { lc = (LoginCredentials) evt.getNewValue(); if (lc != null) { tryLogin(); } } else if (ScreenLogin.QUIT_PROPERTY.equals(prop)) { if (displayTop) { System.exit(0); } else { view.dispose(); } } else if (ScreenLogin.TO_FRONT_PROPERTY.equals(prop) || ScreenLogo.MOVE_FRONT_PROPERTY.equals(prop)) { } } }