Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

In this page you can find the example usage for java.beans PropertyChangeListener PropertyChangeListener.

Prototype

PropertyChangeListener

Source Link

Usage

From source file:org.jitsi.service.osgi.OSGiService.java

/**
 * Method called by OSGi impl when start command completes.
 */// ww  w .j  a  v  a 2s.com
public void onOSGiStarted() {
    if (JitsiApplication.isIconEnabled()) {
        showIcon();
    }
    JitsiApplication.getConfig().addPropertyChangeListener(JitsiApplication.SHOW_ICON_PROPERTY_NAME,
            new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent event) {
                    if (JitsiApplication.isIconEnabled()) {
                        showIcon();
                    } else {
                        hideIcon();
                    }
                }
            });
    serviceStarted = true;
}

From source file:org.drugis.addis.presentation.wizard.StudyCriteriaAndAlternativesPresentation.java

public StudyCriteriaAndAlternativesPresentation(ValueHolder<Indication> indication,
        ModifiableHolder<AnalysisType> analysisType, ObservableList<Study> studies) {
    super(indication, analysisType);
    d_studyModel = new ModifiableHolder<Study>();
    d_availableCriteria = new ArrayListModel<OutcomeMeasure>();

    d_studyModel.addValueChangeListener(new PropertyChangeListener() {
        @Override// w ww. j ava  2 s.c  o m
        public void propertyChange(PropertyChangeEvent evt) {
            studyChanged();
        }
    });

    d_studiesWithIndicationHolder = new FilteredObservableList<Study>(studies,
            new IndicationFilter(d_indicationModel.getValue()));
    d_indicationModel.addValueChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            d_studiesWithIndicationHolder.setFilter(new IndicationFilter(d_indicationModel.getValue()));
        }
    });
}

From source file:org.openconcerto.map.ui.ITextComboVilleViewer.java

public ITextComboVilleViewer() {
    this.setOpaque(false);
    this.setLayout(new BorderLayout());

    this.supp = new ValueChangeSupport<String>(this);
    this.emptyHelper = new EmptyObjectHelper(this, new Predicate() {
        public boolean evaluate(final Object object) {
            // object: le getUncheckedValue()
            return ITextComboVilleViewer.this.getValue() == null
                    || ITextComboVilleViewer.this.getValue().trim().length() == 0;
        }/*from  ww  w.j a v  a 2 s  .  co m*/
    });
    this.text.addValueListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            ITextComboVilleViewer.this.supp.fireValueChange();
        }
    });

    this.cache = new ITextComboCacheVille();
    this.text.initCache(this.cache);
    this.add(this.text, BorderLayout.CENTER);

    this.add(this.button, BorderLayout.EAST);
    this.button.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final JFrame f = new JFrame();
            final MapViewerPanel mapViewerPanel = new MapViewerPanel(true);

            f.setContentPane(mapViewerPanel);
            f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            f.setSize(600, 500);
            f.setMinimumSize(new Dimension(600, 500));
            final File conf = new File(System.getProperty("user.home"),
                    ".java" + File.separator + "ilm" + File.separator + "map" + File.separator);
            new WindowStateManager(f, new File(conf, "Configuration" + File.separator + "MapFrame.properties"),
                    true).loadState();
            f.setVisible(true);
            if (ITextComboVilleViewer.this.currentVille != null) {
                final long x = ITextComboVilleViewer.this.currentVille.getXLambert();
                final long y = ITextComboVilleViewer.this.currentVille.getYLambert();
                f.setTitle(ITextComboVilleViewer.this.currentVille.getName());
                mapViewerPanel.getVilleRendererPanel().centerScreenXYLambert(x, y);
                mapViewerPanel.getVilleRendererPanel().setHighlight(ITextComboVilleViewer.this.currentVille);
                mapViewerPanel.getVilleRendererPanel().setAlwayVisible(ITextComboVilleViewer.this.currentVille);
            }
        }
    });
    this.text.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(final DocumentEvent e) {
            ITextComboVilleViewer.this.currentVille = Ville
                    .getVilleFromVilleEtCode(ITextComboVilleViewer.this.text.getValue());
            ITextComboVilleViewer.this.button.setEnabled(
                    ITextComboVilleViewer.this.currentVille != null && ITextComboVilleViewer.this.isEnabled());

        }

        public void insertUpdate(final DocumentEvent e) {
            this.changedUpdate(e);
        }

        public void removeUpdate(final DocumentEvent e) {
            this.changedUpdate(e);
        }
    });
    final JPopupMenu popupMenu = new JPopupMenu();
    // FIXME ajouter la possibilit de supprimer une ville prcdemment enregistre
    final JMenuItem menuItem = new JMenuItem("Enregistrer cette ville");
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final String t = ITextComboVilleViewer.this.text.getTextComp().getText();
            ITextComboVilleViewer.this.cache.addToCache(t);
            final Ville createVilleFrom = ITextComboVilleViewer.this.cache.createVilleFrom(t);
            if (createVilleFrom != null) {
                final String villeEtCode = createVilleFrom.getVilleEtCode();
                ITextComboVilleViewer.this.setValue(villeEtCode);
                ITextComboVilleViewer.this.firePropertyChange("value", null, villeEtCode);
            }
        }
    });
    popupMenu.add(menuItem);

    this.text.getTextComp().addMouseListener(new PopupMouseListener(popupMenu));

}

From source file:OptPaneComparison.java

public OptPaneComparison(final String message) {
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    final int msgType = JOptionPane.QUESTION_MESSAGE;
    final int optType = JOptionPane.OK_CANCEL_OPTION;
    final String title = message;

    setSize(350, 200);/*  w ww. j  av a 2 s.  co  m*/

    // Create a desktop for internal frames
    final JDesktopPane desk = new JDesktopPane();
    setContentPane(desk);

    // Add a simple menu bar
    JMenuBar mb = new JMenuBar();
    setJMenuBar(mb);

    JMenu menu = new JMenu("Dialog");
    JMenu imenu = new JMenu("Internal");
    mb.add(menu);
    mb.add(imenu);
    final JMenuItem construct = new JMenuItem("Constructor");
    final JMenuItem stat = new JMenuItem("Static Method");
    final JMenuItem iconstruct = new JMenuItem("Constructor");
    final JMenuItem istat = new JMenuItem("Static Method");
    menu.add(construct);
    menu.add(stat);
    imenu.add(iconstruct);
    imenu.add(istat);

    // Create our JOptionPane. We're asking for input, so we call
    // setWantsInput.
    // Note that we cannot specify this via constructor parameters.
    optPane = new JOptionPane(message, msgType, optType);
    optPane.setWantsInput(true);

    // Add a listener for each menu item that will display the appropriate
    // dialog/internal frame
    construct.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {

            // Create and display the dialog
            JDialog d = optPane.createDialog(desk, title);
            d.setVisible(true);

            respond(getOptionPaneValue());
        }
    });

    stat.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(desk, message, title, msgType);
            respond(s);
        }
    });

    iconstruct.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {

            // Create and display the dialog
            JInternalFrame f = optPane.createInternalFrame(desk, title);
            f.setVisible(true);

            // Listen for the frame to close before getting the value from
            // it.
            f.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent ev) {
                    if ((ev.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))
                            && (ev.getNewValue() == Boolean.TRUE)) {
                        respond(getOptionPaneValue());
                    }
                }
            });
        }
    });

    istat.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInternalInputDialog(desk, message, title, msgType);
            respond(s);
        }
    });
}

From source file:com.trivadis.loganalysis.ui.ChartPanel.java

public ChartPanel(final Composite parent, final int style, final IJvmRun jvm, final IChart chart,
        final IDatasetProvider datasetProvider) {
    super(parent, style);
    setLayout(new GridLayout(1, false));
    this.jvm = jvm;
    jfreeChart = createChart(null, this, chart, chart.getLabel(), "x", "y");
    this.chart = chart;
    this.datasetProvider = datasetProvider;

    oldCollectionListener = new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            final boolean showOldCollection = (Boolean) evt.getNewValue();
            if (showOldCollection) {
                addMarkers(GarbageCollectionType.OLD);
            } else {
                removeMarkers(GarbageCollectionType.OLD);
            }//from   w  ww  . j av a 2 s.  c o m
        }
    };
    youngCollectionListener = new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            final boolean showYoungCollection = (Boolean) evt.getNewValue();
            if (showYoungCollection) {
                addMarkers(GarbageCollectionType.YOUNG);
            } else {
                removeMarkers(GarbageCollectionType.YOUNG);
            }

        }
    };
    markersByType = new HashMap<GarbageCollectionType, List<Marker>>();
    markersByType.put(GarbageCollectionType.OLD,
            datasetProvider.getMarkers(jvm, chart, GarbageCollectionType.OLD));
    markersByType.put(GarbageCollectionType.YOUNG,
            datasetProvider.getMarkers(jvm, chart, GarbageCollectionType.YOUNG));

    initializeChart();
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelHeader.java

public void setConnection(AbstractConnection theConnection) {
    myConnection = theConnection;/*from w ww  . j a va  2  s  .com*/

    if (myConnection instanceof InboundConnection) {
        setLabelText("Incoming Message Receiver");
    } else {
        setLabelText("Outgoing Message Sender");
    }

    myNameBox.setText(theConnection.getName());

    myNamePropertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            if (!myIgnoreNameChanges) {
                myNameBox.setText(myConnection.getName());
            }
        }
    };
    myConnection.addPropertyChangeListener(OutboundConnection.NAME_PROPERTY, myNamePropertyChangeListener);

    myStatusPropertyChangeListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            updateStatus();
        }
    };
    myConnection.addPropertyChangeListener(OutboundConnection.STATUS_PROPERTY, myStatusPropertyChangeListener);

    myStatusLinePropertyChangeListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            updateStatus();
        }
    };
    myConnection.addPropertyChangeListener(OutboundConnection.STATUS_LINE_PROPERTY,
            myStatusLinePropertyChangeListener);

    updateStatus();

    updateRememberAsUi();

}

From source file:de.genvlin.plugins.jfreechart.JFreeChartPluginImpl.java

public boolean plot(final XYPool xyVectorPool, final ID id) {
    final GTask t = new GTask() {
        ChartPanel panel;//w  w  w . jav  a2 s.  co m

        public void runTask() {
            XYVectorPoolWrapper dataset = new XYVectorPoolWrapper(xyVectorPool);

            JFreeChart chart = ChartFactory.createXYLineChart("JFreechart Plot Panel.", // chart title
                    "X Title", // x axis label
                    "Y Title", // y axis label
                    dataset, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );

            panel = new ChartPanel(chart);
            panel.setName("plot:" + dataset.getID());
        }

        public Object getResult() {
            return panel;
        }
    };//GTask

    t.addChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == GTask.FINISHED) {
                showPanel((ChartPanel) t.getResult(), "east");
            }
        }
    });
    t.start();
    return true;
}

From source file:org.eclipse.wb.internal.swing.customize.CustomizerAction.java

private void performCustomize0() throws Exception {
    Customizer customizer = m_customizerClass.newInstance();
    // prepare properties information
    final JavaInfoState javaInfoState = JavaInfoState.getState(m_javaInfo);
    boolean explicit = isExplicitPropertyChange(m_javaInfo);
    PropertyChangeListener propertyChangeListener = null;
    if (explicit) {
        propertyChangeListener = new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                javaInfoState.changedProperties.add(event.getPropertyName());
                javaInfoState.changedPropertyValues.put(event.getPropertyName(), event.getNewValue());
            }//from w  w  w .  j  av a 2  s. c om
        };
        customizer.addPropertyChangeListener(propertyChangeListener);
    }
    //
    try {
        // open customizer dialog
        customizer.setObject(javaInfoState.object);
        AwtComponentDialog dialog = new AwtComponentDialog(DesignerPlugin.getDefault(), (Component) customizer,
                ModelMessages.CustomizerAction_dialogTitle, MessageFormat
                        .format(ModelMessages.CustomizerAction_dialogMessage, m_customizerClass.getName()));
        int dialogResult = dialog.open();
        // handle update properties
        if (dialogResult == Window.OK) {
            RunnableEx runnable = null;
            if (explicit) {
                // update changed properties
                runnable = new RunnableEx() {
                    public void run() throws Exception {
                        int size = javaInfoState.properties.size();
                        for (int i = 0; i < size; i++) {
                            Property property = javaInfoState.properties.get(i);
                            if (javaInfoState.changedProperties.contains(property.getTitle())) {
                                Object newValue = javaInfoState.changedPropertyValues.get(property.getTitle());
                                Object oldValue = javaInfoState.oldValues.get(i);
                                if (!ObjectUtils.equals(newValue, oldValue)) {
                                    property.setValue(newValue);
                                }
                            }
                        }
                    }
                };
            } else {
                // update all properties
                runnable = new RunnableEx() {
                    public void run() throws Exception {
                        int size = javaInfoState.properties.size();
                        for (int i = 0; i < size; i++) {
                            Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object);
                            Object oldValue = javaInfoState.oldValues.get(i);
                            if (!ObjectUtils.equals(newValue, oldValue)) {
                                javaInfoState.properties.get(i).setValue(newValue);
                            }
                        }
                    }
                };
            }
            // run update
            ExecutionUtils.run(m_javaInfo, runnable);
        }
        // rollback property changes
        if (dialogResult == Window.CANCEL) {
            ExecutionUtils.run(m_javaInfo, new RunnableEx() {
                public void run() throws Exception {
                    int size = javaInfoState.properties.size();
                    for (int i = 0; i < size; i++) {
                        Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object);
                        Object oldValue = javaInfoState.oldValues.get(i);
                        if (!ObjectUtils.equals(newValue, oldValue)) {
                            javaInfoState.setters.get(i).invoke(javaInfoState.object, oldValue);
                        }
                    }
                }
            });
        }
    } finally {
        if (propertyChangeListener != null) {
            customizer.removePropertyChangeListener(propertyChangeListener);
        }
    }
}

From source file:org.en.tealEye.guiMain.MainAppFrame.java

public MainAppFrame() {
    this.h = new Hypervisor(this);
    this.menuController = new MenuController(this, h);
    this.windowController = new WindowController(this);
    this.createGroupController = new CreateGroupController(this, h);
    this.showGroupsController = new ShowGroupsController(this, h);
    this.teamController = new TeamController(this, h);
    this.locationController = new LocationController(this, h);
    this.vendorController = new VendorController(this, h);
    task = new TaskbarConstr();
    addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            Collection<ExtendedJPanelImpl> panels = getPanelMap().values();
            for (ExtendedJPanelImpl panel : panels) {
                if (panel instanceof ExtJTablePanel || panel instanceof CreateGroup)
                    panel.getPanelController().refreshAndWait(panel);
            }// w  ww .  j av a 2 s .c o m
        }
    });
}

From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java

/**
 * The constructor.//ww w  .  j  a v a 2s . c o m
 */
public LiveDataMonitor() {
    _attListener = new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            // aah, is this for the scenario we're watching
            if (_myIndexedAttr != null)
                if (evt.getSource() == _myIndexedAttr.index) {

                    final DataDoublet newD = (DataDoublet) evt.getNewValue();
                    final long time = newD.getTime();
                    final Object newValue = newD.getValue();
                    if (newValue instanceof Number) {
                        final Number value = (Number) newValue;

                        // and store it
                        final TimeSeriesCollection coll = (TimeSeriesCollection) _chart.getXYPlot()
                                .getDataset();

                        TimeSeries tmpSeries;

                        if (coll == null) {
                            final TimeSeriesCollection dataset = new TimeSeriesCollection();
                            tmpSeries = new TimeSeries(_watchedAttr.getName());
                            dataset.addSeries(tmpSeries);
                            // add to series in different thread...
                            Display.getDefault().asyncExec(new Runnable() {
                                public void run() {
                                    _chart.getXYPlot().setDataset(dataset);
                                }
                            });
                        } else {
                            tmpSeries = coll.getSeries(0);
                        }

                        final TimeSeries series = tmpSeries;

                        // add to series in current thread, accepting it will slow down
                        // the
                        // UI
                        Display.getDefault().syncExec(new Runnable() {
                            public void run() {
                                // are we still open?i
                                if (!_chartFrame.isDisposed()) {
                                    // sure, go for it,
                                    series.addOrUpdate(new Millisecond(new Date(time)), value);
                                }
                            }
                        });
                    }
                }
        }
    };
}