List of usage examples for java.beans PropertyChangeEvent PropertyChangeEvent
public PropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue)
From source file:org.jcurl.core.helpers.PropertyChangeSupport.java
/** * Shortcut for firing an event on integer properties. * /*from ww w.jav a2 s.com*/ * @param property * the name of the property which changed. * @param old * The old value. * @param neo * The new value. */ public void firePropertyChange(final String property, final int old, final int neo) { final PropertyChangeEvent event = new PropertyChangeEvent(producer, property, new Integer(old), new Integer(neo)); this.firePropertyChange(event); }
From source file:blue.mixer.Channel.java
public void firePropertyChange(String propertyName, Object oldVal, Object newVal) { if (listeners == null || listeners.size() == 0) { return;/* w w w. jav a 2s . co m*/ } PropertyChangeEvent pce = new PropertyChangeEvent(this, propertyName, oldVal, newVal); for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) { PropertyChangeListener pcl = it.next(); pcl.propertyChange(pce); } }
From source file:uk.ac.diamond.scisoft.analysis.rcp.inspector.AxisSelection.java
/** * Select an axis with given name//from www. j a v a 2 s . c o m * @param name * @param fire */ public void selectAxis(String name, boolean fire) { int i = names.indexOf(name); if (i < 0) return; String oldName = getSelectedName(); for (AxisSelData d : asData) d.setSelected(false); AxisSelData a = asData.get(i); a.setSelected(true); if (fire) fire(new PropertyChangeEvent(this, propName, oldName, name)); }
From source file:org.jcurl.core.helpers.PropertyChangeSupport.java
/** * Notify listeners that an object type property has changed * /*from w w w.java 2 s.c o m*/ * @param property * the name of the property which changed. * @param old * The old value. * @param neo * The new value. */ public void firePropertyChange(final String property, final Object old, final Object neo) { final PropertyChangeEvent event = new PropertyChangeEvent(producer, property, old, neo); this.firePropertyChange(event); }
From source file:edu.ku.brc.af.core.db.MySQLBackupService.java
/** * Does the backup on a SwingWorker Thread. * @param isMonthly whether it is a monthly backup * @param doSendAppExit requests sending an application exit command when done * @return true if the prefs are set up and there were no errors before the SwingWorker thread was started *///from w w w . jav a 2 s . c o m private boolean doBackUp(final boolean isMonthly, final boolean doSendAppExit, final PropertyChangeListener propChgListener) { AppPreferences remotePrefs = AppPreferences.getLocalPrefs(); final String mysqldumpLoc = remotePrefs.get(MYSQLDUMP_LOC, getDefaultMySQLDumpLoc()); final String backupLoc = remotePrefs.get(MYSQLBCK_LOC, getDefaultBackupLoc()); if (!(new File(mysqldumpLoc)).exists()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_DUMP", mysqldumpLoc); if (propChgListener != null) { propChgListener.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1)); } return false; } File backupDir = new File(backupLoc); if (!backupDir.exists()) { if (!backupDir.mkdir()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_BK_DIR", backupDir.getAbsoluteFile()); if (propChgListener != null) { propChgListener.propertyChange(new PropertyChangeEvent(MySQLBackupService.this, ERROR, 0, 1)); } return false; } } errorMsg = null; final String databaseName = DBConnection.getInstance().getDatabaseName(); getNumberofTables(); SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() { protected String fullPath = null; /* (non-Javadoc) * @see javax.swing.SwingWorker#doInBackground() */ @Override protected Integer doInBackground() throws Exception { FileOutputStream backupOut = null; try { Thread.sleep(100); // Create output file SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_kk_mm_ss"); String fileName = sdf.format(Calendar.getInstance().getTime()) + (isMonthly ? "_monthly" : "") + ".sql"; fullPath = backupLoc + File.separator + fileName; File file = new File(fullPath); backupOut = new FileOutputStream(file); writeStats(getCollectionStats(getTableNames()), getStatsName(fullPath)); String userName = DBConnection.getInstance().getUserName(); String password = DBConnection.getInstance().getPassword(); if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) { Pair<String, String> up = UserAndMasterPasswordMgr.getInstance().getUserNamePasswordForDB(); if (up != null && up.first != null && up.second != null) { userName = up.first; password = up.second; } } String port = DatabaseDriverInfo.getDriver(DBConnection.getInstance().getDriverName()) .getPort(); String server = DBConnection.getInstance().getServerName(); Vector<String> args = new Vector<String>(); args.add(mysqldumpLoc); args.add("--user=" + userName); args.add("--password=" + password); args.add("--host=" + server); if (port != null) { args.add("--port=" + port); } args.add(databaseName); Process process = Runtime.getRuntime().exec(args.toArray(new String[0])); InputStream input = process.getInputStream(); byte[] bytes = new byte[8192 * 2]; double oneMeg = (1024.0 * 1024.0); long dspMegs = 0; long totalBytes = 0; do { int numBytes = input.read(bytes, 0, bytes.length); totalBytes += numBytes; if (numBytes > 0) { long megs = (long) (totalBytes / oneMeg); if (megs != dspMegs) { dspMegs = megs; long megsWithTenths = (long) ((totalBytes * 10.0) / oneMeg); firePropertyChange(MEGS, 0, megsWithTenths); } backupOut.write(bytes, 0, numBytes); } else { break; } } while (true); StringBuilder sb = new StringBuilder(); String line; BufferedReader errIn = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((line = errIn.readLine()) != null) { //System.err.println(line); if (line.startsWith("ERR") || StringUtils.contains(line, "Got error")) { sb.append(line); sb.append("\n"); if (StringUtils.contains(line, "1044") && StringUtils.contains(line, "LOCK TABLES")) { sb.append("\n"); sb.append(UIRegistry.getResourceString("MySQLBackupService.LCK_TBL_ERR")); sb.append("\n"); } } } errorMsg = sb.toString(); } catch (Exception ex) { ex.printStackTrace(); errorMsg = ex.toString(); UIRegistry.showLocalizedError("MySQLBackupService.EXCP_BK"); } finally { if (backupOut != null) { try { backupOut.flush(); backupOut.close(); } catch (IOException ex) { ex.printStackTrace(); errorMsg = ex.toString(); } } } return null; } @Override protected void done() { super.done(); UIRegistry.getStatusBar().setProgressDone(STATUSBAR_NAME); UIRegistry.clearSimpleGlassPaneMsg(); if (StringUtils.isNotEmpty(errorMsg)) { UIRegistry.showError(errorMsg); } if (doSendAppExit) { CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit")); } if (propChgListener != null) { propChgListener .propertyChange(new PropertyChangeEvent(MySQLBackupService.this, DONE, null, fullPath)); } } }; final JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setIndeterminate(STATUSBAR_NAME, true); UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("MySQLBackupService.BACKINGUP", databaseName), 24); backupWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (MEGS.equals(evt.getPropertyName())) { long value = (Long) evt.getNewValue(); double val = value / 10.0; statusBar.setText(UIRegistry.getLocalizedMessage("MySQLBackupService.BACKUP_MEGS", val)); } } }); backupWorker.execute(); return true; }
From source file:org.polymap.core.data.ui.featuretable.FeatureTableViewer.java
protected void firePropChange(final String name, Object oldValue, final Object newValue) { final PropertyChangeEvent ev = new PropertyChangeEvent(this, name, oldValue, newValue); Display display = getTable().getDisplay(); display.asyncExec(new Runnable() { public void run() { if (getTable().isDisposed()) { return; }//from ww w .j ava2s. c om // if (PROP_CONTENT_SIZE.equals( name ) ) { // getTable().setForeground( Graphics.getColor( 0x70, 0x70, 0x80 ) ); // } for (PropertyChangeListener l : listeners.getListeners()) { l.propertyChange(ev); } } }); }
From source file:org.apache.geode.modules.session.TestSessionsBase.java
/** * Test setting the session expiration via a property change as would happen under normal * deployment conditions./* ww w .j a va2s . com*/ */ @Test public void testSessionExpiration2() throws Exception { // TestSessions only live for a minute sessionManager.propertyChange(new PropertyChangeEvent(server.getRootContext(), "sessionTimeout", new Integer(30), new Integer(1))); // Check that the value has been set to 60 seconds assertEquals(60, sessionManager.getMaxInactiveInterval()); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.inspector.AxisSelection.java
/** * Select an axis with given index// ww w . j av a2 s.co m * @param index * @param fire */ public void selectAxis(int index, boolean fire) { AxisSelData a = (AxisSelData) CollectionUtils.find(asData, axisSelectionPredicate); if (a != null) a.setSelected(false); asData.get(index).setSelected(true); if (!fire) { return; } String oldName = a == null ? null : names.get(asData.indexOf(a)); fire(new PropertyChangeEvent(this, propName, oldName, names.get(index))); }
From source file:blue.soundObject.tracker.Track.java
public void firePropertyChange(String propertyName, Object oldVal, Object newVal) { if (listeners == null || listeners.size() == 0) { return;/* w ww . ja v a 2 s . com*/ } PropertyChangeEvent pce = new PropertyChangeEvent(this, propertyName, oldVal, newVal); for (Iterator it = listeners.iterator(); it.hasNext();) { PropertyChangeListener pcl = (PropertyChangeListener) it.next(); pcl.propertyChange(pce); } }
From source file:uk.ac.diamond.scisoft.analysis.rcp.inspector.InspectionTab.java
@Override public Composite createTabComposite(Composite parent) { ScrolledComposite sComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); Composite holder = new Composite(sComposite, SWT.NONE); holder.setLayout(new GridLayout(2, false)); axisLabels = new ArrayList<Label>(); combos = new ArrayList<Combo>(); SelectionAdapter listener = new SelectionAdapter() { @Override//from w ww. j a v a2 s.co m public void widgetSelected(SelectionEvent e) { Combo c = (Combo) e.widget; int i = combos.indexOf(c); if (i >= 0 && paxes != null) { PlotAxisProperty p = paxes.get(i); String item = c.getItem(c.getSelectionIndex()); if (item.equals(p.getName())) return; p.setName(item, false); repopulateCombos(null, null); } } }; createCombos(holder, listener); if (daxes != null) populateCombos(); if (itype == InspectorType.LINESTACK) { final Button b = new Button(holder, SWT.CHECK); b.setText("In 3D"); b.setToolTipText("Check to plot stack of lines in 3D"); b.setSelection(plotStackIn3D); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { plotStackIn3D = b.getSelection(); if (paxes != null) { // signal a replot without a slice reset PlotAxisProperty p = paxes.get(0); p.fire(new PropertyChangeEvent(p, PlotAxisProperty.plotUpdate, p.getName(), p.getName())); } } }); } else if (itype == InspectorType.SURFACE) { final IPlottingSystem plottingSystem = PlottingFactory.getPlottingSystem(PLOTNAME); final Link openWindowing = new Link(holder, SWT.WRAP); openWindowing.setText("Open the <a>Slice Window</a>"); openWindowing.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 0)); openWindowing.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (plottingSystem != null) { try { final IToolPageSystem system = (IToolPageSystem) plottingSystem .getAdapter(IToolPageSystem.class); system.setToolVisible("org.dawb.workbench.plotting.tools.windowTool", ToolPageRole.ROLE_3D, "org.dawb.workbench.plotting.views.toolPageView.3D"); } catch (Exception e1) { logger.error("Cannot open window tool!", e1); } } } }); } holder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); sComposite.setContent(holder); holder.setSize(holder.computeSize(SWT.DEFAULT, SWT.DEFAULT)); composite = sComposite; return composite; }