use of net.sourceforge.processdash.ui.lib.ToolTipTimingCustomizer in project processdash by dtuma.
the class UserGroupEditor method promptForName.
private Object[] promptForName(String resKey, String resArg, String defaultName, boolean isCustom, boolean showCustom) {
String title = resources.getString(resKey + "_Title");
String prompt;
if (resArg == null)
prompt = resources.getString(resKey + "_Prompt");
else
prompt = resources.format(resKey + "_Prompt_FMT", resArg);
JTextField nameField = new JTextField(defaultName);
Object[] typePanel = null;
JRadioButton sharedOption, customOption = null;
if (showCustom) {
String typePrompt = resources.getString("Type_Prompt");
Border indent = BorderFactory.createEmptyBorder(0, 20, 0, 0);
sharedOption = new JRadioButton(resources.getString("Type_Shared"));
sharedOption.setBorder(indent);
customOption = new JRadioButton(resources.getString("Type_Custom"));
customOption.setBorder(indent);
if (readOnlyCode != null) {
sharedOption.setEnabled(false);
sharedOption.setToolTipText("<html><div style='width:250px'>" + resources.getHTML(resKey + "_Error." + readOnlyCode) + "</div></html>");
new ToolTipTimingCustomizer().install(sharedOption);
isCustom = true;
}
ButtonGroup bg = new ButtonGroup();
bg.add(sharedOption);
bg.add(customOption);
(isCustom ? customOption : sharedOption).setSelected(true);
typePanel = new Object[] { " ", typePrompt, sharedOption, customOption };
}
Object message = new Object[] { prompt, nameField, typePanel, new JOptionPaneTweaker.GrabFocus(nameField) };
PROMPT: while (true) {
// prompt the user for the new name
nameField.selectAll();
int userChoice = JOptionPane.showConfirmDialog(userInterface, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (userChoice != JOptionPane.OK_OPTION)
return null;
// if they did not enter a name, display an error
String name = nameField.getText().trim();
if (!StringUtils.hasValue(name)) {
JOptionPane.showMessageDialog(userInterface, resources.getString("Name_Missing"), resources.getString("Name_Error_Title"), JOptionPane.ERROR_MESSAGE);
continue PROMPT;
}
// when renaming, if they did not alter the value, abort.
if (defaultName != null && name.equals(defaultName))
return null;
// make a note of whether this is a custom group.
boolean custom = showCustom ? customOption.isSelected() : isCustom;
// if they entered a duplicate name, display an error
for (int i = groups.size(); i-- > 0; ) {
UserGroup g = (UserGroup) groups.get(i);
if (g.isCustom() == custom && g.getDisplayName().equals(name)) {
JOptionPane.showMessageDialog(userInterface, resources.format("Name_Duplicate_FMT", name), resources.getString("Name_Error_Title"), JOptionPane.ERROR_MESSAGE);
continue PROMPT;
}
}
// all seems OK. Return the values the user selected.
return new Object[] { name, custom };
}
}
use of net.sourceforge.processdash.ui.lib.ToolTipTimingCustomizer in project processdash by dtuma.
the class PercentSpentIndicator method buildUI.
private void buildUI() {
layout = new CardLayout();
setLayout(layout);
levelIndicator = new LevelIndicator(true);
levelIndicator.setPaintBarRect(false);
add(levelIndicator, LEVEL_INDICATOR_KEY);
Icon hourglassIcon = DashboardIconFactory.getHourglassIcon();
JLabel label = new JLabel(hourglassIcon);
add(label, MISSING_ESTIMATE_KEY);
if (!Settings.isReadOnly()) {
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
showEditEstimateDialog();
}
});
}
setBorder(BorderFactory.createLineBorder(UIManager.getColor("controlDkShadow")));
Dimension d = new Dimension(hourglassIcon.getIconWidth() + 4, hourglassIcon.getIconHeight() + 6);
setMinimumSize(d);
setPreferredSize(d);
new ToolTipTimingCustomizer(750, 60000).install(this);
}
Aggregations