Example usage for java.beans PropertyChangeEvent getNewValue

List of usage examples for java.beans PropertyChangeEvent getNewValue

Introduction

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

Prototype

public Object getNewValue() 

Source Link

Document

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

Usage

From source file:com.emr.schemas.SavedProcessesDataMover.java

/**
 * Constructor/*from  ww  w. ja va2s. c o  m*/
 */
public SavedProcessesDataMover() {
    initComponents();
    this.setClosable(true);
    final Action processDelete = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            String foreignKeysTable = (String) tblProcesses.getModel().getValueAt(modelRow, 0);
            if (foreignKeysTable == null || "".equals(foreignKeysTable)) {
                JOptionPane.showMessageDialog(null, "Table is Empty", "Empty Table", JOptionPane.ERROR_MESSAGE);
            } else {

            }
        }

    };
    final SQLiteGetProcesses sp = new SQLiteGetProcesses();
    sp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            switch (event.getPropertyName()) {
            case "progress":
                System.out.println("Fetching data from db");
                break;
            case "state":
                switch ((SwingWorker.StateValue) event.getNewValue()) {
                case DONE:
                    try {
                        model = sp.get();
                        tblProcesses.setModel(model);
                        tblProcesses.getColumnModel().getColumn(0).setMaxWidth(300);
                        //hide irrelevant columns
                        tblProcesses.getColumnModel().getColumn(2).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(2).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(3).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(3).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(4).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(4).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(5).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(5).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(6).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(6).setMaxWidth(0);

                        ButtonColumn buttonColumn = new ButtonColumn(tblProcesses, processDelete, 7, "Delete");
                    } catch (final CancellationException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    break;
                }
                break;
            }
        }

    });
    sp.execute();

    tblProcesses.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                JTable target = (JTable) e.getSource();
                int rowIndex = target.getSelectedRow();
                String selectQry = (String) target.getModel().getValueAt(rowIndex, 2);
                String destinationTable = (String) target.getModel().getValueAt(rowIndex, 3);
                String truncateFirst = (String) target.getModel().getValueAt(rowIndex, 4);
                String destinationColumns = (String) target.getModel().getValueAt(rowIndex, 5);
                String columnsToBeMapped = (String) target.getModel().getValueAt(rowIndex, 6);
                lblUpdateText.setText("<html><b color='red'>Moving Data</b></html>");
                dbProgressBar.setIndeterminate(true);
                new DBUpdater(selectQry, destinationTable, truncateFirst, destinationColumns, columnsToBeMapped)
                        .execute();
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

}

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

/**
 * @param fileName/*from   ww w  .  j a va 2 s .  c  om*/
 * @param urlStr
 * @param isSiteFile
 * @param propChgListener
 */
public void transferFile(final String fileName, final String urlStr, final boolean isSiteFile,
        final PropertyChangeListener propChgListener) {

    final String prgName = HttpLargeFileTransfer.class.toString();

    final File file = new File(fileName);
    if (file.exists()) {
        final long fileSize = file.length();
        if (fileSize > 0) {
            SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
                protected String errorMsg = null;
                protected FileInputStream fis = null;
                protected OutputStream fos = null;
                protected int nChunks = 0;

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

                        nChunks = (int) (fileSize / MAX_CHUNK_SIZE);
                        if (fileSize % MAX_CHUNK_SIZE > 0) {
                            nChunks++;
                        }

                        byte[] buf = new byte[BUFFER_SIZE];
                        long bytesRemaining = fileSize;

                        String clientID = String.valueOf((long) (Long.MIN_VALUE * Math.random()));

                        URL url = new URL(urlStr);

                        UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);

                        for (int i = 0; i < nChunks; i++) {
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                            if (i == nChunks - 1) {
                                Thread.sleep(500);
                                int x = 0;
                                x++;
                            }

                            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                            conn.setRequestMethod("PUT");
                            conn.setDoOutput(true);
                            conn.setDoInput(true);
                            conn.setUseCaches(false);

                            int chunkSize = (int) ((bytesRemaining > MAX_CHUNK_SIZE) ? MAX_CHUNK_SIZE
                                    : bytesRemaining);
                            bytesRemaining -= chunkSize;

                            conn.setRequestProperty("Content-Type", "application/octet-stream");
                            conn.setRequestProperty("Content-Length", String.valueOf(chunkSize));

                            conn.setRequestProperty(CLIENT_ID_HEADER, clientID);
                            conn.setRequestProperty(FILE_NAME_HEADER, fileName);
                            conn.setRequestProperty(FILE_CHUNK_COUNT_HEADER, String.valueOf(nChunks));
                            conn.setRequestProperty(FILE_CHUNK_HEADER, String.valueOf(i));
                            conn.setRequestProperty(SERVICE_NUMBER, "10");
                            conn.setRequestProperty(IS_SITE_FILE, Boolean.toString(isSiteFile));

                            fos = conn.getOutputStream();

                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, (int)((double)chunkSize / BUFFER_SIZE));
                            int cnt = 0;
                            int bytesRead = 0;
                            while (bytesRead < chunkSize) {
                                int read = fis.read(buf);
                                if (read == -1) {
                                    break;

                                } else if (read > 0) {
                                    bytesRead += read;
                                    fos.write(buf, 0, read);
                                }
                                cnt++;
                                //firePropertyChange(prgName, cnt-1, cnt);
                            }
                            fos.close();

                            if (conn.getResponseCode() != HttpServletResponse.SC_OK) {
                                System.err.println(
                                        conn.getResponseMessage() + " " + conn.getResponseCode() + " ");
                                BufferedReader in = new BufferedReader(
                                        new InputStreamReader(conn.getErrorStream()));
                                String line = null;
                                StringBuilder sb = new StringBuilder();
                                while ((line = in.readLine()) != null) {
                                    sb.append(line);
                                    sb.append("\n");
                                }
                                System.out.println(sb.toString());
                                in.close();

                            } else {
                                System.err.println("OK");
                            }
                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                        }

                    } catch (IOException ex) {
                        errorMsg = ex.toString();
                    }

                    //firePropertyChange(prgName, 0, 100);
                    return null;
                }

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

                    UIRegistry.getStatusBar().setProgressDone(prgName);

                    UIRegistry.clearSimpleGlassPaneMsg();

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

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

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

            UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("Transmitting..."), 24);

            backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(final PropertyChangeEvent evt) {
                    System.out.println(evt.getPropertyName() + "  " + evt.getNewValue());
                    if (prgName.equals(evt.getPropertyName())) {
                        Integer value = (Integer) evt.getNewValue();
                        if (value == Integer.MAX_VALUE) {
                            statusBar.setIndeterminate(prgName, true);
                            UIRegistry.writeSimpleGlassPaneMsg(
                                    getLocalizedMessage("Transfering data into the database."), 24);

                        } else {
                            statusBar.setValue(prgName, value);
                        }
                    }
                }
            });
            backupWorker.execute();

        } else {
            // file doesn't exist
        }
    } else {
        // file doesn't exist
    }
}

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

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 * //from  w  ww .j ava2  s  .  co  m
 * @return A panel.
 */
/*    public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset());
return new ChartPanel(chart);
   }*/

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

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

    if (propertyName.equals("DataUpdate")) {
        //update the local version of the dataTable by outside source
        dataTable = (JTable) (e.getNewValue());
        dataPanel.removeAll();
        dataPanel.add(new JScrollPane(dataTable));

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

From source file:org.pentaho.aggdes.ui.form.controller.ConnectionController.java

@RequestHandler
public void onLoad() throws Exception {
    BindingFactory bf = bindingFactory;/*from   w  w w  .j  a  v  a 2  s .c  o m*/
    bf.setDocument(document);

    for (final SchemaProviderUiExtension extension : schemaProviders) {
        try {
            document.addOverlay(extension.getOverlayPath());
            getXulDomContainer().addEventHandler(extension);

            ((XulEventSource) extension).addPropertyChangeListener(new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    boolean schemaAppliable = false;
                    if (evt.getPropertyName().equals("schemaDefined")
                            || evt.getPropertyName().equals("selected")) {
                        logger.debug("*** got schemaDefined=" + evt.getNewValue()
                                + ", checking if any providers are applyable");
                        for (SchemaProviderUiExtension ex : schemaProviders) {

                            //De-select other extensions
                            if (evt.getPropertyName().equals("selected") && extension != ex
                                    && evt.getNewValue() == Boolean.TRUE) {
                                ex.setSelected(false);
                            }

                            if (ex.isSchemaDefined() && ex.isSelected()) {
                                logger.debug("provider " + ex.getName() + " is applyable");
                                schemaAppliable = true;
                            } else {
                                logger.debug(ex.getName() + " NOT applyable: defined=[" + ex.isSchemaDefined()
                                        + "] selected=[" + ex.isSelected() + "]");
                            }
                        }
                        connectionModel.setApplySchemaSourceEnabled(schemaAppliable);
                    }
                }

            });

            bf.setBindingType(Binding.Type.ONE_WAY);
            bf.createBinding(connectionModel, "schemaLocked", extension, "!enabled");

            //        extension.onLoad();
        } catch (XulException e) {
            logger.error("Error loading Schema Provider Overlay", e);
        }
    }

    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);

    bf.createBinding(workspace, "applicationUnlocked", "open_advisor", "!disabled");
    bf.createBinding(workspace, "applicationUnlocked", "open_export", "!disabled");
    bf.createBinding(workspace, "applicationUnlocked", "agg_add_btn", "!disabled");
    bf.createBinding(connectionModel, "cubeNames", "cubeSelector", "elements");
    bf.createBinding(connectionModel, "cubeName", "cubeSelector", "selectedItem");

    bf.setBindingType(Binding.Type.ONE_WAY);

    bf.createBinding(connectionModel, "applySchemaSourceEnabled", "applySchemaSourceButton", "!disabled");
    bf.createBinding(connectionModel, "databaseName", "databaseName", "value");
    bf.createBinding(connectionModel, "cubeSelectionEnabled", "cubeSelector", "!disabled");

    bf.createBinding(connectionModel, "schemaLocked", "cubeSelector", "disabled");
    bf.createBinding(connectionModel, "schemaLocked", "applySchemaSourceButton", "disabled");

    bf.createBinding(connectionModel, "connectEnabled", "connection_dialog_accept", "!disabled")
            .fireSourceChanged();

    connectionModel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("selectedSchemaModel")) {
                SchemaModel model = (SchemaModel) evt.getNewValue();
                // select the correct schema value
                for (SchemaProviderUiExtension extension : schemaProviders) {
                    if (model != null && extension.supportsSchemaModel(model)) {
                        selectedSchemaProvider = extension;
                        extension.setSelected(true);
                        extension.setSchemaModel(model);
                    } else {
                        extension.setSelected(false);
                    }
                }
            }
        }
    });

    //call unload after the bindings since the extension's onload might trigger something
    for (SchemaProviderUiExtension extension : schemaProviders) {
        extension.onLoad();
    }

    // auto select provider if only one is present
    if (schemaProviders.size() == 1) {
        schemaProviders.get(0).setSelected(true);
    }

    document.invokeLater(new Runnable() {
        public void run() {
            showConnectionDialog();
        }
    });

}

From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java

private void addSparkClustersLineItem() {
    JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)");
    sparkClusterLabel.setToolTipText(/*from  w  w w . ja va  2s.c  o  m*/
            "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    GridBagConstraints c11 = new GridBagConstraints();
    c11.gridx = 0;
    c11.gridy = 0;
    c11.insets = new Insets(margin, margin, 0, margin);
    add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));

    clustersListComboBox = new ComboboxWithBrowseButton();
    clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH));
    clustersListComboBox.getButton().setToolTipText("Refresh");
    clustersListComboBox.getButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Cursor cursor = getCursor();
            setCursor(new Cursor(Cursor.WAIT_CURSOR));
            List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance()
                    .getClusterDetails(submitModel.getProject());
            setCursor(cursor);
            submitModel.setClusterComboBoxModel(clusterDetails);
        }
    });
    clustersListComboBox.getComboBox().setToolTipText(
            "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) {
                int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize();
                setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0);
            }
        }
    });

    add(clustersListComboBox,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));

    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel(
            "Cluster Name Should not be null");
    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());

    clustersListComboBox.getComboBox().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0);
        }
    });

    add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}

From source file:BeanContainer.java

public void propertyChange(PropertyChangeEvent evt) {
        m_data.setProperty(evt.getPropertyName(), evt.getNewValue());
    }

From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImageWizardModel.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt != null) {
        firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
    }/*from ww w  . j a  v a 2 s  .  c  o m*/
}

From source file:au.org.ala.delta.editor.ui.ActionSetsDialog.java

private void exportDirectivesAndRun() {
    DeltaEditor editor = (DeltaEditor) Application.getInstance();
    ExportController exportController = new ExportController(editor);
    exportController.begin(new PropertyChangeListener() {

        @Override//  w w w .j a  va  2  s  . c  om
        public void propertyChange(PropertyChangeEvent evt) {
            if ("done".equals(evt.getPropertyName())) {
                if (Boolean.TRUE.equals(evt.getNewValue())) {
                    fireRunDirectiveFileAction();
                }
            }
        }
    });
}

From source file:com.anrisoftware.prefdialog.fields.filechooser.FileChooserField.java

/**
 * @see FileChooserFieldFactory#create(Object, String)
 *///w  w  w . j  ava  2s  .  c o m
@Inject
FileChooserField(FileChooserFieldLogger logger, UiPanel panel, FileTextField fileTextField,
        OpenDialogAction openDialogAction, @Assisted Object parentObject, @Assisted String fieldName) {
    super(panel, parentObject, fieldName);
    this.panel = panel;
    this.log = logger;
    this.fileTextField = fileTextField;
    this.openDialogAction = openDialogAction;
    this.fileListener = lockedVetoableChangeListener(new VetoableChangeListener() {

        @Override
        public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
            try {
                fileListener.lock();
                setValue(evt.getNewValue());
            } finally {
                fileListener.unlock();
            }
        }
    });
    this.fileTextFieldValueListener = lockedPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            try {
                setValue(evt.getNewValue());
            } catch (PropertyVetoException e) {
            }
        }
    });
    this.fileAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                setValue(FileChooserField.this.fileTextField.getValue());
            } catch (PropertyVetoException e1) {
            }
        }
    };
    setupPanel();
}

From source file:edu.ku.brc.specify.tasks.CleanupToolsTask.java

/**
 * /*from  ww  w.  j  a va2  s .  c  om*/
 */
private void updateNames(final Vector<AgentNameCleanupParserDlg.DataItem> dataItemsList) {
    final String PRC = "PROCESS";
    final SimpleGlassPane glassPane = UIRegistry.writeSimpleGlassPaneMsg("Processing agents...", 24);

    //prgDlg = new ProgressDialog(getResourceString("CLNUP_AG_PRG_TITLE"), true, false);
    //prgDlg.getProcessProgress().setIndeterminate(true);
    //prgDlg.setDesc(getResourceString("CLNUP_AG_INIT_MSG"));
    //UIHelper.centerAndShow(prgDlg);

    final SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
        double tot = 0; // 1 -> 100
        double step = 1.0;
        int cnt = 0;

        @Override
        protected Object doInBackground() throws Exception {
            step = 100.0 / dataItemsList.size();

            Connection conn = null;
            PreparedStatement pStmt = null;
            try {
                String sql = "UPDATE agent SET LastName=?, FirstName=?,MiddleInitial=? WHERE AgentID = ?";
                conn = DBConnection.getInstance().createConnection();
                pStmt = conn.prepareStatement(sql);

                for (DataItem di : dataItemsList) {
                    if (di.isIncluded()) {
                        setColumn(pStmt, 1, di.getLastName());
                        setColumn(pStmt, 2, di.getFirstName());
                        setColumn(pStmt, 3, di.getMidName());
                        pStmt.setInt(4, di.getAgentId());

                        if (pStmt.executeUpdate() != 1) {
                            log.error(String.format("Error updating AgentID %d", di.getAgentId()));
                        }
                    }

                    tot += step;
                    if (((int) tot) > cnt) {
                        cnt = (int) tot;
                        firePropertyChange(PRC, -1, cnt);
                    }
                }
                dataItemsList.clear();

            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (pStmt != null)
                        pStmt.close();
                    if (conn != null)
                        conn.close();

                } catch (SQLException ex) {
                }
            }
            return null;
        }

        @Override
        protected void done() {
            UIRegistry.clearSimpleGlassPaneMsg();
            UIRegistry.showLocalizedMsg("Done.");
        }
    };
    worker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (PRC.equals(evt.getPropertyName())) {
                glassPane.setProgress((Integer) evt.getNewValue());
            }
        }
    });
    worker.execute();
}