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.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java

private void openMailEditor(final String name) throws IOException {
    String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", "File format",
            JOptionPane.QUESTION_MESSAGE, null, PluginConstants.MAIL_TEMPLATE_FORMATS,
            MailTemplateFormat.TEXT.name());

    if (StringUtils.isNotBlank(formatStr)) {

        MailTemplateFormat format = MailTemplateFormat.valueOf(formatStr);
        String type = null;/*from  w  w w.j  a v a  2 s  .  co m*/
        InputStream is = null;

        try {
            switch (format) {
            case HTML:
                type = "html";
                is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.HTML);
                break;
            case TEXT:
                type = "txt";
                is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.TEXT);
                break;
            default:
                LOG.log(Level.SEVERE, String.format("Format [%s] not supported", format));
                break;
            }
        } catch (SyncopeClientException e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), e);
            if (ClientExceptionType.NotFound.equals(e.getType())) {
                LOG.log(Level.SEVERE,
                        String.format("Report template in [%s] format not found, create an empty one", format));
            } else {
                JOptionPane.showMessageDialog(null,
                        String.format("Unable to get [%s] report template in [%s] format", name, format),
                        "Connection Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), e);
            JOptionPane.showMessageDialog(null,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        String content = is == null ? StringUtils.EMPTY : IOUtils.toString(is, encodingPattern);

        String mailTemplatesDirName = System.getProperty("java.io.tmpdir") + "/Templates/Mail/";
        File mailTemplatesDir = new File(mailTemplatesDirName);
        if (!mailTemplatesDir.exists()) {
            mailTemplatesDir.mkdirs();
        }
        File file = new File(mailTemplatesDirName + name + "." + type);
        FileWriter fw = new FileWriter(file);
        fw.write(content);
        fw.flush();
        FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile());
        fob.setAttribute("description", "TEXT");
        DataObject data = DataObject.find(fob);
        data.getLookup().lookup(OpenCookie.class).open();
        data.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                    //save item remotely
                    LOG.info(String.format("Saving Mail template [%s]", name));
                    saveContent();
                }
            }
        });
    }
}

From source file:visolate.Visolate.java

private JPanel getZCuttingHeightPanel() {
    if (myZCuttingHeightPanel == null) {
        myZCuttingHeightPanel = new JPanel();
        myZCuttingHeightPanel.setLayout(new BorderLayout());
        myZCuttingHeightPanel.add(new JLabel("cutting height"), BorderLayout.WEST);
        myZCuttingHeightPanel.setToolTipText(
                "When cutting, the head should have this z-coordinate, in mm or inch. Likely a negative value, decimals in native language (point or comma)");
        myZCuttingHeightPanel.setEnabled(gCodeWriter.getIsAbsolute());
        final JTextField field = new JTextField(
                NumberFormat.getInstance().format(gCodeWriter.getZCuttingHeight()));
        myZCuttingHeightPanel.add(field, BorderLayout.CENTER);
        myZCuttingHeightPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                field.setEnabled(myZCuttingHeightPanel.isEnabled());
            }/*from w w  w  .  j a  va 2s .  c o  m*/
        });
        field.setEnabled(myZCuttingHeightPanel.isEnabled());
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter
                            .setZCuttingHeight(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getZCuttingHeight()));
            }
        });
    }
    return myZCuttingHeightPanel;
}

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

/**
 * Instantiates a new movie extended search
 * //from  w  ww.  ja  v a2s .co m
 * @param model
 *          the model
 */
public MovieExtendedSearchPanel(MovieSelectionModel model) {
    super();
    setOpaque(false);
    shadowAlpha = 100;
    arcs = new Dimension(10, 10);

    this.movieSelectionModel = model;
    Map<MovieSearchOptions, Object> savedSearchOptions = MovieModuleManager.MOVIE_SETTINGS.getUiFilters();

    // add a dummy mouse listener to prevent clicking through
    addMouseListener(new MouseAdapter() {
    });

    listCheckListener = new ListCheckListener() {
        @Override
        public void removeCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }

        @Override
        public void addCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }
    };

    setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
            FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.UNRELATED_GAP_ROWSPEC, }));

    JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$
    setComponentFont(lblFilterBy);
    add(lblFilterBy, "2, 2, 3, 1");

    cbFilterNewMovies = new JCheckBox("");
    cbFilterNewMovies.setUI(CHECKBOX_UI); // $hide$
    cbFilterNewMovies.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.NEW_MOVIES));
    cbFilterNewMovies.setAction(actionFilter);
    add(cbFilterNewMovies, "2, 4");

    lblNewMovies = new JLabel(BUNDLE.getString("movieextendedsearch.newmovies")); //$NON-NLS-1$
    setComponentFont(lblNewMovies);
    add(lblNewMovies, "4, 4, right, default");

    cbFilterDuplicates = new JCheckBox("");
    cbFilterDuplicates.setUI(CHECKBOX_UI); // $hide$
    cbFilterDuplicates.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DUPLICATES));
    cbFilterDuplicates.setAction(actionFilter);
    add(cbFilterDuplicates, "2, 5");

    JLabel lblShowDuplicates = new JLabel(BUNDLE.getString("movieextendedsearch.duplicates")); //$NON-NLS-1$
    setComponentFont(lblShowDuplicates);
    add(lblShowDuplicates, "4, 5, right, default");

    cbFilterWatched = new JCheckBox("");
    cbFilterWatched.setUI(CHECKBOX_UI); // $hide$
    cbFilterWatched.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.WATCHED));
    cbFilterWatched.setAction(actionFilter);
    add(cbFilterWatched, "2, 6");

    JLabel lblWatchedFlag = new JLabel(BUNDLE.getString("movieextendedsearch.watched")); //$NON-NLS-1$
    setComponentFont(lblWatchedFlag);
    add(lblWatchedFlag, "4, 6, right, default");

    cbWatched = new SmallComboBox(WatchedFlag.values());
    setComponentFont(cbWatched);
    cbWatched.setAction(actionFilter);
    add(cbWatched, "6, 6, fill, default");

    cbFilterGenre = new JCheckBox("");
    cbFilterGenre.setUI(CHECKBOX_UI); // $hide$
    cbFilterGenre.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.GENRE));
    cbFilterGenre.setAction(actionFilter);
    add(cbFilterGenre, "2, 7");

    JLabel lblGenre = new JLabel(BUNDLE.getString("movieextendedsearch.genre")); //$NON-NLS-1$
    setComponentFont(lblGenre);
    add(lblGenre, "4, 7, right, default");

    cbGenre = new SmallComboBox(MediaGenres.values());
    setComponentFont(cbGenre);
    cbGenre.setAction(actionFilter);
    add(cbGenre, "6, 7, fill, default");

    cbFilterCertification = new JCheckBox("");
    cbFilterCertification.setUI(CHECKBOX_UI); // $hide$
    cbFilterCertification.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CERTIFICATION));
    cbFilterCertification.setAction(actionFilter);
    add(cbFilterCertification, "2, 8");

    lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
    setComponentFont(lblCertification);
    add(lblCertification, "4, 8, right, default");

    cbCertification = new SmallComboBox();
    setComponentFont(cbCertification);
    cbCertification.setAction(actionFilter);
    add(cbCertification, "6, 8, fill, default");

    cbFilterYear = new JCheckBox("");
    cbFilterYear.setUI(CHECKBOX_UI); // $hide$
    cbFilterYear.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.YEAR));
    cbFilterYear.setAction(actionFilter);
    add(cbFilterYear, "2, 9");

    lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    setComponentFont(lblYear);
    add(lblYear, "4, 9, right, default");

    int year = Calendar.getInstance().get(Calendar.YEAR);
    spYear = new JSpinner();
    setComponentFont(spYear);
    spYear.setUI(new SmallSpinnerUI());// $hide$
    spYear.setModel(new SpinnerNumberModel(year, 0, 3000, 1));
    spYear.setEditor(new JSpinner.NumberEditor(spYear, "#"));
    spYear.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            actionFilter.actionPerformed(null);
        }
    });
    add(spYear, "6, 9");

    cbFilterCast = new JCheckBox("");
    cbFilterCast.setUI(CHECKBOX_UI); // $hide$
    cbFilterCast.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CAST));
    cbFilterCast.setAction(actionFilter);
    add(cbFilterCast, "2, 10");

    JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$
    setComponentFont(lblCastMember);
    add(lblCastMember, "4, 10, right, default");

    tfCastMember = new JTextField();
    setComponentFont(tfCastMember);
    tfCastMember.setBorder(new SmallTextFieldBorder());
    add(tfCastMember, "6, 10, fill, default");
    tfCastMember.setColumns(10);
    tfCastMember.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void insertUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void removeUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }
    });

    cbFilterTag = new JCheckBox("");
    cbFilterTag.setUI(CHECKBOX_UI); // $hide$
    cbFilterTag.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.TAG));
    cbFilterTag.setAction(actionFilter);
    add(cbFilterTag, "2, 11");

    JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$
    setComponentFont(lblTag);
    add(lblTag, "4, 11, right, default");

    cbTag = new SmallCheckComboBox();
    cbTag.setTextFor(CheckComboBox.NONE, BUNDLE.getString("movieextendedsearch.tags.selected.none")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("movieextendedsearch.tags.selected.multiple")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.ALL, BUNDLE.getString("movieextendedsearch.tags.selected.all")); //$NON-NLS-1$
    cbTag.getModel().addListCheckListener(listCheckListener);
    add(cbTag, "6, 11, fill, default");

    cbFilterMovieset = new JCheckBox("");
    cbFilterMovieset.setUI(CHECKBOX_UI); // $hide$
    cbFilterMovieset.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MOVIESET));
    cbFilterMovieset.setAction(actionFilter);
    add(cbFilterMovieset, "2, 12");

    JLabel lblMoviesInMovieset = new JLabel(BUNDLE.getString("movieextendedsearch.movieset")); //$NON-NLS-1$
    setComponentFont(lblMoviesInMovieset);
    add(lblMoviesInMovieset, "4, 12, right, default");

    cbMovieset = new SmallComboBox(MovieInMovieSet.values());
    setComponentFont(cbMovieset);
    cbMovieset.setAction(actionFilter);
    add(cbMovieset, "6, 12, fill, default");

    cbFilterVideoFormat = new JCheckBox("");
    cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoFormat.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_FORMAT));
    cbFilterVideoFormat.setAction(actionFilter);
    add(cbFilterVideoFormat, "2, 13");

    JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$
    setComponentFont(lblVideoFormat);
    add(lblVideoFormat, "4, 13, right, default");

    cbVideoFormat = new SmallComboBox(getVideoFormats());
    setComponentFont(cbVideoFormat);
    cbVideoFormat.setAction(actionFilter);
    add(cbVideoFormat, "6, 13, fill, default");

    cbFilterVideoCodec = new JCheckBox("");
    cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_CODEC));
    cbFilterVideoCodec.setAction(actionFilter);
    add(cbFilterVideoCodec, "2, 14");

    JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$
    setComponentFont(lblVideoCodec);
    add(lblVideoCodec, "4, 14, right, default");

    cbVideoCodec = new SmallComboBox();
    setComponentFont(cbVideoCodec);
    cbVideoCodec.setAction(actionFilter);
    add(cbVideoCodec, "6, 14, fill, default");

    cbFilterVideo3D = new JCheckBox("");
    cbFilterVideo3D.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideo3D.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_3D));
    cbFilterVideo3D.addActionListener(actionFilter);
    add(cbFilterVideo3D, "2, 15");

    JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
    setComponentFont(lblVideo3D);
    add(lblVideo3D, "4, 15, right, default");

    cbFilterAudioCodec = new JCheckBox("");
    cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterAudioCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.AUDIO_CODEC));
    cbFilterAudioCodec.setAction(actionFilter);
    add(cbFilterAudioCodec, "2, 16");

    JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$
    setComponentFont(lblAudioCodec);
    add(lblAudioCodec, "4, 16, right, default");

    cbAudioCodec = new SmallComboBox();
    setComponentFont(cbAudioCodec);
    cbAudioCodec.setAction(actionFilter);
    add(cbAudioCodec, "6, 16, fill, default");

    cbFilterDatasource = new JCheckBox("");
    cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$
    cbFilterDatasource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DATASOURCE));
    cbFilterDatasource.setAction(actionFilter);
    add(cbFilterDatasource, "2, 17");

    JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$
    setComponentFont(lblDatasource);
    add(lblDatasource, "4, 17, right, default");

    cbDatasource = new SmallCheckComboBox();
    cbDatasource.setTextFor(CheckComboBox.NONE, BUNDLE.getString("checkcombobox.selected.none")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("checkcombobox.selected.multiple")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.ALL, BUNDLE.getString("checkcombobox.selected.all")); //$NON-NLS-1$
    cbDatasource.getModel().addListCheckListener(listCheckListener);
    add(cbDatasource, "6, 17, fill, default");

    cbFilterMediaSource = new JCheckBox("");
    cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$
    cbFilterMediaSource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MEDIA_SOURCE));
    cbFilterMediaSource.addActionListener(actionFilter);
    add(cbFilterMediaSource, "2, 18");

    JLabel lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    setComponentFont(lblMediaSource);
    add(lblMediaSource, "4, 18, right, default");

    cbMediaSource = new SmallComboBox(MediaSource.values());
    setComponentFont(cbMediaSource);
    cbMediaSource.setAction(actionFilter);
    add(cbMediaSource, "6, 18, fill, default");

    cbFilterMissingMetadata = new JCheckBox("");
    cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingMetadata.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_METADATA));
    cbFilterMissingMetadata.setAction(actionFilter);
    add(cbFilterMissingMetadata, "2, 19");

    JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$
    setComponentFont(lblMissingMetadata);
    add(lblMissingMetadata, "4, 19, right, default");

    cbFilterMissingArtwork = new JCheckBox("");
    cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingArtwork.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_ARTWORK));
    cbFilterMissingArtwork.setAction(actionFilter);
    add(cbFilterMissingArtwork, "2, 20");

    JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$
    setComponentFont(lblMissingArtwork);
    add(lblMissingArtwork, "4, 20, right, default");

    cbFilterMissingSubtitles = new JCheckBox("");
    cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingSubtitles.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_SUBTITLES));
    cbFilterMissingSubtitles.setAction(actionFilter);
    add(cbFilterMissingSubtitles, "2, 21");

    JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$
    setComponentFont(lblMissingSubtitles);
    add(lblMissingSubtitles, "4, 21, right, default");

    cbFilterOffline = new JCheckBox("");
    cbFilterOffline.setUI(CHECKBOX_UI); // $hide$
    cbFilterOffline.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.OFFLINE));
    cbFilterOffline.setAction(actionFilter);
    add(cbFilterOffline, "2, 22");

    lblOffline = new JLabel(BUNDLE.getString("movieextendedsearch.offline")); //$NON-NLS-1$
    setComponentFont(lblOffline);
    add(lblOffline, "4, 22, right, default");

    cbOffline = new SmallComboBox(OfflineMovie.values());
    cbOffline.setAction(actionFilter);
    add(cbOffline, "6, 22, fill, default");

    JSeparator separator = new JSeparator();
    add(separator, "2, 24, 5, 1");

    JLabel lblSortBy = new JLabel(BUNDLE.getString("movieextendedsearch.sortby")); //$NON-NLS-1$
    setComponentFont(lblSortBy);
    add(lblSortBy, "2, 26, 3, 1");

    cbSortColumn = new SmallComboBox(SortColumn.values());
    setComponentFont(cbSortColumn);
    cbSortColumn.setAction(actionSort);
    add(cbSortColumn, "2, 28, 3, 1, fill, default");

    cbSortOrder = new SmallComboBox(SortOrder.values());
    setComponentFont(cbSortOrder);
    cbSortOrder.setAction(actionSort);
    add(cbSortOrder, "6, 28, fill, default");

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() instanceof MovieList && "tag".equals(evt.getPropertyName())) {
                buildAndInstallTagsArray();
            }
            if (evt.getSource() instanceof MovieList && "videoCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieList && "audioCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieSettings && "movieDataSource".equals(evt.getPropertyName())) {
                buildAndInstallDatasourceArray();
            }
            if (evt.getSource() instanceof MovieList && "certification".equals(evt.getPropertyName())) {
                buildAndInstallCertificationArray();
            }
        }
    };
    movieList.addPropertyChangeListener(propertyChangeListener);
    MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(propertyChangeListener);
    buildAndInstallTagsArray();
    buildAndInstallCodecArray();
    buildAndInstallDatasourceArray();
    buildAndInstallCertificationArray();
}

From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java

/**
 * /*from  w  w  w. j a va  2 s  .co  m*/
 */
public void createDB() {
    getValues(properties);

    final String databaseName = dbNameTxt.getText();
    final String dbUserName = usernameTxt.getText();
    final String dbPwd = passwordTxt.getText();
    final String hostName = hostNameTxt.getText();

    if (isMobile()) {
        DBConnection.clearMobileMachineDir();
        File tmpDir = DBConnection.getMobileMachineDir(databaseName);
        setEmbeddedDBPath(tmpDir.getAbsolutePath());
    }

    final DatabaseDriverInfo driverInfo = (DatabaseDriverInfo) drivers.getSelectedItem();
    String connStrInitial = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName,
            databaseName, dbUserName, dbPwd, driverInfo.getName());
    //System.err.println(connStrInitial);

    DBConnection.checkForEmbeddedDir("createDB - " + connStrInitial);

    DBConnection.getInstance().setDriverName(driverInfo.getName());
    DBConnection.getInstance().setServerName(hostName);

    VerifyStatus status = verifyDatabase(properties);
    if ((isOK == null || !isOK) && status == VerifyStatus.OK) {
        progressBar.setIndeterminate(true);
        progressBar.setVisible(true);

        label.setText(getResourceString("CONN_DB"));

        setUIEnabled(false);

        DatabasePanel.this.label.setForeground(Color.BLACK);

        SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
            /* (non-Javadoc)
             * @see javax.swing.SwingWorker#doInBackground()
             */
            @Override
            protected Object doInBackground() throws Exception {
                isOK = false;

                DBMSUserMgr mgr = DBMSUserMgr.getInstance();

                boolean dbmsOK = false;
                if (driverInfo.isEmbedded()) {
                    if (checkForProcesses) {
                        SpecifyDBSecurityWizardFrame.checkForMySQLProcesses();
                        checkForProcesses = false;
                    }

                    if (isMobile()) {
                        File mobileTmpDir = DBConnection.getMobileMachineDir();
                        if (!mobileTmpDir.exists()) {
                            if (!mobileTmpDir.mkdirs()) {
                                System.err.println(
                                        "Dir[" + mobileTmpDir.getAbsolutePath() + "] didn't get created!");
                                // throw exception
                            }
                            DBConnection.setCopiedToMachineDisk(true);
                        }
                    }

                    String newConnStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open,
                            hostName, databaseName, dbUserName, dbPwd, driverInfo.getName());
                    if (driverInfo.isEmbedded()) {
                        //System.err.println(newConnStr);
                        try {
                            Class.forName(driverInfo.getDriverClassName());

                            // This call will create the database if it doesn't exist
                            DBConnection testDB = DBConnection.createInstance(driverInfo.getDriverClassName(),
                                    driverInfo.getDialectClassName(), databaseName, newConnStr, dbUserName,
                                    dbPwd);
                            testDB.getConnection(); // Opens the connection

                            if (testDB != null) {
                                testDB.close();
                            }
                            dbmsOK = true;

                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                        DBConnection.getInstance().setDatabaseName(null);
                    }
                } else if (mgr.connectToDBMS(dbUserName, dbPwd, hostName)) {
                    mgr.close();
                    dbmsOK = true;
                }

                if (dbmsOK) {
                    firePropertyChange(PROPNAME, 0, 1);

                    try {
                        SpecifySchemaGenerator.generateSchema(driverInfo, hostName, databaseName, dbUserName,
                                dbPwd); // false means create new database, true means update

                        String connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Create,
                                hostName, databaseName);
                        if (connStr == null) {
                            connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open,
                                    hostName, databaseName);
                        }

                        firePropertyChange(PROPNAME, 0, 2);

                        // tryLogin sets up DBConnection
                        if (UIHelper.tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(),
                                dbNameTxt.getText(), connStr, dbUserName, dbPwd)) {

                            if (!checkEngineCharSet(properties)) {
                                return false;
                            }
                            isOK = true;

                            firePropertyChange(PROPNAME, 0, 3);

                            Thumbnailer thumb = Thumbnailer.getInstance();
                            File thumbFile = XMLHelper.getConfigDir("thumbnail_generators.xml");
                            thumb.registerThumbnailers(thumbFile);
                            thumb.setQuality(.5f);
                            thumb.setMaxSize(128, 128);

                            File attLoc = getAppDataSubDir("AttachmentStorage", true);
                            AttachmentManagerIface attachMgr = new FileStoreAttachmentManager(attLoc);
                            AttachmentUtils.setAttachmentManager(attachMgr);
                            AttachmentUtils.setThumbnailer(thumb);

                        } else {
                            errorKey = "NO_LOGIN_ROOT";
                        }
                    } catch (Exception ex) {
                        errorKey = "DB_UNRECOVERABLE";
                    }
                } else {
                    errorKey = "NO_CONN_ROOT";
                    mgr.close();
                }
                return null;
            }

            /* (non-Javadoc)
             * @see javax.swing.SwingWorker#done()
             */
            @Override
            protected void done() {
                super.done();

                setUIEnabled(true);

                progressBar.setIndeterminate(false);
                progressBar.setVisible(false);

                updateBtnUI();

                if (isOK) {
                    label.setText(getResourceString("DB_CREATED"));
                    setUIEnabled(false);

                } else {
                    label.setText(getResourceString(errorKey != null ? errorKey : "ERR_CRE_DB"));
                    showLocalizedError(errorKey != null ? errorKey : "ERR_CRE_DB");
                }
            }
        };

        worker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (PROPNAME.equals(evt.getPropertyName())) {
                    String key = null;
                    switch ((Integer) evt.getNewValue()) {
                    case 1:
                        key = "BLD_SCHEMA";
                        break;
                    case 2:
                        key = "DB_FRST_LOGIN";
                        break;
                    case 3:
                        key = "BLD_CACHE";
                        break;
                    default:
                        break;
                    }
                    if (key != null) {
                        DatabasePanel.this.label.setText(getResourceString(key));
                    }
                }
            }
        });
        worker.execute();

    } else if (status == VerifyStatus.ERROR) {
        errorKey = "NO_LOGIN_ROOT";
        DatabasePanel.this.label.setText(getResourceString(errorKey));
        DatabasePanel.this.label.setForeground(Color.RED);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                getTopWindow().pack();
            }
        });
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorUI.java

/**
 * Removes the other annotations./*from   w  ww .  ja  va  2s .  c  o m*/
 * 
 * @param src The mouse clicked location.
 * @param location The location of the mouse pressed.
 */
void removeOtherAnnotations(JComponent src, Point location) {
    if (!generalPane.hasOtherAnnotationsToUnlink())
        return;
    if (model.isGroupLeader() || model.isAdministrator()) {
        if (otherAnnotationMenu == null) {
            otherAnnotationMenu = new PermissionMenu(PermissionMenu.REMOVE, "Other annotations");
            otherAnnotationMenu.addPropertyChangeListener(new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    String n = evt.getPropertyName();
                    if (PermissionMenu.SELECTED_LEVEL_PROPERTY.equals(n)) {
                        removeLinks((Integer) evt.getNewValue(), model.getAllOtherAnnotations());
                    }
                }
            });
        }
        otherAnnotationMenu.show(src, location.x, location.y);
        return;
    }
    SwingUtilities.convertPointToScreen(location, src);
    MessageBox box = new MessageBox(model.getRefFrame(), "Remove All Your Other Annotations",
            "Are you sure you want to remove all your other annotations?");
    Dimension d = box.getPreferredSize();
    Point p = new Point(location.x - d.width / 2, location.y);
    if (box.showMsgBox(p) == MessageBox.YES_OPTION) {
        List<AnnotationData> list = generalPane.removeOtherAnnotations();
        if (list.size() > 0)
            saveData(true);
    }
}

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Initialises the menu's and toolbars, but does not actually create any of
 * the main panel components.//  ww  w . j  ava  2s. com
 *
 */
private void initGUI() {

    setupHelpSystem();
    statusBar = new ChainsawStatusBar(this);
    setupReceiverPanel();

    setToolBarAndMenus(new ChainsawToolBarAndMenus(this));
    toolbar = getToolBarAndMenus().getToolbar();
    setJMenuBar(getToolBarAndMenus().getMenubar());

    setTabbedPane(new ChainsawTabbedPane());
    getSettingsManager().addSettingsListener(getTabbedPane());
    getSettingsManager().configure(getTabbedPane());

    /**
     * This adds Drag & Drop capability to Chainsaw
     */
    FileDnDTarget dnDTarget = new FileDnDTarget(tabbedPane);
    dnDTarget.addPropertyChangeListener("fileList", new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            final List fileList = (List) evt.getNewValue();

            Thread thread = new Thread(new Runnable() {

                public void run() {
                    logger.debug("Loading files: " + fileList);
                    for (Iterator iter = fileList.iterator(); iter.hasNext();) {
                        File file = (File) iter.next();
                        final Decoder decoder = new XMLDecoder();
                        try {
                            getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "...");
                            FileLoadAction.importURL(handler, decoder, file.getName(), file.toURI().toURL());
                        } catch (Exception e) {
                            String errorMsg = "Failed to import a file";
                            logger.error(errorMsg, e);
                            getStatusBar().setMessage(errorMsg);
                        }
                    }

                }
            });

            thread.setPriority(Thread.MIN_PRIORITY);
            thread.start();

        }
    });

    applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel);

    applicationPreferenceModelPanel.setOkCancelActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            preferencesFrame.setVisible(false);
        }
    });
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action closeAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            preferencesFrame.setVisible(false);
        }
    };
    preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    preferencesFrame.getRootPane().getActionMap().put("ESCAPE", closeAction);

    OSXIntegration.init(this);

}

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

private ValueModel createNameAvailableModel() {
    final FilteredObservableList<TreatmentCategorization> categorizations = new FilteredObservableList<TreatmentCategorization>(
            d_domain.getTreatmentCategorizations(), createDrugFilter((Drug) getDrug().getValue()));
    getDrug().addValueChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            categorizations.setFilter(createDrugFilter((Drug) getDrug().getValue()));
        }/*from  w w  w.  j a  v a 2s . c o m*/
    });
    return new PropertyUniqueModel<TreatmentCategorization>(categorizations, getBean(),
            TreatmentCategorization.PROPERTY_NAME);
}

From source file:com.leclercb.taskunifier.gui.main.Main.java

private static void loadShutdownHooks() {
    QUITTING = false;//from   w  w  w .j a  v  a 2s  .  c  om

    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            boolean quit = ActionQuit.quit(true);

            if (!quit) {
                Synchronizing.getInstance().addPropertyChangeListener(Synchronizing.PROP_SYNCHRONIZING,
                        new PropertyChangeListener() {

                            @Override
                            public void propertyChange(PropertyChangeEvent evt) {
                                ActionQuit.quit(true);
                            }
                        });
            }
        }

    });
}

From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java

/**
 * Creates new form WebDavPicturePanel.// ww  w  . j a va2  s  .  c om
 *
 * @param  editable           DOCUMENT ME!
 * @param  urlProp            DOCUMENT ME!
 * @param  beanCollProp       DOCUMENT ME!
 * @param  bildClassName      DOCUMENT ME!
 * @param  numberProp         DOCUMENT ME!
 * @param  geoFieldProp       DOCUMENT ME!
 * @param  connectionContext  DOCUMENT ME!
 */
public WebDavPicturePanel(final boolean editable, final String urlProp, final String beanCollProp,
        final String bildClassName, final String numberProp, final String geoFieldProp,
        final ConnectionContext connectionContext) {
    this.beanCollProp = beanCollProp;
    this.bildClassName = bildClassName;
    this.numberProp = numberProp;
    this.geoFieldProp = geoFieldProp;
    this.connectionContext = connectionContext;

    String webdavDirectory = null;
    WebDavHelper webdavHelper = null;
    try {
        final ResourceBundle bundle = ResourceBundle.getBundle("WebDav");
        String pass = bundle.getString("password");

        if ((pass != null) && pass.startsWith(PasswordEncrypter.CRYPT_PREFIX)) {
            pass = PasswordEncrypter.decryptString(pass);
        }
        final String user = bundle.getString("user");
        webdavDirectory = bundle.getString(urlProp);

        webdavHelper = new WebDavHelper(Proxy.fromPreferences(), user, pass, false);
    } catch (final Exception ex) {
        final String message = "Fehler beim Initialisieren der Bilderablage.";
        LOG.error(message, ex);
        ObjectRendererUtils.showExceptionWindowToUser(message, ex, null);
    }
    this.webdavDirectory = webdavDirectory;
    this.webdavHelper = webdavHelper;

    initComponents();

    fileChooser.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(final File f) {
            return f.isDirectory() || IMAGE_FILE_PATTERN.matcher(f.getName()).matches();
        }

        @Override
        public String getDescription() {
            return "Bilddateien";
        }
    });
    fileChooser.setMultiSelectionEnabled(true);

    listRepaintListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            lstFotos.repaint();
        }
    };

    lstFotos.getModel().addListDataListener(new ListDataListener() {

        @Override
        public void intervalAdded(final ListDataEvent e) {
            defineButtonStatus();
        }

        @Override
        public void intervalRemoved(final ListDataEvent e) {
            defineButtonStatus();
        }

        @Override
        public void contentsChanged(final ListDataEvent e) {
            defineButtonStatus();
        }
    });

    timer = new Timer(300, new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (resizeListenerEnabled) {
                //                    if (isShowing()) {
                if (currentResizeWorker != null) {
                    currentResizeWorker.cancel(true);
                }
                currentResizeWorker = new ImageResizeWorker();
                CismetThreadPool.execute(currentResizeWorker);
                //                    } else {
                //                        timer.restart();
                //                    }
            }
        }
    });
    timer.setRepeats(false);

    btnAddImg.setVisible(editable);
    btnRemoveImg.setVisible(editable);
}

From source file:com.microsoft.live.LiveConnectClient.java

/**
 * Constructs a new {@code LiveConnectClient} instance and initializes it.
 *
 * @param session that will be used to authenticate calls over to the Live Connect REST API.
 * @throws NullPointerException if session is null or if session.getAccessToken() is null.
 * @throws IllegalArgumentException if session.getAccessToken() is empty.
 *//*from w  w w  .  ja va  2s  .  co m*/
public LiveConnectClient(LiveConnectSession session) {
    LiveConnectUtils.assertNotNull(session, ParamNames.SESSION);

    String accessToken = session.getAccessToken();
    LiveConnectUtils.assertNotNullOrEmpty(accessToken, ParamNames.ACCESS_TOKEN);

    this.session = session;
    this.sessionState = SessionState.LOGGED_IN;

    // set a listener for the accessToken. If it is set to null, then the session was logged
    // out.
    this.session.addPropertyChangeListener("accessToken", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            String newValue = (String) event.getNewValue();

            if (TextUtils.isEmpty(newValue)) {
                LiveConnectClient.this.sessionState = SessionState.LOGGED_OUT;
            } else {
                LiveConnectClient.this.sessionState = SessionState.LOGGED_IN;
            }
        }
    });

    this.httpClient = getHttpClient();
}