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:org.jfree.data.time.TimeSeriesCollection.java

/**
 * Receives notification that the key for one of the series in the 
 * collection has changed, and vetos it if the key is already present in 
 * the collection./*from w  w  w.j a v  a 2 s .co  m*/
 * 
 * @param e  the event.
 * 
 * @since 1.0.17
 */
@Override
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException {
    // if it is not the series name, then we have no interest
    if (!"Key".equals(e.getPropertyName())) {
        return;
    }

    // to be defensive, let's check that the source series does in fact
    // belong to this collection
    Series s = (Series) e.getSource();
    if (getSeriesIndex(s.getKey()) == -1) {
        throw new IllegalStateException(
                "Receiving events from a series " + "that does not belong to this collection.");
    }
    // check if the new series name already exists for another series
    Comparable key = (Comparable) e.getNewValue();
    if (getSeriesIndex(key) >= 0) {
        throw new PropertyVetoException("Duplicate key2", e);
    }
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

/**
 PropertyChange method is called when a FormattedTextField is modified
 @param ev The event//from  w  w w .j  a v a 2 s .  c om
 */
public void propertyChange(PropertyChangeEvent ev) {
    if (ev.getPropertyName().equals("value")) {
        Object src = ev.getSource();
        if (src.getClass() == JFormattedTextField.class) {
            PhotoInfoFields field = (PhotoInfoFields) ((JFormattedTextField) src).getClientProperty(FIELD);
            Object value = ((JFormattedTextField) src).getValue();

            StringBuffer debugMsg = new StringBuffer();
            debugMsg.append("valueChange ").append(field).append(": ").append(value);

            /* Field value is set to null (as it is when ctrl is
             controlling multiple photos which have differing
            value for te field) this is called every time the
            field is accessed, so we must not notify the
            controller.  After the user has actually set the
            value it is no longer null.
            */
            if (value != null) {
                log.debug("Property changed: " + field);
                ctrl.viewChanged(this, field, value);
            }
        }
    }
}

From source file:org.tinymediamanager.core.tvshow.TvShowList.java

/**
 * Instantiates a new TvShowList.//from w  w w .ja va2s . c  o m
 */
private TvShowList() {
    // create the lists
    tvShowTagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>());
    episodeTagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>());
    videoCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>());
    audioCodecsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>());

    // the tag listener: its used to always have a full list of all tags used in tmm
    propertyChangeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            // listen to changes of tags
            if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShow) {
                TvShow tvShow = (TvShow) evt.getSource();
                updateTvShowTags(tvShow);
            }
            if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShowEpisode) {
                TvShowEpisode episode = (TvShowEpisode) evt.getSource();
                updateEpisodeTags(episode);
            }
            if ((MEDIA_FILES.equals(evt.getPropertyName()) || MEDIA_INFORMATION.equals(evt.getPropertyName()))
                    && evt.getSource() instanceof TvShowEpisode) {
                TvShowEpisode episode = (TvShowEpisode) evt.getSource();
                updateMediaInformationLists(episode);
            }
            if (EPISODE_COUNT.equals(evt.getPropertyName())) {
                firePropertyChange(EPISODE_COUNT, 0, 1);
            }
        }
    };
}

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

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Sasha aaa
    contentPanel = new JPanel();
    label16 = new JLabel();
    label17 = new JLabel();
    label18 = new JLabel();
    label1 = new JLabel();
    cbFilterType = new JComboBox();
    label5 = new JLabel();
    tbAParam = new JTextField();
    label2 = new JLabel();
    cbFilterForm = new JComboBox();
    label6 = new JLabel();
    tbBParam = new JTextField();
    label3 = new JLabel();
    tbName = new JTextField();
    label7 = new JLabel();
    tbCParam = new JTextField();
    label4 = new JLabel();
    panel2 = new JPanel();
    tbImage = new JTextField();
    btnUploadImage = new JButton();
    label8 = new JLabel();
    tbDParam = new JTextField();
    label19 = new JLabel();
    cbFilterStatus = new JComboBox();
    label9 = new JLabel();
    tbEParam = new JTextField();
    label15 = new JLabel();
    scrollPane1 = new JScrollPane();
    tbAdditionalInfo = new JTextArea();
    label10 = new JLabel();
    tbFParam = new JTextField();
    label11 = new JLabel();
    tbGParam = new JTextField();
    label12 = new JLabel();
    tbHParam = new JTextField();
    label13 = new JLabel();
    tbPbParam = new JTextField();
    label14 = new JLabel();
    tbNrParam = new JTextField();
    panel1 = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();
    CellConstraints cc = new CellConstraints();

    //======== this ========
    setModal(true);/*from  www.j  a v a 2  s  .  co m*/
    setTitle("\u0424\u0438\u043b\u044c\u0442\u0440");
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("default:grow", "fill:default:grow"));

    //======== contentPanel ========
    {

        // JFormDesigner evaluation mark
        contentPanel.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                        "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                        javax.swing.border.TitledBorder.BOTTOM,
                        new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                contentPanel.getBorder()));
        contentPanel.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        contentPanel.setLayout(new FormLayout(
                "$rgap, default, $lcgap, default:grow, $lcgap, right:20dlu, $lcgap, default:grow, $rgap",
                "13*(default, $lgap), fill:default:grow, $lgap, default"));

        //---- label16 ----
        label16.setText(
                "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0435. ");
        contentPanel.add(label16, cc.xywh(2, 1, 7, 1));

        //---- label17 ----
        label17.setText(
                "\u041f\u043e\u043b\u044f, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.");
        contentPanel.add(label17, cc.xywh(2, 3, 7, 1));

        //---- label18 ----
        label18.setText(
                "\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043b\u0438 \u0444\u043e\u0440\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b\"->\"\u0422\u0438\u043f\u044b \u0438 \u0444\u043e\u0440\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\"");
        label18.setForeground(Color.blue);
        contentPanel.add(label18, cc.xywh(2, 5, 7, 1));

        //---- label1 ----
        label1.setText("\u0422\u0438\u043f*");
        contentPanel.add(label1, cc.xy(2, 7));
        contentPanel.add(cbFilterType, cc.xy(4, 7));

        //---- label5 ----
        label5.setText("A");
        contentPanel.add(label5, cc.xy(6, 7));
        contentPanel.add(tbAParam, cc.xy(8, 7));

        //---- label2 ----
        label2.setText("\u0424\u043e\u0440\u043c\u0430*");
        contentPanel.add(label2, cc.xy(2, 9));
        contentPanel.add(cbFilterForm, cc.xy(4, 9));

        //---- label6 ----
        label6.setText("B");
        contentPanel.add(label6, cc.xy(6, 9));
        contentPanel.add(tbBParam, cc.xy(8, 9));

        //---- label3 ----
        label3.setText("\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435*");
        contentPanel.add(label3, cc.xy(2, 11));

        //---- tbName ----
        tbName.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
                tbNameKeyTyped(e);
            }
        });
        tbName.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                tbNameFocusGained(e);
            }

            @Override
            public void focusLost(FocusEvent e) {
                tbNameFocusGained(e);
            }
        });
        contentPanel.add(tbName, cc.xy(4, 11));

        //---- label7 ----
        label7.setText("C");
        contentPanel.add(label7, cc.xy(6, 11));
        contentPanel.add(tbCParam, cc.xy(8, 11));

        //---- label4 ----
        label4.setText("\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435");
        contentPanel.add(label4, cc.xy(2, 13));

        //======== panel2 ========
        {
            panel2.setLayout(new FormLayout("default:grow, $lcgap, default", "default"));
            panel2.add(tbImage, cc.xy(1, 1));

            //---- btnUploadImage ----
            btnUploadImage.setText("...");
            btnUploadImage.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnUploadImageActionPerformed();
                }
            });
            panel2.add(btnUploadImage, cc.xy(3, 1));
        }
        contentPanel.add(panel2, cc.xy(4, 13));

        //---- label8 ----
        label8.setText("D");
        contentPanel.add(label8, cc.xy(6, 13));
        contentPanel.add(tbDParam, cc.xy(8, 13));

        //---- label19 ----
        label19.setText("\u0421\u0442\u0430\u0442\u0443\u0441");
        contentPanel.add(label19, cc.xy(2, 15));

        //---- cbFilterStatus ----
        cbFilterStatus.setModel(new DefaultComboBoxModel(new String[] {
                "\u0412 \u041f\u0420\u041e\u0418\u0417\u0412\u041e\u0414\u0421\u0422\u0412\u0415",
                "\u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f",
                "\u041d\u0415 \u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f" }));
        contentPanel.add(cbFilterStatus, cc.xy(4, 15));

        //---- label9 ----
        label9.setText("E");
        contentPanel.add(label9, cc.xy(6, 15));
        contentPanel.add(tbEParam, cc.xy(8, 15));

        //---- label15 ----
        label15.setText("\u0414\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f");
        contentPanel.add(label15, cc.xy(2, 17));

        //======== scrollPane1 ========
        {
            scrollPane1.setViewportView(tbAdditionalInfo);
        }
        contentPanel.add(scrollPane1, cc.xywh(4, 17, 1, 11));

        //---- label10 ----
        label10.setText("F");
        contentPanel.add(label10, cc.xy(6, 17));
        contentPanel.add(tbFParam, cc.xy(8, 17));

        //---- label11 ----
        label11.setText("G");
        contentPanel.add(label11, cc.xy(6, 19));
        contentPanel.add(tbGParam, cc.xy(8, 19));

        //---- label12 ----
        label12.setText("H");
        contentPanel.add(label12, cc.xy(6, 21));
        contentPanel.add(tbHParam, cc.xy(8, 21));

        //---- label13 ----
        label13.setText("PB");
        contentPanel.add(label13, cc.xy(6, 23));
        contentPanel.add(tbPbParam, cc.xy(8, 23));

        //---- label14 ----
        label14.setText("NR");
        contentPanel.add(label14, cc.xy(6, 25));
        contentPanel.add(tbNrParam, cc.xy(8, 25));

        //======== panel1 ========
        {
            panel1.setLayout(new FormLayout("default:grow, 2*($lcgap, $button)", "default"));

            //---- okButton ----
            okButton.setText("OK");
            okButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    okButtonActionPerformed(e);
                }
            });
            panel1.add(okButton, cc.xy(3, 1));

            //---- cancelButton ----
            cancelButton.setText("\u041e\u0442\u043c\u0435\u043d\u0430");
            cancelButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    cancelButtonActionPerformed(e);
                }
            });
            panel1.add(cancelButton, cc.xy(5, 1));
        }
        contentPanel.add(panel1, cc.xywh(2, 29, 7, 1));
    }
    contentPane.add(contentPanel, cc.xy(1, 1));
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents

    cbFilterType.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                SelectItem selectItem = (SelectItem) e.getItem();
                FilterType ft = carsService.getFilterTypeByCode(selectItem.getId());
                reReadFilterForms(ft.getCode());

            }
        }
    });

    cbFilterForm.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                adjustParameters();
                adjustButtonsEnabled();
            }
        }
    });
}

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

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("copyStart")) {
        enabledDlgBtns(false);//from   w  w w . ja  va2s  .  c  o m

    } else if (evt.getPropertyName().equals("copyEnd")) {
        enabledDlgBtns(true);
    }
}

From source file:org.talend.designer.runprocess.ui.TraceDebugProcessComposite.java

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();
    if (ProcessMessageManager.PROP_MESSAGE_ADD.equals(propName)
            || ProcessMessageManager.PROP_DEBUG_MESSAGE_ADD.equals(propName)) {
        IProcessMessage psMess = (IProcessMessage) evt.getNewValue();

        if (errorMessMap.size() <= CorePlugin.getDefault().getPreferenceStore()
                .getInt(ITalendCorePrefConstants.PREVIEW_LIMIT)) {
            if (!(LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL))) {
                getAllErrorMess(psMess);
            } else {
                addPerlMark(psMess);/*from  w  w w.ja va2s. com*/
            }
        }
        appendToConsole(psMess);
    } else if (ProcessMessageManager.PROP_MESSAGE_CLEAR.equals(propName)) {
        getShell().getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (!consoleText.isDisposed()) {
                    consoleText.setText(""); //$NON-NLS-1$
                }
            }
        });
    } else if (RunProcessContext.PROP_MONITOR.equals(propName)) {
        // perfBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.TRACE_MONITOR.equals(propName)) {
        // traceBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
        getShell().getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (isDisposed()) {
                    return;
                }
                boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                setRunnable(!running);
                killBtn.setEnabled(running);
                // previousRow.setEnabled(running);
                // nextRow.setEnabled(running);
                // nextBreakPoint.setEnabled(running);
            }
        });
    }
}

From source file:org.talend.designer.runprocess.ui.MemoryRuntimeComposite.java

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    if (isDisposed()) {
        return;/*from   w  w  w . j ava 2  s.  com*/
    }
    String propName = evt.getPropertyName();

    if (RunProcessContext.MEMORY_MONITOR.equals(propName)) {
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (isDisposed()) {
                    return;
                }
                boolean monitoring = ((Boolean) evt.getNewValue()).booleanValue();
                if (runtimeButton != null && !runtimeButton.isDisposed()) {
                    setRuntimeButtonByStatus(processContext != null && processContext.isRunning());
                    if (processContext == null) {
                        setRuntimeButtonByStatus(false);
                    } else if (processContext.isRunning()) {
                        setRuntimeButtonByStatus(false);
                    } else {
                        disconnectJVM();
                        setRuntimeButtonByStatus(true);
                        processContext.setMonitoring(false);
                        if (AbstractRuntimeGraphcsComposite.isMonitoring()) {
                            AbstractRuntimeGraphcsComposite.setMonitoring(false);
                            String content = getExecutionInfo("End"); //$NON-NLS-1$
                            messageManager.setEndMessage(content, getDisplay().getSystemColor(SWT.COLOR_BLUE),
                                    getDisplay().getSystemColor(SWT.COLOR_WHITE));
                        }
                        ((RuntimeGraphcsComposite) chartComposite).displayReportField();
                        lock = false;
                    }
                }
                if (!monitoring && chartComposite != null && chartComposite.isDisposed()) {
                    viewPart.setSelection(null);
                    refreshMonitorComposite();
                }
            }
        });
    }

}

From source file:YoungDoubleSlit.YoungDoubleSlit.java

private void theWaveLengthSliderPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_theWaveLengthSliderPropertyChange
    // TODO add your handling code here:
    //System.out.println("Found PropertyChanged.");
    String property = evt.getPropertyName();
    if ("value".equals(property)) {
        wavelength = (int) evt.getNewValue();
    }/*w w  w .  j  av a 2  s  .  c o m*/
}

From source file:org.company.processmaker.TreeFilesTopComponent.java

public TreeFilesTopComponent() {
    initComponents();//from w  w w  . j  a va  2s .c o  m

    setName(Bundle.CTL_TreeFilesTopComponent());
    setToolTipText(Bundle.HINT_TreeFilesTopComponent());
    // new codes
    instance = this;

    MouseListener ml = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            int selRow = jTree1.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY());

            if (selRow != -1) {
                if (e.getClickCount() == 1) {
                    //mySingleClick(selRow, selPath);
                } else if (e.getClickCount() == 2) {

                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1
                            .getLastSelectedPathComponent();
                    if (node == null) {
                        return;
                    }
                    Object nodeInfo = node.getUserObject();
                    int node_level = node.getLevel();

                    if (node_level < 2) {
                        return;
                    }

                    // for each dyna form
                    if (node_level == 2) {

                        Global gl_obj = Global.getInstance();

                        //myDoubleClick(selRow, selPath);
                        conf = Config.getInstance();

                        DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
                        String parentName = (String) parent.getUserObject();

                        // handle triggers
                        if (parentName.equals("Triggers")) {

                            String filePath = "";
                            for (String[] s : res_trigger) {

                                if (s[0].equals(nodeInfo.toString())) {
                                    // get path of dyna in xml forms
                                    filePath = conf.tmp + "triggers/" + s[3] + "/" + s[2] + ".php";
                                    break;
                                }

                            }

                            File toAdd = new File(filePath);

                            try {
                                DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd));

                                dObject.getLookup().lookup(OpenCookie.class).open();
                                // dont listen for exist listen files
                                if (existFile(filePath)) {
                                    return;
                                }
                                dObject.addPropertyChangeListener(new PropertyChangeListener() {
                                    @Override
                                    public void propertyChange(PropertyChangeEvent evt) {
                                        if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                                            //fire a dummy event
                                            if (!Boolean.TRUE.equals(evt.getNewValue())) {

                                                /*String msg = "Saved to" + evt.toString();
                                                NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
                                                DialogDisplayer.getDefault().notify(nd);*/
                                                TopComponent activeTC = TopComponent.getRegistry()
                                                        .getActivated();
                                                DataObject dataLookup = activeTC.getLookup()
                                                        .lookup(DataObject.class);
                                                String filePath = FileUtil.toFile(dataLookup.getPrimaryFile())
                                                        .getAbsolutePath();

                                                File userFile = new File(filePath);
                                                String fileName = userFile.getName();
                                                fileName = fileName.substring(0, fileName.lastIndexOf("."));

                                                try {
                                                    String content = new String(
                                                            Files.readAllBytes(Paths.get(filePath)));
                                                    // remote php tag and info "<?php //don't remove this tag! \n"
                                                    content = content.substring(6, content.length());

                                                    String query = "update triggers set TRI_WEBBOT = '"
                                                            + StringEscapeUtils.escapeSql(content)
                                                            + "' where TRI_UID = '" + fileName + "'";
                                                    GooglePanel.updateQuery(query);

                                                } catch (Exception e) {
                                                    //Exceptions.printStackTrace(e);
                                                    String msg = "Can not update trigger";
                                                    NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                                            NotifyDescriptor.INFORMATION_MESSAGE);
                                                    DialogDisplayer.getDefault().notify(nd);
                                                }

                                            }

                                        }

                                    }
                                });

                            } catch (DataObjectNotFoundException ex) {
                                //Exceptions.printStackTrace(ex);
                                String msg = "Trigger not found";
                                NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                        NotifyDescriptor.INFORMATION_MESSAGE);
                                DialogDisplayer.getDefault().notify(nd);
                            }

                            return;
                        }

                        List<String[]> res_dyna = gl_obj.getDyna();
                        String FileDir = "";
                        for (String[] s : res_dyna) {

                            if (s[1].equals(nodeInfo.toString())) {
                                // get path of dyna in xml forms
                                FileDir = s[3];
                                break;
                            }

                        }

                        //String msg = "selRow" + nodeInfo.toString() + "|" + conf.getXmlForms() + FileDir;
                        String filePath = conf.getXmlForms() + FileDir + ".xml";
                        if (conf.isRemote()) {
                            String[] res = FileDir.split("/");
                            filePath = conf.get("local_tmp_for_remote") + "/" + FileDir + "/" + res[1] + ".xml";
                        }

                        File toAdd = new File(filePath);

                        //Result will be null if the user clicked cancel or closed the dialog w/o OK
                        if (toAdd != null) {
                            try {
                                DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd));

                                dObject.getLookup().lookup(OpenCookie.class).open();
                                // dont listen for exist listen files
                                if (existFile(filePath)) {
                                    return;
                                }
                                dObject.addPropertyChangeListener(new PropertyChangeListener() {
                                    @Override
                                    public void propertyChange(PropertyChangeEvent evt) {
                                        if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                                            //fire a dummy event
                                            if (!Boolean.TRUE.equals(evt.getNewValue())) {

                                                /*String msg = "Saved to" + evt.toString();
                                                NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
                                                DialogDisplayer.getDefault().notify(nd);*/
                                                TopComponent activeTC = TopComponent.getRegistry()
                                                        .getActivated();
                                                DataObject dataLookup = activeTC.getLookup()
                                                        .lookup(DataObject.class);
                                                String filePath = FileUtil.toFile(dataLookup.getPrimaryFile())
                                                        .getAbsolutePath();

                                                File userFile = new File(filePath);
                                                String fileName = userFile.getName();
                                                fileName = fileName.substring(0, fileName.lastIndexOf("."));

                                                Global gl_obj = Global.getInstance();

                                                List<String[]> res_dyna = gl_obj.getDyna();
                                                String FileDir = "";
                                                for (String[] s : res_dyna) {

                                                    if (filePath.contains(s[0])) {

                                                        FileDir = s[3];
                                                        break;

                                                    }

                                                }

                                                if (conf.isRemote()) {
                                                    boolean res_Upload = SSH.getInstance().uplaodFile(FileDir);
                                                    if (res_Upload) {
                                                        String msg = "file upload Successfully!";
                                                        NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                                                NotifyDescriptor.INFORMATION_MESSAGE);
                                                        DialogDisplayer.getDefault().notify(nd);
                                                    } else {
                                                        String msg = "error in uploading file!";
                                                        NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                                                NotifyDescriptor.INFORMATION_MESSAGE);
                                                        DialogDisplayer.getDefault().notify(nd);
                                                    }
                                                }

                                            }

                                        }

                                    }
                                });

                            } catch (DataObjectNotFoundException ex) {
                                //Exceptions.printStackTrace(ex);
                                String msg = "Can not find xml file";
                                NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                        NotifyDescriptor.INFORMATION_MESSAGE);
                                DialogDisplayer.getDefault().notify(nd);
                            }
                        }
                    }

                    // for each js file
                    if (node_level == 3) {

                        TreeNode parentInfo = node.getParent();

                        Global gl_obj = Global.getInstance();

                        List<String[]> res_dyna = gl_obj.getDyna();
                        String FileDir = "";
                        for (String[] s : res_dyna) {

                            if (s[1].equals(parentInfo.toString())) {
                                // get path of dyna in xml forms
                                FileDir = s[3];
                                break;
                            }

                        }

                        //myDoubleClick(selRow, selPath);
                        conf = Config.getInstance();
                        String filePath = conf.tmp + "xmlForms/" + FileDir + "/" + nodeInfo.toString() + ".js";
                        if (conf.isRemote()) {
                            filePath = conf.get("local_tmp_for_remote") + FileDir + "/" + nodeInfo.toString()
                                    + ".js";
                        }

                        File toAdd = new File(filePath);

                        //Result will be null if the user clicked cancel or closed the dialog w/o OK
                        if (toAdd != null) {
                            try {
                                DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd));

                                dObject.getLookup().lookup(OpenCookie.class).open();
                                // dont listen for exist listen files
                                if (existFile(filePath)) {
                                    return;
                                }
                                dObject.addPropertyChangeListener(new PropertyChangeListener() {
                                    @Override
                                    public void propertyChange(PropertyChangeEvent evt) {
                                        if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                                            //fire a dummy event
                                            if (!Boolean.TRUE.equals(evt.getNewValue())) {

                                                JTextComponent ed = EditorRegistry.lastFocusedComponent();
                                                String jsDoc = "";
                                                try {
                                                    jsDoc = ed.getText();
                                                } catch (Exception ex) {
                                                    //Exceptions.printStackTrace(ex);
                                                    String msg = "Can not get text from editor";
                                                    NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                                            NotifyDescriptor.INFORMATION_MESSAGE);
                                                    DialogDisplayer.getDefault().notify(nd);
                                                }

                                                TopComponent activeTC = TopComponent.getRegistry()
                                                        .getActivated();
                                                DataObject dataLookup = activeTC.getLookup()
                                                        .lookup(DataObject.class);
                                                String filePath = FileUtil.toFile(dataLookup.getPrimaryFile())
                                                        .getAbsolutePath();

                                                File userFile = new File(filePath);
                                                String fileName = userFile.getName();
                                                fileName = fileName.substring(0, fileName.lastIndexOf("."));

                                                Global gl_obj = Global.getInstance();

                                                List<String[]> res_dyna = gl_obj.getDyna();
                                                String FileDir = "";
                                                for (String[] s : res_dyna) {

                                                    if (filePath.contains(s[0])) {

                                                        FileDir = s[3];
                                                        break;

                                                    }

                                                }

                                                String fullPath = conf.getXmlForms() + FileDir + ".xml";
                                                if (conf.isRemote()) {
                                                    String[] res = FileDir.split("/");
                                                    fullPath = conf.get("local_tmp_for_remote") + FileDir + "/"
                                                            + res[1] + ".xml";
                                                }
                                                try {
                                                    DocumentBuilderFactory factory = DocumentBuilderFactory
                                                            .newInstance();
                                                    DocumentBuilder builder = factory.newDocumentBuilder();
                                                    Document mainDoc = builder.parse(fullPath);

                                                    XPath xPath = XPathFactory.newInstance().newXPath();
                                                    Node startDateNode = (Node) xPath
                                                            .compile("//dynaForm/" + fileName)
                                                            .evaluate(mainDoc, XPathConstants.NODE);
                                                    Node cdata = mainDoc.createCDATASection(jsDoc);
                                                    startDateNode.setTextContent("");
                                                    startDateNode.appendChild(cdata);

                                                    /*String msg = evt.getPropertyName() + "-" + fileName;
                                                    NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
                                                    DialogDisplayer.getDefault().notify(nd);*/
                                                    // write the content into xml file
                                                    TransformerFactory transformerFactory = TransformerFactory
                                                            .newInstance();
                                                    Transformer transformer = transformerFactory
                                                            .newTransformer();
                                                    DOMSource source = new DOMSource(mainDoc);
                                                    StreamResult result = new StreamResult(new File(fullPath));
                                                    transformer.transform(source, result);

                                                    if (conf.isRemote()) {
                                                        boolean res_Upload = SSH.getInstance()
                                                                .uplaodFile(FileDir);
                                                        if (res_Upload) {
                                                            String msg = "file upload Successfully!";
                                                            NotifyDescriptor nd = new NotifyDescriptor.Message(
                                                                    msg, NotifyDescriptor.INFORMATION_MESSAGE);
                                                            DialogDisplayer.getDefault().notify(nd);
                                                        } else {
                                                            String msg = "error in uploading file!";
                                                            NotifyDescriptor nd = new NotifyDescriptor.Message(
                                                                    msg, NotifyDescriptor.INFORMATION_MESSAGE);
                                                            DialogDisplayer.getDefault().notify(nd);
                                                        }
                                                    }

                                                } catch (Exception ex) {
                                                    //Exceptions.printStackTrace(ex);
                                                    String msg = "Can not save to xml form";
                                                    NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                                            NotifyDescriptor.INFORMATION_MESSAGE);
                                                    DialogDisplayer.getDefault().notify(nd);
                                                }

                                            }

                                        }

                                    }
                                });

                            } catch (DataObjectNotFoundException ex) {
                                //Exceptions.printStackTrace(ex);
                                String msg = "Can not save to xml form";
                                NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
                                        NotifyDescriptor.INFORMATION_MESSAGE);
                                DialogDisplayer.getDefault().notify(nd);
                            }
                        }
                    }
                }
            }
        }
    };
    jTree1.addMouseListener(ml);
    jTree1.setModel(null);
}

From source file:op.care.med.inventory.DlgNewStocks.java

private void btnMedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMedActionPerformed

    //        String pzn = MedPackageTools.parsePZN(txtMedSuche.getText());
    final JidePopup popup = new JidePopup();

    WizardDialog wizard = new MedProductWizard(new Closure() {
        @Override//from ww  w . j  a va 2  s  .  com
        public void execute(Object o) {
            if (o != null) {
                MedPackage aPackage = (MedPackage) o;
                txtMedSuche.setText(aPackage.getPzn());
            }
            popup.hidePopup();

        }
    }).getWizard();

    popup.setMovable(false);
    popup.setPreferredSize((new Dimension(800, 450)));
    popup.setResizable(false);
    popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
    popup.getContentPane().add(wizard.getContentPane());
    popup.setOwner(btnMed);
    popup.removeExcludedComponent(btnMed);
    popup.setTransient(true);
    popup.setDefaultFocusComponent(wizard.getContentPane());
    popup.addPropertyChangeListener("visible", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            OPDE.debug("popup property: " + propertyChangeEvent.getPropertyName() + " value: "
                    + propertyChangeEvent.getNewValue() + " compCount: "
                    + popup.getContentPane().getComponentCount());
            popup.getContentPane().getComponentCount();
        }
    });

    GUITools.showPopup(popup, SwingConstants.WEST);

    //        popup.showPopup(new Insets(-5, wizard.getPreferredSize().width * -1 - 200, -5, -100), btnMed);

}