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:ome.formats.importer.gui.HistoryTable.java

public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if (prop.equals("QUICK_HISTORY"))
        getQuickHistory((Integer) e.getNewValue());
    if (prop.equals("date")) {
        getItemQuery(-1, getExperimenterID(), searchField.getText(), fromDate.getDate(), toDate.getDate());
    }/*from w  w w  .  j a  va 2s.c o m*/

}

From source file:com.codejumble.opentube.Main.java

/**
 * Checks if progress has changed and updates the download progress bar
 * value.//from ww  w . j  a v  a 2  s . c  o m
 *
 * @param pce property
 */
@Override
public void propertyChange(PropertyChangeEvent pce) {
    if ("progress".equals(pce.getPropertyName())) {
        int progress = (Integer) pce.getNewValue();
        downloadProgressBar.setValue(progress);
    }
}

From source file:edu.ku.brc.specify.config.FixAttachments.java

/**
 * @param resultsHashMap/*ww  w  .  j a v  a  2s  .  c o  m*/
 * @param tableHash
 * @param totalFiles
 */
private void doAttachmentRefCleanup(final HashMap<Integer, Vector<Object[]>> resultsHashMap,
        final HashMap<Integer, AttchTableModel> tableHash, final int totalFiles) {
    final int numAttachs = getNumberofBadAttachments();

    final String CNT = "CNT";
    final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() {
        int filesCnt = 0;
        int errs = 0;

        @Override
        protected Integer doInBackground() throws Exception {
            try {
                for (int tblId : resultsHashMap.keySet()) {
                    DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(tblId);
                    AttchTableModel model = tableHash.get(tblId);
                    for (int r = 0; r < model.getRowCount(); r++) {
                        int attachId = model.getAttachmentId(r);
                        int attachJoinId = model.getAttachmentJoinId(r);

                        String sql = String.format("DELETE FROM %s WHERE %s = %d", ti.getName(),
                                ti.getIdColumnName(), attachJoinId);
                        int rv = BasicSQLUtils.update(sql);
                        if (rv == 1) {
                            rv = BasicSQLUtils
                                    .update("DELETE FROM attachment WHERE AttachmentID = " + attachId);
                            if (rv == 1) {
                                filesCnt++;
                            } else {
                                errs++;
                            }
                        } else {
                            errs++;
                        }

                        firePropertyChange(CNT, 0, (int) ((double) filesCnt / (double) totalFiles * 100.0));
                    }
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return null;
        }

        @Override
        protected void done() {
            UIRegistry.clearSimpleGlassPaneMsg();
            UIRegistry.displayInfoMsgDlg(String.format("Attachments removed: %d / %d", filesCnt, numAttachs));

            if (errs > 0) {
                UIRegistry.displayErrorDlg(
                        String.format("There were %d errors when deleting the attachments.", errs));
            } else {
                if (getNumberofBadAttachments() == 0) {
                    AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", false);
                }
            }
            super.done();
        }
    };

    final SimpleGlassPane glassPane = UIRegistry
            .writeSimpleGlassPaneMsg(String.format("Removing %d attachments.", numAttachs), 24);
    glassPane.setProgress(0);

    worker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (CNT.equals(evt.getPropertyName())) {
                glassPane.setProgress((Integer) evt.getNewValue());
            }
        }
    });

    worker.execute();
}

From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java

/**
 * Catch all property events generated by TimelordDayView.
 *
 * @param evt the event/* w w w.  ja  va2 s.c o  m*/
 */
public void propertyChange(PropertyChangeEvent evt) {
    if (log.isDebugEnabled()) {
        log.debug("Got propertyChange [" + evt.getPropertyName() + "]");
    }

    // This will set the focus on the panel, and more importantly,
    // remove the focus from any particular button.
    requestFocus();

    if (log.isTraceEnabled()) {
        log.trace("Got PropertyChangeEvent.getPropertyName [" + evt.getPropertyName() + "]");
    }

    if ("viewTaskList".equals(evt.getPropertyName())) {
        buildTaskList();
    } else if ("totalTimeToday".equals(evt.getPropertyName())) {
        summaryPanel.updateTotalTimeLabel();
        summaryPanel.updateTimeLeftLabel();

        /*
        if (isToday()) {
        double untrackedTimeLeftToday =
            getTimelordDayView().getUntrackedTime();
                
        if (untrackedTimeLeftToday
            <= DateUtil.getSmallestTimeIncremented()) {
                
            Preferences preferences =
                Preferences.userNodeForPackage(Timelord.class);
                
            if (Timelord.ANNOYANCE_JORDAN.equals(
                            preferences.get(
                                Timelord.ANNOYANCE_MODE,
                                null))) {
                // hideFrame();
            }
        }
        }
        */
    } else if ("untrackedTimeLeftToday".equals(evt.getPropertyName())) {
        summaryPanel.updateTimeLeftLabel();
        summaryPanel.updateTotalTimeLabel();
    } else if ("dayStartTime".equals(evt.getPropertyName())) {
        summaryPanel.updateTimeLeftLabel();
        summaryPanel.updateTotalTimeLabel();
    }
}

From source file:edu.ku.brc.specify.config.FixAttachments.java

/**
 * @param resultsHashMap//from   w w w  .jav  a2  s .c o  m
 * @param tableHash
 * @param totalFiles
 */
private void reattachFiles(final HashMap<Integer, Vector<Object[]>> resultsHashMap,
        final HashMap<Integer, AttchTableModel> tableHash, final int totalFiles) {
    final String CNT = "CNT";
    final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() {
        int filesCnt = 0;

        @Override
        protected Integer doInBackground() throws Exception {
            DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
            if (session != null) {
                try {
                    for (int tblId : resultsHashMap.keySet()) {
                        AttchTableModel model = tableHash.get(tblId);
                        int cnt = 0;
                        for (int r = 0; r < model.getRowCount(); r++) {
                            if (model.isRecoverable(r)) {
                                Thread.sleep(100);

                                session.beginTransaction();
                                Integer attachID = model.getAttachmentId(r);
                                Attachment attachment = session.get(Attachment.class, attachID);
                                AttachmentUtils.getAttachmentManager()
                                        .setStorageLocationIntoAttachment(attachment, false);
                                try {
                                    attachment.storeFile(true); // false means do not display an error dialog
                                    session.saveOrUpdate(attachment);
                                    session.commit();
                                    model.setRecovered(r, true);
                                    filesCnt++;

                                } catch (IOException ex) {
                                    session.rollback();
                                }
                            }
                            cnt++;
                            firePropertyChange(CNT, 0, (int) ((double) cnt / (double) totalFiles * 100.0));
                        }
                    }
                } catch (Exception ex) {
                    session.rollback();

                } finally {
                    session.close();
                }
            }
            return null;
        }

        @Override
        protected void done() {
            UIRegistry.clearSimpleGlassPaneMsg();
            UIRegistry.displayInfoMsgDlg(String.format("Files recovered: %d / %d", filesCnt, totalFiles));

            File file = produceSummaryReport(resultsHashMap, tableHash, totalFiles);
            if (file != null) {
                try {
                    AttachmentUtils.openFile(file);
                } catch (Exception e) {
                }
            }

            if (getNumberofBadAttachments() == 0) {
                AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", true);
            }
            super.done();
        }
    };

    final SimpleGlassPane glassPane = UIRegistry
            .writeSimpleGlassPaneMsg(String.format("Recovering %d files.", totalFiles), 24);
    glassPane.setProgress(0);

    worker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (CNT.equals(evt.getPropertyName())) {
                glassPane.setProgress((Integer) evt.getNewValue());
            }
        }
    });

    worker.execute();
}

From source file:org.tinymediamanager.ui.movies.dialogs.MovieBatchEditorDialog.java

/**
 * Instantiates a new movie batch editor.
 * //from   w ww  .  java  2  s  .c o m
 * @param movies
 *          the movies
 */
public MovieBatchEditorDialog(final List<Movie> movies) {
    super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$
    setBounds(5, 5, 350, 230);
    getContentPane().setLayout(new BorderLayout(0, 0));

    {
        JPanel panelContent = new JPanel();
        getContentPane().add(panelContent, BorderLayout.CENTER);
        panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        panelContent.add(lblGenres, "2, 2, 2, 1, right, default");

        // cbGenres = new JComboBox(MediaGenres2.values());
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        panelContent.add(cbGenres, "5, 2, fill, default");

        JButton btnAddGenre = new JButton("");
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        btnAddGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = null;
                Object item = cbGenres.getSelectedItem();

                // genre
                if (item instanceof MediaGenres) {
                    genre = (MediaGenres) item;
                }

                // newly created genre?
                if (item instanceof String) {
                    genre = MediaGenres.getGenre((String) item);
                }
                // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem();
                if (genre != null) {
                    for (Movie movie : moviesToEdit) {
                        movie.addGenre(genre);
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddGenre, "7, 2");

        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeGenre(genre);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveGenre, "9, 2");

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        panelContent.add(lblTags, "2, 4, 2, 1, right, default");

        cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray());
        cbTags.setEditable(true);
        panelContent.add(cbTags, "5, 4, fill, default");

        JButton btnAddTag = new JButton("");
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                if (StringUtils.isBlank(tag)) {
                    return;
                }

                for (Movie movie : moviesToEdit) {
                    movie.addToTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddTag, "7, 4");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeFromTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveTag, "9, 4");

        JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
        panelContent.add(lblCertification, "2, 6, 2, 1, right, default");

        final JComboBox cbCertification = new JComboBox();
        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }
        panelContent.add(cbCertification, "5, 6, fill, default");

        JButton btnCertification = new JButton("");
        btnCertification.setMargin(new Insets(2, 2, 2, 2));
        btnCertification.setIcon(IconManager.APPLY);
        btnCertification.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Certification cert = (Certification) cbCertification.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.setCertification(cert);
                    ;
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnCertification, "7, 6");

        JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
        panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default");

        cbMovieSet = new JComboBox();
        panelContent.add(cbMovieSet, "5, 8, fill, default");

        JButton btnSetMovieSet = new JButton("");
        btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2));
        btnSetMovieSet.setIcon(IconManager.APPLY);
        btnSetMovieSet.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // movie set
                Object obj = cbMovieSet.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    if (obj instanceof String) {
                        movie.removeFromMovieSet();
                    }
                    if (obj instanceof MovieSet) {
                        MovieSet movieSet = (MovieSet) obj;

                        if (movie.getMovieSet() != movieSet) {
                            movie.removeFromMovieSet();
                            movie.setMovieSet(movieSet);
                            movieSet.insertMovie(movie);
                        }
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnSetMovieSet, "7, 8");

        JButton btnNewMovieset = new JButton("");
        btnNewMovieset.setMargin(new Insets(2, 2, 2, 2));
        btnNewMovieset.setAction(new MovieSetAddAction(false));
        panelContent.add(btnNewMovieset, "9, 8");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        panelContent.add(lblWatched, "2, 10, 2, 1, right, default");

        chckbxWatched = new JCheckBox("");
        panelContent.add(chckbxWatched, "5, 10");

        JButton btnWatched = new JButton("");
        btnWatched.setMargin(new Insets(2, 2, 2, 2));
        btnWatched.setIcon(IconManager.APPLY);
        btnWatched.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setWatched(chckbxWatched.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnWatched, "7, 10");

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

        final JCheckBox chckbxVideo3D = new JCheckBox("");
        panelContent.add(chckbxVideo3D, "5, 12");

        JButton btnVideo3D = new JButton("");
        btnVideo3D.setMargin(new Insets(2, 2, 2, 2));
        btnVideo3D.setIcon(IconManager.APPLY);
        btnVideo3D.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setVideoIn3D(chckbxVideo3D.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnVideo3D, "7, 12");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        panelContent.add(lblMediasource, "2, 14, 2, 1, right, default");

        final JComboBox cbMediaSource = new JComboBox(MediaSource.values());
        panelContent.add(cbMediaSource, "5, 14, fill, default");

        JButton btnMediaSource = new JButton("");
        btnMediaSource.setMargin(new Insets(2, 2, 2, 2));
        btnMediaSource.setIcon(IconManager.APPLY);
        btnMediaSource.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                Object obj = cbMediaSource.getSelectedItem();
                if (obj instanceof MediaSource) {
                    MediaSource mediaSource = (MediaSource) obj;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setMediaSource(mediaSource);
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }
        });
        panelContent.add(btnMediaSource, "7, 14");

        JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$
        panelContent.add(lblLanguage, "2, 16, 2, 1, right, default");

        tfLanguage = new JTextField();
        panelContent.add(tfLanguage, "5, 16, fill, default");
        tfLanguage.setColumns(10);

        JButton btnLanguage = new JButton("");
        btnLanguage.setMargin(new Insets(2, 2, 2, 2));
        btnLanguage.setIcon(IconManager.APPLY);
        btnLanguage.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setSpokenLanguages(tfLanguage.getText());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnLanguage, "7, 16");
        {

            JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            panelContent.add(lblSorttitleT, "2, 18, right, default");

            JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$
            btnSetSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle(movie.getTitleSortable());
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });

            JLabel lblSorttitleInfo = new JLabel(IconManager.HINT);
            lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$
            panelContent.add(lblSorttitleInfo, "3, 18");
            panelContent.add(btnSetSorttitle, "5, 18");

            JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$
            btnClearSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle("");
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });
            panelContent.add(btnClearSorttitle, "5, 20");
        }
    }

    {
        JPanel panelButtons = new JPanel();
        FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout();
        flowLayout.setAlignment(FlowLayout.RIGHT);
        getContentPane().add(panelButtons, BorderLayout.SOUTH);

        JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$
        btnClose.setIcon(IconManager.APPLY);
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // rewrite movies, if anything changed
                if (changed) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
                setVisible(false);
            }
        });
        panelButtons.add(btnClose);

        // add window listener to write changes (if the window close button "X" is
        // pressed)
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // rewrite movies, if anything changed
                if (changed) {
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    // if configured - sync with trakt.tv
                    if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) {
                        TmmTask task = new SyncTraktTvTask(moviesToEdit, null);
                        TmmTaskManager.getInstance().addUnnamedTask(task);
                    }
                }
            }
        });
    }

    {
        setMovieSets();
        moviesToEdit = movies;

        PropertyChangeListener listener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("addedMovieSet".equals(evt.getPropertyName())) {
                    setMovieSets();
                }
            }
        };
        movieList.addPropertyChangeListener(listener);
    }
}

From source file:edu.ku.brc.specify.tasks.InteractionsProcessor.java

/**
 * Creates a new loan from a RecordSet.//  www .  ja  v a  2 s . c  o  m
 * @param currPrepProvider an existing loan that needs additional Preps
 * @param infoRequest a info request
 * @param recordSetArg the recordset to use to create the loan
 */
public void createOrAdd(final T currPrepProvider, final InfoRequest infoRequest,
        final RecordSetIFace recordSetArg) {
    RecordSetIFace recordSet = recordSetArg;
    boolean isEmptyAcc = false;
    if (infoRequest == null && recordSet == null) {
        String catNumField = "catalogNumber";

        // Get a List of InfoRequest RecordSets
        Vector<RecordSetIFace> rsList = task.getInfoReqRecordSetsFromSideBar();
        RecordSetTask rsTask = (RecordSetTask) TaskMgr.getTask(RecordSetTask.RECORD_SET);
        List<RecordSetIFace> colObjRSList = rsTask.getRecordSets(CollectionObject.getClassTableId());

        // If the List is empty then
        if (rsList.size() == 0 && colObjRSList.size() == 0 && (isFor != forAcc || currPrepProvider != null)) {
            recordSet = task.askForDataObjRecordSet(CollectionObject.class, catNumField);

        } else {
            ASK_TYPE rv = askSourceOfPreps(rsList.size() > 0, colObjRSList.size() > 0, currPrepProvider);
            if (rv == ASK_TYPE.ChooseRS) {
                recordSet = RecordSetTask.askForRecordSet(CollectionObject.getClassTableId(), rsList);

            } else if (rv == ASK_TYPE.EnterDataObjs) {
                recordSet = task.askForDataObjRecordSet(CollectionObject.class, catNumField);

            } else if (rv == ASK_TYPE.None) {
                recordSet = null;
                isEmptyAcc = true;
            } else if (rv == ASK_TYPE.Cancel) {
                if (viewable != null) {
                    viewable.setNewObject(null);
                }
                return;
            }
        }
    }

    if (recordSet == null && !isEmptyAcc) {
        return;
    }

    if (isEmptyAcc) {
        PrepLoaderSQL prepLoaderSQL = new PrepLoaderSQL(null, recordSet, infoRequest, isFor);
        prepLoaderSQL.execute();
    } else {
        DBTableIdMgr.getInstance().getInClause(recordSet);

        DBTableInfo tableInfo = DBTableIdMgr.getInstance().getInfoById(recordSet.getDbTableId());

        DataProviderFactory.getInstance().evict(tableInfo.getClassObj()); // XXX Not sure if this is really needed

        DataProviderSessionIFace session = null;
        try {
            session = DataProviderFactory.getInstance().createSession();

            // OK, it COULD be a RecordSet contain one or more InfoRequest, 
            // we will only accept an RS with one InfoRequest
            if (infoRequest == null && recordSet.getDbTableId() == InfoRequest.getClassTableId()) {
                if (recordSet.getNumItems() == 1) {
                    RecordSetItemIFace item = recordSet.getOnlyItem();
                    if (item != null) {
                        InfoRequest infoReq = session.get(InfoRequest.class, item.getRecordId().intValue());
                        if (infoReq != null) {
                            createOrAdd(null, infoReq, infoReq.getRecordSets().iterator().next());

                        } else {
                            // error about missing info request
                            // Error Dialog
                        }
                    } else {
                        // error about item being null for some unbelievable reason 
                        // Error Dialog
                    }
                } else {
                    // error about item having more than one or none
                    // Error Dialog
                }
                return;
            }

            // OK, here we have a recordset of CollectionObjects
            // First we process all the CollectionObjects in the RecordSet
            // and create a list of Preparations that can be loaned
            String sqlStr = DBTableIdMgr.getInstance().getQueryForTable(recordSet);
            if (StringUtils.isNotBlank(sqlStr)) {

                //CACA 
                final JStatusBar statusBar = UIRegistry.getStatusBar();
                statusBar.setIndeterminate(LOAN_LOADR, true);

                if (recordSet.getNumItems() > 2) {
                    UIRegistry.writeSimpleGlassPaneMsg(getResourceString("NEW_INTER_LOADING_PREP"), 24);
                }

                PrepLoaderSQL prepLoaderSQL = new PrepLoaderSQL(currPrepProvider, recordSet, infoRequest,
                        isFor);
                prepLoaderSQL.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent evt) {
                        log.debug(evt.getNewValue());
                        if ("progress".equals(evt.getPropertyName())) {
                            statusBar.setValue(LOAN_LOADR, (Integer) evt.getNewValue());
                        }
                    }
                });
                prepLoaderSQL.execute();

            } else {
                log.error("Query String empty for RecordSet tableId[" + recordSet.getDbTableId() + "]");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(InteractionsProcessor.class, ex);
        }
    }
}

From source file:com.m4rc310.cb.builders.ComponentBuilder.java

private void buildAllComponents() {
    for (Map.Entry<Field, AbstractComponetAdapter> entrySet : adapters.entrySet()) {
        Field field = entrySet.getKey();

        Acomponent ac = field.getDeclaredAnnotation(Acomponent.class);

        AbstractComponetAdapter adapter = entrySet.getValue();
        Object target = getTargetForField(field);

        adapter.setComponentsBuilder(this);
        adapter.build(field, target);/* w ww . j a  v  a2s .c  om*/

        Adialog adialog = objectAnnotated.getClass().getDeclaredAnnotation(Adialog.class);

        if (adialog.debug()) {
            try {
                Object component = adapter.getComponent();

                StringBuilder sgroup = new StringBuilder();
                for (String group : ac.groups()) {
                    sgroup.append("[ ");
                    sgroup.append(group);
                    sgroup.append(" ]");
                }

                String toolTipText = String.format("Name: %s - ToolTipText: %s - Groups: %s", ac.ref(),
                        ac.toolTipText(), sgroup);
                MethodUtils.method(component, "setToolTipText", String.class).invoke(toolTipText);
            } catch (Exception e) {
                infoError(e);
            }
        } else {
            Object component = adapter.getComponent();
            MethodUtils.method(component, "setToolTipText", String.class).invoke(getString(ac.toolTipText()));

        }

        try {
            Object value = field.get(target);
            adapter.update(field, value);

            if (ac.type().equals(EnumComponentType.PANEL)) {

                Object component = adapter.getComponent();

                //                    Object[] components = ((JPanel) component).getComponents();
                //                    
                //                    for (Object c : components) {
                //                        boolean bvalue = (boolean) MethodUtils.method(c, "isEnabled").invoke();
                //                        mc.put(c, bvalue);
                //                    }
                PropertyChangeListener pcl = new PropertyChangeListener() {
                    Map<Object, Boolean> mc = new HashMap<>();

                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        Object[] components = ((JPanel) component).getComponents();

                        if (evt.getPropertyName().equals("enabled")) {

                            boolean enable = (boolean) evt.getNewValue();

                            for (Object com : components) {
                                if (!mc.containsKey(com)) {
                                    boolean bvalue = (boolean) MethodUtils.method(com, "isEnabled").invoke();
                                    mc.put(com, bvalue);
                                }

                                if (enable) {
                                    MethodUtils.method(com, "setEnabled", boolean.class).invoke(mc.get(com));
                                } else {
                                    MethodUtils.method(com, "setEnabled", boolean.class).invoke(enable);
                                }
                            }
                        }
                    }
                };

                MethodUtils.method(component, "addPropertyChangeListener", PropertyChangeListener.class)
                        .invoke(pcl);
                putContainer(value.hashCode(), component);
            }
        } catch (IllegalArgumentException | IllegalAccessException e) {
            infoError(e);
            throw new UnsupportedOperationException(e);
        }
    }
}

From source file:org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController.java

/** invoked by {@link OnStart} to make sure that the ImageAnalyzer listeners
 * get setup as early as possible, and do other setup stuff. */
void onStart() {/*from  w ww. j  a v a 2 s  . co  m*/
    Platform.setImplicitExit(false);
    LOGGER.info("setting up ImageAnalyzer listeners");
    //TODO can we do anything usefull in an InjestJobEventListener?
    //IngestManager.getInstance().addIngestJobEventListener((PropertyChangeEvent evt) -> {});
    IngestManager.getInstance().addIngestModuleEventListener((PropertyChangeEvent evt) -> {
        switch (IngestManager.IngestModuleEvent.valueOf(evt.getPropertyName())) {
        case CONTENT_CHANGED:
            //TODO: do we need to do anything here?  -jm
        case DATA_ADDED:
            /* we could listen to DATA events and progressivly
             * update files, and get data from DataSource ingest
             * modules, but given that most modules don't post new
             * artifacts in the events and we would have to query for
             * them, without knowing which are the new ones, we just
             * ignore these events for now. The relevant data should all
             * be captured by file done event, anyways -jm */
            break;
        case FILE_DONE:
            /** getOldValue has fileID
             * getNewValue has {@link Abstractfile} */
            AbstractFile file = (AbstractFile) evt.getNewValue();
            if (isListeningEnabled()) {
                if (ImageAnalyzerModule.isSupportedAndNotKnown(file)) {
                    //this file should be included and we don't already know about it from hash sets (NSRL)
                    queueDBWorkerTask(new UpdateFileTask(file));
                } else if (ImageAnalyzerModule.getAllSupportedExtensions().contains(file.getNameExtension())) {
                    //doing this check results in fewer tasks queued up, and faster completion of db update
                    //this file would have gotten scooped up in initial grab, but actually we don't need it
                    queueDBWorkerTask(new RemoveFileTask(file));
                }
            } else { //TODO: keep track of what we missed for later
                setStale(true);
            }
            break;
        }
    });
    Case.addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (Case.Events.valueOf(evt.getPropertyName())) {
        case CURRENT_CASE:
            Case newCase = (Case) evt.getNewValue();
            if (newCase != null) { // case has been opened
                setCase(newCase); //connect db, groupmanager, start worker thread
            } else { // case is closing
                //close window, reset everything
                SwingUtilities.invokeLater(ImageAnalyzerTopComponent::closeTopComponent);
                reset();
            }
            break;
        case DATA_SOURCE_ADDED:
            //copy all file data to drawable databse
            Content newDataSource = (Content) evt.getNewValue();
            if (isListeningEnabled()) {
                queueDBWorkerTask(new PrePopulateDataSourceFiles(newDataSource.getId()));
            } else {//TODO: keep track of what we missed for later
                setStale(true);
            }
            break;
        }
    });
}

From source file:plugins.ImageRectificationPanel.java

/**
 * Invoked when task's progress property changes.
 *//*from   w w  w  .j  a  v  a 2s  . com*/
@Override
public void propertyChange(PropertyChangeEvent evt) {

    if (evt.getPropertyName().equals("progress")) {
        int progress = (Integer) evt.getNewValue();
        progressBar.setValue(progress);
    }
}