From c50360b424a129933e8507bbec5e0e3795787d01 Mon Sep 17 00:00:00 2001
From: Tobias Schwarz
Date: Tue, 3 Mar 2015 08:08:53 +0100
Subject: SM: rework wizard page
---
.../ui/wizards/pages/AbstractConfigWizardPage.java | 43 ++++++++++++----------
1 file changed, 23 insertions(+), 20 deletions(-)
(limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui')
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java
index 2aa35e586..def6b7550 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java
@@ -16,7 +16,6 @@ import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -188,6 +187,13 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
initializeUsedNameList();
}
+ public String getConfigName() {
+ if (configName != null) {
+ return configName.getEditFieldControlText();
+ }
+ return null;
+ }
+
/**
* Creates the selector section.
*
@@ -254,13 +260,6 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
*/
protected abstract String getPeerType();
- /**
- * Returns the default configuration name template.
- *
- * @return The default configuration name template. Never null
.
- */
- protected abstract String getDefaultConfigNameTemplate();
-
/**
* Return the pattern that matches a configuration name with
* the default name. The pattern is used to decide if the user
@@ -269,7 +268,9 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
* @param The default configuration name template. Must not be null
.
* @return The default configuration name pattern. Never null
.
*/
- protected abstract String getDefaultConfigNamePattern(String template);
+ protected abstract String getConfigNamePattern();
+
+ protected abstract String getNewConfigName();
/**
* Initialize the used name list.
@@ -303,20 +304,17 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
* @param customID The custom ID to bind with the default configuration name template, or null
.
*/
public void autoGenerateConfigurationName(String customID) {
- customID = customID.replaceAll("[^0-9a-zA-Z. _()-]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ customID = customID != null ? customID.replaceAll("[^0-9a-zA-Z. _()-]", "_") : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // Get the default configuration name template
- String template = getDefaultConfigNameTemplate();
- Assert.isNotNull(template);
// If the user modified the configuration name, we have to leave it alone.
- String pattern = getDefaultConfigNamePattern(template);
+ String pattern = getConfigNamePattern();
Assert.isNotNull(pattern);
String currentName = configName != null ? configName.getEditFieldControlText().trim() : null;
if (currentName != null && !"".equals(currentName.trim()) && !currentName.matches(pattern)) { //$NON-NLS-1$
return;
}
// Generate a new proposal
- String origProposedName = NLS.bind(template, customID != null ? customID : ""); //$NON-NLS-1$
+ String origProposedName = customID;
String proposedName = origProposedName;
if (usedNames.contains(proposedName.trim().toUpperCase()) && proposedName.matches(".* \\([0-9]*\\)")) { //$NON-NLS-1$
@@ -327,6 +325,10 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
}
}
+ if (usedNames.contains(proposedName.trim().toUpperCase()) && proposedName.matches(pattern)) {
+ proposedName = getNewConfigName();
+ }
+
// Unify the proposed name to avoid duplicated configuration names
int count = 0;
while (usedNames.contains(proposedName.trim().toUpperCase())) {
@@ -438,11 +440,6 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
*/
@Override
public void setupData(IPropertiesContainer data) {
- if (data.containsKey(IPeer.ATTR_NAME)) {
- String name = data.getStringProperty(IPeer.ATTR_NAME);
- name = name.replaceAll("[^0-9a-zA-Z. _()-]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
- autoGenerateConfigurationName(name);
- }
if (selectorSection instanceof IDataExchangeNode) {
((IDataExchangeNode)selectorSection).setupData(data);
}
@@ -454,6 +451,12 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i
((IDataExchangeNode)additionalSection).setupData(data);
}
}
+
+ if (data.containsKey(IPeer.ATTR_NAME)) {
+ String name = data.getStringProperty(IPeer.ATTR_NAME);
+ name = name.replaceAll("[^0-9a-zA-Z. _()-]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ autoGenerateConfigurationName(name);
+ }
}
/* (non-Javadoc)
--
cgit v1.2.3