Author: adietish
Date: 2012-02-24 10:08:03 -0500 (Fri, 24 Feb 2012)
New Revision: 39116
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
Log:
[JBIDE-11037] changed error to warning iforming the user that the app names could possibly
conflict with an existing proj in his workspace
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-24
15:07:46 UTC (rev 39115)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-24
15:08:03 UTC (rev 39116)
@@ -78,6 +78,7 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -97,7 +98,8 @@
* @author Andre Dietisheim
* @author Xavier Coulon
*/
-public class ApplicationConfigurationWizardPage extends AbstractOpenShiftWizardPage {
+public class ApplicationConfigurationWizardPage extends
+ AbstractOpenShiftWizardPage {
private CheckboxTableViewer viewer;
private ApplicationConfigurationWizardPageModel pageModel;
@@ -113,84 +115,108 @@
private Button checkAllButton;
private Button uncheckAllButton;
- public ApplicationConfigurationWizardPage(IWizard wizard,
OpenShiftExpressApplicationWizardModel wizardModel) {
- super("Setup OpenShift Application", "Select an existing or create a new
OpenShift Express Application.",
+ public ApplicationConfigurationWizardPage(IWizard wizard,
+ OpenShiftExpressApplicationWizardModel wizardModel) {
+ super(
+ "Setup OpenShift Application",
+ "Select an existing or create a new OpenShift Express Application.",
"Setup OpenShift Application", wizard);
try {
- this.pageModel = new ApplicationConfigurationWizardPageModel(wizardModel);
+ this.pageModel = new ApplicationConfigurationWizardPageModel(
+ wizardModel);
} catch (OpenShiftException e) {
- IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
+ IStatus status = OpenShiftUIActivator.createErrorStatus(
+ e.getMessage(), e);
OpenShiftUIActivator.log(status);
- ErrorDialog.openError(getShell(), "Error", "Error initializing
application configuration page", status);
+ ErrorDialog
+ .openError(
+ getShell(),
+ "Error",
+ "Error initializing application configuration page",
+ status);
}
}
@Override
protected void doCreateControls(Composite container, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().applyTo(container);
- GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL,
SWT.FILL).applyTo(container);
+ GridDataFactory.fillDefaults().grab(true, true)
+ .align(SWT.FILL, SWT.FILL).applyTo(container);
createApplicationSelectionGroup(container, dbc);
createApplicationConfigurationGroup(container, dbc);
}
- private Composite createApplicationSelectionGroup(Composite container,
DataBindingContext dbc) {
+ private Composite createApplicationSelectionGroup(Composite container,
+ DataBindingContext dbc) {
Composite existingAppSelectionGroup = new Composite(container, SWT.NONE);
// projectGroup.setText("Project");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL,
SWT.CENTER).grab(true, false)
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER)
+ .align(SWT.FILL, SWT.CENTER).grab(true, false)
.applyTo(existingAppSelectionGroup);
- GridLayoutFactory.fillDefaults().numColumns(3).margins(6,
6).applyTo(existingAppSelectionGroup);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6)
+ .applyTo(existingAppSelectionGroup);
// existing app checkbox
useExistingAppBtn = new Button(existingAppSelectionGroup, SWT.CHECK);
useExistingAppBtn.setText("Use existing application:");
- useExistingAppBtn.setToolTipText("Select an existing application or uncheck to
create a new one.");
+ useExistingAppBtn
+ .setToolTipText("Select an existing application or uncheck to create a new
one.");
useExistingAppBtn.setFocus();
- GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false,
false)
- .applyTo(useExistingAppBtn);
- IObservableValue useExistingAppObservable = BeanProperties.value(
- ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION).observe(pageModel);
- final IObservableValue useExistingAppBtnSelection =
WidgetProperties.selection().observe(useExistingAppBtn);
+ GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER)
+ .grab(false, false).applyTo(useExistingAppBtn);
+ IObservableValue useExistingAppObservable = BeanProperties
+ .value(ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION)
+ .observe(pageModel);
+ final IObservableValue useExistingAppBtnSelection = WidgetProperties
+ .selection().observe(useExistingAppBtn);
dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);
// existing app name
- this.existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false)
- .applyTo(existingAppNameText);
- IObservableValue existingAppNameTextObservable =
WidgetProperties.text(SWT.Modify).observe(existingAppNameText);
- IObservableValue existingAppNameModelObservable = BeanProperties.value(
- ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel);
- ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
+ this.existingAppNameText = new Text(existingAppSelectionGroup,
+ SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1)
+ .grab(true, false).applyTo(existingAppNameText);
+ IObservableValue existingAppNameTextObservable = WidgetProperties.text(
+ SWT.Modify).observe(existingAppNameText);
+ IObservableValue existingAppNameModelObservable = BeanProperties
+ .value(ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME)
+ .observe(pageModel);
+ ValueBindingBuilder.bind(existingAppNameTextObservable)
+ .to(existingAppNameModelObservable).in(dbc);
UIUtils.focusOnSelection(useExistingAppBtn, existingAppNameText);
createExistingAppNameContentAssist();
this.browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
browseAppsButton.setText("Browse...");
browseAppsButton.addSelectionListener(onBrowseApps());
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).span(1, 1).grab(false, false)
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER)
+ .hint(100, SWT.DEFAULT).span(1, 1).grab(false, false)
.applyTo(browseAppsButton);
// observe the list of application, get notified once they have been
- IObservableValue existingApplicationsLoaded =
- BeanProperties.value(ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATIONS_LOADED)
- .observe(pageModel);
- final ApplicationToSelectNameValidator existingAppValidator =
- new ApplicationToSelectNameValidator(
- useExistingAppBtnSelection, existingAppNameTextObservable,
existingApplicationsLoaded);
+ IObservableValue existingApplicationsLoaded = BeanProperties
+ .value(ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATIONS_LOADED)
+ .observe(pageModel);
+ final ApplicationToSelectNameValidator existingAppValidator = new
ApplicationToSelectNameValidator(
+ useExistingAppBtnSelection, existingAppNameTextObservable,
+ existingApplicationsLoaded);
dbc.addValidationStatusProvider(existingAppValidator);
- ControlDecorationSupport.create(existingAppValidator, SWT.LEFT | SWT.TOP, null,
- new CustomControlDecorationUpdater(false));
+ ControlDecorationSupport.create(existingAppValidator, SWT.LEFT
+ | SWT.TOP, null, new CustomControlDecorationUpdater(false));
return existingAppSelectionGroup;
}
private void createExistingAppNameContentAssist() {
- ControlDecoration dec = new ControlDecoration(existingAppNameText, SWT.TOP |
SWT.LEFT);
- FieldDecoration contentProposalFieldIndicator =
FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ ControlDecoration dec = new ControlDecoration(existingAppNameText,
+ SWT.TOP | SWT.LEFT);
+ FieldDecoration contentProposalFieldIndicator = FieldDecorationRegistry
+ .getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
dec.setImage(contentProposalFieldIndicator.getImage());
dec.setDescriptionText("Auto-completion is enabled when you start typing an
application name.");
dec.setShowOnlyOnFocus(true);
- AutoCompleteField adapter = new AutoCompleteField(existingAppNameText, new
TextContentAdapter(),
- new String[] {});
+ AutoCompleteField adapter = new AutoCompleteField(existingAppNameText,
+ new TextContentAdapter(), new String[] {});
adapter.setProposals(pageModel.getApplicationNames());
}
@@ -200,17 +226,23 @@
@Override
public void widgetSelected(SelectionEvent e) {
final ApplicationSelectionDialog appSelectionDialog = new
ApplicationSelectionDialog(
- (OpenShiftExpressApplicationWizard) getWizard(), null, getShell());
+ (OpenShiftExpressApplicationWizard) getWizard(), null,
+ getShell());
final int result = appSelectionDialog.open();
if (result == IDialogConstants.OK_ID) {
- final IApplication selectedApplication =
appSelectionDialog.getSelectedApplication();
+ final IApplication selectedApplication = appSelectionDialog
+ .getSelectedApplication();
if (selectedApplication != null) {
try {
- pageModel.setExistingApplication(selectedApplication);
+ pageModel
+ .setExistingApplication(selectedApplication);
} catch (OpenShiftException ex) {
- OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(NLS.bind(
- "Could not get embedded cartridges for application {0}",
- selectedApplication.getName()), ex));
+ OpenShiftUIActivator
+ .log(OpenShiftUIActivator.createErrorStatus(
+ NLS.bind(
+ "Could not get embedded cartridges for application {0}",
+ selectedApplication
+ .getName()), ex));
}
}
}
@@ -218,86 +250,113 @@
};
}
- private void createApplicationConfigurationGroup(Composite parent, DataBindingContext
dbc) {
+ private void createApplicationConfigurationGroup(Composite parent,
+ DataBindingContext dbc) {
this.newAppConfigurationGroup = new Group(parent, SWT.NONE);
newAppConfigurationGroup.setText("New application");
- GridLayoutFactory.fillDefaults().numColumns(2).margins(6,
6).applyTo(newAppConfigurationGroup);
- GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL,
SWT.FILL).applyTo(newAppConfigurationGroup);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6)
+ .applyTo(newAppConfigurationGroup);
+ GridDataFactory.fillDefaults().grab(true, true)
+ .align(SWT.FILL, SWT.FILL).applyTo(newAppConfigurationGroup);
- IObservableValue useExistingApplication =
WidgetProperties.selection().observe(useExistingAppBtn);
+ IObservableValue useExistingApplication = WidgetProperties.selection()
+ .observe(useExistingAppBtn);
- useExistingApplication.addValueChangeListener(
- onUseExistingApplication(
- newAppConfigurationGroup, existingAppNameText, browseAppsButton));
+ useExistingApplication
+ .addValueChangeListener(onUseExistingApplication(
+ newAppConfigurationGroup, existingAppNameText,
+ browseAppsButton));
this.newAppNameLabel = new Label(newAppConfigurationGroup, SWT.NONE);
newAppNameLabel.setText("Name:");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(newAppNameLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .applyTo(newAppNameLabel);
this.newAppNameText = new Text(newAppConfigurationGroup, SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL,
SWT.FILL).applyTo(newAppNameText);
+ GridDataFactory.fillDefaults().grab(true, false)
+ .align(SWT.FILL, SWT.FILL).applyTo(newAppNameText);
UIUtils.selectAllOnFocus(newAppNameText);
- final IObservableValue applicationNameTextObservable =
WidgetProperties.text(SWT.Modify)
- .observe(newAppNameText);
- final IObservableValue applicationNameModelObservable = BeanProperties.value(
- ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel);
- ValueBindingBuilder.bind(applicationNameTextObservable).to(applicationNameModelObservable).in(dbc);
+ final IObservableValue applicationNameTextObservable = WidgetProperties
+ .text(SWT.Modify).observe(newAppNameText);
+ final IObservableValue applicationNameModelObservable = BeanProperties
+ .value(ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_NAME)
+ .observe(pageModel);
+ ValueBindingBuilder.bind(applicationNameTextObservable)
+ .to(applicationNameModelObservable).in(dbc);
this.newAppTypeLabel = new Label(newAppConfigurationGroup, SWT.NONE);
newAppTypeLabel.setText("Type:");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1,
1).applyTo(newAppTypeLabel);
- this.newAppCartridgeCombo = new Combo(newAppConfigurationGroup, SWT.BORDER |
SWT.READ_ONLY);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false)
- .applyTo(newAppCartridgeCombo);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1)
+ .applyTo(newAppTypeLabel);
+ this.newAppCartridgeCombo = new Combo(newAppConfigurationGroup,
+ SWT.BORDER | SWT.READ_ONLY);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1)
+ .grab(true, false).applyTo(newAppCartridgeCombo);
fillCartridgesCombo(dbc, newAppCartridgeCombo);
- final ISWTObservableValue selectedCartridgeComboObservable =
WidgetProperties.selection().observe(
- newAppCartridgeCombo);
- final IObservableValue selectedCartridgeModelObservable = BeanProperties.value(
- NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel);
- ValueBindingBuilder.bind(selectedCartridgeComboObservable).converting(new
StringToCartridgeConverter())
- .to(selectedCartridgeModelObservable).converting(new
CartridgeToStringConverter()).in(dbc);
+ final ISWTObservableValue selectedCartridgeComboObservable = WidgetProperties
+ .selection().observe(newAppCartridgeCombo);
+ final IObservableValue selectedCartridgeModelObservable = BeanProperties
+ .value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE)
+ .observe(pageModel);
+ ValueBindingBuilder.bind(selectedCartridgeComboObservable)
+ .converting(new StringToCartridgeConverter())
+ .to(selectedCartridgeModelObservable)
+ .converting(new CartridgeToStringConverter()).in(dbc);
- final ISWTObservableValue useExistingAppBtnSelection =
WidgetProperties.selection().observe(useExistingAppBtn);
+ final ISWTObservableValue useExistingAppBtnSelection = WidgetProperties
+ .selection().observe(useExistingAppBtn);
final NewApplicationNameValidator newApplicationNameValidator = new
NewApplicationNameValidator(
useExistingAppBtnSelection, applicationNameTextObservable);
dbc.addValidationStatusProvider(newApplicationNameValidator);
- ControlDecorationSupport.create(newApplicationNameValidator, SWT.LEFT | SWT.TOP, null,
- new CustomControlDecorationUpdater());
+ ControlDecorationSupport.create(newApplicationNameValidator, SWT.LEFT
+ | SWT.TOP, null, new CustomControlDecorationUpdater());
final NewApplicationTypeValidator newApplicationTypeValidator = new
NewApplicationTypeValidator(
useExistingAppBtnSelection, selectedCartridgeComboObservable);
dbc.addValidationStatusProvider(newApplicationTypeValidator);
- ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
- new CustomControlDecorationUpdater());
+ ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT
+ | SWT.TOP, null, new CustomControlDecorationUpdater());
// embeddable cartridges
- this.newAppEmbeddableCartridgesGroup = new Group(newAppConfigurationGroup, SWT.NONE);
+ this.newAppEmbeddableCartridgesGroup = new Group(
+ newAppConfigurationGroup, SWT.NONE);
newAppEmbeddableCartridgesGroup.setText("Embeddable Cartridges");
- GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(2, 1)
+ GridDataFactory.fillDefaults().grab(true, true)
+ .align(SWT.FILL, SWT.FILL).span(2, 1)
.applyTo(newAppEmbeddableCartridgesGroup);
- GridLayoutFactory.fillDefaults().numColumns(2).margins(6,
6).applyTo(newAppEmbeddableCartridgesGroup);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6)
+ .applyTo(newAppEmbeddableCartridgesGroup);
- Composite tableContainer = new Composite(newAppEmbeddableCartridgesGroup, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1,
2).hint(400, 250)
+ Composite tableContainer = new Composite(
+ newAppEmbeddableCartridgesGroup, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
+ .grab(true, true).span(1, 2).hint(400, 250)
.applyTo(tableContainer);
this.viewer = createTable(tableContainer);
- dbc.bindSet(ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
- BeanProperties.set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
+ dbc.bindSet(
+ ViewerProperties.checkedElements(IEmbeddableCartridge.class)
+ .observe(viewer),
+ BeanProperties
+ .set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
.observe(pageModel));
- this.checkAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
+ this.checkAllButton = new Button(newAppEmbeddableCartridgesGroup,
+ SWT.PUSH);
checkAllButton.setText("&Select All");
- GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false,
false).align(SWT.FILL, SWT.TOP)
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT)
+ .grab(false, false).align(SWT.FILL, SWT.TOP)
.applyTo(checkAllButton);
checkAllButton.addSelectionListener(onCheckAll());
- this.uncheckAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
+ this.uncheckAllButton = new Button(newAppEmbeddableCartridgesGroup,
+ SWT.PUSH);
uncheckAllButton.setText("&Deselect All");
- GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL,
SWT.TOP)
- .applyTo(uncheckAllButton);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, true)
+ .align(SWT.FILL, SWT.TOP).applyTo(uncheckAllButton);
uncheckAllButton.addSelectionListener(onUncheckAll());
// bottom filler
Composite spacer = new Composite(newAppConfigurationGroup, SWT.NONE);
- GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(spacer);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL)
+ .grab(true, true).applyTo(spacer);
}
/**
@@ -309,7 +368,8 @@
* @param applicationBrowseButton
* @return
*/
- private IValueChangeListener onUseExistingApplication(final Group
applicationConfigurationGroup,
+ private IValueChangeListener onUseExistingApplication(
+ final Group applicationConfigurationGroup,
final Text applicationNameText, final Button applicationBrowseButton) {
return new IValueChangeListener() {
@@ -318,9 +378,9 @@
Object newValue = event.diff.getNewValue();
if (newValue instanceof Boolean) {
Boolean useExisting = (Boolean) newValue;
-// if (!useExisting) {
-// resetExistingApplication();
-// }
+ // if (!useExisting) {
+ // resetExistingApplication();
+ // }
enableApplicationWidgets(useExisting);
}
}
@@ -328,7 +388,8 @@
}
/**
- * Enables/disables the given widgets based on the flag to use an existing app or create
a new application.
+ * Enables/disables the given widgets based on the flag to use an existing
+ * app or create a new application.
*
* @param useExisting
* @param applicationConfigurationGroup
@@ -348,16 +409,21 @@
}, newAppConfigurationGroup);
}
- private void fillCartridgesCombo(DataBindingContext dbc, Combo cartridgesCombo) {
- dbc.bindList(WidgetProperties.items().observe(cartridgesCombo),
- BeanProperties.list(ApplicationConfigurationWizardPageModel.PROPERTY_CARTRIDGES).observe(pageModel),
- new UpdateListStrategy(UpdateListStrategy.POLICY_NEVER),
- new UpdateListStrategy().setConverter(new CartridgeToStringConverter()));
+ private void fillCartridgesCombo(DataBindingContext dbc,
+ Combo cartridgesCombo) {
+ dbc.bindList(
+ WidgetProperties.items().observe(cartridgesCombo),
+ BeanProperties
+ .list(ApplicationConfigurationWizardPageModel.PROPERTY_CARTRIDGES)
+ .observe(pageModel), new UpdateListStrategy(
+ UpdateListStrategy.POLICY_NEVER),
+ new UpdateListStrategy()
+ .setConverter(new CartridgeToStringConverter()));
}
protected CheckboxTableViewer createTable(Composite tableContainer) {
- Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL
| SWT.H_SCROLL
- | SWT.CHECK);
+ Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION
+ | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK);
table.setLinesVisible(true);
TableColumnLayout tableLayout = new TableColumnLayout();
tableContainer.setLayout(tableLayout);
@@ -369,19 +435,22 @@
@Override
public void update(ViewerCell cell) {
- IEmbeddableCartridge cartridge = (IEmbeddableCartridge) cell.getElement();
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) cell
+ .getElement();
cell.setText(cartridge.getName());
}
}, viewer, tableLayout);
return viewer;
}
- private void createTableColumn(String name, int weight, CellLabelProvider
cellLabelProvider, TableViewer viewer,
+ private void createTableColumn(String name, int weight,
+ CellLabelProvider cellLabelProvider, TableViewer viewer,
TableColumnLayout layout) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(name);
column.setLabelProvider(cellLabelProvider);
- layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true));
+ layout.setColumnData(column.getColumn(), new ColumnWeightData(weight,
+ true));
}
private ICheckStateListener onCartridgeChecked() {
@@ -390,11 +459,14 @@
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
try {
- IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event
+ .getElement();
if (event.getChecked()) {
- if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
+ if (IEmbeddableCartridge.PHPMYADMIN_34
+ .equals(cartridge)) {
addPhpMyAdminCartridge(cartridge);
- } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
+ } else if (IEmbeddableCartridge.JENKINS_14
+ .equals(cartridge)) {
addJenkinsCartridge(cartridge);
} else {
addCartridge(cartridge);
@@ -407,17 +479,20 @@
}
}
} catch (OpenShiftException e) {
- OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
+ OpenShiftUIActivator.log(
+ "Could not process embeddable cartridges", e);
}
}
};
}
- private void addJenkinsCartridge(final IEmbeddableCartridge cartridge) throws
OpenShiftException {
+ private void addJenkinsCartridge(final IEmbeddableCartridge cartridge)
+ throws OpenShiftException {
if (pageModel.hasApplication(ICartridge.JENKINS_14)) {
pageModel.getSelectedEmbeddableCartridges().add(cartridge);
} else {
- final JenkinsApplicationDialog dialog = new JenkinsApplicationDialog(getShell());
+ final JenkinsApplicationDialog dialog = new JenkinsApplicationDialog(
+ getShell());
if (dialog.open() == Dialog.OK) {
createJenkinsApplication(cartridge, dialog.getValue());
} else {
@@ -426,41 +501,52 @@
}
}
- private void createJenkinsApplication(final IEmbeddableCartridge cartridge, final String
name) {
+ private void createJenkinsApplication(final IEmbeddableCartridge cartridge,
+ final String name) {
try {
- WizardUtils.runInWizard(new Job(NLS.bind("Creating jenkins application
\"{0}\"...", name)) {
+ WizardUtils.runInWizard(
+ new Job(NLS.bind("Creating jenkins application \"{0}\"...",
+ name)) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- IApplication jenkinsApplication = pageModel.createJenkinsApplication(name,
monitor);
- pageModel.getSelectedEmbeddableCartridges().add(cartridge);
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ IApplication jenkinsApplication = pageModel
+ .createJenkinsApplication(name, monitor);
+ pageModel.getSelectedEmbeddableCartridges()
+ .add(cartridge);
- openLogDialog(jenkinsApplication);
+ openLogDialog(jenkinsApplication);
- return Status.OK_STATUS;
- } catch (Exception e) {
- getShell().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- viewer.setChecked(cartridge, false);
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ getShell().getDisplay().syncExec(
+ new Runnable() {
+ @Override
+ public void run() {
+ viewer.setChecked(cartridge,
+ false);
+ }
+ });
+ return OpenShiftUIActivator.createErrorStatus(
+ "Could not load embeddable cartridges",
+ e);
}
- });
- return OpenShiftUIActivator.createErrorStatus("Could not load embeddable
cartridges", e);
- }
- }
+ }
- }, getContainer(), getDataBindingContext());
+ }, getContainer(), getDataBindingContext());
} catch (Exception e) {
// ignore
}
}
- private void addPhpMyAdminCartridge(IEmbeddableCartridge cartridge) throws
OpenShiftException {
+ private void addPhpMyAdminCartridge(IEmbeddableCartridge cartridge)
+ throws OpenShiftException {
if (!viewer.getChecked(IEmbeddableCartridge.MYSQL_51)) {
if (MessageDialog.openQuestion(getShell(), "Embed mysql cartridge",
"To embed phpmyadmin, you'd also have to embed mysql.")) {
- pageModel.getSelectedEmbeddableCartridges().add(IEmbeddableCartridge.MYSQL_51);
+ pageModel.getSelectedEmbeddableCartridges().add(
+ IEmbeddableCartridge.MYSQL_51);
pageModel.getSelectedEmbeddableCartridges().add(cartridge);
viewer.setChecked(IEmbeddableCartridge.MYSQL_51, true);
} else {
@@ -471,15 +557,19 @@
}
}
- private void addCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
+ private void addCartridge(IEmbeddableCartridge cartridge)
+ throws OpenShiftException {
pageModel.getSelectedEmbeddableCartridges().add(cartridge);
}
- private void removeMySQLCartridge(IEmbeddableCartridge cartridge) throws
OpenShiftException {
- Set<IEmbeddableCartridge> checkedCartridges =
pageModel.getSelectedEmbeddableCartridges();
+ private void removeMySQLCartridge(IEmbeddableCartridge cartridge)
+ throws OpenShiftException {
+ Set<IEmbeddableCartridge> checkedCartridges = pageModel
+ .getSelectedEmbeddableCartridges();
if (viewer.getChecked(IEmbeddableCartridge.PHPMYADMIN_34)) {
- if (MessageDialog.openQuestion(getShell(), "Remove phpmyadmin cartridge",
- "If you remove the mysql cartridge, you'd also have to remove
phpmyadmin.")) {
+ if (MessageDialog
+ .openQuestion(getShell(), "Remove phpmyadmin cartridge",
+ "If you remove the mysql cartridge, you'd also have to remove
phpmyadmin.")) {
checkedCartridges.remove(IEmbeddableCartridge.PHPMYADMIN_34);
checkedCartridges.remove(cartridge);
viewer.setChecked(IEmbeddableCartridge.PHPMYADMIN_34, false);
@@ -491,7 +581,8 @@
}
}
- private void removeCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException
{
+ private void removeCartridge(IEmbeddableCartridge cartridge)
+ throws OpenShiftException {
pageModel.getSelectedEmbeddableCartridges().remove(cartridge);
}
@@ -504,7 +595,8 @@
try {
addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
} catch (OpenShiftException ex) {
- OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
+ OpenShiftUIActivator.log(
+ "Could not select jenkins cartridge", ex);
}
}
@@ -522,7 +614,8 @@
};
}
- private void setViewerInput(final Collection<IEmbeddableCartridge> cartridges) {
+ private void setViewerInput(
+ final Collection<IEmbeddableCartridge> cartridges) {
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
@@ -554,7 +647,8 @@
@Override
public Object convert(Object fromObject) {
- if (fromObject instanceof String && ((String) fromObject).length() > 0) {
+ if (fromObject instanceof String
+ && ((String) fromObject).length() > 0) {
return new Cartridge(((String) fromObject));
}
return null;
@@ -564,9 +658,12 @@
private static class JenkinsApplicationDialog extends InputDialog {
public JenkinsApplicationDialog(Shell shell) {
- super(shell, "New Jenkins application",
+ super(
+ shell,
+ "New Jenkins application",
"To embed jenkins into your application, you'd first have to create a
jenkins application.\n"
- + "Please provide a name for your jenkins application:", null, new
JenkinsNameValidator());
+ + "Please provide a name for your jenkins application:",
+ null, new JenkinsNameValidator());
}
private static class JenkinsNameValidator implements IInputValidator {
@@ -592,11 +689,12 @@
}
/**
- * Viewer element comparer based on #equals(). The default implementation in
CheckboxTableViewer compares elements
- * based on instance identity.
+ * Viewer element comparer based on #equals(). The default implementation in
+ * CheckboxTableViewer compares elements based on instance identity.
* <p>
- * We need this since the available cartridges (item listed in the viewer) are not the
same instance as the ones in
- * the embedded application (items to check in the viewer).
+ * We need this since the available cartridges (item listed in the viewer)
+ * are not the same instance as the ones in the embedded application (items
+ * to check in the viewer).
*/
private static class EqualityComparer implements IElementComparer {
@@ -629,7 +727,8 @@
Display.getDefault().asyncExec(new Runnable() {
public void run() {
loadOpenshiftResources(dbc);
- enableApplicationWidgets(pageModel.isUseExistingApplication());
+ enableApplicationWidgets(pageModel
+ .isUseExistingApplication());
createExistingAppNameContentAssist();
// this is needed because of weird issues with UI not
// reacting to model changes while wizard runnable is
@@ -642,7 +741,8 @@
}
@Override
- protected void onPageWillGetActivated(Direction direction, PageChangingEvent event,
DataBindingContext dbc) {
+ protected void onPageWillGetActivated(Direction direction,
+ PageChangingEvent event, DataBindingContext dbc) {
if (direction == Direction.BACKWARDS) {
return;
}
@@ -650,15 +750,17 @@
final IUser user = this.pageModel.getUser();
if (user != null && !user.hasDomain()) {
IWizard domainDialog = new NewDomainDialog(user);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
domainDialog);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), domainDialog);
dialog.create();
dialog.setBlockOnOpen(true);
int result = dialog.open();
- if(result != Dialog.OK) {
- final IWizardContainer container = getWizard().getContainer();
- if(container instanceof WizardDialog) {
+ if (result != Dialog.OK) {
+ final IWizardContainer container = getWizard()
+ .getContainer();
+ if (container instanceof WizardDialog) {
event.doit = false;
- ((WizardDialog)container).close();
+ ((WizardDialog) container).close();
}
}
}
@@ -669,47 +771,57 @@
protected void loadOpenshiftResources(final DataBindingContext dbc) {
try {
- WizardUtils.runInWizard(new Job("Loading existing applications...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- pageModel.loadExistingApplications();
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load
applications", e);
- }
- }
+ WizardUtils.runInWizard(
+ new Job("Loading existing applications...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ pageModel.loadExistingApplications();
+ return Status.OK_STATUS;
+ } catch (NotFoundOpenShiftException e) {
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return OpenShiftUIActivator.createErrorStatus(
+ "Could not load applications", e);
+ }
+ }
- }, getContainer(), dbc);
+ }, getContainer(), dbc);
- WizardUtils.runInWizard(new Job("Loading application cartridges...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- pageModel.loadCartridges();
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load application
cartridges", e);
- }
- }
- }, getContainer(), dbc);
- WizardUtils.runInWizard(new Job("Loading embeddable cartridges...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- setViewerInput(pageModel.loadEmbeddableCartridges());
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load embeddable
cartridges", e);
- }
- }
- }, getContainer(), dbc);
+ WizardUtils.runInWizard(
+ new Job("Loading application cartridges...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ pageModel.loadCartridges();
+ return Status.OK_STATUS;
+ } catch (NotFoundOpenShiftException e) {
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return OpenShiftUIActivator
+ .createErrorStatus(
+ "Could not load application cartridges",
+ e);
+ }
+ }
+ }, getContainer(), dbc);
+ WizardUtils.runInWizard(
+ new Job("Loading embeddable cartridges...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ setViewerInput(pageModel
+ .loadEmbeddableCartridges());
+ return Status.OK_STATUS;
+ } catch (NotFoundOpenShiftException e) {
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return OpenShiftUIActivator.createErrorStatus(
+ "Could not load embeddable cartridges",
+ e);
+ }
+ }
+ }, getContainer(), dbc);
} catch (Exception ex) {
// ignore
}
@@ -721,8 +833,10 @@
private final IObservableValue existingAppNameTextObservable;
private final IObservableValue existingApplicationsLoadedObservable;
- public ApplicationToSelectNameValidator(IObservableValue useExistingAppBtnbservable,
- IObservableValue existingAppNameTextObservable, IObservableValue
existingApplicationsLoadedObservable) {
+ public ApplicationToSelectNameValidator(
+ IObservableValue useExistingAppBtnbservable,
+ IObservableValue existingAppNameTextObservable,
+ IObservableValue existingApplicationsLoadedObservable) {
this.useExistingAppBtnbservable = useExistingAppBtnbservable;
this.existingAppNameTextObservable = existingAppNameTextObservable;
this.existingApplicationsLoadedObservable = existingApplicationsLoadedObservable;
@@ -730,24 +844,32 @@
@Override
protected IStatus validate() {
- final boolean useExistingApp = (Boolean) useExistingAppBtnbservable.getValue();
- final String appName = (String) existingAppNameTextObservable.getValue();
- final Boolean existingApplicationsLoaded = (Boolean)
existingApplicationsLoadedObservable.getValue();
+ final boolean useExistingApp = (Boolean) useExistingAppBtnbservable
+ .getValue();
+ final String appName = (String) existingAppNameTextObservable
+ .getValue();
+ final Boolean existingApplicationsLoaded = (Boolean)
existingApplicationsLoadedObservable
+ .getValue();
if (!useExistingApp) {
return ValidationStatus.ok();
}
if (StringUtils.isEmpty(appName)) {
- return ValidationStatus.cancel("Please select an existing OpenShift
application");
+ return ValidationStatus
+ .cancel("Please select an existing OpenShift application");
}
if (existingApplicationsLoaded != null
&& !existingApplicationsLoaded) {
- return ValidationStatus.cancel("Existing applications are not loaded
yet.");
+ return ValidationStatus
+ .cancel("Existing applications are not loaded yet.");
} else {
if (!pageModel.hasApplication(appName)) {
- return ValidationStatus.error(NLS.bind("The application \"{0}\" does
not exist.", appName));
+ return ValidationStatus
+ .error(NLS.bind(
+ "The application \"{0}\" does not exist.",
+ appName));
}
}
@@ -769,7 +891,8 @@
private final IObservableValue useExistingAppbservable;
private final IObservableValue applicationNameObservable;
- public NewApplicationNameValidator(IObservableValue useExistingAppObservable,
+ public NewApplicationNameValidator(
+ IObservableValue useExistingAppObservable,
IObservableValue applicationNameObservable) {
this.useExistingAppbservable = useExistingAppObservable;
this.applicationNameObservable = applicationNameObservable;
@@ -777,32 +900,35 @@
@Override
protected IStatus validate() {
- final String applicationName = (String) applicationNameObservable.getValue();
- final boolean useExistingApp = (Boolean) useExistingAppbservable.getValue();
+ final String applicationName = (String) applicationNameObservable
+ .getValue();
+ final boolean useExistingApp = (Boolean) useExistingAppbservable
+ .getValue();
if (useExistingApp) {
return ValidationStatus.ok();
}
if (applicationName.isEmpty()) {
- return ValidationStatus.cancel(
- "Select an alphanumerical name and a type for the application to
create.");
+ return ValidationStatus
+ .cancel("Select an alphanumerical name and a type for the application to
create.");
}
if (!StringUtils.isAlphaNumeric(applicationName)) {
- return ValidationStatus.error(
- "The name may only contain lower-case letters and digits.");
+ return ValidationStatus
+ .error("The name may only contain lower-case letters and digits.");
}
if (pageModel.isExistingApplication(applicationName)) {
- return ValidationStatus.error(
- "An application with the same name already exists on OpenShift.");
+ return ValidationStatus
+ .error("An application with the same name already exists on
OpenShift.");
}
if (isExistingProject(applicationName)) {
- return ValidationStatus.error(
- NLS.bind("A project {0} already exists in the workspace.",
applicationName));
+ return ValidationStatus
+ .warning("A project already exists with the same application name. This can
cause problems when importing.");
}
return ValidationStatus.ok();
}
private boolean isExistingProject(String name) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(name);
return project.exists();
}
@@ -819,7 +945,8 @@
private final IObservableValue useExistingAppBtnbservable;
private final IObservableValue selectedCartridgeObservable;
- public NewApplicationTypeValidator(IObservableValue useExistingAppBtnbservable,
+ public NewApplicationTypeValidator(
+ IObservableValue useExistingAppBtnbservable,
IObservableValue selectedCartridgeObservable) {
this.useExistingAppBtnbservable = useExistingAppBtnbservable;
this.selectedCartridgeObservable = selectedCartridgeObservable;
@@ -827,8 +954,10 @@
@Override
protected IStatus validate() {
- final boolean useExistingApp = (Boolean) useExistingAppBtnbservable.getValue();
- final String cartridge = (String) selectedCartridgeObservable.getValue();
+ final boolean useExistingApp = (Boolean) useExistingAppBtnbservable
+ .getValue();
+ final String cartridge = (String) selectedCartridgeObservable
+ .getValue();
if (useExistingApp) {
return ValidationStatus.ok();
}
@@ -846,4 +975,9 @@
return targets;
}
}
+
+ protected void setupWizardPageSupport(DataBindingContext dbc) {
+ ParametrizableWizardPageSupport.create(IStatus.ERROR | IStatus.INFO
+ | IStatus.CANCEL, this, dbc);
+ }
}