use of net.sourceforge.processdash.team.group.UserGroupManager in project processdash by dtuma.
the class GroupPermissionEditor method editPermission.
@Override
public Map<String, String> editPermission(GroupPermission p, Component parent, boolean isAdd) {
// retrieve the list of shared groups known to this dashboard. Custom
// groups are not included, because they can't form the basis of a
// meaningful cross-user permission grant.
Vector<UserGroup> groups = new Vector<UserGroup>();
UserGroupManager mgr = UserGroupManager.getInstance();
for (UserGroup g : mgr.getGroups().values()) {
if (!g.isCustom())
groups.add(g);
}
// sort the list, and insert "Everyone" at the beginning.
Collections.sort(groups);
groups.add(0, UserGroup.EVERYONE);
// retrieve the group named in the given permission. If it was a
// "missing" permission, it will come back with the custom flag set.
// In that case, add it to the list we'll display in the combo box.
UserGroup currentGroup = p.getGroup();
if (currentGroup.isCustom())
groups.add(currentGroup);
// create a combo box for selecting a group
JComboBox<UserGroup> cb = new JComboBox<UserGroup>(groups);
cb.setSelectedItem(currentGroup);
// display a user interface for selecting a group
String title = UserGroupEditor.resources.getString(isAdd ? "Add_Permission" : "Edit_Permission");
String prompt = p.getSpec().getResources().getString("Edit_Prompt");
Object[] message = { prompt, BoxUtils.hbox(20, cb) };
int userChoice = JOptionPane.showConfirmDialog(parent, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
// otherwise return null to indicate that they cancelled the operation.
if (userChoice == JOptionPane.OK_OPTION) {
UserGroup selected = (UserGroup) cb.getSelectedItem();
return Collections.singletonMap(GROUP_PARAM, selected.getId());
} else {
return null;
}
}
use of net.sourceforge.processdash.team.group.UserGroupManager in project processdash by dtuma.
the class TaskScheduleDialog method buildMenuBar.
private JMenuBar buildMenuBar() {
JMenuBar result = new JMenuBar();
boolean rw = canEdit();
// create the File menu
JMenu fileMenu = makeMenu("File");
fileMenu.add(closeAction);
if (rw)
fileMenu.add(saveAction);
result.add(fileMenu);
// If we're in read-write mode, create the Edit menu.
if (rw) {
JMenu editMenu = makeMenu("Edit");
editMenu.add(addTaskAction);
editMenu.add(deleteTaskAction);
editMenu.add(moveUpAction);
editMenu.add(moveDownAction);
editMenu.add(copyTaskInfoAction);
if (!isRollup()) {
editMenu.addSeparator();
editMenu.add(addPeriodAction);
editMenu.add(insertPeriodAction);
editMenu.add(deletePeriodAction);
}
result.add(editMenu);
}
// create the View menu
JMenu viewMenu = makeMenu("View");
viewMenu.add(expandAllAction);
viewMenu.add(chartAction);
viewMenu.add(filteredChartAction);
viewMenu.add(reportAction);
viewMenu.add(weekReportAction);
for (TSAction t : altReportActions) viewMenu.add(t);
viewMenu.add(filteredReportAction);
viewMenu.add(errorAction);
if (Settings.isPersonalMode()) {
viewMenu.addSeparator();
viewMenu.add(showTimeLogAction);
viewMenu.add(showDefectLogAction);
}
viewMenu.addSeparator();
viewMenu.add(JTableColumnVisibilityAction.getForTable(treeTable));
viewMenu.add(new TSAction("Column_Chooser.Reset_Columns") {
public void actionPerformed(ActionEvent e) {
guiPrefs.reset("treeTable", "flatTable");
}
});
if (flatViewAction != null) {
viewMenu.addSeparator();
JCheckBoxMenuItem item = new JCheckBoxMenuItem(flatViewAction);
flatViewAction.installButtonModel(item);
viewMenu.add(item);
} else if (mergedViewAction != null) {
viewMenu.addSeparator();
JCheckBoxMenuItem item = new JCheckBoxMenuItem(mergedViewAction);
mergedViewAction.installButtonModel(item);
viewMenu.add(item);
}
result.add(viewMenu);
// create the Tools menu
if (Settings.isReadWrite()) {
JMenu toolsMenu = makeMenu("Tools");
saveBaselineAction = new BaselineAction("Buttons.Save_Baseline") {
public void actionPerformed(ActionEvent e) {
saveBaseline();
}
};
toolsMenu.add(saveBaselineAction);
manageBaselinesAction = new BaselineAction("Buttons.Manage_Baselines") {
public void actionPerformed(ActionEvent e) {
manageBaselines();
}
};
toolsMenu.add(manageBaselinesAction);
if (rw) {
if (!isCollaborationBlocked()) {
collaborateAction = new TSAction("Buttons.Collaborate") {
public void actionPerformed(ActionEvent e) {
showCollaborationWizard();
}
};
toolsMenu.add(collaborateAction);
}
scheduleOptionsAction = new TSAction("Buttons.Schedule_Options") {
public void actionPerformed(ActionEvent e) {
showOptionsDialog();
}
};
toolsMenu.add(scheduleOptionsAction);
}
result.add(toolsMenu);
}
// create the Help menu
JMenu helpMenu = makeMenu("Help_Menu.Title");
JMenuItem usingTaskSchedule = new JMenuItem(resources.getString("Help_Menu.Using_Item"));
usingTaskSchedule.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PCSH.displayHelpTopic("UsingTaskSchedule");
}
});
helpMenu.add(usingTaskSchedule);
result.add(helpMenu);
// add a group selector, if applicable
UserGroupManager groupMgr = UserGroupManager.getInstance();
if (isRollup() && groupMgr.isEnabled()) {
UserFilter filter = groupMgr.getGlobalFilter();
groupFilterMenu = new GroupFilterMenu(filter, groupMgr.isIndivFilteringSupported());
//
groupFilterMenu.addGroupChangeListener(new GroupFilterHandler(filter));
result.add(Box.createHorizontalGlue());
result.add(groupFilterMenu);
}
return result;
}
use of net.sourceforge.processdash.team.group.UserGroupManager in project processdash by dtuma.
the class TeamProjectBrowser method augmentTeamDashboardFileMenu.
/**
* Add team-project-related items to the File menu.
*/
private void augmentTeamDashboardFileMenu(ProcessDashboard dash) {
JMenuBar menuBar = dash.getConfigurationMenus();
if (Settings.isReadWrite()) {
JMenu fileMenu = menuBar.getMenu(0);
fileMenu.insert(new NewProjectAction(), 0);
fileMenu.insert(new AlterTeamProjectMenu(), 1);
}
UserGroupManager groupMgr = UserGroupManager.getInstance();
if (groupMgr.isEnabled()) {
GroupFilterMenu groupFilterMenu = new GroupFilterMenu(UserGroup.EVERYONE, groupMgr.isIndivFilteringSupported());
groupFilterMenu.addGroupChangeListener(handler);
menuBar.add(Box.createHorizontalGlue());
menuBar.add(groupFilterMenu);
}
}
Aggregations