Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

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

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:ds.monte.carlo.Application.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if ("progress".equals(evt.getPropertyName())) {
        int progress = (Integer) evt.getNewValue();
        jProgressBar1.setValue(progress);
        if (progress == 100) {
            createFrequencyGraph(monteCarlo.getDictionary());
            createGrowthGraph(monteCarlo.getGrowthMap());
            createLengthGraph(monteCarlo.findProbability());
            ImageIcon img = new ImageIcon("img.png");
            this.setIconImage(img.getImage());
            jLabel13.setText(((double) monteCarlo.getSuccessful() / numberOfReplications) * 100 + "%");
            jLabel16.setText(monteCarlo.getAvg() + "");
            jLabel18.setText(monteCarlo.getP80() + "");
        }//  w  w w  .  ja v  a 2  s.com
    }
}

From source file:ch.fork.AdHocRailway.ui.locomotives.configuration.LocomotiveConfig.java

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final Locomotive locomotive = presentationModel.getBean();

    if (event.getPropertyName().equals(Locomotive.PROPERTYNAME_LOCOMOTIVE_TYPE)) {
        initializeFunctions(locomotive);

    }//from  w ww.  java2s.  com

    if (!validate(locomotive, event)) {
        return;
    }
}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.GeneManiaSubInspector.java

private void registerDownloadListener() {
    try {//from ww  w.j  a  v  a  2 s . c o  m
        DownloadTask downloadTask = GenemaniaInfoRetriever.getGeneManiaDownloadTask();
        if (currentDownloadTask != downloadTask) {
            currentDownloadTask = downloadTask;

            final DownloadTask dt = downloadTask;
            dt.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("downloadState")) {
                        DownloadState ds = (DownloadState) evt.getNewValue();
                        if (ds == DownloadState.CANCELLED) {
                            panel.removeAll();
                            panel.add(downloadGeneManiaButton);
                            panel.revalidate();
                            panel.repaint();
                        } else if (ds == DownloadState.FINISHED) {
                            //this should always be true.
                            if (DirectorySettings.isGeneManiaInstalled()) {
                                try {
                                    dataPresent = true;
                                    genemania = new GenemaniaInfoRetriever();
                                    genemaniaSettings = new GeneManiaSettingsDialog(genemania);
                                    panel.removeAll();
                                    buildPanel();
                                    updateRelatedGenesPanel(genes);
                                } catch (IOException e) {
                                    DialogUtils.displayMessage("Error downloading GeneMANIA files");
                                    LOG.error("Error downloading GeneMANIA files " + e);
                                    dataPresent = false;
                                }
                            } else {
                                LOG.error("Error downloading GeneMANIA files.");
                            }
                        }
                    }
                }
            });
        }
    } catch (IOException e) {
    }
}

From source file:be.nbb.demetra.dfm.output.ConfidenceGraph.java

public ConfidenceGraph() {
    chartPanel = new ChartPanel(createMarginViewChart());
    chartPanel.setMouseWheelEnabled(true);
    data = new ConfidenceData(null, null, null);
    revealObs = new RevealObs();

    Charts.avoidScaling(chartPanel);//from   w  w  w. ja v  a2 s  .  c o  m
    Charts.enableFocusOnClick(chartPanel);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);

    addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (evt.getPropertyName()) {
        case DATA_PROPERTY:
        case CONFIDENCE_PROPERTY:
            onDataChange();
            break;
        case ORIGINAL_VISIBLE_PROPERTY:
            onVisibilityChange();
            break;
        }
    });

    chartPanel.addChartMouseListener(new HighlightChartMouseListener2());
    chartPanel.addKeyListener(revealObs);

    highlight = null;

    onDataFormatChange();
    onColorSchemeChange();
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java

/**
 * // w  w  w . j a v  a 2s  .c om
 */
@SuppressWarnings("unchecked")
protected void exportSchemaLocales() {
    FileDialog dlg = new FileDialog(((Frame) UIRegistry.getTopWindow()), getResourceString("Save"),
            FileDialog.SAVE);
    dlg.setVisible(true);

    String fileName = dlg.getFile();
    if (fileName != null) {
        final File outFile = new File(dlg.getDirectory() + File.separator + fileName);
        //final File    outFile = new File("xxx.xml");

        final SimpleGlassPane glassPane = new SimpleGlassPane(getResourceString("SL_EXPORT_SCHEMA"), 18);
        glassPane.setBarHeight(12);
        glassPane.setFillColor(new Color(0, 0, 0, 85));

        setGlassPane(glassPane);
        glassPane.setVisible(true);

        SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
            @Override
            protected Integer doInBackground() throws Exception {

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

                    int dispId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId();
                    String sql = String.format(
                            "FROM SpLocaleContainer WHERE disciplineId = %d AND schemaType = %d", dispId,
                            schemaType);
                    List<SpLocaleContainer> spContainers = (List<SpLocaleContainer>) session.getDataList(sql);
                    try {
                        FileWriter fw = new FileWriter(outFile);

                        //fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vector>\n");
                        fw.write("<vector>\n");

                        BeanWriter beanWriter = new BeanWriter(fw);
                        XMLIntrospector introspector = beanWriter.getXMLIntrospector();
                        introspector.getConfiguration().setWrapCollectionsInElement(true);
                        beanWriter.getBindingConfiguration().setMapIDs(false);
                        beanWriter.setWriteEmptyElements(false);

                        beanWriter.enablePrettyPrint();

                        double step = 100.0 / (double) spContainers.size();
                        double total = 0.0;
                        for (SpLocaleContainer container : spContainers) {
                            // force Load of lazy collections
                            container.getDescs().size();
                            container.getNames().size();

                            // Leaving this Code as an example of specifying the bewtixt file.
                            /*InputStream inputStream = Specify.class.getResourceAsStream("datamodel/SpLocaleContainer.betwixt");
                            //InputStream inputStream = Specify.class.getResourceAsStream("/edu/ku/brc/specify/tools/schemalocale/SpLocaleContainer.betwixt");
                            InputSource inputSrc    = new InputSource(inputStream); 
                            beanWriter.write(container, inputSrc);
                            inputStream.close(); */

                            beanWriter.write(container);

                            total += step;
                            firePropertyChange("progress", 0, (int) total);
                        }

                        fw.write("</vector>\n");
                        fw.close();

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

                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerDlg.class, e);
                    e.printStackTrace();

                } finally {
                    if (session != null) {
                        session.close();
                    }
                }

                return null;
            }

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

                glassPane.setVisible(false);
            }
        };

        backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                }
            }
        });
        backupWorker.execute();
    }
}

From source file:ui.panel.UILicenseAdd.java

public JPanel createButtonPanel() {
    JPanel panel = p.createPanel(Layouts.flow);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER));

    btnSubmit = b.createButton("Submit");
    btnCancel = b.createButton("Cancel");

    btnSubmit.addActionListener(new ActionListener() {

        @Override//from w  w w  .  ja va  2 s . c  om
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    TreePath[] path = checkTreeManager.getSelectionModel().getSelectionPaths();
                    ArrayList<String> featureL = new ArrayList<String>();
                    String[] features = new String[] {};
                    for (TreePath tp : path) {

                        if (tp.getLastPathComponent().toString().equals("Features")) {
                            Object rootNode = tree.getModel().getRoot();
                            int parentCount = tree.getModel().getChildCount(rootNode);
                            for (int i = 0; i < parentCount; i++) {
                                Object parentNode = tree.getModel().getChild(rootNode, i);
                                int childrenCount = tree.getModel().getChildCount(parentNode);

                                for (int x = 0; x < childrenCount; x++) {
                                    MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x);
                                    featureL.add(node.getValue());
                                }
                            }
                        } else if (tp.getPathCount() == 2) {
                            Object rootNode = tree.getModel().getRoot();
                            int parentCount = tree.getModel().getChildCount(rootNode);
                            for (int i = 0; i < parentCount; i++) {
                                Object parentNode = tree.getModel().getChild(rootNode, i);
                                if (parentNode.toString().equals(tp.getLastPathComponent().toString())) {

                                    int childrenCount = tree.getModel().getChildCount(parentNode);

                                    for (int x = 0; x < childrenCount; x++) {
                                        MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x);
                                        featureL.add(node.getValue());
                                    }
                                }
                            }
                        } else if (tp.getPathCount() == 3) {
                            MyDataNode node = (MyDataNode) tp.getLastPathComponent();
                            featureL.add(node.getValue());
                        }

                    }
                    features = featureL.toArray(features);
                    String duration = spnValidity.getValue().toString();
                    if (cbPerpetual.isSelected()) {
                        duration = "-1";
                    }
                    String storage = spnCloud.getValue().toString();
                    String maxVCA = spnConcurrentVCA.getValue().toString();
                    String response = apiCall.addNodeLicense(Data.targetURL, Data.sessionKey, Data.bucketID,
                            features, duration, storage, maxVCA);

                    try {
                        JSONObject responseObject = new JSONObject(response);
                        if (responseObject.get("result").equals("ok")) {
                            Data.mainFrame.uiLicenseDetail.getLicenseData();
                            Data.mainFrame.showPanel("license");
                        }
                    } catch (JSONException e1) {
                        e1.printStackTrace();
                    }
                    return null;
                }
            };
            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving License..."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });

    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("license");
        }
    });

    panel.add(btnSubmit);
    panel.add(btnCancel);

    return panel;
}

From source file:tufts.vue.action.ActionUtil.java

public static File selectFile(String title, final String fileType) {
    File picked = null;//from  w  w w  . j ava2s .  c  o m

    saveChooser = VueFileChooser.getVueFileChooser();

    saveChooser.setDialogTitle(title);
    saveChooser.setAcceptAllFileFilterUsed(false);
    //chooser.set

    if (fileType != null && !fileType.equals("export"))
        saveChooser.setFileFilter(new VueFileFilter(fileType));
    else if (fileType != null && fileType.equals("export")) {
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION));
        //  chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION));
    } else {
        VueFileFilter defaultFilter = new VueFileFilter(VueFileFilter.VUE_DESCRIPTION);

        saveChooser.addChoosableFileFilter(defaultFilter);
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.VPK_DESCRIPTION));
        //SIMILE    chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SIMILE_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter("PDF"));

        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION));
        //chooser.addChoosableFileFilter(new VueFileFilter("html"));

        saveChooser.addChoosableFileFilter(new VueFileFilter("RDF"));
        saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION));
        //   chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION));

        //chooser.addChoosableFileFilter(new VueFileFilter("HTML Outline", "htm"));

        saveChooser.setFileFilter(defaultFilter);
    }
    saveChooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            if (arg0.getPropertyName() == VueFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
                adjustExtension();
            }
        }
    });
    adjustExtension();
    int option = saveChooser.showSaveDialog(VUE.getDialogParentAsFrame());//, VueResources.getString("dialog.save.title"));

    if (option == VueFileChooser.APPROVE_OPTION) {
        picked = saveChooser.getSelectedFile();

        String fileName = picked.getAbsolutePath();

        /**
         * 2009-10-16 There was a bug in here that sliced up the filename, I think removing this block
         * of code should fix the issue. If you had a name like Object.Generic-Tufts, VUE would get
         * all confused and put files in the wrong directory or make a file called Object the filename
         * slicing seemed unnecessary. -MK
         * 
         */
        String extension = ((VueFileFilter) saveChooser.getFileFilter()).getExtensions()[0];
        //if it isn't a file name with the right extension 
        if (!picked.getName().endsWith("." + extension)) {
            fileName += "." + extension;
            picked = new File(fileName);
        }

        if (picked.exists()) {
            int n = VueUtil.confirm(null,
                    VueResources.getString("replaceFile.text") + " \'" + picked.getName() + "\'",
                    VueResources.getString("replaceFile.title"), JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE);

            if (n == JOptionPane.NO_OPTION) {
                picked = null;
                saveChooser.showDialog(VUE.getDialogParentAsFrame(),
                        VueResources.getString("dialog.save.title"));
            }
        }

        if (picked != null)
            VueUtil.setCurrentDirectoryPath(picked.getParent());
    }

    return picked;
}

From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java

public void propertyChange(final PropertyChangeEvent evt) {
    if (log.isDebugEnabled())
        log.debug(evt.getSource());//from   w  w w .  j a v  a2  s.  c  om
    if (evt.getSource() == broom) {
        if ("idx16".equals(evt.getPropertyName()))
            syncM2V(broom == null ? -1 : broom.getIdx16());
        else if ("outTurn".equals(evt.getPropertyName()))
            syncM2V(broom == null ? null : broom.getOutTurn());
        else if ("splitTimeMillis".equals(evt.getPropertyName()))
            syncM2V(broom == null ? null : broom.getSplitTimeMillis());
        else if ("broom".equals(evt.getPropertyName()))
            syncM2V(broom == null ? null : broom.getBroom());
    } else if (evt.getSource() == x || evt.getSource() == y) {
        if ("valueIsAdjusting".equals(evt.getPropertyName()))
            if (Boolean.TRUE.equals(evt.getNewValue()))
                firstXY = new XYMemento(broom, broom.getBroom());
            else {
                if (Boolean.FALSE.equals(evt.getNewValue()))
                    getChanger().undoable(firstXY, new XYMemento(broom, x.getValue(), y.getValue()));
                firstXY = null;
            }
    } else
        log.warn("Unprocessed event from " + evt.getSource());
}

From source file:ch.fork.AdHocRailway.ui.locomotives.configuration.LocomotiveConfig.java

private boolean validate(final Locomotive locomotive, final PropertyChangeEvent event) {

    boolean validate = true;
    if (event == null || event.getPropertyName().equals(Locomotive.PROPERTYNAME_NAME)) {
        if (locomotive.getName() == null || locomotive.getName().equals("")) {
            validate = false;// w w w.java2  s .co  m
            nameTextField.setBackground(UIConstants.ERROR_COLOR);
        } else {
            nameTextField.setBackground(UIConstants.DEFAULT_TEXTFIELD_COLOR);
        }
    }
    if (event == null || event.getPropertyName().equals(Locomotive.PROPERTYNAME_BUS)
            || event.getPropertyName().equals(Locomotive.PROPERTYNAME_ADDRESS1)) {
        boolean busValid = true;

        if (locomotive.getBus() == 0) {
            setSpinnerColor(busSpinner, UIConstants.ERROR_COLOR);
            validate = false;
            busValid = false;
        } else {
            setSpinnerColor(busSpinner, UIConstants.DEFAULT_TEXTFIELD_COLOR);
        }

        boolean addressValid = true;

        if (locomotive.getAddress1() == 0 || locomotive.getAddress1() > MMTurnout.MAX_MM_TURNOUT_ADDRESS) {
            setSpinnerColor(address1Spinner, UIConstants.ERROR_COLOR);
            validate = false;
            addressValid = false;
        } else {
            setSpinnerColor(address1Spinner, UIConstants.DEFAULT_TEXTFIELD_COLOR);
        }

        if (busValid && addressValid) {

            final int bus = ((Integer) busSpinner.getValue()).intValue();
            final int address = ((Integer) address1Spinner.getValue()).intValue();
            boolean unique = true;
            for (final Locomotive l : ctx.getLocomotiveManager().getAllLocomotives()) {
                if (l.getBus() == bus && l.getAddress1() == address && !l.equals(locomotive)) {
                    unique = false;
                }
            }
            if (!unique) {
                setSpinnerColor(busSpinner, UIConstants.WARN_COLOR);
                setSpinnerColor(address1Spinner, UIConstants.WARN_COLOR);
            } else {
                setSpinnerColor(busSpinner, UIConstants.DEFAULT_TEXTFIELD_COLOR);
                setSpinnerColor(address1Spinner, UIConstants.DEFAULT_TEXTFIELD_COLOR);
            }
        }
    }

    return validate;
}

From source file:ome.formats.importer.gui.LoginHandler.java

public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();

    if (!NEW_LOGIN) {
        if (prop.equals(LOGIN)) {
            tryLogin();/*from  ww  w.j  a  va2  s  . com*/
        }
        if (prop.equals(LOGIN_CANCELLED)) {
            loginCancelled();
        }

    } else {
        if (prop.equals(ScreenLogin.LOGIN_PROPERTY)) {
            lc = (LoginCredentials) evt.getNewValue();
            if (lc != null) {
                tryLogin();
            }
        } else if (ScreenLogin.QUIT_PROPERTY.equals(prop)) {
            if (displayTop) {
                System.exit(0);
            } else {
                view.dispose();
            }

        } else if (ScreenLogin.TO_FRONT_PROPERTY.equals(prop) || ScreenLogo.MOVE_FRONT_PROPERTY.equals(prop)) {
        }
    }
}