173423 : Two kinds of 'New Process Component' dialog can be found, when CP's name confilcts
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/UserInputsDialog.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/UserInputsDialog.java
index 49f0663..10103fb 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/UserInputsDialog.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/UserInputsDialog.java
@@ -59,6 +59,8 @@
private String title;
+ private String globalErrorTxt = "";
+
private String message;
private List userInputs;
@@ -70,7 +72,7 @@
Label errorArea;
HashMap oldInfoForCancel;
-
+
public UserInputsDialog(Shell parentShell, List userInputs, String title,
String message) {
super(parentShell);
@@ -179,10 +181,11 @@
errorTxt = validator.isValid(text.getText());
if (errorTxt != null && errorTxt.length() > 0) {
errorArea.setText(errorTxt);
- getButton(OK).setEnabled(false);
+ getButton(OK).setEnabled(false);
} else {
errorArea.setText("");
}
+ globalErrorTxt = errorTxt;
}
if (errorTxt == null || errorTxt.length() <= 0) {
localinput.setInput(text.getText());
@@ -218,20 +221,29 @@
if (userInput.getLabelProvider() != null) {
viewer.setLabelProvider(userInput.getLabelProvider());
}
- viewer.setInput(userInput.getChoices());
+ List choices = userInput.getChoices();
+ viewer.setInput(choices);
+ if (choices != null && choices.size() > 0) {
+ viewer.setSelection(new StructuredSelection(choices.get(0)));
+ localInput.setInput(choices.get(0));
+ }
viewer.getCombo().addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
+ String errorTxt = "";
IStructuredSelection selected = (IStructuredSelection) viewer
.getSelection();
IStatus status = validator.isValid(selected.getFirstElement());
- String errorTxt = "";
if (status.getSeverity() == IStatus.ERROR) {
errorTxt = status.getMessage();
}
if (errorTxt != null && errorTxt.length() > 0) {
errorArea.setText(errorTxt);
getButton(OK).setEnabled(false);
- } else
+ } if (globalErrorTxt != null && globalErrorTxt.length() > 0) {
+ errorArea.setText(globalErrorTxt);
+ getButton(OK).setEnabled(false);
+ }
+ else
errorArea.setText("");
}
});
@@ -253,16 +265,18 @@
if (errorTxt != null && errorTxt.length() > 0) {
errorArea.setText(errorTxt);
}
+ else if (globalErrorTxt != null && globalErrorTxt.length() > 0) {
+ errorArea.setText(globalErrorTxt);
+ getButton(OK).setEnabled(false);
+ }
+ else
+ errorArea.setText("");
}
if (errorTxt == null || errorTxt.length() <= 0) {
localInput.setInput(obj);
}
}
- });
- Object obj = userInput.getInput();
- if (obj != null) {
- viewer.setSelection(new StructuredSelection(obj));
- }
+ });
}
/**
@@ -371,11 +385,8 @@
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
- boolean flag = true;
- if (flag) {
- result = true;
- super.okPressed();
- }
+ result = true;
+ super.okPressed();
}
/*