List of usage examples for java.beans PropertyChangeEvent getPropertyName
public String getPropertyName()
From source file:org.tinymediamanager.ui.MainWindow.java
private void checkForUpdate() { try {/*from w w w . j av a2s . c om*/ final UpdaterTask updateWorker = new UpdaterTask(); updateWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("state".equals(evt.getPropertyName()) && evt.getNewValue() == StateValue.DONE) { try { boolean update = updateWorker.get(); LOGGER.debug("update result was: " + update); if (update) { // we might need this somewhen... if (updateWorker.isForcedUpdate()) { LOGGER.info("Updating (forced)..."); closeTmmAndStart(Utils.getPBforTMMupdate()); return; } // show whatsnewdialog with the option to update if (StringUtils.isNotBlank(updateWorker.getChangelog())) { UpdateDialog dialog = new UpdateDialog(updateWorker.getChangelog()); dialog.setVisible(true); } else { // do the update without changelog popup int answer = JOptionPane.showConfirmDialog(null, BUNDLE.getString("tmm.update.message"), BUNDLE.getString("tmm.update.title"), JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.OK_OPTION) { LOGGER.info("Updating..."); // spawn getdown and exit TMM closeTmmAndStart(Utils.getPBforTMMupdate()); } } } } catch (Exception e) { LOGGER.error("Update task failed!" + e.getMessage()); } } } }); // update task start a few secs after GUI... Timer timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateWorker.execute(); } }); timer.setRepeats(false); timer.start(); } catch (Exception e) { LOGGER.error("Update task failed!" + e.getMessage()); } }
From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java
/** * @param infileName/*from ww w .ja va 2 s . co m*/ * @param outFileName * @param changeListener * @return */ public boolean compressFile(final String infileName, final String outFileName, final PropertyChangeListener propChgListener) { final File file = new File(infileName); if (file.exists()) { long fileSize = file.length(); if (fileSize > 0) { SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() { protected String errorMsg = null; protected FileInputStream fis = null; protected GZIPOutputStream fos = null; /* (non-Javadoc) * @see javax.swing.SwingWorker#doInBackground() */ @Override protected Integer doInBackground() throws Exception { try { Thread.sleep(100); long totalSize = file.length(); long bytesCnt = 0; FileInputStream fis = new FileInputStream(infileName); GZIPOutputStream fos = new GZIPOutputStream(new FileOutputStream(outFileName)); byte[] bytes = new byte[BUFFER_SIZE * 10]; while (true) { int len = fis.read(bytes); if (len > 0) { fos.write(bytes, 0, len); bytesCnt += len; firePropertyChange("MEGS", 0, (int) (((double) bytesCnt / (double) totalSize) * 100.0)); } else { break; } } fis.close(); fos.close(); } catch (Exception ex) { ex.printStackTrace(); errorMsg = ex.toString(); } finally { try { if (fis != null) { fis.close(); } if (fos != null) { fos.close(); } } catch (IOException ex) { errorMsg = ex.toString(); } } firePropertyChange("MEGS", 0, 100); return null; } @Override protected void done() { super.done(); UIRegistry.getStatusBar().setProgressDone(HttpLargeFileTransfer.class.toString()); //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("Compressing Backup..."), 24); backupWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if ("MEGS".equals(evt.getPropertyName())) { Integer value = (Integer) evt.getNewValue(); double val = value / 10.0; statusBar .setText(UIRegistry.getLocalizedMessage("MySQLBackupService.BACKUP_MEGS", val)); } } }); backupWorker.execute(); } else { // file doesn't exist } } else { // file doesn't exist } return false; }
From source file:Converter.java
/** * Detects when the value of the text field (not necessarily the same number * as you'd get from getText) changes.//from w ww . j a va 2 s .c o m */ public void propertyChange(PropertyChangeEvent e) { if ("value".equals(e.getPropertyName())) { Number value = (Number) e.getNewValue(); sliderModel.setDoubleValue(value.doubleValue()); } }
From source file:edu.ucla.stat.SOCR.analyses.gui.Clustering.java
/** Implementation of PropertyChageListener.*/ public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); if (propertyName.equals("DataUpdate")) { //update the local version of the dataTable by outside source dataTable = (JTable) (e.getNewValue()); dataPanel.removeAll();/*from w w w . java 2s. c o m*/ dataPanel.add(new JScrollPane(dataTable)); } }
From source file:org.rdv.viz.spectrum.SpectrumViz.java
/** * Hanles property change events from the spectrum analyzer panel. * /*from www. jav a2 s . c o m*/ * @param pce the property change event */ private void hanelSpectrumAnalyzerPanelPropertyChanges(PropertyChangeEvent pce) { String propertyName = pce.getPropertyName(); if (propertyName.equals(SpectrumAnalyzerPanel.SAMPLE_RATE_PROPERTY)) { String sampleRate = Double.toString(spectrumAnalyzerPanel.getSampleRate()); sampleRateTextField.setText(sampleRate); properties.setProperty(DATA_PANEL_PROPERTY_SAMPLE_RATE, sampleRate); } else if (propertyName.equals(SpectrumAnalyzerPanel.NUMBER_OF_SAMPLES_PROPERTY)) { String numberOfSamples = Integer.toString(spectrumAnalyzerPanel.getNumberOfSamples()); numberOfSamplesTextField.setText(numberOfSamples); properties.setProperty(DATA_PANEL_PROPERTY_NUMBER_OF_SAMPLES, numberOfSamples); } else if (propertyName.equals(SpectrumAnalyzerPanel.WINDOW_FUNCTION_PROPERTY)) { WindowFunction windowFunction = spectrumAnalyzerPanel.getWindowFunction(); windowFunctionComboBox.setSelectedItem(windowFunction); String windowFunctionString = windowFunction.toString(); properties.setProperty(DATA_PANEL_PROPERTY_WINDOW_FUNCTION, windowFunctionString); } else if (propertyName.equals(SpectrumAnalyzerPanel.SEGMENT_SIZE_PROPERTY)) { String segmentSize = Integer.toString(spectrumAnalyzerPanel.getSegmentSize()); segmentSizeTextField.setText(segmentSize); properties.setProperty(DATA_PANEL_PROPERTY_SEGMENT_SIZE, segmentSize); } else if (propertyName.equals(SpectrumAnalyzerPanel.OVERLAP_PROPERTY)) { String overlap = Integer.toString(spectrumAnalyzerPanel.getOverlap()); overlapTextField.setText(overlap); properties.setProperty(DATA_PANEL_PROPERTY_OVERLAP, overlap); } }
From source file:finale.year.stage.main.Authentification.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*w w w .j av a2 s .c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - unknown private void initComponents() { innerPanel = new JPanel(); emailField = new JTextField(); rememberMe = new JCheckBox(); logInBtn = new JButton(); passWord = new JPasswordField(); signUpBtn = new JButton(); forgotBtn = new JButton(); userIcon = new JLabel(); passwordIcon = new JLabel(); errorStatusBar = new JLabel(); //======== this ======== // JFormDesigner evaluation mark 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), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); setLayout(new GridBagLayout()); //======== innerPanel ======== { innerPanel.setBorder(new EtchedBorder()); //---- emailField ---- emailField.setText("Email"); emailField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { emailFieldActionPerformed(e); } }); //---- rememberMe ---- rememberMe.setText("Remember me"); rememberMe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rememberMeActionPerformed(e); } }); //---- logInBtn ---- logInBtn.setText("Log In"); logInBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logInBtnActionPerformed(e); } }); //---- passWord ---- passWord.setText("password"); //---- signUpBtn ---- signUpBtn.setText("Sign Up"); signUpBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { signUpBtnActionPerformed(e); } }); //---- forgotBtn ---- forgotBtn.setText("Forgot Password?"); forgotBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { forgotBtnActionPerformed(e); } }); //---- userIcon ---- userIcon.setIcon(new ImageIcon(getClass().getResource("/Resources/glyphicons_user.png"))); //---- passwordIcon ---- passwordIcon.setIcon(new ImageIcon(getClass().getResource("/Resources/glyphicons_lock.png"))); GroupLayout innerPanelLayout = new GroupLayout(innerPanel); innerPanel.setLayout(innerPanelLayout); innerPanelLayout.setHorizontalGroup(innerPanelLayout.createParallelGroup().addGroup(innerPanelLayout .createSequentialGroup() .addGroup(innerPanelLayout.createParallelGroup() .addGroup(innerPanelLayout.createSequentialGroup().addGap(106, 106, 106) .addComponent(forgotBtn)) .addGroup(innerPanelLayout.createSequentialGroup().addGap(73, 73, 73) .addGroup(innerPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(userIcon, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE) .addComponent(passwordIcon, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(innerPanelLayout .createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(passWord).addComponent(emailField, GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))) .addGroup(innerPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addGroup(innerPanelLayout.createSequentialGroup().addGap(106, 106, 106) .addComponent(rememberMe) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(logInBtn, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)) .addGroup(innerPanelLayout.createSequentialGroup().addGap(375, 375, 375) .addComponent(signUpBtn, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE))) .addGroup(innerPanelLayout.createSequentialGroup().addGap(218, 218, 218) .addComponent(errorStatusBar))) .addContainerGap(100, Short.MAX_VALUE))); innerPanelLayout.setVerticalGroup(innerPanelLayout.createParallelGroup().addGroup(innerPanelLayout .createSequentialGroup().addContainerGap().addComponent(errorStatusBar).addGap(30, 30, 30) .addGroup(innerPanelLayout.createParallelGroup() .addComponent(userIcon, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(emailField, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30) .addGroup(innerPanelLayout.createParallelGroup() .addComponent(passwordIcon, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE) .addComponent(passWord, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( innerPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(rememberMe, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE) .addComponent(logInBtn)) .addGap(6, 6, 6).addComponent(forgotBtn).addGap(6, 6, 6).addComponent(signUpBtn) .addContainerGap(69, Short.MAX_VALUE))); } add(innerPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -20, 4)); }
From source file:edu.ku.brc.specify.config.init.MasterUserPanel.java
/** * // www . ja v a 2 s . c om */ protected void createMasterUser() { String saUsrNm = ((JTextField) comps.get("saUserName")).getText(); if (StringUtils.isNotEmpty(saUsrNm) && saUsrNm.equalsIgnoreCase("root")) { UIRegistry.showLocalizedError("MASTER_NO_ROOT"); ((JTextField) comps.get("saUserName")).setText(""); return; } if (!checkPermsForMasterUserCreation()) { return; } if (isOK == null || !isOK) { progressBar.setIndeterminate(true); progressBar.setVisible(true); setUIEnabled(false); label.setText(UIRegistry.getResourceString("CONN_DB")); createMUBtn.setVisible(false); SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { MasterUserPanel.this.label.setForeground(Color.BLACK); isOK = false; if (!isEmbedded) { DBMSUserMgr mgr = DBMSUserMgr.getInstance(); String dbUserName = properties.getProperty("dbUserName"); String dbPassword = properties.getProperty("dbPassword"); String dbName = properties.getProperty("dbName"); String hostName = properties.getProperty("hostName"); String saUserName = ((JTextField) comps.get("saUserName")).getText(); String saPassword = ((JTextField) comps.get("saPassword")).getText(); if (mgr.connectToDBMS(dbUserName, dbPassword, hostName)) { if (mgr.doesUserExists(saUserName)) { if (!mgr.setPermissions(saUserName, dbName, DBMSUserMgr.PERM_ALL_BASIC)) { errorKey = "ERR_SET_PERM"; } else { isOK = true; } } if (!mgr.doesUserExists(saUserName)) { firePropertyChange(propName, 0, 1); isOK = mgr.createUser(saUserName, saPassword, dbName, DBMSUserMgr.PERM_ALL_BASIC); if (!isOK) { errorKey = "ERR_CRE_MASTER"; } else { isOK = true; } } } else { errorKey = "NO_CONN_ROOT"; isOK = false; } if (mgr != null) { mgr.close(); } } else { isOK = true; } return null; } /* (non-Javadoc) * @see javax.swing.SwingWorker#done() */ @Override protected void done() { super.done(); progressBar.setIndeterminate(false); progressBar.setVisible(false); setUIEnabled(true); updateBtnUI(); createMUBtn.setVisible(!isOK); if (isOK) { setUIEnabled(false); label.setText(UIRegistry.getResourceString("MASTER_CREATED")); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { nextBtn.doClick(); } }); } else { label.setText(UIRegistry.getResourceString(errorKey)); UIRegistry.showLocalizedError(errorKey); } } }; worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (propName.equals(evt.getPropertyName())) { MasterUserPanel.this.label.setText(UIRegistry.getLocalizedMessage("CREATE_MASTER")); } } }); worker.execute(); } }
From source file:org.esa.snap.graphbuilder.gpf.ui.worldmap.NestWorldMapPane.java
private void updateUiState(PropertyChangeEvent evt) { if (NestWorldMapPaneDataModel.PROPERTY_LAYER.equals(evt.getPropertyName())) { exchangeWorldMapLayer();//from w w w. j ava2 s .c om } if (NestWorldMapPaneDataModel.PROPERTY_PRODUCTS.equals(evt.getPropertyName())) { repaint(); } if (NestWorldMapPaneDataModel.PROPERTY_SELECTED_PRODUCT.equals(evt.getPropertyName()) || NestWorldMapPaneDataModel.PROPERTY_AUTO_ZOOM_ENABLED.equals(evt.getPropertyName())) { final Product selectedProduct = dataModel.getSelectedProduct(); if (selectedProduct != null && dataModel.isAutoZommEnabled()) { zoomToProduct(selectedProduct); } else { repaint(); } } if (NestWorldMapPaneDataModel.PROPERTY_ADDITIONAL_GEO_BOUNDARIES.equals(evt.getPropertyName()) || NestWorldMapPaneDataModel.PROPERTY_SELECTED_GEO_BOUNDARIES.equals(evt.getPropertyName())) { repaint(); } }
From source file:org.docx4all.swing.ExternalHyperlinkDialog.java
/** This method reacts to state changes in the option pane. */ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == this.optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object userAnswer = this.optionPane.getValue(); if (userAnswer == JOptionPane.UNINITIALIZED_VALUE) { //ignore reset return; }/*w ww . j a v a2 s .c o m*/ //Reset the JOptionPane's value. //If you don't do this, then if the user //presses the same button next time, no //property change event will be fired. this.optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); setVisible(false); if (OK_BUTTON_TEXT.equals(userAnswer)) { this.value = OK_BUTTON_TEXT; StringBuilder target = new StringBuilder(); if (isSourceFileDirectory(this.directoryUrlPath)) { target.append(this.documentNameField.getText()); } else { target.append(VFSUtils.getFriendlyName(this.directoryUrlPath, false)); target.append("/"); target.append(this.documentNameField.getText()); } if (!target.toString().endsWith(".docx")) { target.append(".docx"); } if (this.hyperlinkML.canSetTarget()) { this.hyperlinkML.setTarget(target.toString()); } else { this.hyperlinkML.setDummyTarget(target.toString()); } if (this.displayTextField.getText().length() == 0) { this.hyperlinkML.setDisplayText(target.toString()); } else { this.hyperlinkML.setDisplayText(this.displayTextField.getText()); } this.hyperlinkML.setTooltip(this.tooltipField.getText()); } else { //User closed dialog or clicked cancel this.value = CANCEL_BUTTON_TEXT; } //do not keep a reference to the edited hyperlinkML //so that this dialog can be disposed of. this.hyperlinkML = null; } }
From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java
/** * Reacts to property changes fired by the {@link TwoKnobsSlider}s. * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */// w w w . j a v a 2s .c om public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); Object source = evt.getSource(); if (!controlsBar.isLiveUpdate()) { if (TwoKnobsSlider.KNOB_RELEASED_PROPERTY.equals(name)) { paintHorizontal = false; paintVertical = false; if (source.equals(domainSlider)) { controller.setInputInterval(domainSlider.getStartValue(), domainSlider.getEndValue()); onCurveChange(); } else if (source.equals(codomainSlider)) { int s = codomainSlider.getStartValue(); int e = codomainSlider.getEndValue(); controller.setCodomainInterval(s, e); onCurveChange(); } } else if (TwoKnobsSlider.LEFT_MOVED_PROPERTY.equals(name)) { if (source.equals(domainSlider)) { verticalLine = (int) (domainSlider.getStartValue() * domainSlider.getRoundingFactor()); paintHorizontal = false; paintVertical = true; onCurveChange(); } else if (source.equals(codomainSlider)) { horizontalLine = codomainSlider.getEndValue(); paintHorizontal = true; paintVertical = false; onCurveChange(); } } else if (TwoKnobsSlider.RIGHT_MOVED_PROPERTY.equals(name)) { if (source.equals(domainSlider)) { verticalLine = (int) (domainSlider.getEndValue() * domainSlider.getRoundingFactor()); horizontalLine = -1; paintHorizontal = false; paintVertical = true; onCurveChange(); } else if (source.equals(codomainSlider)) { horizontalLine = codomainSlider.getStartValue(); verticalLine = -1; paintHorizontal = true; paintVertical = false; onCurveChange(); } } } else { paintHorizontal = false; paintVertical = false; if (TwoKnobsSlider.LEFT_MOVED_PROPERTY.equals(name) || TwoKnobsSlider.RIGHT_MOVED_PROPERTY.equals(name)) { if (source.equals(domainSlider)) { controller.setInputInterval(domainSlider.getStartValue(), domainSlider.getEndValue()); onCurveChange(); } else if (source.equals(codomainSlider)) { int s = codomainSlider.getStartValue(); int e = codomainSlider.getEndValue(); controller.setCodomainInterval(s, e); onCurveChange(); } } else if (TwoKnobsSlider.KNOB_RELEASED_PROPERTY.equals(name)) { if (source.equals(domainSlider)) { controller.setInputInterval(domainSlider.getStartValue(), domainSlider.getEndValue()); } else if (source.equals(codomainSlider)) { int s = codomainSlider.getStartValue(); int e = codomainSlider.getEndValue(); controller.setCodomainInterval(s, e); onCurveChange(); } } } }