Search in sources :

Example 26 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project Botnak by Gocnak.

the class BaseTitlePane method maximize.

protected void maximize() {
    Frame frame = getFrame();
    if (frame != null) {
        PropertyChangeListener[] pcl = frame.getPropertyChangeListeners();
        for (PropertyChangeListener aPcl : pcl) {
            aPcl.propertyChange(new PropertyChangeEvent(this, "windowMaximize", Boolean.FALSE, Boolean.FALSE));
        }
        DecorationHelper.setExtendedState(frame, state | BaseRootPaneUI.MAXIMIZED_BOTH);
        for (PropertyChangeListener aPcl : pcl) {
            aPcl.propertyChange(new PropertyChangeEvent(this, "windowMaximized", Boolean.FALSE, Boolean.FALSE));
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 27 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project ACS by ACS-Community.

the class BeanUtils method addWeakListenerByReflection.

/**
   * Add a weak PropertyChangeListener to an object, using reflection to look up the addPropertyChangeListener method
   * @param listener the listener to add
   * @param source the object to which a PCL shall be added
   */
public static void addWeakListenerByReflection(PropertyChangeListener listener, Object source) {
    try {
        PropertyChangeListener pcl = WeakListener.propertyChange(listener, source);
        Method addPCL = source.getClass().getMethod("addPropertyChangeListener", new Class[] { java.beans.PropertyChangeListener.class });
        addPCL.invoke(source, new Object[] { pcl });
    } catch (Exception ex) {
        // [PENDING] should use logging API here
        System.err.println("Warning: unable to add a property change listener to object " + source);
    //ex.printStackTrace();
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) Method(java.lang.reflect.Method)

Example 28 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project ACS by ACS-Community.

the class BeanNode method getCustomizer.

/**
   * Returns the customizer component.
   * @return the component or <code>null</code> if there is no customizer
   */
public java.awt.Component getCustomizer() {
    Class clazz = _beanInfo.getBeanDescriptor().getCustomizerClass();
    if (clazz == null)
        return null;
    Object o;
    try {
        o = clazz.newInstance();
    } catch (InstantiationException e) {
        exception(e);
        return null;
    } catch (IllegalAccessException e) {
        exception(e);
        return null;
    }
    if (!(o instanceof Customizer))
        return null;
    Customizer cust = ((java.beans.Customizer) o);
    attachCustomizer(this, cust);
    // looking for the component
    java.awt.Component comp = null;
    if (o instanceof java.awt.Component) {
        comp = (java.awt.Component) o;
    } else {
        // create the dialog from descriptor
        comp = createDialog(o);
    }
    if (comp == null) {
        // no component provided
        return null;
    }
    cust.setObject(_bean);
    if (!_guiUpdater.hasRegisteredListenerInternal()) {
        cust.addPropertyChangeListener(new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent e) {
                firePropertyChange(e.getPropertyName(), e.getOldValue(), e.getNewValue());
            }
        });
    }
    return comp;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) Customizer(java.beans.Customizer)

Example 29 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project ACS by ACS-Community.

the class WorkspaceSwitchListenerSupport method startListening.

/**
   * tell this object to start listening again. This method is called in the constructor.
   * It is not necessary (but not harmful either) to call this menthod again even if we are
   * already listening. Precautions are taken to avoid adding a second listener.
   * This method is thread safe with regards to its counterpart
   * @see #stopListening
   */
public void startListening() {
    if (!listening) {
        synchronized (listeningLock) {
            if (!listening) {
                // double-check condition
                PropertyChangeListener propL = WeakListener.propertyChange(this, WindowManager.getDefault());
                WindowManager.getDefault().addPropertyChangeListener(propL);
                listening = !listening;
            }
        }
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener)

Example 30 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project EnrichmentMapApp by BaderLab.

the class PostAnalysisKnownSignaturePanel method createKnownSignatureGMTPanel.

/**
	 * @return Panel for choosing and loading GMT and SignatureGMT Geneset-Files
	 */
private JPanel createKnownSignatureGMTPanel() {
    knownSignatureGMTFileNameTextField = new JFormattedTextField();
    knownSignatureGMTFileNameTextField.setColumns(15);
    knownSignatureGMTFileNameTextField.setToolTipText(Messages.GMT_INSTRUCTION);
    final Color textFieldForeground = knownSignatureGMTFileNameTextField.getForeground();
    knownSignatureGMTFileNameTextField.addPropertyChangeListener("value", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            // if the text is red set it back to black as soon as the user starts typing
            knownSignatureGMTFileNameTextField.setForeground(textFieldForeground);
        }
    });
    JButton selectSigGMTFileButton = new JButton("Browse...");
    selectSigGMTFileButton.setToolTipText(Messages.GMT_INSTRUCTION);
    selectSigGMTFileButton.setActionCommand("Known Signature");
    selectSigGMTFileButton.addActionListener(e -> {
        parentPanel.chooseGMTFile(knownSignatureGMTFileNameTextField);
    });
    makeSmall(knownSignatureGMTFileNameTextField, selectSigGMTFileButton);
    JPanel panel = new JPanel();
    panel.setBorder(LookAndFeelUtil.createTitledBorder("SigGMT File (contains signature-genesets)"));
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
    layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(knownSignatureGMTFileNameTextField, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(selectSigGMTFileButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(knownSignatureGMTFileNameTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(selectSigGMTFileButton));
    if (LookAndFeelUtil.isAquaLAF())
        panel.setOpaque(false);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) Color(java.awt.Color) JFormattedTextField(javax.swing.JFormattedTextField) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)152 PropertyChangeEvent (java.beans.PropertyChangeEvent)124 ActionEvent (java.awt.event.ActionEvent)16 ActionListener (java.awt.event.ActionListener)15 JPanel (javax.swing.JPanel)15 ArrayList (java.util.ArrayList)11 BorderLayout (java.awt.BorderLayout)10 JButton (javax.swing.JButton)9 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 IOException (java.io.IOException)8 JLabel (javax.swing.JLabel)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Dimension (java.awt.Dimension)6 FlowLayout (java.awt.FlowLayout)6 PropertyChangeSupport (java.beans.PropertyChangeSupport)6 File (java.io.File)6 BoxLayout (javax.swing.BoxLayout)6