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:com.jmstoolkit.queuebrowser.QueueBrowserView.java

/**
 *
 * @param app/*  w ww  .j  a  v a2 s .c o m*/
 */
public QueueBrowserView(SingleFrameApplication app) {
    super(app);

    _init();
    initComponents();

    // post components, finish inititalization based on initial values
    // of combo boxes
    try {
        this.jmsTemplate.setDefaultDestination(
                (Destination) this.jndiTemplate.lookup(destinationComboBox.getSelectedItem().toString()));
        connectionFactory.setTargetConnectionFactory(
                wrapConnectionFactory(connectionFactoryComboBox.getSelectedItem().toString()));
    } catch (NamingException ex) {
        messageTextArea.setText(JTKException.formatException(ex));
    } catch (NullPointerException e) {
        // if we have no previous properties, we'll get NullPointerException from
        // the .toString()s... but we don't care.
    }

    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            statusMessageLabel.setText("");
        }
    });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
        busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
            statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
        }
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
                if (!busyIconTimer.isRunning()) {
                    statusAnimationLabel.setIcon(busyIcons[0]);
                    busyIconIndex = 0;
                    busyIconTimer.start();
                }
                progressBar.setVisible(true);
                progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName)) {
                busyIconTimer.stop();
                statusAnimationLabel.setIcon(idleIcon);
                progressBar.setVisible(false);
                progressBar.setValue(0);
            } else if ("message".equals(propertyName)) {
                String text = (String) (evt.getNewValue());
                statusMessageLabel.setText((text == null) ? "" : text);
                messageTimer.restart();
            } else if ("progress".equals(propertyName)) {
                int value = (Integer) (evt.getNewValue());
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            }
        }
    });
}

From source file:VASL.build.module.map.ASLBoardPicker.java

public void addTo(Buildable b) {
    DirectoryConfigurer config = new VASSAL.configure.DirectoryConfigurer(BOARD_DIR, "Board Directory");

    final GameModule g = GameModule.getGameModule();

    g.getPrefs().addOption(config);//from   w ww.  java  2  s  .  c om
    String storedValue = g.getPrefs().getStoredValue(BOARD_DIR);
    if (storedValue == null || !new File(storedValue).exists()) {
        File archive = new File(g.getDataArchive().getName());
        File dir = archive.getParentFile();
        File defaultDir = new File(dir, "boards");
        if (!defaultDir.exists()) {
            defaultDir.mkdir();
        }
        config.setValue(defaultDir);
    }
    setBoardDir((File) g.getPrefs().getValue(BOARD_DIR));
    g.getPrefs().getOption(BOARD_DIR).addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            setBoardDir((File) evt.getNewValue());
        }
    });
    super.addTo(b);
}

From source file:ca.sqlpower.wabit.dao.session.WorkspacePersisterListener.java

public void propertyChanged(PropertyChangeEvent evt) {

    if (wouldEcho())
        return;//from   ww w. j  av a2  s  .  co  m

    this.transactionStarted(TransactionEvent.createStartTransactionEvent(this,
            "Creating start transaction event from propertyChange on object "
                    + evt.getSource().getClass().getSimpleName() + " and property name "
                    + evt.getPropertyName()));

    SPObject source = (SPObject) evt.getSource();
    String uuid = source.getUUID();
    String propertyName = evt.getPropertyName();
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();

    PropertyDescriptor propertyDescriptor;
    try {
        propertyDescriptor = PropertyUtils.getPropertyDescriptor(source, propertyName);
    } catch (Exception ex) {
        this.rollback();
        throw new RuntimeException(ex);
    }

    //Not persisting non-settable properties
    if (propertyDescriptor == null || propertyDescriptor.getWriteMethod() == null) {
        this.transactionEnded(TransactionEvent.createEndTransactionEvent(this));
        return;
    }

    for (PropertyToIgnore ignoreProperty : ignoreList) {
        if (ignoreProperty.getPropertyName().equals(propertyName)
                && ignoreProperty.getClassType().isAssignableFrom(source.getClass())) {
            this.transactionEnded(TransactionEvent.createEndTransactionEvent(this));
            return;
        }
    }

    //XXX special case that I want to remove even though I'm implementing it
    List<Object> additionalParams = new ArrayList<Object>();
    if (source instanceof OlapQuery && propertyName.equals("currentCube")) {
        additionalParams.add(((OlapQuery) source).getOlapDataSource());
    }

    DataType typeForClass = PersisterUtils.getDataType(newValue == null ? Void.class : newValue.getClass());
    Object oldBasicType;
    Object newBasicType;
    oldBasicType = converter.convertToBasicType(oldValue, additionalParams.toArray());
    newBasicType = converter.convertToBasicType(newValue, additionalParams.toArray());

    logger.debug("Calling persistProperty on propertyChange");
    this.persistProperty(uuid, propertyName, typeForClass, oldBasicType, newBasicType);

    this.transactionEnded(TransactionEvent.createEndTransactionEvent(this));
}

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()));
                }/*from   w  w w .  j av  a  2  s  .  c o 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:org.openmicroscopy.shoola.agents.fsimporter.chooser.LocationDialog.java

/**
 * Handles property fired by the Editor Dialog.
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 *//*from  w w  w  . j  av a2  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()));
        }
    }
}

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

/**
 * Downloads the possible script./* w  ww .j a  v a  2  s .  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:oct.analysis.application.OCTAnalysisUI.java

private void lrpSelectionWidthBeanPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lrpSelectionWidthBeanPropertyChange
    if (LRPSelectionWidthBean.LRP_SELECTION_WIDTH_PROPERTY.equals(evt.getPropertyName())) {
        //update the selection width (will only affect those selections that are resizable (OCTLines are NOT resizable)
        selectionLRPManager.setSelectionWidth((int) evt.getNewValue());
        //update display with new values
        octAnalysisPanel.repaint();/*  w  ww .  j  a v a2 s . com*/
        //ensure the value in the input box is bounded to possible values for selection width
        JFormattedTextField widthInput = getLrpWidthTextField();
        Object value = widthInput.getValue();
        int lrpw;
        if (value instanceof Long) {
            lrpw = (int) ((long) value);
        } else if (value instanceof Integer) {
            lrpw = (int) value;
        } else {
            lrpw = 5;
        }
        if (lrpw != selectionLRPManager.getSelectionWidth()) {
            //update UI to reflect bounded input value
            widthInput.setValue(selectionLRPManager.getSelectionWidth());
        }
    }
}

From source file:org.apache.catalina.mbeans.ServerLifecycleListener.java

/**
 * Handle a <code>PropertyChangeEvent</code> from one of the Containers
 * we are interested in.//from   w  w w  .j a  v a 2s  .  c o  m
 *
 * @param event The event that has occurred
 */
public void propertyChange(PropertyChangeEvent event) {

    if (event.getSource() instanceof Container) {
        try {
            processContainerPropertyChange((Container) event.getSource(), event.getPropertyName(),
                    event.getOldValue(), event.getNewValue());
        } catch (Exception e) {
            log.error("Exception handling Container property change", e);
        }
    } else if (event.getSource() instanceof DefaultContext) {
        try {
            processDefaultContextPropertyChange((DefaultContext) event.getSource(), event.getPropertyName(),
                    event.getOldValue(), event.getNewValue());
        } catch (Exception e) {
            log.error("Exception handling DefaultContext property change", e);
        }
    } else if (event.getSource() instanceof NamingResources) {
        try {
            processNamingResourcesPropertyChange((NamingResources) event.getSource(), event.getPropertyName(),
                    event.getOldValue(), event.getNewValue());
        } catch (Exception e) {
            log.error("Exception handling NamingResources property change", e);
        }
    } else if (event.getSource() instanceof Server) {
        try {
            processServerPropertyChange((Server) event.getSource(), event.getPropertyName(),
                    event.getOldValue(), event.getNewValue());
        } catch (Exception e) {
            log.error("Exception handing Server property change", e);
        }
    } else if (event.getSource() instanceof Service) {
        try {
            processServicePropertyChange((Service) event.getSource(), event.getPropertyName(),
                    event.getOldValue(), event.getNewValue());
        } catch (Exception e) {
            log.error("Exception handing Service property change", 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() {//  w w w.ja  va  2s . 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:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Creates the menu hosting the users belonging to the specified group.
 * Returns <code>true</code> if the group is selected, <code>false</code>
 * otherwise./*from  www.  ja v a  2s  .  co  m*/
 * 
 * @param groupItem The item hosting the group.
 * @param size The number of groups.
 * @return See above.
 */
private boolean createGroupMenu(GroupItem groupItem, int size) {
    long loggedUserID = model.getUserDetails().getId();
    GroupData group = groupItem.getGroup();
    //Determine the user already added to the display
    Browser browser = model.getBrowser(Browser.PROJECTS_EXPLORER);
    TreeImageDisplay refNode = null;
    List<TreeImageDisplay> nodes;
    ExperimenterVisitor visitor;
    List<Long> users = new ArrayList<Long>();
    //Find the group already displayed
    if (group != null && size > 0) {
        visitor = new ExperimenterVisitor(browser, group.getId());
        browser.accept(visitor);
        nodes = visitor.getNodes();
        if (nodes.size() == 1) {
            refNode = nodes.get(0);
        }
        visitor = new ExperimenterVisitor(browser, -1, -1);
        if (refNode != null)
            refNode.accept(visitor);
        else if (size == 1)
            browser.accept(visitor);
        nodes = visitor.getNodes();

        TreeImageDisplay n;
        if (CollectionUtils.isNotEmpty(nodes)) {
            Iterator<TreeImageDisplay> j = nodes.iterator();
            while (j.hasNext()) {
                n = j.next();
                if (n.getUserObject() instanceof ExperimenterData) {
                    users.add(((ExperimenterData) n.getUserObject()).getId());
                }
            }
            if (size == 1) {
                groupItem.setMenuSelected(true, false);
            }
        }
    }

    //now add the users
    List<DataMenuItem> items = new ArrayList<DataMenuItem>();
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    List l = null;
    if (group != null)
        l = sorter.sort(group.getLeaders());
    Iterator i;
    ExperimenterData exp;

    DataMenuItem item, allUser;
    JPanel list;

    boolean view = true;
    if (group != null) {
        int level = group.getPermissions().getPermissionsLevel();
        if (level == GroupData.PERMISSIONS_PRIVATE) {
            view = model.isAdministrator() || model.isGroupOwner(group);
        }
    }

    list = new JPanel();
    list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
    allUser = new DataMenuItem(DataMenuItem.ALL_USERS_TEXT, true);
    items.add(allUser);
    if (view)
        list.add(allUser);
    p.add(UIUtilities.buildComponentPanel(list));
    int count = 0;
    int total = 0;
    if (CollectionUtils.isNotEmpty(l)) {
        total += l.size();
        i = l.iterator();
        list = new JPanel();
        list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
        while (i.hasNext()) {
            exp = (ExperimenterData) i.next();
            if (view || exp.getId() == loggedUserID) {
                item = new DataMenuItem(exp, true);
                item.setSelected(users.contains(exp.getId()));
                if (item.isSelected())
                    count++;
                item.addPropertyChangeListener(groupItem);
                items.add(item);
                list.add(item);
            }
        }
        if (list.getComponentCount() > 0) {
            p.add(formatHeader("Group owners"));
            p.add(UIUtilities.buildComponentPanel(list));
        }
    }

    if (group != null)
        l = sorter.sort(group.getMembersOnly());
    if (CollectionUtils.isNotEmpty(l)) {
        total += l.size();
        i = l.iterator();
        list = new JPanel();
        list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
        while (i.hasNext()) {
            exp = (ExperimenterData) i.next();
            if (view || exp.getId() == loggedUserID) {
                item = new DataMenuItem(exp, true);
                item.setSelected(users.contains(exp.getId()));
                if (item.isSelected())
                    count++;
                item.addPropertyChangeListener(groupItem);
                items.add(item);
                list.add(item);
            }
        }
        if (list.getComponentCount() > 0) {
            p.add(formatHeader("Members"));
            p.add(UIUtilities.buildComponentPanel(list));
        }
    }
    allUser.setSelected(total != 0 && total == count);
    allUser.addPropertyChangeListener(groupItem);
    JScrollPane pane = new JScrollPane(p);
    Dimension d = p.getPreferredSize();
    int max = 500;
    if (d.height > max) {
        Insets insets = pane.getInsets();
        pane.setPreferredSize(new Dimension(d.width + insets.left + insets.right + 20, max));
    }

    groupItem.add(pane);
    groupItem.setUsersItem(items);
    groupItem.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (GroupItem.USER_SELECTION_PROPERTY.equals(name))
                handleSelection();
            else if (GroupItem.ALL_GROUPS_SELECTION_PROPERTY.equals(name))
                handleAllGroupsSelection(true);
            else if (GroupItem.ALL_GROUPS_DESELECTION_PROPERTY.equals(name))
                handleAllGroupsSelection(false);
            else if (GroupItem.ALL_USERS_SELECTION_PROPERTY.equals(name))
                handleAllUsersSelection((Boolean) evt.getNewValue());
        }
    });
    return groupItem.isMenuSelected();
}