Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

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

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:de.xirp.plugin.ViewerBase.java

/**
 * If a property has changed the controls which are referenced by
 * this property are determined and the value of the property is
 * set to them. Controls which are already disposed are ignored.
 * //  w ww.  j a v a 2s .c o  m
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
@Override
public void propertyChange(PropertyChangeEvent event) {
    String propName = event.getPropertyName();
    String setterName = SET_PREFIX + StringUtils.capitalize(propName);

    List<Control> controls = setter.get(setterName);
    List<Control> delete = new ArrayList<Control>(controls.size());
    for (Control control : controls) {
        if (SWTUtil.swtAssert(control)) {
            Object value = event.getNewValue();
            // if the method returned something
            // update the ui with it
            if (value != null) {
                setValue(control, value);
            }
        } else {
            // mark disposed controls for deletion
            delete.add(control);
        }
    }
    // Delete disposed controls
    for (Control control : delete) {
        setter.remove(setterName, control);
    }
}

From source file:org.tinymediamanager.ui.movies.MovieTrailerPanel.java

/**
 * Instantiates a new movie details panel.
 * //from   w  ww  . j  a v a  2s  . c  o  m
 * @param model
 *          the model
 */
public MovieTrailerPanel(MovieSelectionModel model) {
    this.movieSelectionModel = model;
    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    trailerEventList = new SortedList<>(GlazedLists.threadSafeList(new ObservableElementList<>(
            new BasicEventList<MovieTrailer>(), GlazedLists.beanConnector(MovieTrailer.class))));
    trailerTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(trailerEventList),
            new TrailerTableFormat());

    table = new ZebraJTable(trailerTableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setSelectionModel(new NullSelectionModel());
    TableComparatorChooser.install(table, trailerEventList, TableComparatorChooser.SINGLE_COLUMN);

    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    add(scrollPane, "2, 2, fill, fill");
    scrollPane.setViewportView(table);

    LinkListener linkListener = new LinkListener();
    table.addMouseListener(linkListener);
    table.addMouseMotionListener(linkListener);

    // install the propertychangelistener
    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of a trailer
            if ((source.getClass() == MovieSelectionModel.class && "selectedMovie".equals(property))
                    || (source.getClass() == Movie.class && "trailer".equals(property))) {
                trailerEventList.clear();
                trailerEventList.addAll(movieSelectionModel.getSelectedMovie().getTrailer());
                try {
                    TableColumnResizer.adjustColumnPreferredWidths(table, 7);
                } catch (Exception e) {
                }
            }
        }
    };

    movieSelectionModel.addPropertyChangeListener(propertyChangeListener);

}

From source file:org.openmicroscopy.shoola.env.ui.UserNotifierImpl.java

/**
 * Listens to property fired by the <code>ChangesDialog</code>
 * //from w w w. ja  v  a 2 s .c o m
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (ChangesDialog.DONE_PROPERTY.equals(name)) {
        if (dialog != null) {
            dialog.setVisible(false);
            dialog.dispose();
            dialog = null;
        }
    }
}

From source file:de.fhg.fokus.hss.model.Impi.java

/**
 * Method to change property/*from  w w  w .jav  a 2  s . c  om*/
 * @param evt Property change event   
 */
public void propertyChange(PropertyChangeEvent evt) {
    super.propertyChange(evt);

    if ((evt.getPropertyName().equals("scscfName")) && (evt.getOldValue() != null)) {
        this.changeScscfName = true;
    }
}

From source file:org.tinymediamanager.ui.moviesets.MovieSetInformationPanel.java

/**
 * Instantiates a new movie set information panel.
 * //from   ww  w  .  java 2 s. c  om
 * @param model
 *          the model
 */
public MovieSetInformationPanel(MovieSetSelectionModel model) {
    this.selectionModel = model;
    movieEventList = new ObservableElementList<>(
            GlazedListsSwing.swingThreadProxyList(new BasicEventList<Movie>()),
            GlazedLists.beanConnector(Movie.class));

    setLayout(new BorderLayout(0, 0));

    panel = new JPanel();
    add(panel, BorderLayout.CENTER);
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("180px:grow"),
                    ColumnSpec.decode("1px"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("pref:grow"), RowSpec.decode("bottom:default"), }));

    lblMovieSetName = new JLabel("");
    TmmFontHelper.changeFont(lblMovieSetName, 1.5, Font.BOLD);
    panel.add(lblMovieSetName, "2,1, fill, fill");

    layeredPane = new JLayeredPane();
    panel.add(layeredPane, "1, 3, 2, 1, fill, fill");
    layeredPane.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("10px"), ColumnSpec.decode("120px"),
                    ColumnSpec.decode("200px:grow"), },
            new RowSpec[] { RowSpec.decode("10px"), RowSpec.decode("180px"),
                    RowSpec.decode("default:grow"), }));

    lblMovieSetPoster = new ImageLabel();
    lblMovieSetPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
    lblMovieSetPoster.enableLightbox();
    layeredPane.setLayer(lblMovieSetPoster, 1);
    layeredPane.add(lblMovieSetPoster, "2, 2, fill, fill");

    lblMovieSetFanart = new ImageLabel(false, true);
    lblMovieSetFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
    lblMovieSetFanart.enableLightbox();
    layeredPane.add(lblMovieSetFanart, "1, 1, 3, 3, fill, fill");

    panelSouth = new JSplitPane();
    panelSouth.setContinuousLayout(true);
    panelSouth.setResizeWeight(0.5);
    add(panelSouth, BorderLayout.SOUTH);

    panelOverview = new JPanel();
    panelSouth.setLeftComponent(panelOverview);
    panelOverview.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("100px:grow"), },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("24px:grow"), }));

    lblOverview = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
    panelOverview.add(lblOverview, "1, 2");

    scrollPaneOverview = new JScrollPane();
    panelOverview.add(scrollPaneOverview, "1, 4, fill, fill");

    tpOverview = new JTextPane();
    tpOverview.setEditable(false);
    scrollPaneOverview.setViewportView(tpOverview);

    JPanel panelMovies = new JPanel();
    panelSouth.setRightComponent(panelMovies);
    panelMovies.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200px:grow(3)"), },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("203px:grow"), }));

    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(movieEventList),
            new MovieInMovieSetTableFormat());
    // tableAssignedMovies = new JTable(movieTableModel);
    tableAssignedMovies = new ZebraJTable(movieTableModel);
    // JScrollPane scrollPaneMovies = new JScrollPane();
    JScrollPane scrollPaneMovies = ZebraJTable.createStripedJScrollPane(tableAssignedMovies);
    panelMovies.add(scrollPaneMovies, "1, 2, fill, fill");

    tableAssignedMovies.setPreferredScrollableViewportSize(new Dimension(450, 200));
    scrollPaneMovies.setViewportView(tableAssignedMovies);

    initDataBindings();

    // adjust table columns
    // year column
    int width = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(" 2000");
    int titleWidth = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont())
            .stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    if (titleWidth > width) {
        width = titleWidth;
    }
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5));

    // watched column
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(70);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMinWidth(70);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85);

    // install the propertychangelistener
    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of media files
            if ((source.getClass() == MovieSetSelectionModel.class && "selectedMovieSet".equals(property))
                    || (source.getClass() == MovieSet.class && "movies".equals(property))) {
                movieEventList.clear();
                movieEventList.addAll(selectionModel.getSelectedMovieSet().getMovies());
                if (StringUtils.isNotBlank(
                        selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER))) {
                    lblMovieSetPoster.setImagePath(
                            selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER));
                } else {
                    lblMovieSetPoster.setImagePath("");
                    lblMovieSetPoster.setImageUrl(
                            selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.POSTER));
                }
                if (StringUtils.isNotBlank(
                        selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART))) {
                    lblMovieSetFanart.setImagePath(
                            selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART));
                } else {
                    lblMovieSetFanart.setImagePath("");
                    lblMovieSetFanart.setImageUrl(
                            selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.FANART));
                }
            }

            // react on changes of the images
            if ((source.getClass() == MovieSet.class && FANART.equals(property))) {
                MovieSet movieSet = (MovieSet) source;
                lblMovieSetFanart.clearImage();
                lblMovieSetFanart.setImagePath(movieSet.getArtworkFilename(MediaFileType.FANART));
            }
            if ((source.getClass() == MovieSet.class && POSTER.equals(property))) {
                MovieSet movieSet = (MovieSet) source;
                lblMovieSetPoster.clearImage();
                lblMovieSetPoster.setImagePath(movieSet.getArtworkFilename(MediaFileType.POSTER));
            }
        }
    };

    selectionModel.addPropertyChangeListener(propertyChangeListener);
}

From source file:ec.ui.view.MarginView.java

private void enableProperties() {
    addPropertyChangeListener(new PropertyChangeListener() {
        @Override//from w ww. j  a v  a 2s .com
        public void propertyChange(PropertyChangeEvent evt) {
            switch (evt.getPropertyName()) {
            case DATA_PROPERTY:
                onDataChange();
                break;
            case PRECISION_MARKERS_VISIBLE_PROPERTY:
                onPrecisionMarkersVisible();
                break;
            case "componentPopupMenu":
                onComponentPopupMenuChange();
                break;
            }
        }
    });
}

From source file:edu.ku.brc.specify.plugins.LocalityGoogleEarthPlugin.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("latlon")) {
        Object obj = evt.getNewValue();
        if (obj instanceof Pair<?, ?>) {
            latLon = latLonPlugin.getLatLon();
            isLatLonOK = latLon != null && latLon.first != null && latLon.second != null
                    && latLonPlugin.getState() == ErrorType.Valid;
            setEnabled(isLatLonOK);// ww w  .ja  v  a 2 s.  c om
        }
    }
}

From source file:org.eclipse.virgo.ide.runtime.internal.ui.editor.StaticResourcesEditorSection.java

protected void addConfigurationChangeListener() {
    this.listener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (org.eclipse.virgo.ide.runtime.core.IServer.PROPERTY_STATIC_FILENAMES
                    .equals(event.getPropertyName())) {
                StaticResourcesEditorSection.this.filenamesTableViewer
                        .setInput(StaticResourcesEditorSection.this.server);
            }/*from   www.  j a  va  2s  .  co m*/
        }
    };
    this.serverWorkingCopy.addConfigurationChangeListener(this.listener);
}

From source file:com.qspin.qtaste.ui.MainPanel.java

public void genUI() {
    try {//from  ww w  . j ava 2  s. c om
        getContentPane().setLayout(new BorderLayout());
        // prepare the top panel that contains the following panes:
        //   - logo
        //   - ConfigInfopanel
        //   - Current Date/time
        JPanel topanel = new JPanel(new BorderLayout());
        JPanel center = new JPanel(new GridBagLayout());
        ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin");
        JLabel iconlabel = new JLabel(topLeftLogo);

        mHeaderPanel = new ConfigInfoPanel(this);
        mTestCasePanel = new TestCasePane(this);
        mTestCampaignPanel = new TestCampaignMainPanel(this);

        mHeaderPanel.init();

        GridBagLineAdder centeradder = new GridBagLineAdder(center);
        JLabel sep = new JLabel("  ");
        sep.setFont(ResourceManager.getInstance().getSmallFont());
        sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor()));
        centeradder.setWeight(1.0f, 0.0f);
        centeradder.add(mHeaderPanel);

        // prepare the right panels containg the main information:
        // the right pane is selected through the tabbed pane:
        //    - Test cases: management of test cases and test suites
        //    - Test campaign: management of test campaigns
        //    - Interactive: ability to invoke QTaste verbs one by one

        mRightPanels = new JPanel(new CardLayout());

        mRightPanels.add(mTestCasePanel, "Test Cases");
        mRightPanels.add(mTestCampaignPanel, "Test Campaign");

        final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel();
        mRightPanels.add(testInterractivePanel, "Interactive");

        mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM);
        mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT));

        TestCaseTree tct = new TestCaseTree(mTestCasePanel);
        JScrollPane sp2 = new JScrollPane(tct);
        mTreeTabsPanel.addTab("Test Cases", sp2);

        // add tree view for test campaign definition
        com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree(
                mTestCampaignPanel.getTreeTable());
        JScrollPane sp3 = new JScrollPane(mtct);
        mTreeTabsPanel.addTab("Test Campaign", sp3);

        genMenu(tct);

        // add another tab contain used for Interactive mode
        TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel);
        JScrollPane spInter = new JScrollPane(jInteractive);
        mTreeTabsPanel.addTab("Interactive", spInter);

        // init will do the link between the tree view and the pane
        testInterractivePanel.init();

        // Define the listener to display the pane depending on the selected tab
        mTreeTabsPanel.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex());
                CardLayout rcl = (CardLayout) mRightPanels.getLayout();
                rcl.show(mRightPanels, componentName);
            }
        });
        mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (e.getID() == TestCampaignMainPanel.RUN_ID) {
                    if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) {
                        // open the tab test cases
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                mTreeTabsPanel.setSelectedIndex(0);
                                mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX);
                            }
                        });

                        // update the buttons
                        mTestCasePanel.setExecutingTestCampaign(true,
                                ((TestCampaignMainPanel) e.getSource()).getExecutionThread());
                        mTestCasePanel.updateButtons(true);
                    } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) {
                        mTestCasePanel.setExecutingTestCampaign(false, null);
                        mTestCasePanel.updateButtons();
                    }
                }
            }
        });

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels);
        splitPane.setDividerSize(4);
        GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
        int mainHorizontalSplitDividerLocation = guiConfiguration
                .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285);
        splitPane.setDividerLocation(mainHorizontalSplitDividerLocation);

        splitPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("dividerLocation")) {
                    GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
                    if (evt.getSource() instanceof JSplitPane) {
                        JSplitPane splitPane = (JSplitPane) evt.getSource();
                        guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY,
                                splitPane.getDividerLocation());
                        try {
                            guiConfiguration.save();
                        } catch (ConfigurationException ex) {
                            logger.error("Error while saving GUI configuration: " + ex.getMessage());
                        }
                    }
                }
            }
        });

        topanel.add(iconlabel, BorderLayout.WEST);
        topanel.add(center);

        getContentPane().add(topanel, BorderLayout.NORTH);
        getContentPane().add(splitPane);
        this.pack();

        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        if (mTestSuiteDir != null) {
            DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir);
            if (testSuite != null) {
                testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour);
                setTestSuite(testSuite.getName());
                mTestCasePanel.runTestSuite(testSuite, false);
            }
        }
        setVisible(true);
        //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT));

    } catch (Exception e) {
        logger.fatal(e);
        e.printStackTrace();
        TestEngine.shutdown();
        System.exit(1);
    }

}

From source file:org.formic.wizard.step.gui.FeatureListStep.java

/**
 * {@inheritDoc}//ww w  . j ava  2s. c o  m
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init() {
    featureInfo = new JEditorPane("text/html", StringUtils.EMPTY);
    featureInfo.setEditable(false);
    featureInfo.addHyperlinkListener(new HyperlinkListener());

    Feature[] features = provider.getFeatures();
    JTable table = new JTable(features.length, 1) {
        private static final long serialVersionUID = 1L;

        public Class getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    table.setBackground(new javax.swing.JList().getBackground());

    GuiForm form = createForm();

    for (int ii = 0; ii < features.length; ii++) {
        final Feature feature = (Feature) features[ii];
        final JCheckBox box = new JCheckBox();

        String name = getName() + '.' + feature.getKey();
        form.bind(name, box);

        box.putClientProperty("feature", feature);
        featureMap.put(feature.getKey(), box);

        if (feature.getInfo() == null) {
            feature.setInfo(Installer.getString(getName() + "." + feature.getKey() + ".html"));
        }
        feature.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                if (Feature.ENABLED_PROPERTY.equals(event.getPropertyName())) {
                    if (box.isSelected() != feature.isEnabled()) {
                        box.setSelected(feature.isEnabled());
                    }
                }
            }
        });

        box.setText(Installer.getString(name));
        box.setBackground(table.getBackground());
        if (!feature.isAvailable()) {
            box.setSelected(false);
            box.setEnabled(false);
        }
        table.setValueAt(box, ii, 0);
    }

    FeatureListMouseListener mouseListener = new FeatureListMouseListener();
    for (int ii = 0; ii < features.length; ii++) {
        Feature feature = (Feature) features[ii];
        if (feature.isEnabled() && feature.isAvailable()) {
            JCheckBox box = (JCheckBox) featureMap.get(feature.getKey());
            box.setSelected(true);
            mouseListener.processDependencies(feature);
            mouseListener.processExclusives(feature);
        }
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setDefaultRenderer(JCheckBox.class, new ComponentTableCellRenderer());

    table.addKeyListener(new FeatureListKeyListener());
    table.addMouseListener(mouseListener);
    table.getSelectionModel().addListSelectionListener(new FeatureListSelectionListener(table));

    table.setRowSelectionInterval(0, 0);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel container = new JPanel(new BorderLayout());
    container.add(table, BorderLayout.CENTER);
    panel.add(new JScrollPane(container), BorderLayout.CENTER);
    JScrollPane infoScroll = new JScrollPane(featureInfo);
    infoScroll.setMinimumSize(new Dimension(0, 50));
    infoScroll.setMaximumSize(new Dimension(0, 50));
    infoScroll.setPreferredSize(new Dimension(0, 50));
    panel.add(infoScroll, BorderLayout.SOUTH);

    return panel;
}