Author: adietish
Date: 2011-02-04 09:08:44 -0500 (Fri, 04 Feb 2011)
New Revision: 29002
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
Log:
[JBIDE-8093] added field decorations and appropriate error texts
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2011-02-04
13:32:58 UTC (rev 29001)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2011-02-04
14:08:44 UTC (rev 29002)
@@ -14,6 +14,8 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.swt.SWT;
@@ -21,10 +23,12 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -44,6 +48,12 @@
* @author Rob Stryker
*/
public class RSEandASWizardPage extends WizardPage implements INewInstanceWizardPage {
+ private static final String SELECT_RUNTIME_ERROR = "Please select a local runtime.
The created server will be of the same version as the local runtime.";
+ private static final String DEPLOY_FOLDER_NOT_EMPTY = "The deploy folder must not
be empty";
+ private final static String REMOTE_DETAILS_LOC_ERROR = "You must fill in a path to
fetch the server configuration from";
+ private static final String SERVER_CONFIG_ERROR = "You must select a server
configuration";
+ private static final String SERVER_HOME_ERROR = "You must set a server home
directory";
+
private final static String CREATE_RSE_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_RSE_PREF_KEY";
private final static String CREATE_SERVER_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_SERVER_PREF_KEY";
@@ -52,11 +62,13 @@
private Button createRSE, createServer;
private Group serverDetailsGroup;
- private Button autoScanCheck, hardCodeServerDetails, deployOnlyRadio,
+ private Button autoScanCheck, hardCodeServerDetails, deployOnlyRadio,
addLocalRuntimeButton, autoAddLocalRuntimeButton;
+ private ControlDecoration deployFolderDeco, autoLocalRuntimeDeco, serverHomeDeco,
remoteDetailsLocDeco,
+ localRuntimeDeco, serverConfigDeco;
private Text remoteDetailsLoc, serverHomeText, serverConfigText, deployFolderText;
private Label serverHome, serverConfig, localRuntimeLabel, autoLocalRuntimeLabel,
deployFolder;
- private Combo autoLocalRuntimeCombo,localRuntimeCombo;
+ private Combo autoLocalRuntimeCombo, localRuntimeCombo;
private IHost initialHost;
private ArrayList<IRuntime> localRuntimes = new ArrayList<IRuntime>();
@@ -66,7 +78,7 @@
setTitle("Create RSE Connection and Server");
setDescription("Here you can choose to create a matching RSE connection and a
Server adapter");
}
-
+
public RSEandASWizardPage(IHost host) {
this();
this.initialHost = host;
@@ -85,24 +97,26 @@
Group g = new Group(c2, SWT.SHADOW_IN);
serverDetailsGroup = g;
g.setLayout(new FormLayout());
- g.setLayoutData(UIUtils.createFormData(createServer,5,null,0,0,5,100,-5));
+ g.setLayoutData(UIUtils.createFormData(createServer, 5, null, 0, 0, 5, 100, -5));
g.setText("Server Details");
-
+
final int INDENTATION = 40;
-
+
autoScanCheck = new Button(g, SWT.RADIO);
autoScanCheck.setText("Determine server details from this remote file:");
- autoScanCheck.setLayoutData(UIUtils.createFormData(0,5,null,0,0,5,null,0));
+ autoScanCheck.setLayoutData(UIUtils.createFormData(0, 5, null, 0, 0, 5, null, 0));
autoScanCheck.setSelection(true);
-
+
remoteDetailsLoc = new Text(g, SWT.BORDER);
- remoteDetailsLoc.setLayoutData(UIUtils.createFormData(autoScanCheck,5,null,0,0,INDENTATION,100,-5));
+ remoteDetailsLoc.setLayoutData(UIUtils.createFormData(autoScanCheck, 5, null, 0, 0,
INDENTATION, 100, -5));
remoteDetailsLoc.setText("./.jboss");
-
+ this.remoteDetailsLocDeco = createErrorDecoration(REMOTE_DETAILS_LOC_ERROR,
remoteDetailsLoc);
+
autoLocalRuntimeLabel = new Label(g, SWT.NONE);
autoLocalRuntimeLabel.setText("Local Runtime: ");
- autoLocalRuntimeLabel.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 7, null,
0, 0, INDENTATION, null, 0 ));
-
+ autoLocalRuntimeLabel.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 7, null,
0, 0, INDENTATION, null,
+ 0));
+
autoAddLocalRuntimeButton = new Button(g, SWT.DEFAULT);
autoAddLocalRuntimeButton.setText("Configure Runtimes...");
autoAddLocalRuntimeButton.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 7,
null, 0, null, 0, 100, -5));
@@ -110,35 +124,39 @@
public void widgetSelected(SelectionEvent e) {
configureRuntimesPressed();
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
});
autoLocalRuntimeCombo = new Combo(g, SWT.READ_ONLY);
- autoLocalRuntimeCombo.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 5, null,
0, autoLocalRuntimeLabel, 5, autoAddLocalRuntimeButton, -5));
-
-
+ autoLocalRuntimeCombo.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 5, null,
0, autoLocalRuntimeLabel,
+ 10, autoAddLocalRuntimeButton, -5));
+ this.autoLocalRuntimeDeco = createErrorDecoration(SELECT_RUNTIME_ERROR,
autoLocalRuntimeCombo);
+
hardCodeServerDetails = new Button(g, SWT.RADIO);
hardCodeServerDetails.setText("Set remote server details manually");
- hardCodeServerDetails.setLayoutData(UIUtils.createFormData(autoLocalRuntimeCombo,5,null,0,0,5,null,0));
+ hardCodeServerDetails.setLayoutData(UIUtils.createFormData(autoLocalRuntimeCombo, 5,
null, 0, 0, 10, null, 0));
serverHome = new Label(g, SWT.NONE);
serverHome.setText("JBoss Server Home: ");
- serverHome.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ serverHome.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 7, null, 0, 0,
INDENTATION, null, 0));
serverHomeText = new Text(g, SWT.BORDER);
- serverHomeText.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 5, null, 0,
serverHome, 5, 100, -5));
+ serverHomeText.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 5, null, 0,
serverHome, 10, 100, -5));
serverHomeText.setText("/etc/jboss/jboss-as");
+ this.serverHomeDeco = createErrorDecoration(SERVER_HOME_ERROR, serverHomeText);
serverConfig = new Label(g, SWT.NONE);
serverConfig.setText("Configuration: ");
- serverConfig.setLayoutData(UIUtils.createFormData(serverHomeText, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ serverConfig.setLayoutData(UIUtils.createFormData(serverHomeText, 7, null, 0, 0,
INDENTATION, null, 0));
serverConfigText = new Text(g, SWT.BORDER);
- serverConfigText.setLayoutData(UIUtils.createFormData(serverHomeText, 5, null, 0,
serverHome, 5, 100, -5));
+ serverConfigText.setLayoutData(UIUtils.createFormData(serverHomeText, 5, null, 0,
serverHome, 10, 100, -5));
serverConfigText.setText("default");
-
+ this.serverConfigDeco = createErrorDecoration(SERVER_CONFIG_ERROR, serverConfigText);
+
localRuntimeLabel = new Label(g, SWT.NONE);
localRuntimeLabel.setText("Local Runtime: ");
- localRuntimeLabel.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null, 0, 0,
INDENTATION, null, 0 ));
-
+ localRuntimeLabel.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null, 0, 0,
INDENTATION, null, 0));
+
addLocalRuntimeButton = new Button(g, SWT.DEFAULT);
addLocalRuntimeButton.setText("Configure Runtimes...");
addLocalRuntimeButton.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null,
0, null, 0, 100, -5));
@@ -146,32 +164,34 @@
public void widgetSelected(SelectionEvent e) {
configureRuntimesPressed();
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
});
localRuntimeCombo = new Combo(g, SWT.READ_ONLY);
- localRuntimeCombo.setLayoutData(UIUtils.createFormData(serverConfigText, 5, null, 0,
serverHome, 5, addLocalRuntimeButton, -5));
-
-
+ localRuntimeCombo.setLayoutData(UIUtils.createFormData(serverConfigText, 5, null, 0,
serverHome, 10,
+ addLocalRuntimeButton, -5));
+ this.localRuntimeDeco = createErrorDecoration(SELECT_RUNTIME_ERROR,
localRuntimeCombo);
+
deployOnlyRadio = new Button(g, SWT.RADIO);
deployOnlyRadio.setText("Use a deploy-only server adapter");
- deployOnlyRadio.setLayoutData(UIUtils.createFormData(localRuntimeCombo,5,null,0,0,5,null,0));
-
+ deployOnlyRadio.setLayoutData(UIUtils.createFormData(localRuntimeCombo, 5, null, 0, 0,
5, null, 0));
+
deployFolder = new Label(g, SWT.NONE);
deployFolder.setText("Deploy Folder: ");
- deployFolder.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ deployFolder.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 7, null, 0, 0,
INDENTATION, null, 0));
deployFolderText = new Text(g, SWT.BORDER);
deployFolderText.setText("/path/to/deploy");
- deployFolderText.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 5, null, 0,
deployFolder, 5, 100, -5));
-
-
+ deployFolderText.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 5, null, 0,
deployFolder, 10, 100, -5));
+ this.deployFolderDeco = createErrorDecoration(DEPLOY_FOLDER_NOT_EMPTY,
deployFolderText);
+
IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
boolean initRSE, initServer;
initRSE = prefs.getBoolean(CREATE_RSE_PREF_KEY, DEFALUT_CREATE_RSE);
initServer = prefs.getBoolean(CREATE_SERVER_PREF_KEY, DETAULT_CREATE_SERVERADAPTER);
createRSE.setSelection(initRSE);
createServer.setSelection(initServer);
- if( initialHost != null ) {
+ if (initialHost != null) {
createRSE.setEnabled(false);
createRSE.setSelection(true);
createServer.setSelection(true);
@@ -201,21 +221,32 @@
deployOnlyRadio.addSelectionListener(listener);
remoteDetailsLoc.addModifyListener(modListener);
serverHomeText.addModifyListener(modListener);
- serverConfigText.addModifyListener(modListener);
+ serverConfigText.addModifyListener(modListener);
deployFolderText.addModifyListener(modListener);
autoLocalRuntimeCombo.addModifyListener(modListener);
localRuntimeCombo.addModifyListener(modListener);
setControl(c2);
}
+ private ControlDecoration createErrorDecoration(String errorText, Control control) {
+ ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP);
+ Image errorImage = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
+ decoration.setImage(errorImage);
+ decoration.setDescriptionText(errorText);
+ decoration.setShowHover(true);
+ decoration.hide();
+ return decoration;
+ }
+
private void fillRuntimeTypeCombo() {
localRuntimes.clear();
IRuntime[] rts = ServerCore.getRuntimes();
ArrayList<String> names = new ArrayList<String>();
- for( int i = 0; i < rts.length; i++ ) {
- if( rts[i].getRuntimeType() == null )
+ for (int i = 0; i < rts.length; i++) {
+ if (rts[i].getRuntimeType() == null)
continue;
- if( rts[i].getRuntimeType().getId().startsWith("org.jboss.")
+ if (rts[i].getRuntimeType().getId().startsWith("org.jboss.")
&&
!rts[i].getRuntimeType().getId().equals(IJBossToolingConstants.DEPLOY_ONLY_RUNTIME)) {
localRuntimes.add(rts[i]);
names.add(rts[i].getName());
@@ -224,12 +255,12 @@
localRuntimeCombo.setItems((String[]) names.toArray(new String[names.size()]));
autoLocalRuntimeCombo.setItems((String[]) names.toArray(new String[names.size()]));
}
-
+
protected void configureRuntimesPressed() {
ServerUIUtil.showNewRuntimeWizard(addLocalRuntimeButton.getShell(), null, null);
fillRuntimeTypeCombo();
}
-
+
private void handleSelection(Widget w) {
if (w == createRSE) {
if (!createRSE.getSelection()) {
@@ -240,41 +271,60 @@
createServer.setEnabled(true);
}
}
- if( w == createServer ) {
+ if (w == createServer) {
refreshServerWidgets();
}
verifyPageComplete();
}
private void verifyPageComplete() {
- boolean complete = true;
String error = null;
- if( createServer.getSelection()) {
- if( deployOnlyRadio.getSelection()) {
- complete = !deployFolderText.getText().equals("");
- if( !complete )
- error = "The deploy folder must not be empty";
- } else if( autoScanCheck.getSelection()) {
- int index = autoLocalRuntimeCombo.getSelectionIndex();
- complete = index != -1 && !remoteDetailsLoc.getText().equals("");
- if( !complete )
- error = "Please select a local runtime. The created server will be of the same
version as the local runtime.";
- } else if( hardCodeServerDetails.getSelection()) {
- int index = localRuntimeCombo.getSelectionIndex();
- complete = index != -1 && !serverHomeText.getText().equals("")
&& !serverConfigText.getText().equals("");
- if( !complete )
- error = "Please select a local runtime. The created server will be of the same
version as the local runtime.";
+ deployFolderDeco.hide();
+ autoLocalRuntimeDeco.hide();
+ remoteDetailsLocDeco.hide();
+ localRuntimeDeco.hide();
+ serverHomeDeco.hide();
+ serverConfigDeco.hide();
+
+ if (createServer.getSelection()) {
+ if (deployOnlyRadio.getSelection()) {
+ if (deployFolderText.getText().equals("")) {
+ error = DEPLOY_FOLDER_NOT_EMPTY;
+ deployFolderDeco.show();
+ }
+ } else if (autoScanCheck.getSelection()) {
+ if (autoLocalRuntimeCombo.getSelectionIndex() < 0) {
+ autoLocalRuntimeDeco.show();
+ error = SELECT_RUNTIME_ERROR;
+ }
+ if (remoteDetailsLoc.getText().equals("")) {
+ remoteDetailsLocDeco.show();
+ error = REMOTE_DETAILS_LOC_ERROR;
+ }
+ } else if (hardCodeServerDetails.getSelection()) {
+ if (localRuntimeCombo.getSelectionIndex() < 0) {
+ localRuntimeDeco.show();
+ error = SELECT_RUNTIME_ERROR;
+ }
+ if (serverHomeText.getText().equals("")) {
+ serverHomeDeco.show();
+ error = SERVER_HOME_ERROR;
+ }
+ if (serverConfigText.getText().equals("")) {
+ serverConfigDeco.show();
+ error = SERVER_CONFIG_ERROR;
+ }
}
}
setErrorMessage(error);
- setPageComplete(complete);
+ setPageComplete(error == null);
}
-
+
private void refreshServerWidgets() {
- if( initialHost != null ) {
+ if (initialHost != null) {
createRSE.setEnabled(false);
}
-
+
boolean enabled = createServer.getSelection();
serverDetailsGroup.setEnabled(enabled);
autoScanCheck.setEnabled(enabled);
@@ -292,7 +342,7 @@
localRuntimeLabel.setEnabled(enabled);
localRuntimeCombo.setEnabled(enabled);
}
-
+
public ChainedJob getPerformFinishJob(final DeltaCloudInstance instance) {
IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
prefs.putBoolean(CREATE_RSE_PREF_KEY, createRSE.getSelection());
@@ -303,32 +353,32 @@
// ignore
}
- if( !createRSE.getSelection())
+ if (!createRSE.getSelection())
return null;
-
- CreateRSEFromInstanceJob j =
- new CreateRSEFromInstanceJob(instance, INewInstanceWizardPage.NEW_INSTANCE_FAMILY);
- if( createServer.getSelection()) {
+ CreateRSEFromInstanceJob j =
+ new CreateRSEFromInstanceJob(instance, INewInstanceWizardPage.NEW_INSTANCE_FAMILY);
+
+ if (createServer.getSelection()) {
String[] data = null;
String type = null;
- if( deployOnlyRadio.getSelection()) {
+ if (deployOnlyRadio.getSelection()) {
type = CreateServerFromRSEJob.CREATE_DEPLOY_ONLY_SERVER;
- data = new String[]{deployFolderText.getText()};
- } else if( autoScanCheck.getSelection()) {
+ data = new String[] { deployFolderText.getText() };
+ } else if (autoScanCheck.getSelection()) {
type = CreateServerFromRSEJob.CHECK_SERVER_FOR_DETAILS;
int index = autoLocalRuntimeCombo.getSelectionIndex();
String rtId = localRuntimes.get(index).getId();
- data = new String[]{remoteDetailsLoc.getText(), rtId};
- } else if( hardCodeServerDetails.getSelection()) {
+ data = new String[] { remoteDetailsLoc.getText(), rtId };
+ } else if (hardCodeServerDetails.getSelection()) {
type = CreateServerFromRSEJob.SET_DETAILS_NOW;
int index = localRuntimeCombo.getSelectionIndex();
String rtId = localRuntimes.get(index).getId();
- data = new String[]{serverHomeText.getText(), serverConfigText.getText(), rtId};
+ data = new String[] { serverHomeText.getText(), serverConfigText.getText(), rtId };
}
- if( type != null && data != null ) {
+ if (type != null && data != null) {
CreateServerFromRSEJob job2 = new CreateServerFromRSEJob(type, data, instance);
- if( initialHost != null ) {
+ if (initialHost != null) {
job2.setHost(initialHost);
return job2;
}
@@ -337,5 +387,5 @@
}
return j;
}
-
+
}