Search in sources :

Example 6 with UserGroup

use of net.sourceforge.processdash.team.group.UserGroup in project processdash by dtuma.

the class UserGroupEditor method createUI.

private Component createUI() {
    // create the button panel
    JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 5, 5));
    buttonPanel.add(new JButton(new AddAction()));
    buttonPanel.add(new JButton(copyAction = new CopyAction()));
    buttonPanel.add(new JButton(renameAction = new RenameAction()));
    buttonPanel.add(new JButton(deleteAction = new DeleteAction()));
    // read the known groups, and add them to a list
    List<UserGroup> allGroups = new ArrayList<UserGroup>();
    allGroups.addAll(UserGroupManager.getInstance().getGroups().values());
    Collections.sort(allGroups);
    groups = new DefaultListModel();
    for (UserGroup g : allGroups) groups.addElement(g);
    groupList = new JList(groups);
    groupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupList.addListSelectionListener(new SelectionHandler());
    JScrollPane gsp = new JScrollPane(groupList);
    gsp.setPreferredSize(new Dimension(200, 300));
    // create an object for editing the members in the selected group
    memberList = new GroupMembershipSelector(readOnlyCode);
    JScrollPane msp = new JScrollPane(memberList);
    msp.setPreferredSize(new Dimension(200, 300));
    // create titles to display on the dialog
    JLabel groupTitle = new JLabel(resources.getString("User_Groups"));
    JLabel memberTitle = new JLabel(resources.getString("Selected_User_Group"));
    Font f = groupTitle.getFont();
    f = f.deriveFont(f.getSize2D() * 1.5f);
    groupTitle.setFont(f);
    memberTitle.setFont(f);
    Border b = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black);
    groupTitle.setBorder(b);
    memberTitle.setBorder(b);
    // arrange the components onto a panel
    GridBagLayout layout = new GridBagLayout();
    userInterface = new JPanel(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    layout.addLayoutComponent(groupTitle, c);
    userInterface.add(groupTitle);
    c.gridx = 2;
    Component comp = new JOptionPaneTweaker.MakeResizable();
    layout.addLayoutComponent(comp, c);
    userInterface.add(comp);
    c.gridx = 1;
    c.insets = new Insets(0, 10, 0, 0);
    layout.addLayoutComponent(memberTitle, c);
    userInterface.add(memberTitle);
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 20, 0, 0);
    layout.addLayoutComponent(buttonPanel, c);
    userInterface.add(buttonPanel);
    c.gridy = 2;
    c.weightx = c.weighty = 1.0;
    layout.addLayoutComponent(gsp, c);
    userInterface.add(gsp);
    c.gridx = c.gridy = 1;
    c.insets = new Insets(10, 30, 0, 0);
    c.gridheight = 2;
    layout.addLayoutComponent(msp, c);
    userInterface.add(msp);
    // load the preferred size of the window
    try {
        String[] size = Settings.getVal(SIZE_PREF).split(",");
        Dimension d = new Dimension(Integer.parseInt(size[0]), Integer.parseInt(size[1]));
        userInterface.setPreferredSize(d);
    } catch (Exception e) {
    }
    return userInterface;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) DefaultListModel(javax.swing.DefaultListModel) Font(java.awt.Font) UserGroup(net.sourceforge.processdash.team.group.UserGroup) GridLayout(java.awt.GridLayout) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Border(javax.swing.border.Border) JList(javax.swing.JList)

Example 7 with UserGroup

use of net.sourceforge.processdash.team.group.UserGroup in project processdash by dtuma.

the class GroupFilterMenu method userGroupEdited.

@Override
public void userGroupEdited(UserGroupEditEvent e) {
    if (selectedItem instanceof UserGroup) {
        UserGroup selectedGroup = (UserGroup) selectedItem;
        UserGroup changedGroup = e.getGroup();
        if (selectedGroup.getId().equals(changedGroup.getId())) {
            final UserGroup newGroup = (e.isDelete() ? UserGroup.EVERYONE : changedGroup);
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    setSelectedItem(newGroup);
                }
            });
        }
    }
}
Also used : UserGroup(net.sourceforge.processdash.team.group.UserGroup)

Aggregations

UserGroup (net.sourceforge.processdash.team.group.UserGroup)7 Border (javax.swing.border.Border)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 GridLayout (java.awt.GridLayout)1 Insets (java.awt.Insets)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 ButtonGroup (javax.swing.ButtonGroup)1 DefaultListModel (javax.swing.DefaultListModel)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JList (javax.swing.JList)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 JScrollPane (javax.swing.JScrollPane)1