Author: rob.stryker(a)jboss.com
Date: 2011-10-20 06:57:03 -0400 (Thu, 20 Oct 2011)
New Revision: 35836
Modified:
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
Log:
Last minute cleanup for astools including runtime validation in the new openshift proj
wizard, synchronized state, second message box for forced push, etc
Modified:
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
===================================================================
---
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-10-20
10:16:20 UTC (rev 35835)
+++
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-10-20
10:57:03 UTC (rev 35836)
@@ -459,13 +459,6 @@
IteratorService.createInitialIterator(repo));
indexDiff.diff(jgitMonitor, 0, 0, NLS.bind(
UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));
- System.out.println(indexDiff.getAdded().size());
- System.out.println(indexDiff.getChanged().size());
- System.out.println(indexDiff.getConflicting().size());
- System.out.println(indexDiff.getMissing().size());
- System.out.println(indexDiff.getModified().size());
- System.out.println(indexDiff.getRemoved().size());
- System.out.println(indexDiff.getUntracked().size());
return indexDiff.getModified().size();
} catch( IOException ioe ) {
Modified:
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
---
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-10-20
10:16:20 UTC (rev 35835)
+++
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-10-20
10:57:03 UTC (rev 35836)
@@ -44,26 +44,43 @@
int state = behaviour.getServer().getModulePublishState(module);
IProject p = module[module.length-1].getProject();
int changed = EGitUtils.countCommitableChanges(p, new NullProgressMonitor() );
- if( changed != 0 && (kind == IServer.PUBLISH_FULL || state ==
IServer.PUBLISH_STATE_FULL)) {
- if( requestApproval(module)) {
+ if( changed == 0 || (kind == IServer.PUBLISH_FULL || state ==
IServer.PUBLISH_STATE_FULL)) {
+ if( changed != 0 && requestCommitAndPushApproval(module)) {
monitor.beginTask("Publishing " + p.getName(), 200);
EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
EGitUtils.push(EGitUtils.getRepository(p), new SubProgressMonitor(monitor, 100));
- return IServer.PUBLISH_STATE_NONE;
+ monitor.done();
+ } else if( changed == 0 && requestPushApproval(module)) {
+ monitor.beginTask("Publishing " + p.getName(), 100);
+ EGitUtils.push(EGitUtils.getRepository(p), new SubProgressMonitor(monitor, 100));
+ monitor.done();
}
+ return IServer.PUBLISH_STATE_NONE;
}
return IServer.PUBLISH_STATE_INCREMENTAL;
}
- private boolean requestApproval(final IModule[] module) {
+ private boolean requestCommitAndPushApproval(final IModule[] module) {
+ String projName = module[module.length-1].getProject().getName();
+ String msg = "Do you wish to publish \"" + projName + "\" to
OpenShift by commiting and pushing its git repository?";
+ String title = "Publish " + projName + "?";
+ return requestApproval(module, msg, title);
+ }
+
+ private boolean requestPushApproval(final IModule[] module) {
+ String projName = module[module.length-1].getProject().getName();
+ String msg = "Do you wish to publish \"" + projName + "\" to
OpenShift by pushing its git repository?";
+ String title = "Publish " + projName + "?";
+ return requestApproval(module, msg, title);
+ }
+
+ private boolean requestApproval(final IModule[] module, final String message, final
String title) {
final boolean[] b = new boolean[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_QUESTION | SWT.YES |
SWT.NO);
- String projName = module[module.length-1].getProject().getName();
- String msg = "Do you wish to publish \"" + projName + "\" to
OpenShift by commiting and pushing it's git repository?";
- messageBox.setMessage(msg);
- messageBox.setText("Publish " + projName + "?");
+ messageBox.setMessage(message);
+ messageBox.setText(title);
int response = messageBox.open();
if (response == SWT.YES)
b[0] = true;
Modified:
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-20
10:16:20 UTC (rev 35835)
+++
branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-20
10:57:03 UTC (rev 35836)
@@ -19,9 +19,11 @@
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -74,7 +76,7 @@
private Text gitUriValueText;
private AdapterWizardPageModel model;
- private Combo suitableRuntimes;
+ private Combo suitableRuntimesCombo;
private IServerType serverTypeToCreate;
private IRuntime runtimeDelegate;
private Label domainLabel;
@@ -83,6 +85,10 @@
private Label runtimeLabel;
private Button serverAdapterCheckbox;
+ private IObservableValue serverAdapterCheckboxObservable;
+ private IObservableValue selectedRuntimeObservable;
+ private IObservableList suitableRuntimesObservable;
+
public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
super(
"Import Project",
@@ -102,7 +108,7 @@
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(projectGroup);
- Group serverAdapterGroup = createAdapterGroup(parent);
+ Group serverAdapterGroup = createAdapterGroup(parent, dbc);
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(serverAdapterGroup);
}
@@ -266,7 +272,7 @@
};
}
- private Group createAdapterGroup(Composite parent) {
+ private Group createAdapterGroup(Composite parent, DataBindingContext dbc) {
Group serverAdapterGroup = new Group(parent, SWT.BORDER);
serverAdapterGroup.setText("JBoss Server adapter");
FillLayout fillLayout = new FillLayout();
@@ -279,7 +285,7 @@
}
protected void enableServerWidgets(boolean enabled) {
- suitableRuntimes.setEnabled(enabled);
+ suitableRuntimesCombo.setEnabled(enabled);
runtimeLabel.setEnabled(enabled);
addRuntimeLink.setEnabled(enabled);
// domainLabel.setEnabled(enabled);
@@ -291,12 +297,11 @@
c.setLayout(new FormLayout());
serverAdapterCheckbox = new Button(c, SWT.CHECK);
serverAdapterCheckbox.setText("Create a JBoss server adapter");
- final Button serverAdapterCheckbox2 = serverAdapterCheckbox;
serverAdapterCheckbox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
- serverAdapterCheckbox2.getSelection());
- enableServerWidgets(serverAdapterCheckbox2.getSelection());
+ serverAdapterCheckbox.getSelection());
+ enableServerWidgets(serverAdapterCheckbox.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
@@ -306,7 +311,7 @@
runtimeLabel = new Label(c, SWT.NONE);
runtimeLabel.setText("Local Runtime: ");
- suitableRuntimes = new Combo(c, SWT.READ_ONLY);
+ suitableRuntimesCombo = new Combo(c, SWT.READ_ONLY);
addRuntimeLink = new Link(c, SWT.NONE);
addRuntimeLink.setText("<a>" + Messages.addRuntime +
"</a>");
@@ -331,7 +336,7 @@
// appLabel = new Label(c, SWT.NONE);
modeLabel = new Label(c, SWT.NONE);
- suitableRuntimes.addModifyListener(new ModifyListener() {
+ suitableRuntimesCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateSelectedRuntimeDelegate();
}
@@ -339,28 +344,43 @@
addRuntimeLink.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IRuntimeType type = getValidRuntimeType();
- if (type != null)
- showRuntimeWizard(type);
+ if (type != null) {
+ int result = showRuntimeWizard(type);
+ if( result == Window.OK ) {
+ suitableRuntimesCombo.select(0);
+ selectedRuntimeObservable.setValue(0);
+ updateSelectedRuntimeDelegate();
+ }
+ }
}
});
serverAdapterCheckbox.setLayoutData(UIUtil.createFormData2(0, 5, null, 0, 0, 5, null,
0));
runtimeLabel.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, 0,
5, null, 0));
addRuntimeLink.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0,
null, 0, 100, -5));
- suitableRuntimes.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null,
0, runtimeLabel, 5,
+ suitableRuntimesCombo.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5,
null, 0, runtimeLabel, 5,
addRuntimeLink, -5));
- domainLabel.setLayoutData(UIUtil.createFormData2(suitableRuntimes, 5, null, 0, 0, 5,
100, 0));
+ domainLabel.setLayoutData(UIUtil.createFormData2(suitableRuntimesCombo, 5, null, 0, 0,
5, 100, 0));
// appLabel.setLayoutData(UIUtil.createFormData2(domainLabel, 5, null,
// 0, 0, 5, 100, 0));
modeLabel.setLayoutData(UIUtil.createFormData2(domainLabel, 5, null, 0, 0, 5, 100,
0));
- serverAdapterCheckbox.setSelection(true);
model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
- serverAdapterCheckbox2.getSelection());
+ serverAdapterCheckbox.getSelection());
+
+ this.selectedRuntimeObservable =
+ WidgetProperties.singleSelectionIndex().observe(suitableRuntimesCombo);
+ this.suitableRuntimesObservable =
+ WidgetProperties.items().observe(suitableRuntimesCombo);
+ this.serverAdapterCheckboxObservable =
+ WidgetProperties.selection().observe(serverAdapterCheckbox);
+
+ dbc.addValidationStatusProvider(new SelectedRuntimeValidator());
}
private void updateSelectedRuntimeDelegate() {
- if (suitableRuntimes.getSelectionIndex() != -1) {
- runtimeDelegate =
ServerCore.findRuntime(suitableRuntimes.getItem(suitableRuntimes.getSelectionIndex()));
+ if (suitableRuntimesCombo.getSelectionIndex() != -1) {
+ runtimeDelegate =
ServerCore.findRuntime(suitableRuntimesCombo.getItem(suitableRuntimesCombo
+ .getSelectionIndex()));
} else {
runtimeDelegate = null;
}
@@ -397,6 +417,7 @@
String[] names = new String[runtimes.length];
for (int i = 0; i < runtimes.length; i++) {
names[i] = runtimes[i].getName();
+ suitableRuntimesObservable.add(runtimes[i].getName());
}
combo.setItems(names);
}
@@ -407,8 +428,9 @@
serverTypeToCreate = getServerTypeToCreate();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE,
serverTypeToCreate);
refreshValidRuntimes();
- if (suitableRuntimes.getItemCount() > 0) {
- suitableRuntimes.select(0);
+ if (suitableRuntimesCombo.getItemCount() > 0) {
+ suitableRuntimesCombo.select(0);
+ selectedRuntimeObservable.setValue(0);
updateSelectedRuntimeDelegate();
}
IRuntimeType type = getValidRuntimeType();
@@ -439,9 +461,9 @@
IRuntimeType type = getValidRuntimeType();
if (type != null) {
IRuntime[] runtimes = getRuntimesOfType(type.getId());
- fillRuntimeCombo(suitableRuntimes, runtimes);
+ fillRuntimeCombo(suitableRuntimesCombo, runtimes);
} else {
- suitableRuntimes.setItems(new String[0]);
+ suitableRuntimesCombo.setItems(new String[0]);
}
}
@@ -473,8 +495,8 @@
refreshValidRuntimes();
if (returnValue != Window.CANCEL) {
IRuntime rt = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
- if (rt != null && rt.getName() != null &&
suitableRuntimes.indexOf(rt.getName()) != -1) {
- suitableRuntimes.select(suitableRuntimes.indexOf(rt.getName()));
+ if (rt != null && rt.getName() != null &&
suitableRuntimesCombo.indexOf(rt.getName()) != -1) {
+ suitableRuntimesCombo.select(suitableRuntimesCombo.indexOf(rt.getName()));
}
}
return returnValue;
@@ -493,11 +515,34 @@
serverTypeToCreate = getServerTypeToCreate();
boolean canCreateServer = serverTypeToCreate != null;
serverAdapterCheckbox.setEnabled(canCreateServer);
- serverAdapterCheckbox.setSelection(canCreateServer);
+ // serverAdapterCheckbox.setSelection(canCreateServer);
+ serverAdapterCheckboxObservable.setValue(true);
enableServerWidgets(canCreateServer);
refreshValidRuntimes();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE,
serverTypeToCreate);
model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
canCreateServer);
}
+ private class SelectedRuntimeValidator extends MultiValidator {
+
+ @Override
+ protected IStatus validate() {
+ /**
+ * WARNING: it is important to evaluate the validation state on
+ * behalf of observable values (not widgets!). The multi validator
+ * is tracking what observables are read to know when he has to
+ * recalculate it's state.
+ */
+ if (Boolean.FALSE.equals(serverAdapterCheckboxObservable.getValue())) {
+ return ValidationStatus.ok();
+ }
+ if (new Integer(-1).equals(selectedRuntimeObservable.getValue())) {
+ if (suitableRuntimesObservable.size() == 0) {
+ return ValidationStatus.error("Please add a new valid runtime.");
+ }
+ return ValidationStatus.error("Please select a runtime");
+ }
+ return ValidationStatus.ok();
+ }
+ }
}