Example usage for java.beans PropertyChangeEvent getNewValue

List of usage examples for java.beans PropertyChangeEvent getNewValue

Introduction

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

Prototype

public Object getNewValue() 

Source Link

Document

Gets the new value for the property, expressed as an Object.

Usage

From source file:ru.goodfil.catalog.ui.forms.MainWindow.java

private void miExportOeToExcelActionPerformed(ActionEvent e) {
    final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ",
            ", ??  ", 0, 100);
    progressMonitor.setProgress(10);/*from  w  w w .j a  v  a 2s  .c  om*/
    progressMonitor.setMillisToPopup(0);

    ExportOeTask task = new ExportOeTask();
    task.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("progress")) {
                Integer progress = new Integer(evt.getNewValue().toString());
                progressMonitor.setProgress(progress);
            }
        }
    });
    task.execute();
}

From source file:ru.goodfil.catalog.ui.forms.MainWindow.java

private void menuItem1ExportOeCross(ActionEvent e) {
    final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ",
            ", ??  ", 0, 100);
    progressMonitor.setProgress(10);/*from  w  w  w.  j  av a 2  s .  c  om*/
    progressMonitor.setMillisToPopup(0);

    ExportOeTaskCross task = new ExportOeTaskCross();
    task.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("progress")) {
                Integer progress = new Integer(evt.getNewValue().toString());
                progressMonitor.setProgress(progress);
            }
        }
    });
    task.execute();
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java

/**
 * Listens to property to create a new container.
 *///www. ja  va  2  s .  co m
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (CreateFolderDialog.CREATE_FOLDER_PROPERTY.equals(name)) {
        String folderName = (String) evt.getNewValue();
        if (folderName != null && folderName.trim().length() > 0)
            create(folderName);
    }
}

From source file:org.polymap.core.mapeditor.tooling.select.SelectionTool.java

/**
 * Listen to feature selection changes from {@link LayerFeatureSelectionManager}.
 *///  w w w .  j  a  va  2 s .c o  m
@Override
@EventHandler
public void propertyChange(PropertyChangeEvent ev) {
    assert fsm == ev.getSource();

    //select
    if (ev.getPropertyName().equals(LayerFeatureSelectionManager.PROP_FILTER)) {
        vectorLayer.selectFeatures(fsm.getFeatureCollection());
    }
    // hover
    else if (ev.getPropertyName().equals(LayerFeatureSelectionManager.PROP_HOVER)) {
        selectControl.unselectAll();
        selectControl.selectFids(Collections.singletonList((String) ev.getNewValue()));
    }
}

From source file:org.openmicroscopy.shoola.agents.measurement.view.ObjectInspector.java

/** Initializes the component composing the display. */
private void initComponents() {
    infoLabel = new JLabel(MAGNIFICATION + " is " + model.getDrawingView().getScaleFactor());
    //create the table
    fieldTable = new FigureTable(new FigureTableModel(attributeFields, COLUMN_NAMES));
    fieldTable.getTableHeader().setReorderingAllowed(false);
    fieldTable.setRowHeight(26);/*from   ww w .j a  v a  2  s .c  o m*/
    fieldTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fieldTable.setCellSelectionEnabled(true);
    fieldTable.setColumnSelectionAllowed(true);
    fieldTable.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            int col = fieldTable.getSelectedColumn();
            int row = fieldTable.getSelectedRow();
            Object value = fieldTable.getValueAt(row, col);
            if (e.getClickCount() == 1) {
                if (value instanceof Boolean) {
                    toggleValue();
                }
            } else if (e.getClickCount() > 1) {
                e.consume();
                if (value instanceof Color) {
                    //Only if the figure is not read only.
                    FigureTableModel ftm = (FigureTableModel) fieldTable.getModel();
                    ROIFigure figure = ftm.getFigure();
                    if (figure != null && !figure.isReadOnly())
                        if (figure.canEdit())
                            controller.showColorPicker((Color) value);
                } else if (value instanceof Boolean) {
                    toggleValue();
                }
            }
        }
    });
    fieldTable.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FigureTable.VALUE_CHANGED_PROPERTY.equals(name)) {
                handleValueChanged((String) evt.getNewValue());
            }
        }
    });
}

From source file:Converter.java

/**
 * Detects when the value of the text field (not necessarily the same number
 * as you'd get from getText) changes./* w  ww.j  a v a2  s. c o m*/
 */
public void propertyChange(PropertyChangeEvent e) {
    if ("value".equals(e.getPropertyName())) {
        Number value = (Number) e.getNewValue();
        sliderModel.setDoubleValue(value.doubleValue());
    }
}

From source file:edu.uchc.octane.Palm.java

/**
 * Does most of the plotting work/*from w  w  w .j  av a  2s  .c om*/
 * @param type The type of PALM image
 * @param selected Trajectories to be included in the PALM plot
 */
void doConstructPALM(final PalmType type, final int[] selected) {

    class MySwingWorker extends SwingWorker<ImagePlus, Void> {

        @Override
        public ImagePlus doInBackground() {
            ImagePlus imp = null;

            for (int i = 0; i < selected.length; i++) {
                Trajectory traj = dataset_.getTrajectoryByIndex(selected[i]);

                switch (type) {
                case HEAD:
                    renderGaussianSpot(traj.get(0));
                    nPlotted_++;
                    break;
                case TAIL:
                    renderGaussianSpot(traj.get(traj.size() - 1));
                    nPlotted_++;
                    break;
                case AVERAGE:
                    renderAverage(traj);
                    break;
                case ALLPOINTS:
                    renderAllPoints(traj);
                    break;
                case TIMELAPSE:
                    renderMovie(traj);
                    break;
                }

                firePropertyChange("Progress", (double) i / selected.length,
                        (double) (i + 1) / selected.length);
            }

            if (bRenderInColor_) {
                processColor();
            } else {
                for (int i = 0; i < ips_.length; i++) {
                    stack_.addSlice("" + i, ips_[i]);
                }
            }

            if (stack_.getSize() > 1) {
                imp = new ImagePlus("PALM-" + imp_.getTitle(), stack_);
            } else {
                imp = new ImagePlus("PALM-" + imp_.getTitle(), stack_.getProcessor(1));
            }

            return imp;

        }

        @Override
        public void done() {
            ImagePlus imp = null;
            try {
                imp = get();
            } catch (InterruptedException e) {
                System.err.println("PALM thread interrupted");
            } catch (ExecutionException e) {
                IJ.log("PALM rendering error:" + e.getCause().getMessage());
                e.printStackTrace();
            }
            if (imp != null) {
                imp.show();
            }

        }
    }

    MySwingWorker task = new MySwingWorker();

    task.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == "Progress") {
                IJ.showProgress((Double) evt.getNewValue());
            }
        }
    });

    task.execute();

}

From source file:VASSAL.chat.node.NodeClient.java

public NodeClient(String moduleName, String playerId, CommandEncoder encoder, MessageBoard msgSvr,
        WelcomeMessageServer welcomer) {
    this.encoder = encoder;
    this.msgSvr = msgSvr;
    this.welcomer = welcomer;
    this.playerId = playerId;
    this.moduleName = moduleName;
    serverStatus = new CgiServerStatus();
    me = new NodePlayer(playerId);
    messageBoardControls = new MessageBoardControlsInitializer(Resources.getString("Chat.messages"), msgSvr); //$NON-NLS-1$
    roomControls = new LockableNodeRoomControls(this);
    roomControls.addPlayerActionFactory(ShowProfileAction.factory());
    roomControls.addPlayerActionFactory(SynchAction.factory(this));
    PrivateChatManager privateChatManager = new PrivateChatManager(this);
    roomControls.addPlayerActionFactory(PrivateMessageAction.factory(this, privateChatManager));
    roomControls.addPlayerActionFactory(SendSoundAction.factory(this, Resources.getString("Chat.send_wakeup"), //$NON-NLS-1$
            "wakeUpSound", "phone1.wav")); //$NON-NLS-1$ //$NON-NLS-2$
    roomControls.addPlayerActionFactory(InviteAction.factory(this));
    roomControls.addPlayerActionFactory(KickAction.factory(this));
    serverStatusControls = new ServerStatusControlsInitializer(serverStatus);
    playerStatusControls = new SimpleStatusControlsInitializer(this);
    synchEncoder = new SynchEncoder(this, this);
    privateChatEncoder = new PrivateChatEncoder(this, privateChatManager);
    soundEncoder = new SoundEncoder(this);
    inviteEncoder = new InviteEncoder(this);
    nameChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SimplePlayer p = (SimplePlayer) getUserInfo();
            p.setName((String) evt.getNewValue());
            setUserInfo(p);/*  w  ww  .  j  a v  a2  s  . c  om*/
        }
    };
    profileChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SimplePlayer p = (SimplePlayer) getUserInfo();
            SimpleStatus s = (SimpleStatus) p.getStatus();
            s = new SimpleStatus(s.isLooking(), s.isAway(), (String) evt.getNewValue(), s.getClient(),
                    s.getIp(), s.getModuleVersion(), s.getCrc());
            p.setStatus(s);
            setUserInfo(p);
        }
    };
}

From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java

/**
 * @param infileName//ww w  .  jav  a 2s  .com
 * @param outFileName
 * @param changeListener
 * @return
 */
public boolean compressFile(final String infileName, final String outFileName,
        final PropertyChangeListener propChgListener) {
    final File file = new File(infileName);
    if (file.exists()) {
        long fileSize = file.length();
        if (fileSize > 0) {
            SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
                protected String errorMsg = null;
                protected FileInputStream fis = null;
                protected GZIPOutputStream fos = null;

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

                        long totalSize = file.length();
                        long bytesCnt = 0;

                        FileInputStream fis = new FileInputStream(infileName);
                        GZIPOutputStream fos = new GZIPOutputStream(new FileOutputStream(outFileName));

                        byte[] bytes = new byte[BUFFER_SIZE * 10];

                        while (true) {
                            int len = fis.read(bytes);
                            if (len > 0) {
                                fos.write(bytes, 0, len);
                                bytesCnt += len;
                                firePropertyChange("MEGS", 0,
                                        (int) (((double) bytesCnt / (double) totalSize) * 100.0));
                            } else {
                                break;
                            }
                        }

                        fis.close();
                        fos.close();

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

                    } finally {
                        try {
                            if (fis != null) {
                                fis.close();
                            }
                            if (fos != null) {
                                fos.close();
                            }
                        } catch (IOException ex) {
                            errorMsg = ex.toString();
                        }
                    }
                    firePropertyChange("MEGS", 0, 100);
                    return null;
                }

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

                    UIRegistry.getStatusBar().setProgressDone(HttpLargeFileTransfer.class.toString());

                    //UIRegistry.clearSimpleGlassPaneMsg();

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

                    if (propChgListener != null) {
                        propChgListener.propertyChange(
                                new PropertyChangeEvent(HttpLargeFileTransfer.this, "Done", 0, 1));
                    }
                }
            };

            final JStatusBar statusBar = UIRegistry.getStatusBar();
            statusBar.setIndeterminate(HttpLargeFileTransfer.class.toString(), true);

            UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("Compressing Backup..."), 24);

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

        } else {
            // file doesn't exist
        }
    } else {
        // file doesn't exist
    }
    return false;
}

From source file:edu.ucla.stat.SOCR.chart.SuperAreaChart_XY.java

public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();

    System.err.println("From RegCorrAnal:: propertyName =" + propertyName + "!!!");

    if (propertyName.equals("DataUpdate")) {
        //update the local version of the dataTable by outside source
        dataTable = (JTable) (e.getNewValue());
        dataPanel.removeAll();/*from   w  w  w . j a v  a 2s. co  m*/
        dataPanel.add(new JScrollPane(dataTable));
        dataTable.doLayout();

        System.err.println("From RegCorrAnal:: data UPDATED!!!");
    }
}