List of usage examples for java.beans PropertyChangeEvent PropertyChangeEvent
public PropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue)
From source file:org.archive.spring.Sheet.java
/** * Ensure any properties targetted by this Sheet know to * check the right property paths for overrides at lookup time, * and that the override values are compatible types for their * destination properties. //from ww w . ja v a 2 s. c om * * Should be done as soon as all possible targets are * constructed (ApplicationListener ContextRefreshedEvent) * * TODO: consider if an 'un-priming' also needs to occur to * prevent confusing side-effects. * TODO: consider if priming should move to another class */ public void prime() { for (String fullpath : map.keySet()) { int lastDot = fullpath.lastIndexOf("."); String beanPath = fullpath.substring(0, lastDot); String terminalProp = fullpath.substring(lastDot + 1); Object value = map.get(fullpath); int i = beanPath.indexOf("."); Object bean; HasKeyedProperties hkp; if (i < 0) { bean = beanFactory.getBean(beanPath); } else { String beanName = beanPath.substring(0, i); String propPath = beanPath.substring(i + 1); BeanWrapperImpl wrapper = new BeanWrapperImpl(beanFactory.getBean(beanName)); bean = wrapper.getPropertyValue(propPath); } try { hkp = (HasKeyedProperties) bean; } catch (ClassCastException cce) { // targetted bean has no overridable properties throw new TypeMismatchException(bean, HasKeyedProperties.class, cce); } // install knowledge of this path hkp.getKeyedProperties().addExternalPath(beanPath); // verify type-compatibility BeanWrapperImpl wrapper = new BeanWrapperImpl(hkp); Class<?> requiredType = wrapper.getPropertyType(terminalProp); try { // convert for destination type map.put(fullpath, wrapper.convertForProperty(value, terminalProp)); } catch (TypeMismatchException tme) { TypeMismatchException tme2 = new TypeMismatchException( new PropertyChangeEvent(hkp, fullpath, wrapper.getPropertyValue(terminalProp), value), requiredType, tme); throw tme2; } } }
From source file:com.jaspersoft.studio.server.ServerManager.java
public static void saveServerProfile(MServerProfile adapter) { if (serverProfiles.containsKey(adapter)) { // It's an edit, remove the old configuration file and save the new // one/*from www . j ava2s . co m*/ String path = serverProfiles.get(adapter); ConfigurationManager.removeStoregeResource(PREF_TAG, path); saveIntoStrage(adapter, path); propertyChangeSupport .firePropertyChange(new PropertyChangeEvent(adapter, SERVERPROFILE, null, adapter)); } }
From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java
/** * @param infileName/*from w ww . jav a 2 s .c o 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:org.jcurl.core.api.PropertyChangeSupport.java
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:org.pentaho.ui.xul.binding.DefaultBinding.java
public void fireSourceChanged() throws IllegalArgumentException, XulException, InvocationTargetException { try {// w w w . j ava2 s. c om Object getRetVal = sourceGetterMethod.invoke(getSource().get()); forwardListener.propertyChange(new PropertyChangeEvent(getSource(), getSourceAttr(), null, getRetVal)); } catch (IllegalAccessException e) { // TODO: re-implement IllegalAccessException. // cannot be in interface due to GWT incompatibility. handleException(new BindingException(e)); } }
From source file:blue.mixer.Effect.java
public void setNumIns(int numIns) { Integer oldVal = new Integer(this.numIns); Integer newVal = new Integer(numIns); PropertyChangeEvent pce = new PropertyChangeEvent(this, "numIns", oldVal, newVal); this.numIns = numIns; firePropertyChangeEvent(pce);// ww w . ja v a 2 s.c o m }
From source file:org.springframework.binding.value.support.AbstractValueModel.java
/** * Notifies all listeners that have registered interest for * notification on this event type. This method does not check if there is any change * between the old and new value unlike the various fireValueChanged() methods. *///from w ww . j av a2s . co m protected void fireValueChangeEvent(Object oldValue, Object newValue) { if (logger.isDebugEnabled()) { logger.debug("Firing value changed event. Old value='" + oldValue + "' new value='" + newValue + "'"); } final PropertyChangeListener[] propertyChangeListeners = getPropertyChangeListeners(VALUE_PROPERTY); if (propertyChangeListeners.length > 0) { final Object listenerToSkip = listenerToSkipHolder.get(); final PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, VALUE_PROPERTY, oldValue, newValue); for (int i = 0; i < propertyChangeListeners.length; i++) { PropertyChangeListener listener = propertyChangeListeners[i]; if (listener != listenerToSkip) { listener.propertyChange(propertyChangeEvent); } } } }
From source file:zlicense.de.schlichtherle.xml.GenericCertificate.java
public synchronized void setSignature(String paramString) throws GenericCertificateIsLockedException { if (paramString == null) { if (this.signature != null) { }/*from www. ja va2s .com*/ } else if (paramString.equals(this.signature)) { return; } PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "signature", getSignature(), paramString); if (isLocked()) { throw new GenericCertificateIsLockedException(localPropertyChangeEvent); } this.signature = paramString; firePropertyChange(localPropertyChangeEvent); }
From source file:blue.mixer.Effect.java
public void setNumOuts(int numOuts) { Integer oldVal = new Integer(this.numOuts); Integer newVal = new Integer(numOuts); PropertyChangeEvent pce = new PropertyChangeEvent(this, "numOuts", oldVal, newVal); this.numOuts = numOuts; firePropertyChangeEvent(pce);//from w w w . j a va 2s . c o m }
From source file:org.geopublishing.geopublisher.AtlasConfigEditable.java
/** * Informs all registered {@link PropertyChangeListener}s about a change in * the {@link AtlasConfigEditable}. Also informs all listeners of MapPool * and DataPool./*from w w w . j a v a2 s.com*/ */ public void fireChangeEvents() { PropertyChangeEvent pce = new PropertyChangeEvent(this, "change", false, true); for (PropertyChangeListener pcl : listeners) { if (pcl != null) pcl.propertyChange(pce); } getMapPool().fireChangeEvents(this, EventTypes.unknown, null); getDataPool().fireChangeEvents(org.geopublishing.atlasViewer.dp.DataPool.EventTypes.unknown); }