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:edu.ku.brc.af.core.db.MySQLBackupService.java

/**
 * @param databaseName//  ww w . j  a  v  a 2s  . c o m
 * @param restoreFilePath
 * @param glassPane
 * @param completionMsgKey
 */
protected boolean doRestoreInBackground(final String databaseName, final String restoreFilePath,
        final SimpleGlassPane glassPane, final String completionMsgKey, final PropertyChangeListener pcl,
        final boolean doSynchronously) {
    AppPreferences remotePrefs = AppPreferences.getLocalPrefs();
    final String mysqlLoc = remotePrefs.get(MYSQL_LOC, getDefaultMySQLLoc());

    getNumberofTables();

    SynchronousWorker backupWorker = new SynchronousWorker() {
        long dspMegs = 0;
        long fileSize = 0;

        /* (non-Javadoc)
         * @see javax.swing.SwingWorker#doInBackground()
         */
        @Override
        protected Integer doInBackground() throws Exception {
            FileInputStream input = null;
            try {
                String userName = itUsername != null ? itUsername : DBConnection.getInstance().getUserName();
                String password = itPassword != null ? itPassword : DBConnection.getInstance().getPassword();
                String port = DatabaseDriverInfo.getDriver(DBConnection.getInstance().getDriverName())
                        .getPort();
                String server = DBConnection.getInstance().getServerName();

                String cmdLine = String.format("%s -u %s --password=%s --host=%s %s %s", mysqlLoc, userName,
                        password, server, (port != null ? ("--port=" + port) : ""), databaseName);
                Vector<String> args = new Vector<String>();
                args.add(mysqlLoc);
                args.add("--user=" + userName);
                args.add("--password=" + password);
                args.add("--host=" + server);
                if (port != null) {
                    args.add("--port=" + port);
                }
                args.add(databaseName);

                Process process = Runtime.getRuntime().exec(args.toArray(new String[0]));

                Thread.sleep(100);

                OutputStream out = process.getOutputStream();

                // wait as long it takes till the other process has prompted.
                try {
                    File inFile = new File(restoreFilePath);
                    fileSize = inFile.length();
                    //System.out.println(fileSize);

                    double oneMB = (1024.0 * 1024.0);
                    double threshold = fileSize < (oneMB * 4) ? 8192 * 8 : oneMB;
                    long totalBytes = 0;

                    dspMegs = 0;

                    input = new FileInputStream(inFile);
                    try {
                        byte[] bytes = new byte[8192 * 4];
                        do {
                            int numBytes = input.read(bytes, 0, bytes.length);

                            totalBytes += numBytes;
                            if (numBytes > 0) {
                                out.write(bytes, 0, numBytes);

                                long megs = (long) (totalBytes / threshold);
                                if (megs != dspMegs) {
                                    dspMegs = megs;
                                    firePropertyChange(MEGS, dspMegs, (int) ((100.0 * totalBytes) / fileSize));
                                }

                            } else {
                                break;
                            }
                        } while (true);
                    } finally {
                        input.close();
                    }
                } catch (IOException ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(MySQLBackupService.class, ex);
                    ex.printStackTrace();
                    errorMsg = ex.toString();
                    UIRegistry.showLocalizedError("MySQLBackupService.EXCP_RS");

                } catch (Exception ex) {
                    ex.printStackTrace();
                    if (pcl != null) {
                        pcl.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1));
                    }
                }

                setProgress(100);

                out.flush();
                out.close();

                BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String line = null;
                while ((line = in.readLine()) != null) {
                    //System.err.println(line);
                }

                in = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                StringBuilder sb = new StringBuilder();
                while ((line = in.readLine()) != null) {
                    if (line.startsWith("ERR")) {
                        sb.append(line);
                        sb.append("\n");
                    }
                }
                errorMsg = sb.toString();

            } catch (Exception ex) {
                ex.printStackTrace();
                errorMsg = ex.toString();
                if (pcl != null) {
                    pcl.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1));
                }
            }

            return null;
        }

        @Override
        protected void done() {
            super.done();

            JStatusBar statusBar = UIRegistry.getStatusBar();
            if (statusBar != null) {
                statusBar.setProgressDone(STATUSBAR_NAME);
            }

            if (glassPane != null) {
                UIRegistry.clearSimpleGlassPaneMsg();
            }

            if (StringUtils.isNotEmpty(errorMsg)) {
                UIRegistry.showError(errorMsg);
            }

            if (statusBar != null) {
                statusBar.setText(UIRegistry.getLocalizedMessage(completionMsgKey, dspMegs));
            }

            if (pcl != null) {
                pcl.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, DONE, 0, 1));
            }
        }
    };

    if (glassPane != null) {
        glassPane.setProgress(0);
    }

    backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (MEGS.equals(evt.getPropertyName()) && glassPane != null) {
                int value = (Integer) evt.getNewValue();

                if (value < 100) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                } else {
                    glassPane.setProgress(100);
                }
            }
        }
    });

    if (doSynchronously) {
        return backupWorker.doWork();
    }

    backupWorker.execute();
    return true;
}

From source file:edu.ku.brc.specify.datamodel.busrules.CollectionObjectBusRules.java

/**
 * //from  w ww. j  a v  a2s.co  m
 */
public void doCreateBatchOfColObj(final Pair<String, String> catNumPair) {
    if (catNumPair.getFirst().equals(catNumPair.getSecond())) {
        return;
    }

    DBFieldInfo CatNumFld = DBTableIdMgr.getInstance().getInfoById(CollectionObject.getClassTableId())
            .getFieldByColumnName("CatalogNumber");
    final UIFieldFormatterIFace formatter = CatNumFld.getFormatter();
    if (!formatter.isIncrementer()) {
        //XXX this will have been checked earlier, right?
        UIRegistry.showLocalizedError(NonIncrementingCatNum);
        return;
    }

    final Vector<String> nums = new Vector<String>();
    processBatchContents(catNumPair, false, false, nums);
    SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() {
        private Vector<Pair<Integer, String>> objectsAdded = new Vector<Pair<Integer, String>>();
        private Vector<String> objectsNotAdded = new Vector<String>();
        private RecordSet batchRS;
        //private boolean invalidEntry = false;

        /* (non-Javadoc)
         * @see javax.swing.SwingWorker#doInBackground()
         */
        @Override
        protected Integer doInBackground() throws Exception {

            String catNum = catNumPair.getFirst();
            Integer collId = AppContextMgr.getInstance().getClassObject(Collection.class).getId();
            String coIdSql = "select CollectionObjectID from collectionobject where CollectionMemberID = "
                    + collId + " and CatalogNumber = '";
            objectsAdded.add(new Pair<Integer, String>(
                    (Integer) BasicSQLUtils.querySingleObj(coIdSql + catNum + "'"), catNum));

            int cnt = 0;
            CollectionObject co = null;
            //CollectionObject carryForwardCo = (CollectionObject )formViewObj.getDataObj();
            CollectionObject carryForwardCo;
            DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
            try {
                carryForwardCo = session.get(CollectionObject.class,
                        ((CollectionObject) formViewObj.getDataObj()).getId());
            } finally {
                session.close();
            }

            Thread.sleep(666); //Perhaps this is unnecessary, but it seems
            //to prevent sporadic "illegal access to loading collection" hibernate errors.
            try {
                for (String currentCat : nums) {
                    try {
                        co = new CollectionObject();
                        co.initialize();

                        //Collection doesn't get set in co.initialize(), or carryForward, but it needs to be set.
                        co.setCollection(AppContextMgr.getInstance().getClassObject(Collection.class));
                        //ditto, but doesn't so much need to be set
                        co.setModifiedByAgent(carryForwardCo.getModifiedByAgent());

                        co.setCatalogNumber(currentCat);
                        formViewObj.setNewObject(co);

                        if (formViewObj.saveObject()) {
                            objectsAdded.add(new Pair<Integer, String>(
                                    (Integer) BasicSQLUtils
                                            .querySingleObj(coIdSql + co.getCatalogNumber() + "'"),
                                    co.getCatalogNumber()));
                        } else {
                            objectsNotAdded.add(formatter.formatToUI(co.getCatalogNumber()).toString());
                        }
                    } catch (Exception ex) {
                        log.error(ex);
                        objectsNotAdded.add(formatter.formatToUI(currentCat) + ": "
                                + (ex.getLocalizedMessage() == null ? "" : ex.getLocalizedMessage()));
                    }
                    cnt++;
                    firePropertyChange(GLASSKEY, 0, cnt);
                }
                firePropertyChange(GLASSKEY, 0, nums.size());

            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(Uploader.class, ex);
            }
            formViewObj.setDataObj(carryForwardCo);
            saveBatchObjectsToRS();
            return objectsAdded.size();
        }

        /**
         * Save the objects added to a Recordset
         */
        protected void saveBatchObjectsToRS() {
            batchRS = new RecordSet();
            batchRS.initialize();
            batchRS.setDbTableId(CollectionObject.getClassTableId());
            String name = getResourceString(BatchRSBaseName) + " " + formatter.formatToUI(catNumPair.getFirst())
                    + "-" + formatter.formatToUI(catNumPair.getSecond());
            if (objectsNotAdded.size() > 0) {
                name += "-" + UIRegistry.getResourceString(IncompleteSaveFlag);
            }
            batchRS.setName(name);
            for (Pair<Integer, String> obj : objectsAdded) {
                batchRS.addItem(obj.getFirst());
            }
            DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
            boolean transOpen = false;
            try {
                BusinessRulesIFace busRule = DBTableIdMgr.getInstance().getBusinessRule(RecordSet.class);
                if (busRule != null) {
                    busRule.beforeSave(batchRS, session);
                }
                batchRS.setTimestampCreated(new Timestamp(System.currentTimeMillis()));
                batchRS.setOwner(AppContextMgr.getInstance().getClassObject(SpecifyUser.class));
                session.beginTransaction();
                transOpen = true;
                session.save(batchRS);
                if (busRule != null) {
                    if (!busRule.beforeSaveCommit(batchRS, session)) {
                        session.rollback();
                        throw new Exception("Business rules processing failed");
                    }
                }
                session.commit();
                transOpen = false;
                if (busRule != null) {
                    busRule.afterSaveCommit(batchRS, session);
                }
            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(Uploader.class, ex);
                if (transOpen) {
                    session.rollback();
                }
            }
        }

        /**
         * Add the batch RS to the RecordSetTask UI
         */
        protected void addBatchRSToUI() {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    CommandAction cmd = new CommandAction(RecordSetTask.RECORD_SET,
                            RecordSetTask.ADD_TO_NAV_BOX);
                    cmd.setData(batchRS);
                    CommandDispatcher.dispatch(cmd);
                }
            });
        }

        /* (non-Javadoc)
         * @see javax.swing.SwingWorker#done()
         */
        @Override
        protected void done() {
            super.done();
            processingSeries.set(false);
            addBatchRSToUI();
            UIRegistry.clearSimpleGlassPaneMsg();
            if (objectsNotAdded.size() == 0) {
                UIRegistry.displayLocalizedStatusBarText(BatchSaveSuccess,
                        formatter.formatToUI(catNumPair.getFirst()),
                        formatter.formatToUI(catNumPair.getSecond()));
            } else {
                showBatchErrorObjects(objectsNotAdded, BatchSaveErrorsTitle, BatchSaveErrors);
            }
        }
    };

    final SimpleGlassPane gp = UIRegistry.writeSimpleGlassPaneMsg(getI10N("SAVING_BATCH"), 24);
    gp.setProgress(0);
    worker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (GLASSKEY.equals(evt.getPropertyName())) {
                double value = (double) ((Integer) evt.getNewValue()).intValue();
                int percent = (int) (value / ((double) nums.size()) * 100.0);
                gp.setProgress(percent);

            }
        }
    });
    processingSeries.set(true);
    worker.execute();
    //        try {
    //           worker.get();
    //        } catch (Exception ex) {
    //           ex.printStackTrace();
    //        }
}

From source file:Installer.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if ("progress" == evt.getPropertyName()) {
        int progress = (Integer) evt.getNewValue();
        System.out.println(progress);
    }/*from   ww  w .java2 s  .co m*/
}

From source file:org.rdv.viz.image.ImageViz.java

private void initFilmstripPanel() {
    filmstripPanel = new FilmstripPanel();
    filmstripPanel.setBackground(Color.black);
    filmstripPanel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent pce) {
            String propertyName = pce.getPropertyName();
            if (propertyName.equals(FilmstripPanel.MAXIMUM_IMAGES_PROPERTY)) {
                if (filmstripPanel.getMaximumImages() != FilmstripPanel.MAXIMUM_IMAGES_DEFAULT) {
                    properties.setProperty(DATA_PANEL_PROPERTY_MAXIMUM_FILMSTRIP_IMAGES,
                            pce.getNewValue().toString());
                } else {
                    properties.remove(DATA_PANEL_PROPERTY_MAXIMUM_FILMSTRIP_IMAGES);
                }/*from   w w w.j  av a  2 s  .  c  o m*/
                updateMaximumFilmstripImagesRadioButtons();
            }
        }
    });

    filmstripPanel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                setFilmstripMode(false);
            }
        }
    });
}

From source file:edu.ku.brc.af.core.db.MySQLBackupService.java

/**
 * Does the backup on a SwingWorker Thread.
 * @param isMonthly whether it is a monthly backup
 * @param doSendAppExit requests sending an application exit command when done
 * @return true if the prefs are set up and there were no errors before the SwingWorker thread was started
 *//* www .  j  a v  a  2s.  c  o m*/
private boolean doBackUp(final boolean isMonthly, final boolean doSendAppExit,
        final PropertyChangeListener propChgListener) {
    AppPreferences remotePrefs = AppPreferences.getLocalPrefs();

    final String mysqldumpLoc = remotePrefs.get(MYSQLDUMP_LOC, getDefaultMySQLDumpLoc());
    final String backupLoc = remotePrefs.get(MYSQLBCK_LOC, getDefaultBackupLoc());

    if (!(new File(mysqldumpLoc)).exists()) {
        UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_DUMP", mysqldumpLoc);
        if (propChgListener != null) {
            propChgListener.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1));
        }
        return false;
    }

    File backupDir = new File(backupLoc);
    if (!backupDir.exists()) {
        if (!backupDir.mkdir()) {
            UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_BK_DIR", backupDir.getAbsoluteFile());
            if (propChgListener != null) {
                propChgListener.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1));
            }
            return false;
        }
    }

    errorMsg = null;

    final String databaseName = DBConnection.getInstance().getDatabaseName();

    getNumberofTables();

    SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
        protected String fullPath = null;

        /* (non-Javadoc)
         * @see javax.swing.SwingWorker#doInBackground()
         */
        @Override
        protected Integer doInBackground() throws Exception {
            FileOutputStream backupOut = null;
            try {
                Thread.sleep(100);

                // Create output file
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_kk_mm_ss");
                String fileName = sdf.format(Calendar.getInstance().getTime()) + (isMonthly ? "_monthly" : "")
                        + ".sql";

                fullPath = backupLoc + File.separator + fileName;

                File file = new File(fullPath);
                backupOut = new FileOutputStream(file);

                writeStats(getCollectionStats(getTableNames()), getStatsName(fullPath));

                String userName = DBConnection.getInstance().getUserName();
                String password = DBConnection.getInstance().getPassword();

                if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
                    Pair<String, String> up = UserAndMasterPasswordMgr.getInstance().getUserNamePasswordForDB();
                    if (up != null && up.first != null && up.second != null) {
                        userName = up.first;
                        password = up.second;
                    }
                }

                String port = DatabaseDriverInfo.getDriver(DBConnection.getInstance().getDriverName())
                        .getPort();
                String server = DBConnection.getInstance().getServerName();

                Vector<String> args = new Vector<String>();
                args.add(mysqldumpLoc);
                args.add("--user=" + userName);
                args.add("--password=" + password);
                args.add("--host=" + server);
                if (port != null) {
                    args.add("--port=" + port);
                }
                args.add(databaseName);
                Process process = Runtime.getRuntime().exec(args.toArray(new String[0]));

                InputStream input = process.getInputStream();
                byte[] bytes = new byte[8192 * 2];

                double oneMeg = (1024.0 * 1024.0);
                long dspMegs = 0;
                long totalBytes = 0;

                do {
                    int numBytes = input.read(bytes, 0, bytes.length);
                    totalBytes += numBytes;
                    if (numBytes > 0) {
                        long megs = (long) (totalBytes / oneMeg);
                        if (megs != dspMegs) {
                            dspMegs = megs;
                            long megsWithTenths = (long) ((totalBytes * 10.0) / oneMeg);
                            firePropertyChange(MEGS, 0, megsWithTenths);
                        }

                        backupOut.write(bytes, 0, numBytes);

                    } else {
                        break;
                    }

                } while (true);

                StringBuilder sb = new StringBuilder();

                String line;
                BufferedReader errIn = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                while ((line = errIn.readLine()) != null) {
                    //System.err.println(line);
                    if (line.startsWith("ERR") || StringUtils.contains(line, "Got error")) {
                        sb.append(line);
                        sb.append("\n");

                        if (StringUtils.contains(line, "1044") && StringUtils.contains(line, "LOCK TABLES")) {
                            sb.append("\n");
                            sb.append(UIRegistry.getResourceString("MySQLBackupService.LCK_TBL_ERR"));
                            sb.append("\n");
                        }
                    }
                }
                errorMsg = sb.toString();

            } catch (Exception ex) {
                ex.printStackTrace();
                errorMsg = ex.toString();
                UIRegistry.showLocalizedError("MySQLBackupService.EXCP_BK");

            } finally {
                if (backupOut != null) {
                    try {
                        backupOut.flush();
                        backupOut.close();

                    } catch (IOException ex) {
                        ex.printStackTrace();
                        errorMsg = ex.toString();
                    }
                }
            }

            return null;
        }

        @Override
        protected void done() {
            super.done();

            UIRegistry.getStatusBar().setProgressDone(STATUSBAR_NAME);

            UIRegistry.clearSimpleGlassPaneMsg();

            if (StringUtils.isNotEmpty(errorMsg)) {
                UIRegistry.showError(errorMsg);
            }

            if (doSendAppExit) {
                CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit"));
            }

            if (propChgListener != null) {
                propChgListener
                        .propertyChange(new PropertyChangeEvent(MySQLBackupService.this, DONE, null, fullPath));
            }
        }
    };

    final JStatusBar statusBar = UIRegistry.getStatusBar();
    statusBar.setIndeterminate(STATUSBAR_NAME, true);

    UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("MySQLBackupService.BACKINGUP", databaseName), 24);

    backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (MEGS.equals(evt.getPropertyName())) {
                long value = (Long) evt.getNewValue();
                double val = value / 10.0;
                statusBar.setText(UIRegistry.getLocalizedMessage("MySQLBackupService.BACKUP_MEGS", val));
            }
        }
    });
    backupWorker.execute();

    return true;
}

From source file:org.jdesktop.swingworker.AccumulativeRunnable.java

public final void testPropertyChange() throws Exception {
    final Exchanger<Boolean> boolExchanger = 
        new Exchanger<Boolean>();
    final SwingWorker<?,?> test = 
        new SwingWorker<Object, Object>() {
            @Override//from ww w. j  av  a2  s  .co m
            protected Object doInBackground() throws Exception {
                firePropertyChange("test", null, "test");
                return null;
            }
        };
    test.addPropertyChangeListener(
        new PropertyChangeListener() {
            boolean isOnEDT = true;

            public  void propertyChange(PropertyChangeEvent evt) {
                isOnEDT &= SwingUtilities.isEventDispatchThread();
                if ("state".equals(evt.getPropertyName())
                    && StateValue.DONE == evt.getNewValue()) {
                    try {
                        boolExchanger.exchange(isOnEDT);
                    } catch (Exception ignore) {
                        ignore.printStackTrace();
                    }
                }
            }
        });
    test.execute();
    assertTrue(boolExchanger.exchange(null, TIME_OUT, TIME_OUT_UNIT));
}

From source file:org.rdv.viz.image.ImageViz.java

private void initImagePanel() {
    imagePanel = new ImagePanel();
    imagePanel.setBackground(Color.black);
    imagePanel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent pce) {
            String propertyName = pce.getPropertyName();
            if (propertyName.equals(ImagePanel.AUTO_SCALING_PROPERTY)) {
                boolean autoScaling = (Boolean) pce.getNewValue();
                autoScaleMenuItem.setSelected(autoScaling);
                if (autoScaling) {
                    properties.remove(DATA_PANEL_PROPERTY_SCALE);
                    properties.remove(DATA_PANEL_PROPERTY_ORIGIN);
                } else {
                    properties.setProperty(DATA_PANEL_PROPERTY_SCALE, Double.toString(imagePanel.getScale()));
                    properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, pointToString(imagePanel.getOrigin()));
                }/* w ww .  j  a  va2 s.  co  m*/
            } else if (propertyName.equals(ImagePanel.SCALE_PROPERTY) && !imagePanel.isAutoScaling()) {
                properties.setProperty(DATA_PANEL_PROPERTY_SCALE, pce.getNewValue().toString());
            } else if (propertyName.equals(ImagePanel.ORIGIN_PROPERTY) && !imagePanel.isAutoScaling()) {
                Point origin = (Point) pce.getNewValue();
                String originString = pointToString(origin);
                properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, originString);
            } else if (propertyName.equals(ImagePanel.NAVIGATION_IMAGE_ENABLED_PROPERTY)) {
                boolean showNavigationImage = (Boolean) pce.getNewValue();
                showNavigationImageMenuItem.setSelected(showNavigationImage);
                if (showNavigationImage) {
                    properties.setProperty(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE, "true");
                } else {
                    properties.remove(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE);
                }
            }
        }
    });

    panel.add(imagePanel, BorderLayout.CENTER);
}

From source file:view.MainWindow.java

private void jSplitPane1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jSplitPane1PropertyChange
    String propertyName = evt.getPropertyName();
    if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
        workspacePanel.fixTempSignaturePosition(false);
    }/*w  w  w.j a  v a  2 s.  com*/
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java

/**
 * Downloads the possible script./*  w ww . j a v  a2s .  co  m*/
 * 
 * @param param The parameter holding the script.
 */
private void downloadScript(ScriptActivityParam param) {
    FileChooser chooser = new FileChooser(view, FileChooser.SAVE, "Download",
            "Select where to download the file.", null, true);
    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
    chooser.setSelectedFileFull(param.getScript().getName());
    chooser.setApproveButtonText("Download");
    final long id = param.getScript().getScriptID();
    chooser.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
                File[] files = (File[]) evt.getNewValue();
                File folder = files[0];
                IconManager icons = IconManager.getInstance();
                DownloadActivityParam activity;
                activity = new DownloadActivityParam(id, DownloadActivityParam.ORIGINAL_FILE, folder,
                        icons.getIcon(IconManager.DOWNLOAD_22));
                UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
                SecurityContext ctx = new SecurityContext(
                        TreeViewerAgent.getUserDetails().getDefaultGroup().getId());
                un.notifyActivity(ctx, activity);
            }
        }
    });
    chooser.centerDialog();
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.LocationDialog.java

/**
 * Handles property fired by the Editor Dialog.
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 *//*  ww w .jav a 2 s . c o  m*/
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();

    if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) {
        Object ho = evt.getNewValue();
        DataObject child = null, parent = null;
        if (ho instanceof ProjectData || ho instanceof ScreenData) {
            child = (DataObject) ho;
        } else if (ho instanceof DatasetData) {
            child = (DataObject) ho;
            DataNode n = getSelectedItem(projectsBox);
            if (!n.isDefaultNode()) {
                parent = n.getDataObject();
            }
        }

        GroupData selectedGroup = getSelectedGroup();

        if (child != null) {
            firePropertyChange(ImportDialog.CREATE_OBJECT_PROPERTY, null,
                    new ObjectToCreate(selectedGroup, child, parent, getSelectedUser()));
        }
    }
}