List of usage examples for java.beans PropertyChangeEvent getPropertyName
public String getPropertyName()
From source file:edu.ku.brc.specify.tasks.CleanupToolsTask.java
/** * /*from ww w . j av a2 s. c o m*/ */ 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(); }
From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java
/** * @param fileName// www. j a va 2s .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: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/*from w w w . jav a 2 s. c o m*/ public void propertyChange(PropertyChangeEvent evt) { if ("done".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { fireRunDirectiveFileAction(); } } } }); }
From source file:maltcms.ui.nb.pipelineRunner.options.LocalMaltcmsExecutionPanel.java
private void maltcmsInstallationPathPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_maltcmsInstallationPathPropertyChange String propName = evt.getPropertyName(); if (propName.equals("text")) { String value = (String) evt.getNewValue(); checkVersion(value);/* ww w .j ava 2s . c om*/ } }
From source file:uk.ac.ox.cbrg.cpfp.uploadapp.UploadApplet.java
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { int progress = (Integer) evt.getNewValue(); prgUploadProgress.setValue(progress); }// w w w. j av a2 s . c o m }
From source file:org.myrobotlab.service.MarySpeech.java
private void showProgressPanel(List<ComponentDescription> comps, boolean install) { final ProgressPanel pp = new ProgressPanel(comps, install); final JOptionPane optionPane = new JOptionPane(pp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new String[] { "Abort" }, "Abort"); // optionPane.setPreferredSize(new Dimension(640,480)); final JDialog dialog = new JDialog((Frame) null, "Progress", false); dialog.setContentPane(optionPane);//from w w w. j ava2 s . c om optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { pp.requestExit(); dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); new Thread(pp).start(); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
private void addSparkClustersLineItem() { JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)"); sparkClusterLabel.setToolTipText(// w w w . j av a2 s . c om "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:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == "progress") { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress);//w ww .j a v a 2 s.com } }
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 w w w .j a v a 2s .com*/ }
From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java
@Override protected void initComponents() { getAlternativeView().initComponents(); dataset = new XYIntervalSeriesCollection(); this.chart = ChartFactory.createXYLineChart(CHART_TITLE, "Path in pixels", DEFAULT_SAMPLE_DATASET_NAME, dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); deviationRenderer = new DeviationRenderer(); deviationRenderer.setUseFillPaint(true); deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator()); deviationRenderer.setSeriesLinesVisible(0, true); deviationRenderer.setSeriesShapesVisible(0, false); deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f)); deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT); deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT); pointRenderer = new XYErrorRenderer(); pointRenderer.setUseFillPaint(true); pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator()); pointRenderer.setSeriesLinesVisible(0, false); pointRenderer.setSeriesShapesVisible(0, true); pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f)); pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT); pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT); pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE); configureRendererForCorrelativeData(deviationRenderer); configureRendererForCorrelativeData(pointRenderer); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setRenderer(deviationRenderer); final AxisChangeListener axisListener = new AxisChangeListener() { @Override//w w w . j a va 2 s . com public void axisChanged(AxisChangeEvent event) { adjustAxisControlComponents(); } }; final ValueAxis domainAxis = plot.getDomainAxis(); final ValueAxis rangeAxis = plot.getRangeAxis(); // allow transfer from bounds into min/max fields, if auto min/maxis enabled domainAxis.setAutoRange(true); rangeAxis.setAutoRange(true); domainAxis.addChangeListener(axisListener); rangeAxis.addChangeListener(axisListener); intervalMarkers = new HashSet<>(); xAxisRangeControl = new AxisRangeControl("X-Axis"); yAxisRangeControl = new AxisRangeControl("Y-Axis"); final PropertyChangeListener changeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) { updateDataSet(); } if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) { updateScalingOfYAxis(); } updateUIState(); } }; xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener); xAxisRangeControl.getBindingContext().getPropertySet() .addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false)); xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_MARK_SEGMENTS) .setDescription("Toggle whether to mark segments"); yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener); yAxisRangeControl.getBindingContext().getPropertySet() .addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false)); yAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED) .setDescription("Toggle whether to use a logarithmic axis"); dataSourceConfig = new DataSourceConfig(); final BindingContext bindingContext = new BindingContext( PropertyContainer.createObjectBacked(dataSourceConfig)); JPanel middlePanel = createMiddlePanel(bindingContext); createUI(createChartPanel(chart), middlePanel, bindingContext); isInitialized = true; updateComponents(); }