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:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java

/**
 * Listens to property fired by the Editor dialog.
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 *//*www .j  a  v a 2 s. c  om*/
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) {
        //reset text and tooltip
        String text = "";
        String description = "";
        AnnotationData annotation = null;
        if (data instanceof TagAnnotationData || data instanceof TermAnnotationData
                || data instanceof XMLAnnotationData) {
            annotation = (AnnotationData) data;
            text = annotation.getContentAsString();
        }
        description = model.getAnnotationDescription(annotation);
        if (annotation == null)
            return;
        label.setText(text);
        label.setToolTipText(formatToolTip(annotation, null));
        originalName = text;
        originalDescription = description;
        firePropertyChange(AnnotationUI.EDIT_TAG_PROPERTY, null, this);
    } else if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
        if (data == null)
            return;
        FileAnnotationData fa = (FileAnnotationData) data;
        OriginalFile f = (OriginalFile) fa.getContent();
        File folder;
        Object o = evt.getNewValue();
        if (o instanceof String) {
            String path = (String) o;
            if (!path.endsWith(File.separator)) {
                path += File.separator;
            }
            path += fa.getFileName();
            folder = new File(path);
        } else {
            File[] files = (File[]) o;
            folder = files[0];
        }
        if (folder == null)
            folder = UIUtilities.getDefaultFolder();
        UserNotifier un = EditorAgent.getRegistry().getUserNotifier();

        IconManager icons = IconManager.getInstance();

        DownloadActivityParam activity = new DownloadActivityParam(f, folder,
                icons.getIcon(IconManager.DOWNLOAD_22));
        //Check Name space
        activity.setLegend(fa.getDescription());
        un.notifyActivity(model.getSecurityContext(), activity);
    }
}

From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java

/**
 * Handle the event//w ww  . jav  a  2s .  c  om
 *
 * @param event the event
 */
public void propertyChange(PropertyChangeEvent event) {
    if (event.getPropertyName().equals(WayPoint.PROP_WAYPOINTVALUE)) {
        WayPoint source = (WayPoint) event.getSource();
        if (source.canPlaySound()) {
            playSound(source);
        }
        if (getDriveTime() && (animationWidget != null)) {
            lastTimeWeDrove = System.currentTimeMillis();
            animationWidget.setTimeFromUser(new Real(RealType.Time, source.getDomainValue() / 1000));
        }
    } else if (event.getPropertyName().equals(PROP_SELECTEDTIME)) {
        Double dttm = (Double) event.getNewValue();
        if (dttm != null) {
            setTime(dttm.doubleValue(), true);
        }
    }
}

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

private void miExportToExcelActionPerformed(ActionEvent e) {
    if (listsPopupMenu.getInvoker() == vechicleTypesList || listsPopupMenu.getInvoker() == manufactorsList
            || listsPopupMenu.getInvoker() == seriesList) {

        ExportWindow exportWindow = new ExportWindow();
        exportWindow.setVisible(true);// ww  w.j a  va  2 s  .c  om
        if (exportWindow.getDialogResult() == DialogResult.OK) {
            final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ",
                    ", ??  ", 0, 100);
            progressMonitor.setProgress(0);
            progressMonitor.setMillisToPopup(0);
            progressMonitor.setMillisToDecideToPopup(0);

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

From source file:com.marginallyclever.makelangelo.MainGUI.java

protected boolean LoadDXF(String filename) {
    if (ChooseImageConversionOptions(true) == false)
        return false;

    // where to save temp output file?
    final String destinationFile = GetTempDestinationFile();
    final String srcFile = filename;

    TabToLog();/*from   ww w . jav a2s  .c  o  m*/

    final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100);
    pm.setProgress(0);
    pm.setMillisToPopup(0);

    final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() {
        public boolean ok = false;

        @SuppressWarnings("unchecked")
        @Override
        public Void doInBackground() {
            Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile + "</font>\n");

            Parser parser = ParserBuilder.createDefaultParser();

            double dxf_x2 = 0;
            double dxf_y2 = 0;
            OutputStreamWriter out = null;

            try {
                out = new OutputStreamWriter(new FileOutputStream(destinationFile), "UTF-8");
                DrawingTool tool = machineConfiguration.GetCurrentTool();
                out.write(machineConfiguration.GetConfigLine() + ";\n");
                out.write(machineConfiguration.GetBobbinLine() + ";\n");
                out.write("G00 G90;\n");
                tool.WriteChangeTo(out);
                tool.WriteOff(out);

                parser.parse(srcFile, DXFParser.DEFAULT_ENCODING);
                DXFDocument doc = parser.getDocument();
                Bounds b = doc.getBounds();
                double width = b.getMaximumX() - b.getMinimumX();
                double height = b.getMaximumY() - b.getMinimumY();
                double cx = (b.getMaximumX() + b.getMinimumX()) / 2.0f;
                double cy = (b.getMaximumY() + b.getMinimumY()) / 2.0f;
                double sy = machineConfiguration.GetPaperHeight() * 10 / height;
                double sx = machineConfiguration.GetPaperWidth() * 10 / width;
                double scale = (sx < sy ? sx : sy) * machineConfiguration.paper_margin;
                sx = scale * (machineConfiguration.reverseForGlass ? -1 : 1);
                // count all entities in all layers
                Iterator<DXFLayer> layer_iter = (Iterator<DXFLayer>) doc.getDXFLayerIterator();
                int entity_total = 0;
                int entity_count = 0;
                while (layer_iter.hasNext()) {
                    DXFLayer layer = (DXFLayer) layer_iter.next();
                    Log("<font color='yellow'>Found layer " + layer.getName() + "</font>\n");
                    Iterator<String> entity_iter = (Iterator<String>) layer.getDXFEntityTypeIterator();
                    while (entity_iter.hasNext()) {
                        String entity_type = (String) entity_iter.next();
                        List<DXFEntity> entity_list = (List<DXFEntity>) layer.getDXFEntities(entity_type);
                        Log("<font color='yellow'>+ Found " + entity_list.size() + " of type " + entity_type
                                + "</font>\n");
                        entity_total += entity_list.size();
                    }
                }
                // set the progress meter
                pm.setMinimum(0);
                pm.setMaximum(entity_total);

                // convert each entity
                layer_iter = doc.getDXFLayerIterator();
                while (layer_iter.hasNext()) {
                    DXFLayer layer = (DXFLayer) layer_iter.next();

                    Iterator<String> entity_type_iter = (Iterator<String>) layer.getDXFEntityTypeIterator();
                    while (entity_type_iter.hasNext()) {
                        String entity_type = (String) entity_type_iter.next();
                        List<DXFEntity> entity_list = layer.getDXFEntities(entity_type);

                        if (entity_type.equals(DXFConstants.ENTITY_TYPE_LINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFLine entity = (DXFLine) entity_list.get(i);
                                Point start = entity.getStartPoint();
                                Point end = entity.getEndPoint();

                                double x = (start.getX() - cx) * sx;
                                double y = (start.getY() - cy) * sy;
                                double x2 = (end.getX() - cx) * sx;
                                double y2 = (end.getY() - cy) * sy;

                                // is it worth drawing this line?
                                double dx = x2 - x;
                                double dy = y2 - y;
                                if (dx * dx + dy * dy < tool.GetDiameter() / 2.0) {
                                    continue;
                                }

                                dx = dxf_x2 - x;
                                dy = dxf_y2 - y;

                                if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                    if (tool.DrawIsOn()) {
                                        tool.WriteOff(out);
                                    }
                                    tool.WriteMoveTo(out, (float) x, (float) y);
                                }
                                if (tool.DrawIsOff()) {
                                    tool.WriteOn(out);
                                }
                                tool.WriteMoveTo(out, (float) x2, (float) y2);
                                dxf_x2 = x2;
                                dxf_y2 = y2;
                            }
                        } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_SPLINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFSpline entity = (DXFSpline) entity_list.get(i);
                                entity.setLineWeight(30);
                                DXFPolyline polyLine = DXFSplineConverter.toDXFPolyline(entity);
                                boolean first = true;
                                for (int j = 0; j < polyLine.getVertexCount(); ++j) {
                                    DXFVertex v = polyLine.getVertex(j);
                                    double x = (v.getX() - cx) * sx;
                                    double y = (v.getY() - cy) * sy;
                                    double dx = dxf_x2 - x;
                                    double dy = dxf_y2 - y;

                                    if (first == true) {
                                        first = false;
                                        if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                            // line does not start at last tool location, lift and move.
                                            if (tool.DrawIsOn()) {
                                                tool.WriteOff(out);
                                            }
                                            tool.WriteMoveTo(out, (float) x, (float) y);
                                        }
                                        // else line starts right here, do nothing.
                                    } else {
                                        // not the first point, draw.
                                        if (tool.DrawIsOff())
                                            tool.WriteOn(out);
                                        if (j < polyLine.getVertexCount() - 1
                                                && dx * dx + dy * dy < tool.GetDiameter() / 2.0)
                                            continue; // less than 1mm movement?  Skip it. 
                                        tool.WriteMoveTo(out, (float) x, (float) y);
                                    }
                                    dxf_x2 = x;
                                    dxf_y2 = y;
                                }
                            }
                        } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_POLYLINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFPolyline entity = (DXFPolyline) entity_list.get(i);
                                boolean first = true;
                                for (int j = 0; j < entity.getVertexCount(); ++j) {
                                    DXFVertex v = entity.getVertex(j);
                                    double x = (v.getX() - cx) * sx;
                                    double y = (v.getY() - cy) * sy;
                                    double dx = dxf_x2 - x;
                                    double dy = dxf_y2 - y;

                                    if (first == true) {
                                        first = false;
                                        if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                            // line does not start at last tool location, lift and move.
                                            if (tool.DrawIsOn()) {
                                                tool.WriteOff(out);
                                            }
                                            tool.WriteMoveTo(out, (float) x, (float) y);
                                        }
                                        // else line starts right here, do nothing.
                                    } else {
                                        // not the first point, draw.
                                        if (tool.DrawIsOff())
                                            tool.WriteOn(out);
                                        if (j < entity.getVertexCount() - 1
                                                && dx * dx + dy * dy < tool.GetDiameter() / 2.0)
                                            continue; // less than 1mm movement?  Skip it. 
                                        tool.WriteMoveTo(out, (float) x, (float) y);
                                    }
                                    dxf_x2 = x;
                                    dxf_y2 = y;
                                }
                            }
                        }
                    }
                }

                // entities finished.  Close up file.
                tool.WriteOff(out);
                tool.WriteMoveTo(out, 0, 0);

                ok = true;
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
                try {
                    if (out != null)
                        out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

            pm.setProgress(100);
            return null;
        }

        @Override
        public void done() {
            pm.close();
            Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
            PlayConversionFinishedSound();
            if (ok) {
                LoadGCode(destinationFile);
                TabToDraw();
            }
            Halt();
        }
    };

    s.addPropertyChangeListener(new PropertyChangeListener() {
        // Invoked when task's progress property changes.
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == evt.getPropertyName()) {
                int progress = (Integer) evt.getNewValue();
                pm.setProgress(progress);
                String message = String.format("%d%%\n", progress);
                pm.setNote(message);
                if (s.isDone()) {
                    Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
                } else if (s.isCancelled() || pm.isCanceled()) {
                    if (pm.isCanceled()) {
                        s.cancel(true);
                    }
                    Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n");
                }
            }
        }
    });

    s.execute();

    return true;
}

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

/**
 * Reacts to property changed. //from  w  w  w.  j ava 2  s  .c  o  m
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent pce) {
    String name = pce.getPropertyName();
    if (name == null)
        return;
    if (TreeViewer.CANCEL_LOADING_PROPERTY.equals(name)) {
        Browser browser = model.getSelectedBrowser();
        if (browser != null)
            browser.cancel();
    } else if (Browser.POPUP_MENU_PROPERTY.equals(name)) {
        Integer c = (Integer) pce.getNewValue();
        Browser browser = model.getSelectedBrowser();
        if (browser != null)
            view.showPopup(c.intValue(), browser.getClickComponent(), browser.getClickPoint());
    } else if (Browser.CLOSE_PROPERTY.equals(name)) {
        Browser browser = (Browser) pce.getNewValue();
        if (browser != null)
            view.removeBrowser(browser);
    } else if (TreeViewer.FINDER_VISIBLE_PROPERTY.equals(name)) {
        Boolean b = (Boolean) pce.getNewValue();
        if (!b.booleanValue()) {
            model.clearFoundResults();
            model.onComponentStateChange(true);
        }
    } else if (TreeViewer.SELECTED_BROWSER_PROPERTY.equals(name)) {
        Browser b = model.getSelectedBrowser();
        Iterator i = model.getBrowsers().values().iterator();
        Browser browser;
        while (i.hasNext()) {
            browser = (Browser) i.next();
            browser.setSelected(browser.equals(b));
        }
    } else if (Browser.SELECTED_TREE_NODE_DISPLAY_PROPERTY.equals(name)) {
        model.onSelectedDisplay();
        view.updateMenuItems();
    } else if (TreeViewer.HIERARCHY_ROOT_PROPERTY.equals(name)) {
        /*
         Map browsers = model.getBrowsers();
         Iterator i = browsers.values().iterator();
         Browser browser;
         while (i.hasNext()) {
            browser = (Browser) i.next();
            //browser.cleanFilteredNodes();
            //browser.switchUser();
         }
         */
    } else if (AddExistingObjectsDialog.EXISTING_ADD_PROPERTY.equals(name)) {
        model.addExistingObjects((Set) pce.getNewValue());
    } else if (UserManagerDialog.USER_SWITCH_PROPERTY.equals(name)) {
        Map m = (Map) pce.getNewValue();
        Iterator i = m.entrySet().iterator();
        Long groupID;
        List<ExperimenterData> users;
        Entry entry;
        while (i.hasNext()) {
            entry = (Entry) i.next();
            groupID = (Long) entry.getKey();
            users = (List<ExperimenterData>) entry.getValue();
            model.setHierarchyRoot(groupID, users);
        }
    } else if (UserManagerDialog.NO_USER_SWITCH_PROPERTY.equals(name)) {
        UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
        un.notifyInfo("User Selection", "Please select a user first.");
    } else if (EditorDialog.CREATE_PROPERTY.equals(name)) {
        DataObject data = (DataObject) pce.getNewValue();
        model.createObject(data, true);
    } else if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) {
        DataObject data = (DataObject) pce.getNewValue();
        model.createObject(data, false);
    } else if (MetadataViewer.ON_DATA_SAVE_PROPERTY.equals(name)) {
        Object object = pce.getNewValue();
        if (object != null) {
            if (object instanceof DataObject)
                model.onDataObjectSave((DataObject) object, TreeViewer.UPDATE_OBJECT);
            else
                model.onDataObjectSave((List) object, TreeViewer.UPDATE_OBJECT);
        }
    } else if (DataBrowser.SELECTED_NODE_DISPLAY_PROPERTY.equals(name)) {
        model.setSelectedNode(pce.getNewValue());
    } else if (DataBrowser.UNSELECTED_NODE_DISPLAY_PROPERTY.equals(name)) {
        model.setUnselectedNode(pce.getNewValue());
    } else if (DataBrowser.DATA_OBJECT_CREATED_PROPERTY.equals(name)) {
        Map map = (Map) pce.getNewValue();
        if (map != null && map.size() == 1) {
            DataObject data = null;
            Set set = map.entrySet();
            Entry entry;
            Iterator i = set.iterator();
            Object o;
            DataObject parent = null;
            while (i.hasNext()) {
                entry = (Entry) i.next();
                data = (DataObject) entry.getKey();
                o = entry.getValue();
                if (o != null)
                    parent = (DataObject) o;
                break;
            }
            if (parent == null)
                model.onOrphanDataObjectCreated(data);
            else
                model.onDataObjectSave(data, parent, TreeViewer.CREATE_OBJECT);
        }
    } else if (DataBrowser.ADDED_TO_DATA_OBJECT_PROPERTY.equals(name)) {
        //Browser browser =  model.getSelectedBrowser();
        //if (browser != null) browser.refreshLoggedExperimenterData();
        model.refreshTree();
    } else if (DataBrowser.COPY_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        if (data != null)
            model.copyRndSettings((ImageData) data);
        else
            model.copyRndSettings(null);
    } else if (DataBrowser.PASTE_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        PasteRndSettingsCmd cmd;
        if (data instanceof Collection)
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE, (Collection) data);
        else
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE);
        cmd.execute();
    } else if (DataBrowser.RESET_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        PasteRndSettingsCmd cmd;
        if (data instanceof Collection)
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.RESET, (Collection) data);
        else
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.RESET);
        cmd.execute();
    } else if (DataBrowser.SET__ORIGINAL_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        PasteRndSettingsCmd cmd;
        if (data instanceof Collection)
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_MIN_MAX, (Collection) data);
        else
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_MIN_MAX);
        cmd.execute();
    } else if (DataBrowser.SET__ORIGINAL_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        PasteRndSettingsCmd cmd;
        if (data instanceof Collection)
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER, (Collection) data);
        else
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER);
        cmd.execute();
    } else if (DataBrowser.CUT_ITEMS_PROPERTY.equals(name)) {
        CutCmd cmd = new CutCmd(model);
        cmd.execute();
    } else if (DataBrowser.COPY_ITEMS_PROPERTY.equals(name)) {
        CopyCmd cmd = new CopyCmd(model);
        cmd.execute();
    } else if (DataBrowser.PASTE_ITEMS_PROPERTY.equals(name)) {
        PasteCmd cmd = new PasteCmd(model);
        cmd.execute();
    } else if (DataBrowser.REMOVE_ITEMS_PROPERTY.equals(name)) {
        DeleteCmd cmd = new DeleteCmd(model.getSelectedBrowser());
        cmd.execute();
    } else if (DataBrowser.VIEW_IMAGE_NODE_PROPERTY.equals(name)) {
        //view.get
        Browser browser = model.getSelectedBrowser();
        if (browser != null) {
            TreeImageDisplay node = browser.getLastSelectedDisplay();
            model.browse(node, (DataObject) pce.getNewValue(), false);
        }
    } else if (DataBrowser.INTERNAL_VIEW_NODE_PROPERTY.equals(name)) {
        ViewCmd cmd = new ViewCmd(model, true);
        cmd.execute();
    } else if (Finder.RESULTS_FOUND_PROPERTY.equals(name)) {
        model.setSearchResult(pce.getNewValue());
    } else if (GenericDialog.SAVE_GENERIC_PROPERTY.equals(name)) {
        Object parent = pce.getNewValue();
        if (parent instanceof MetadataViewer) {
            MetadataViewer mv = (MetadataViewer) parent;
            mv.saveData();
        }
    } else if (Browser.DATA_REFRESHED_PROPERTY.equals(name)) {
        model.onSelectedDisplay();
    } else if (MetadataViewer.ADMIN_UPDATED_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        Map browsers = model.getBrowsers();
        Set set = browsers.entrySet();
        Entry entry;
        Iterator i = set.iterator();
        Browser browser;
        while (i.hasNext()) {
            entry = (Entry) i.next();
            browser = (Browser) entry.getValue();
            browser.refreshAdmin(data);
        }
        view.createTitle();
    } else if (DataBrowser.TAG_WIZARD_PROPERTY.equals(name)) {
        model.showTagWizard();
    } else if (DataBrowser.FIELD_SELECTED_PROPERTY.equals(name)) {
        model.setSelectedField(pce.getNewValue());
    } else if (MetadataViewer.RENDER_THUMBNAIL_PROPERTY.equals(name)) {
        long imageID = ((Long) pce.getNewValue()).longValue();
        List<Long> ids = new ArrayList<Long>(1);
        ids.add(imageID);
        view.reloadThumbnails(ids);
    } else if (MetadataViewer.APPLY_SETTINGS_PROPERTY.equals(name)) {
        Object object = pce.getNewValue();
        if (object instanceof ImageData) {
            ImageData img = (ImageData) object;
            model.copyRndSettings((ImageData) object);
            List<Long> ids = new ArrayList<Long>(1);
            ids.add(img.getId());
            view.reloadThumbnails(ids);

            //improve code to speed it up
            List l = model.getSelectedBrowser().getSelectedDataObjects();
            Collection toUpdate;
            if (l.size() > 1)
                toUpdate = l;
            else
                toUpdate = model.getDisplayedImages();
            if (toUpdate != null) {
                PasteRndSettingsCmd cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE, toUpdate);
                cmd.execute();
            }
        } else if (object instanceof Object[]) {
            Object[] objects = (Object[]) object;
            WellSampleData wsd = (WellSampleData) objects[0];
            WellData well = (WellData) objects[1];
            ImageData img = wsd.getImage();
            model.copyRndSettings(img);
            List<Long> ids = new ArrayList<Long>(1);
            ids.add(img.getId());
            view.reloadThumbnails(ids);
            ids = new ArrayList<Long>(1);
            ids.add(well.getPlate().getId());
            model.pasteRndSettings(ids, PlateData.class);
        }
    } else if (JXTaskPaneContainerSingle.SELECTED_TASKPANE_PROPERTY.equals(name)) {
        handleTaskPaneSelection((JXTaskPane) pce.getNewValue());
    } else if (MetadataViewer.GENERATE_FIGURE_PROPERTY.equals(name)) {
        Object object = pce.getNewValue();
        if (!(object instanceof FigureParam))
            return;
        UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
        IconManager icons = IconManager.getInstance();
        Icon icon = icons.getIcon(IconManager.SPLIT_VIEW_FIGURE_22);
        FigureActivityParam activity;
        List<Long> ids = new ArrayList<Long>();
        Iterator i;
        DataObject obj;
        FigureParam param = (FigureParam) object;
        Collection l;
        if (param.isSelectedObjects()) {
            Browser b = model.getSelectedBrowser();
            if (b != null)
                l = b.getSelectedDataObjects();
            else {
                l = new ArrayList<DataObject>();
                Collection<DataObject> nodes = model.getSelectedObjectsFromBrowser();
                if (nodes != null) {
                    l.addAll(nodes);
                }
            }
        } else {
            l = model.getDisplayedImages();
        }
        if (CollectionUtils.isEmpty(l))
            return;
        Class klass = null;
        Object p = null;
        if (param.getIndex() == FigureParam.THUMBNAILS) {
            Browser browser = model.getSelectedBrowser();
            if (browser != null) {
                TreeImageDisplay[] nodes = browser.getSelectedDisplays();
                if (nodes != null && nodes.length > 0) {
                    TreeImageDisplay node = nodes[0];
                    Object ho = node.getUserObject();
                    TreeImageDisplay pNode;
                    if (ho instanceof DatasetData) {
                        klass = ho.getClass();
                        p = ho;
                    } else if (ho instanceof ImageData) {
                        klass = ho.getClass();
                        pNode = node.getParentDisplay();
                        if (pNode != null) {
                            p = pNode.getUserObject();
                            if (!(p instanceof DatasetData))
                                p = null;
                        }
                        if (p == null)
                            p = ho;
                    }
                    if (p != null)
                        param.setAnchor((DataObject) p);
                }
            }
        }

        i = l.iterator();
        int n = 0;
        List<Long> groupIds = new ArrayList<Long>();
        boolean canRun = true;
        while (i.hasNext()) {
            obj = (DataObject) i.next();
            if (groupIds.size() == 0)
                groupIds.add(obj.getGroupId());
            if (groupIds.contains(obj.getGroupId())) {
                ids.add(obj.getId());
                if (n == 0)
                    p = obj;
                n++;
            } else {
                canRun = false;
                break;
            }
        }
        if (!canRun) {
            un.notifyInfo("Script", "You can run the script only\non " + "objects from the same group");
            return;
        }
        if (ids.size() == 0)
            return;
        // not set
        if (param.getIndex() != FigureParam.THUMBNAILS)
            param.setAnchor((DataObject) p);

        activity = new FigureActivityParam(object, ids, klass, FigureActivityParam.SPLIT_VIEW_FIGURE);
        activity.setIcon(icon);
        un.notifyActivity(new SecurityContext(groupIds.get(0)), activity);
    } else if (MetadataViewer.HANDLE_SCRIPT_PROPERTY.equals(name)) {
        UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
        ScriptActivityParam p = (ScriptActivityParam) pce.getNewValue();
        int index = p.getIndex();
        ScriptObject script = p.getScript();
        if (index == ScriptActivityParam.VIEW) {
            Environment env = (Environment) TreeViewerAgent.getRegistry().lookup(LookupNames.ENV);
            String path = env.getOmeroFilesHome();
            path += File.separator + script.getName();
            File f = new File(path);
            DownloadAndLaunchActivityParam activity = new DownloadAndLaunchActivityParam(
                    p.getScript().getScriptID(), DownloadAndLaunchActivityParam.ORIGINAL_FILE, f, null);

            un.notifyActivity(model.getSecurityContext(), activity);
        } else if (index == ScriptActivityParam.DOWNLOAD) {
            downloadScript(p);
        }
    } else if (OpenWithDialog.OPEN_DOCUMENT_PROPERTY.equals(name)) {
        ApplicationData data = (ApplicationData) pce.getNewValue();
        //Register 
        if (data == null)
            return;
        String format = view.getObjectMimeType();
        //if (format == null) return;
        if (format != null)
            TreeViewerFactory.register(data, format);
        model.openWith(data);
    } else if (DataBrowser.OPEN_EXTERNAL_APPLICATION_PROPERTY.equals(name)) {
        model.openWith((ApplicationData) pce.getNewValue());
    } else if (AdminDialog.CREATE_ADMIN_PROPERTY.equals(name)) {
        AdminObject object = (AdminObject) pce.getNewValue();
        model.administrate(object);
    } else if (MetadataViewer.REGISTER_PROPERTY.equals(name)) {
        model.register((DataObjectRegistration) pce.getNewValue());
    } else if (MetadataViewer.RESET_PASSWORD_PROPERTY.equals(name)) {
        model.resetPassword((String) pce.getNewValue());
    } else if (MetadataViewer.UPLOAD_SCRIPT_PROPERTY.equals(name)) {
        TreeViewerAction action = getAction(UPLOAD_SCRIPT);
        action.actionPerformed(new ActionEvent(this, 1, ""));
    } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) {
        Map m = (Map) pce.getNewValue();
        if (m == null || m.size() != 1)
            return;
        Entry entry;
        Iterator i = m.entrySet().iterator();
        Class klass;
        TreeImageDisplay node;
        Collection<ExperimenterData> list;
        Object uo;
        AdminObject object;
        while (i.hasNext()) {
            entry = (Entry) i.next();
            klass = (Class) entry.getKey();
            if (ExperimenterData.class.equals(klass)) {
                list = (Collection<ExperimenterData>) entry.getValue();
                node = model.getSelectedBrowser().getLastSelectedDisplay();
                if (node != null) {
                    uo = node.getUserObject();
                    if (uo instanceof GroupData) {
                        object = new AdminObject((GroupData) uo, list);
                        model.administrate(object);
                    }
                }
            }
        }
    } else if (DataBrowser.SET__OWNER_RND_SETTINGS_PROPERTY.equals(name)) {
        Object data = pce.getNewValue();
        PasteRndSettingsCmd cmd;
        if (data instanceof Collection)
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER, (Collection) data);
        else
            cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER);
        cmd.execute();
    } else if (ScriptingDialog.RUN_SELECTED_SCRIPT_PROPERTY.equals(name)) {
        handleScript((ScriptObject) pce.getNewValue(), ScriptActivityParam.RUN);
    } else if (ScriptingDialog.DOWNLOAD_SELECTED_SCRIPT_PROPERTY.equals(name)) {
        Object value = pce.getNewValue();
        if (value instanceof ScriptObject)
            handleScript((ScriptObject) value, ScriptActivityParam.DOWNLOAD);
        else if (value instanceof String) {
            ScriptObject script = view.getScriptFromName((String) value);
            if (script != null)
                handleScript(script, ScriptActivityParam.DOWNLOAD);
        }
    } else if (ScriptingDialog.VIEW_SELECTED_SCRIPT_PROPERTY.equals(name)) {
        Object value = pce.getNewValue();
        if (value instanceof ScriptObject)
            handleScript((ScriptObject) value, ScriptActivityParam.VIEW);
        else if (value instanceof String) {
            ScriptObject script = view.getScriptFromName((String) value);
            if (script != null)
                handleScript(script, ScriptActivityParam.VIEW);
        }
    } else if (TreeViewer.SCRIPTS_LOADING_PROPERTY.equals(name)) {
        view.setScriptsLoadingStatus(true);
    } else if (TreeViewer.SCRIPTS_LOADED_PROPERTY.equals(name)) {
        view.setScriptsLoadingStatus(false);
    } else if (DataBrowser.SELECTED_DATA_BROWSER_NODES_DISPLAY_PROPERTY.equals(name)) {
        model.setSelectedNodes(pce.getNewValue());
    } else if (TreeViewer.GROUP_CHANGED_PROPERTY.equals(name)) {
        view.setPermissions();
    } else if (MacOSMenuHandler.QUIT_APPLICATION_PROPERTY.equals(name)) {
        Action a = getAction(EXIT);
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
        a.actionPerformed(event);
    } else if (GroupManagerDialog.GROUP_SWITCH_PROPERTY.equals(name)) {
        List<GroupData> groups = (List<GroupData>) pce.getNewValue();
        if (groups.size() == 0) {
            UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
            un.notifyInfo(GroupManagerDialog.TITLE, "At least one group " + "must be selected.");
            return;
        }
        model.setUserGroup(groups);
    } else if (DataBrowser.ACTIVATE_USER_PROPERTY.equals(name)) {
        ExperimenterData exp = (ExperimenterData) pce.getNewValue();
        if (exp != null)
            model.activateUser(exp);
    } else if (DataBrowser.RESET_PASSWORD_PROPERTY.equals(name)) {
        getAction(RESET_PASSWORD).actionPerformed(new ActionEvent(pce.getNewValue(), 0, "Reset Password"));
    }
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * @param theMessage//  w  w  w  .  j a v  a  2s  . c  o  m
 *            the message to set
 */
public void setMessage(Hl7V2MessageCollection theMessage) {
    Validate.isTrue(myMessage == null);

    myMessage = theMessage;

    myShowCombo.setModel(new ShowComboModel());

    // Prepopulate the "send to interface" combo to the last value it had
    if (StringUtils.isNotBlank(myMessage.getLastSendToInterfaceId())) {
        for (int i = 0; i < myOutboundInterfaceComboModelShadow.size(); i++) {
            if (myOutboundInterfaceComboModelShadow.get(i).getId()
                    .equals(myMessage.getLastSendToInterfaceId())) {
                myOutboundInterfaceCombo.setSelectedIndex(i);
                break;
            }
        }
    }

    updateEncodingButtons();
    myRdbtnEr7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            removeHighlights();
            myMessage.setEncoding(Hl7V2EncodingTypeEnum.ER_7);
        }
    });
    myRdbtnXml.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            removeHighlights();
            myMessage.setEncoding(Hl7V2EncodingTypeEnum.XML);
        }
    });

    try {
        myDisableCaretUpdateHandling = true;
        updateMessageEditor();
    } finally {
        myDisableCaretUpdateHandling = false;
    }

    myMessageListeneer = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            if (myDontRespondToSourceMessageChanges) {
                return;
            }
            try {
                myDisableCaretUpdateHandling = true;
                updateMessageEditor();
            } finally {
                myDisableCaretUpdateHandling = false;
            }
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.SOURCE_MESSAGE_PROPERTY, myMessageListeneer);

    mySelectedPathListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            String path = myMessage.getHighlitedPath();
            if (path == null) {
                path = "";
            }

            int index = path.indexOf('/');
            if (index > -1) {
                path = path.substring(index);
            }

            myTerserPathTextField.setText(path);
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_HIGHLITED_PATH, mySelectedPathListener);

    myTreePanel.setMessage(myMessage);

    myRangeListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            if (theEvt.getNewValue() == null || !myFollowToggle.isSelected()) {
                return;
            }
            Range range = (Range) theEvt.getNewValue();

            // myMessageScrollPane.getHorizontalScrollBar().setValue(0);

            // myMessageEditor.select(range.getStart(), range.getEnd());
            // myMessageEditor.setCaretPosition(range.getStart());

            myMessageEditor.setCaretPosition(range.getStart());
            myMessageEditor.moveCaretPosition(range.getEnd());

            myMessageEditor.setCaretPosition(range.getEnd());
            myMessageEditor.moveCaretPosition(range.getStart());

            // myMessageEditor.grabFocus();
            myMessageEditor.repaint();

            String substring = myMessage.getSourceMessage().substring(range.getStart(), range.getEnd());
            ourLog.info("Selected range set to " + range + " which is " + substring);
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_HIGHLITED_RANGE, myRangeListener);

    myProfileComboboxModel.update();

    // Window Title
    myWindowTitleListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            updateWindowTitle();
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.SAVED_PROPERTY, myWindowTitleListener);
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_SAVE_FILENAME, myWindowTitleListener);
    updateWindowTitle();

    EventQueue.invokeLater(new Runnable() {

        public void run() {
            myMessageEditor.setCaretPosition(0);
            myMessageEditor.grabFocus();
        }
    });

}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/**
 * Reacts to the D&D properties./* w  w  w  .  ja  v  a 2s.  co m*/
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (DnDTree.DRAGGED_PROPERTY.equals(name)) {
        ObjectToTransfer transfer = (ObjectToTransfer) evt.getNewValue();
        int action = TreeViewer.CUT_AND_PASTE;
        if (transfer.getDropAction() == DnDConstants.ACTION_COPY)
            action = TreeViewer.COPY_AND_PASTE;
        //check the node
        model.transfer(transfer.getTarget(), transfer.getNodes(), action);
    }
}

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

/**
 * Activates itself as a viewer by configuring Size, and location of itself,
 * and configures the default Tabbed Pane elements with the correct layout,
 * table columns, and sets itself viewable.
 *///from   w ww .  j a v  a2  s  .c  o m
public void activateViewer() {
    LoggerRepository repo = LogManager.getLoggerRepository();
    if (repo instanceof LoggerRepositoryEx) {
        this.pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry();
    }
    initGUI();

    initPrefModelListeners();

    /**
     * We add a simple appender to the MessageCenter logger
     * so that each message is displayed in the Status bar
     */
    MessageCenter.getInstance().getLogger().addAppender(new AppenderSkeleton() {
        protected void append(LoggingEvent event) {
            getStatusBar().setMessage(event.getMessage().toString());
        }

        public void close() {
        }

        public boolean requiresLayout() {
            return false;
        }
    });

    initSocketConnectionListener();

    if (pluginRegistry.getPlugins(Receiver.class).size() == 0) {
        noReceiversDefined = true;
    }

    getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.THREAD_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.NDC_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.PROPERTIES_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.CLASS_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.METHOD_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.FILE_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.NONE_COL_NAME);

    JPanel panePanel = new JPanel();
    panePanel.setLayout(new BorderLayout(2, 2));

    getContentPane().setLayout(new BorderLayout());

    getTabbedPane().addChangeListener(getToolBarAndMenus());
    getTabbedPane().addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            LogPanel thisLogPanel = getCurrentLogPanel();
            if (thisLogPanel != null) {
                thisLogPanel.updateStatusBar();
            }
        }
    });

    KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    KeyStroke ksLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    KeyStroke ksGotoLine = KeyStroke.getKeyStroke(KeyEvent.VK_G,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksRight, "MoveRight");
    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksLeft, "MoveLeft");
    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksGotoLine, "GotoLine");

    Action moveRight = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            int temp = getTabbedPane().getSelectedIndex();
            ++temp;

            if (temp != getTabbedPane().getTabCount()) {
                getTabbedPane().setSelectedTab(temp);
            }
        }
    };

    Action moveLeft = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            int temp = getTabbedPane().getSelectedIndex();
            --temp;

            if (temp > -1) {
                getTabbedPane().setSelectedTab(temp);
            }
        }
    };

    Action gotoLine = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number to go:",
                    "Goto Line", -1);
            try {
                int lineNumber = Integer.parseInt(inputLine);
                int row = getCurrentLogPanel().setSelectedEvent(lineNumber);
                if (row == -1) {
                    JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number",
                            "Error", 0);
                }
            } catch (NumberFormatException nfe) {
                JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error",
                        0);
            }
        }
    };

    getTabbedPane().getActionMap().put("MoveRight", moveRight);
    getTabbedPane().getActionMap().put("MoveLeft", moveLeft);
    getTabbedPane().getActionMap().put("GotoLine", gotoLine);

    /**
         * We listen for double clicks, and auto-undock currently selected Tab if
         * the mouse event location matches the currently selected tab
         */
    getTabbedPane().addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            if ((e.getClickCount() > 1) && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) {
                int tabIndex = getTabbedPane().getSelectedIndex();

                if ((tabIndex != -1) && (tabIndex == getTabbedPane().getSelectedIndex())) {
                    LogPanel logPanel = getCurrentLogPanel();

                    if (logPanel != null) {
                        logPanel.undock();
                    }
                }
            }
        }
    });

    panePanel.add(getTabbedPane());
    addWelcomePanel();

    getContentPane().add(toolbar, BorderLayout.NORTH);
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    mainReceiverSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panePanel, receiversPanel);
    dividerSize = mainReceiverSplitPane.getDividerSize();
    mainReceiverSplitPane.setDividerLocation(-1);

    getContentPane().add(mainReceiverSplitPane, BorderLayout.CENTER);

    /**
     * We need to make sure that all the internal GUI components have been added to the
     * JFrame so that any plugns that get activated during initPlugins(...) method
     * have access to inject menus  
     */
    initPlugins(pluginRegistry);

    mainReceiverSplitPane.setResizeWeight(1.0);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            exit();
        }
    });
    preferencesFrame.setTitle("'Application-wide Preferences");
    preferencesFrame.setIconImage(((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage());
    preferencesFrame.getContentPane().add(applicationPreferenceModelPanel);

    preferencesFrame.setSize(750, 520);

    Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    preferencesFrame.setLocation(new Point((screenDimension.width / 2) - (preferencesFrame.getSize().width / 2),
            (screenDimension.height / 2) - (preferencesFrame.getSize().height / 2)));

    pack();

    final JPopupMenu tabPopup = new JPopupMenu();
    final Action hideCurrentTabAction = new AbstractAction("Hide") {
        public void actionPerformed(ActionEvent e) {
            Component selectedComp = getTabbedPane().getSelectedComponent();
            if (selectedComp instanceof LogPanel) {
                displayPanel(getCurrentLogPanel().getIdentifier(), false);
                tbms.stateChange();
            } else {
                getTabbedPane().remove(selectedComp);
            }
        }
    };

    final Action hideOtherTabsAction = new AbstractAction("Hide Others") {
        public void actionPerformed(ActionEvent e) {
            Component selectedComp = getTabbedPane().getSelectedComponent();
            String currentName;
            if (selectedComp instanceof LogPanel) {
                currentName = getCurrentLogPanel().getIdentifier();
            } else if (selectedComp instanceof WelcomePanel) {
                currentName = ChainsawTabbedPane.WELCOME_TAB;
            } else {
                currentName = ChainsawTabbedPane.ZEROCONF;
            }

            int count = getTabbedPane().getTabCount();
            int index = 0;

            for (int i = 0; i < count; i++) {
                String name = getTabbedPane().getTitleAt(index);

                if (getPanelMap().keySet().contains(name) && !name.equals(currentName)) {
                    displayPanel(name, false);
                    tbms.stateChange();
                } else {
                    index++;
                }
            }
        }
    };

    Action showHiddenTabsAction = new AbstractAction("Show All Hidden") {
        public void actionPerformed(ActionEvent e) {
            for (Iterator iter = getPanels().entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                Boolean docked = (Boolean) entry.getValue();
                if (docked.booleanValue()) {
                    String identifier = (String) entry.getKey();
                    int count = getTabbedPane().getTabCount();
                    boolean found = false;

                    for (int i = 0; i < count; i++) {
                        String name = getTabbedPane().getTitleAt(i);

                        if (name.equals(identifier)) {
                            found = true;

                            break;
                        }
                    }

                    if (!found) {
                        displayPanel(identifier, true);
                        tbms.stateChange();
                    }
                }
            }
        }
    };

    tabPopup.add(hideCurrentTabAction);
    tabPopup.add(hideOtherTabsAction);
    tabPopup.addSeparator();
    tabPopup.add(showHiddenTabsAction);

    final PopupListener tabPopupListener = new PopupListener(tabPopup);
    getTabbedPane().addMouseListener(tabPopupListener);

    this.handler.addPropertyChangeListener("dataRate", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            double dataRate = ((Double) evt.getNewValue()).doubleValue();
            statusBar.setDataRate(dataRate);
        }
    });

    getSettingsManager().addSettingsListener(this);
    getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance());
    getSettingsManager().addSettingsListener(receiversPanel);
    try {
        //if an uncaught exception is thrown, allow the UI to continue to load
        getSettingsManager().loadSettings();
    } catch (Exception e) {
        e.printStackTrace();
    }
    //app preferences have already been loaded (and configuration url possibly set to blank if being overridden)
    //but we need a listener so the settings will be saved on exit (added after loadsettings was called)
    getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel));

    setVisible(true);

    if (applicationPreferenceModel.isReceivers()) {
        showReceiverPanel();
    } else {
        hideReceiverPanel();
    }

    removeSplash();

    synchronized (initializationLock) {
        isGUIFullyInitialized = true;
        initializationLock.notifyAll();
    }

    if (noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) {
        SwingHelper.invokeOnEDT(new Runnable() {
            public void run() {
                showReceiverConfigurationPanel();
            }
        });
    }

    Container container = tutorialFrame.getContentPane();
    final JEditorPane tutorialArea = new JEditorPane();
    tutorialArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tutorialArea.setEditable(false);
    container.setLayout(new BorderLayout());

    try {
        tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL);
        JTextComponentFormatter.applySystemFontAndSize(tutorialArea);

        container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER);
    } catch (Exception e) {
        MessageCenter.getInstance().getLogger().error("Error occurred loading the Tutorial", e);
    }

    tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage());
    tutorialFrame.setSize(new Dimension(640, 480));

    final Action startTutorial = new AbstractAction("Start Tutorial",
            new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(null,
                    "This will start 3 \"Generator\" receivers for use in the Tutorial.  Is that ok?",
                    "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                new Thread(new Tutorial()).start();
                putValue("TutorialStarted", Boolean.TRUE);
            } else {
                putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    };

    final Action stopTutorial = new AbstractAction("Stop Tutorial",
            new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(null,
                    "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched.  Is that ok?",
                    "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                new Thread(new Runnable() {
                    public void run() {
                        LoggerRepository repo = LogManager.getLoggerRepository();
                        if (repo instanceof LoggerRepositoryEx) {
                            PluginRegistry pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry();
                            List list = pluginRegistry.getPlugins(Generator.class);

                            for (Iterator iter = list.iterator(); iter.hasNext();) {
                                Plugin plugin = (Plugin) iter.next();
                                pluginRegistry.stopPlugin(plugin.getName());
                            }
                        }
                    }
                }).start();
                setEnabled(false);
                startTutorial.putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    };

    stopTutorial.putValue(Action.SHORT_DESCRIPTION,
            "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched");
    startTutorial.putValue(Action.SHORT_DESCRIPTION,
            "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action");
    stopTutorial.setEnabled(false);

    final SmallToggleButton startButton = new SmallToggleButton(startTutorial);
    PropertyChangeListener pcl = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            stopTutorial.setEnabled(((Boolean) startTutorial.getValue("TutorialStarted")).equals(Boolean.TRUE));
            startButton.setSelected(stopTutorial.isEnabled());
        }
    };

    startTutorial.addPropertyChangeListener(pcl);
    stopTutorial.addPropertyChangeListener(pcl);

    pluginRegistry.addPluginListener(new PluginListener() {
        public void pluginStarted(PluginEvent e) {
        }

        public void pluginStopped(PluginEvent e) {
            List list = pluginRegistry.getPlugins(Generator.class);

            if (list.size() == 0) {
                startTutorial.putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    });

    final SmallButton stopButton = new SmallButton(stopTutorial);

    final JToolBar tutorialToolbar = new JToolBar();
    tutorialToolbar.setFloatable(false);
    tutorialToolbar.add(startButton);
    tutorialToolbar.add(stopButton);
    container.add(tutorialToolbar, BorderLayout.NORTH);
    tutorialArea.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (e.getDescription().equals("StartTutorial")) {
                    startTutorial.actionPerformed(null);
                } else if (e.getDescription().equals("StopTutorial")) {
                    stopTutorial.actionPerformed(null);
                } else {
                    try {
                        tutorialArea.setPage(e.getURL());
                    } catch (IOException e1) {
                        MessageCenter.getInstance().getLogger()
                                .error("Failed to change the URL for the Tutorial", e1);
                    }
                }
            }
        }
    });

    /**
     * loads the saved tab settings and if there are hidden tabs,
     * hide those tabs out of currently loaded tabs..
     */

    if (!getTabbedPane().tabSetting.isWelcome()) {
        displayPanel(ChainsawTabbedPane.WELCOME_TAB, false);
    }
    if (!getTabbedPane().tabSetting.isZeroconf()) {
        displayPanel(ChainsawTabbedPane.ZEROCONF, false);
    }
    tbms.stateChange();

}

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

/**
 * Reacts to property fired by the table.
 * //from  w ww .j ava  2 s .c o  m
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();

    if (FileSelectionTable.ADD_PROPERTY.equals(name)) {
        showLocationDialog();
    } else if (FileSelectionTable.REMOVE_PROPERTY.equals(name)) {
        int n = handleFilesSelection(chooser.getSelectedFiles());
        table.allowAddition(n > 0);
        importButton.setEnabled(table.hasFilesToImport());
    } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(name)) {
        int n = handleFilesSelection(chooser.getSelectedFiles());
        table.allowAddition(n > 0);
    } else if (NumericalTextField.TEXT_UPDATED_PROPERTY.equals(name)) {
        if (partialName.isSelected()) {
            Integer number = (Integer) numberOfFolders.getValueAsNumber();
            if (number != null && number >= 0)
                table.applyToAll();
        }
    } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) {
        Map m = (Map) evt.getNewValue();
        if (m == null || m.size() != 1)
            return;
        Set set = m.entrySet();
        Entry entry;
        Iterator i = set.iterator();
        Class type;
        while (i.hasNext()) {
            entry = (Entry) i.next();
            type = (Class) entry.getKey();
            if (TagAnnotationData.class.getName().equals(type.getName()))
                handleTagsSelection((Collection<TagAnnotationData>) entry.getValue());
        }
    } else if (ImportDialog.PROPERTY_GROUP_CHANGED.equals(name)
            || ImportDialog.REFRESH_LOCATION_PROPERTY.equals(name)
            || ImportDialog.CREATE_OBJECT_PROPERTY.equals(name)) {
        firePropertyChange(name, evt.getOldValue(), evt.getNewValue());
    } else if (LocationDialog.ADD_TO_QUEUE_PROPERTY.equals(name)) {
        Object src = evt.getSource();
        if (src != detachedDialog) {
            addImageJFiles(null, null);
        }
    }
}

From source file:GUI.PizzaCat.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if ("progress" == evt.getPropertyName()) {
        int progress = (Integer) evt.getNewValue();
        taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress()));
    }/*w  w w  .  j ava  2s  .  co  m*/
}