Search in sources :

Example 76 with ChangeListener

use of javax.swing.event.ChangeListener in project jgnash by ccavanaugh.

the class JideSwingUtilities method synchronizeView.

/**
     * Synchronizes the two viewports. The view position changes in the master view, the slave view's view position will
     * change too. Generally speaking, if you want the two viewports to synchronize vertically, they should have the
     * same height. If horizontally, the same width.
     * <p>
     * It's OK if you call this method with the same master viewport and slave viewport duplicate times. It won't cause
     * multiple events fired.
     *
     * @param masterViewport the master viewport
     * @param slaveViewport  the slave viewport
     * @param orientation    the orientation. It could be either SwingConstants.HORIZONTAL or SwingConstants.VERTICAL.
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void synchronizeView(final JViewport masterViewport, final JViewport slaveViewport, final int orientation) {
    if (masterViewport == null || slaveViewport == null) {
        return;
    }
    ChangeListener[] changeListeners = masterViewport.getChangeListeners();
    int i = 0;
    for (; i < changeListeners.length; i++) {
        if (changeListeners[i] == getViewportSynchronizationChangeListener()) {
            break;
        }
    }
    if (i >= changeListeners.length) {
        masterViewport.addChangeListener(getViewportSynchronizationChangeListener());
    }
    Object property = masterViewport.getClientProperty(JideScrollPane.CLIENT_PROPERTY_SLAVE_VIEWPORT);
    if (!(property instanceof Map)) {
        property = new HashMap<JViewport, Integer>();
    }
    Map<JViewport, Integer> slaveViewportMap = (Map) property;
    slaveViewportMap.put(slaveViewport, orientation);
    masterViewport.putClientProperty(JideScrollPane.CLIENT_PROPERTY_SLAVE_VIEWPORT, slaveViewportMap);
    property = slaveViewport.getClientProperty(JideScrollPane.CLIENT_PROPERTY_MASTER_VIEWPORT);
    if (!(property instanceof Map)) {
        property = new HashMap<JViewport, Integer>();
    }
    Map<JViewport, Integer> masterViewportMap = (Map) property;
    masterViewportMap.put(masterViewport, orientation);
    slaveViewport.putClientProperty(JideScrollPane.CLIENT_PROPERTY_MASTER_VIEWPORT, masterViewportMap);
}
Also used : JViewport(javax.swing.JViewport) ChangeListener(javax.swing.event.ChangeListener) Map(java.util.Map) HashMap(java.util.HashMap) Point(java.awt.Point)

Example 77 with ChangeListener

use of javax.swing.event.ChangeListener in project processdash by dtuma.

the class TeamTimePanel method applySubteamFilter.

public void applySubteamFilter(Set<Integer> subteamFilter, String subteamName) {
    this.teamMemberFilter = null;
    this.subteamFilter = subteamFilter;
    this.subteamName = subteamName;
    this.teamList.setSubteamFilter(subteamFilter);
    rebuildPanelContents();
    ChangeEvent evt = new ChangeEvent(this);
    for (ChangeListener l : listenerList.getListeners(ChangeListener.class)) l.stateChanged(evt);
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 78 with ChangeListener

use of javax.swing.event.ChangeListener in project processdash by dtuma.

the class AbstractEVChart method fireStateChanged.

protected void fireStateChanged() {
    if (changeListeners != null) {
        List<ChangeListener> listeners = new ArrayList<ChangeListener>(changeListeners);
        ChangeEvent evt = new ChangeEvent(this);
        for (ChangeListener l : listeners) l.stateChanged(evt);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) ChangeEvent(javax.swing.event.ChangeEvent) ArrayList(java.util.ArrayList) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 79 with ChangeListener

use of javax.swing.event.ChangeListener in project processdash by dtuma.

the class TeamMemberColumnManager method createColumns.

/** Create or recreate TeamMemberTimeColumn objects for each team member
     */
private void createColumns() {
    List<TeamMemberTimeColumn> obsoletePlanTimeColumns = planTimeColumnList;
    List<TeamMemberActualTimeColumn> obsoleteActualTimeColumns = actualTimeColumnList;
    ArrayList newColumns = new ArrayList();
    planTimeColumnList = new ArrayList<TeamMemberTimeColumn>();
    actualTimeColumnList = new ArrayList<TeamMemberActualTimeColumn>();
    Iterator teamMembers = teamList.getTeamMembers().iterator();
    while (teamMembers.hasNext()) {
        // Loop through the list of team members.
        TeamMember m = (TeamMember) teamMembers.next();
        // try to find a preexisting planned time column for this team member.
        TeamMemberTimeColumn planTimeCol = getExistingValidTimeColumn(obsoletePlanTimeColumns, m);
        if (planTimeCol == null) {
            // create a new column for this team member.
            planTimeCol = new TeamMemberTimeColumn(dataModel, m);
            newColumns.add(planTimeCol);
        }
        // add the column to our master list.
        planTimeColumnList.add(planTimeCol);
        // try to find a preexisting actual time column for this team member.
        TeamMemberActualTimeColumn actualTimeCol = getExistingValidTimeColumn(obsoleteActualTimeColumns, m);
        if (actualTimeCol == null) {
            // create a new column for this team member.
            actualTimeCol = new TeamMemberActualTimeColumn(m);
            newColumns.add(actualTimeCol);
        }
        // add the column to our master list.
        actualTimeColumnList.add(actualTimeCol);
    }
    // make the changes to the columns in the data model.
    if (!newColumns.isEmpty() || !obsoletePlanTimeColumns.isEmpty() || !obsoleteActualTimeColumns.isEmpty()) {
        List obsoleteColumns = new ArrayList();
        obsoleteColumns.addAll(obsoletePlanTimeColumns);
        obsoleteColumns.addAll(obsoleteActualTimeColumns);
        dataModel.addRemoveDataColumns(newColumns, obsoleteColumns);
    }
    // alert any listeners that have registered interest
    ChangeEvent e = new ChangeEvent(this);
    for (ChangeListener l : listeners) l.stateChanged(e);
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TeamMemberList(teamdash.team.TeamMemberList) ChangeListener(javax.swing.event.ChangeListener) TeamMember(teamdash.team.TeamMember)

Example 80 with ChangeListener

use of javax.swing.event.ChangeListener in project processdash by dtuma.

the class GroupFilterMenu method setSelectedItem.

public void setSelectedItem(UserFilter selection) {
    if (selection instanceof UserGroup) {
        UserGroup g = (UserGroup) selection;
        setIcon(groupIcon);
        setText(g.toString());
    } else if (selection instanceof UserGroupMember) {
        UserGroupMember m = (UserGroupMember) selection;
        setIcon(personIcon);
        setText(m.toString());
    }
    boolean isChange = !NullSafeObjectUtils.EQ(selectedItem, selection);
    this.selectedItem = selection;
    if (isChange) {
        for (ChangeListener l : listeners.getListeners(ChangeListener.class)) l.stateChanged(new ChangeEvent(this));
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) UserGroupMember(net.sourceforge.processdash.team.group.UserGroupMember) UserGroup(net.sourceforge.processdash.team.group.UserGroup)

Aggregations

ChangeListener (javax.swing.event.ChangeListener)138 ChangeEvent (javax.swing.event.ChangeEvent)129 JPanel (javax.swing.JPanel)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)37 JLabel (javax.swing.JLabel)24 GridBagConstraints (java.awt.GridBagConstraints)18 JCheckBox (javax.swing.JCheckBox)16 BorderLayout (java.awt.BorderLayout)15 GridBagLayout (java.awt.GridBagLayout)15 JButton (javax.swing.JButton)15 Dimension (java.awt.Dimension)13 PropertyChangeListener (java.beans.PropertyChangeListener)13 JSlider (javax.swing.JSlider)13 JTabbedPane (javax.swing.JTabbedPane)13 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)13 Insets (java.awt.Insets)12 PropertyChangeEvent (java.beans.PropertyChangeEvent)11 IOException (java.io.IOException)11 JSpinner (javax.swing.JSpinner)10