in application/org.openjdk.jmc.console.ui.notification/src/main/java/org/openjdk/jmc/console/ui/notification/wizard/NameWizardPage.java [89:184]
public void createControl(Composite parent) {
Composite c = new Composite(parent, SWT.NONE);
StandardUIBuilder suib = new StandardUIBuilder(c);
suib.createLabel(Messages.NameWizardPage_RULE_GROUP_NAME_TEXT, null);
final CCombo combo = suib.createCombo();
final HashSet<String> names = new HashSet<>();
HashSet<String> set = new HashSet<>();
// Collect rules
for (TriggerRule rule : notificationModel.getAvailableRules()) {
set.add(rule.getRulePath());
names.add(rule.getName());
}
// Add this rule group if not already added
if (!set.contains(m_notificationRule.getRulePath())) {
combo.add(m_notificationRule.getRulePath());
}
// Add items to ComboBox
for (String path : set) {
combo.add(path);
}
// Select the rule group of the edited rule
for (int i = 0; i < combo.getItems().length; i++) {
if (m_notificationRule.getRulePath().equals(combo.getItem(i))) {
combo.select(i);
}
}
combo.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
// ignore
}
@Override
public void keyReleased(KeyEvent e) {
m_notificationRule.setRulePath(combo.getText());
}
});
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = combo.getSelectionIndex();
if (index >= 0) {
m_notificationRule.setRulePath(combo.getText());
}
}
});
suib.layout();
suib.createLabel(Messages.NameWizardPage_CAPTION_RULE_NAME_TEXT, null);
text = suib.createText(m_defaultName, "", SWT.NONE); //$NON-NLS-1$
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (e.getSource() instanceof Text) {
Text t = (Text) e.getSource();
String text = t.getText();
if (names.contains(text)) {
setPageComplete(false);
setErrorMessage(
org.openjdk.jmc.console.ui.notification.tab.Messages.TriggerSectionPart_DIALOG_RULE_EXISTS_MESSAGE_TEXT);
} else {
setPageComplete(true);
setErrorMessage(null);
m_notificationRule.setName(text);
}
}
}
});
// Description header
suib.layout();
suib.createLabel(Messages.NameWizardPage_TRIGGER_DESCRIPTION_TEXT, null);
suib.layout();
String desc = m_notificationRule.getDescription() == null ? "" : m_notificationRule.getDescription(); //$NON-NLS-1$
text = suib.createMultiText(desc, ""); //$NON-NLS-1$
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (e.getSource() instanceof Text) {
Text t = (Text) e.getSource();
m_notificationRule.setDescription(t.getText());
}
}
});
suib.layout();
setControl(c);
}