Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Faltermeier2017-11-15 15:19:37 +0000
committerJohannes Faltermeier2017-11-15 15:27:01 +0000
commit32f6ef7e30cc622ad304584571644cb7d5cbff13 (patch)
tree29fd83ee79bce5995a5c0f579c6d21f3ad8033a4
parentca4d1f8541bccf39e731ed18291dbbe6163fdbf0 (diff)
downloadorg.eclipse.emf.edapt-32f6ef7e30cc622ad304584571644cb7d5cbff13.tar.gz
org.eclipse.emf.edapt-32f6ef7e30cc622ad304584571644cb7d5cbff13.tar.xz
org.eclipse.emf.edapt-32f6ef7e30cc622ad304584571644cb7d5cbff13.zip
Bug 527241 - Improve Release Dialog
* pretick update buttons if package was changed Change-Id: I1c9e609a471f37620bed3f69c22761d8e699e4e0 Signed-off-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
-rw-r--r--plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseHandler.java40
-rw-r--r--plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizard.java8
-rw-r--r--plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizardPage.java17
3 files changed, 58 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseHandler.java
index e04bf93..2f86abb 100644
--- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseHandler.java
+++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseHandler.java
@@ -12,13 +12,17 @@
package org.eclipse.emf.edapt.history.instantiation.ui;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.presentation.EcoreEditor;
import org.eclipse.emf.edapt.history.instantiation.ReleaseCommand;
@@ -28,8 +32,12 @@ import org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor;
import org.eclipse.emf.edapt.history.recorder.EditingDomainListener;
import org.eclipse.emf.edapt.internal.common.LoggingUtils;
import org.eclipse.emf.edapt.internal.common.MetamodelExtent;
+import org.eclipse.emf.edapt.spi.history.Change;
+import org.eclipse.emf.edapt.spi.history.CompositeChange;
+import org.eclipse.emf.edapt.spi.history.ContentChange;
import org.eclipse.emf.edapt.spi.history.History;
import org.eclipse.emf.edapt.spi.history.Release;
+import org.eclipse.emf.edapt.spi.history.ValueChange;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -75,7 +83,8 @@ public class ReleaseHandler extends EditingDomainListenerHandlerBase {
if (!isNsURIChanged(extent, listener.getHistory().getLastRelease())) {
final History history = listener.getHistory();
final List<EPackage> rootPackages = history.getRootPackages();
- final ReleaseWizard releaseWizard = new ReleaseWizard(rootPackages);
+ final Set<EPackage> changedPackages = getChangedPackages(history.getLastRelease());
+ final ReleaseWizard releaseWizard = new ReleaseWizard(rootPackages, changedPackages);
final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), releaseWizard);
if (dialog.open() == Window.OK) {
for (final EPackage ePackage : rootPackages) {
@@ -104,6 +113,35 @@ public class ReleaseHandler extends EditingDomainListenerHandlerBase {
}
}
+ private Set<EPackage> getChangedPackages(Release lastRelease) {
+ final Set<EPackage> packages = new LinkedHashSet<EPackage>();
+ if (lastRelease == null) {
+ return packages;
+ }
+ final List<Change> changes = lastRelease.getChanges();
+ collectPackagesFromChanges(packages, changes);
+ return packages;
+ }
+
+ private void collectPackagesFromChanges(final Set<EPackage> packages, final List<Change> changes) {
+ for (final Change change : changes) {
+ EObject target = null;
+ if (ContentChange.class.isInstance(change)) {
+ target = ContentChange.class.cast(change).getTarget();
+ } else if (ValueChange.class.isInstance(change)) {
+ target = ValueChange.class.cast(change).getElement();
+ }
+ if (target != null && EPackage.class.isInstance(target.eContainer())) {
+ packages.add((EPackage) target.eContainer());
+ }
+ if (CompositeChange.class.isInstance(change)) {
+ final List<Change> childChanges = new ArrayList<Change>(
+ CompositeChange.class.cast(change).getChanges());
+ collectPackagesFromChanges(packages, childChanges);
+ }
+ }
+ }
+
/** Update the namespace URI. */
private void updateNamespaceURI(EditingDomain domain,
List<EPackage> rootPackages, String source, String target) {
diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizard.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizard.java
index aaed1a0..1427da6 100644
--- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizard.java
+++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizard.java
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.jface.wizard.Wizard;
@@ -32,14 +33,16 @@ public class ReleaseWizard extends Wizard {
private final Map<EPackage, String> targetMap = new LinkedHashMap<EPackage, String>();
private final List<EPackage> rootPackages;
+ private final Set<EPackage> changedPackages;
private ReleaseWizardPage releaseWizardPage;
- public ReleaseWizard(List<EPackage> rootPackages) {
+ public ReleaseWizard(List<EPackage> rootPackages, Set<EPackage> changedPackages) {
if (rootPackages == null || rootPackages.isEmpty()) {
throw new IllegalArgumentException("There must be at least one root package."); //$NON-NLS-1$
}
this.rootPackages = rootPackages;
+ this.changedPackages = changedPackages;
}
@Override
@@ -53,7 +56,8 @@ public class ReleaseWizard extends Wizard {
releaseWizardPage = new ReleaseWizardPage("Update namespace URI of package(s)", //$NON-NLS-1$
"Enter the label(s) to replace and the target label or deselect the update button", //$NON-NLS-1$
null,
- sources);
+ sources,
+ changedPackages);
addPage(releaseWizardPage);
}
diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizardPage.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizardPage.java
index 5d9a3ac..53005fd 100644
--- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizardPage.java
+++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/ReleaseWizardPage.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.edapt.history.instantiation.ui;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.jface.layout.GridDataFactory;
@@ -48,6 +49,7 @@ public class ReleaseWizardPage extends WizardPage {
private final Map<EPackage, Button> packageToUpdateButton = new LinkedHashMap<EPackage, Button>();
private final List<EPackage> packages;
+ private final Set<EPackage> changedPackages;
/**
* Constructs a new {@link ReleaseWizardPage}.
@@ -56,15 +58,17 @@ public class ReleaseWizardPage extends WizardPage {
* @param description
* @param titleImage
* @param packages the packages
+ * @param changedPackages the changed packages
*/
protected ReleaseWizardPage(String pageName, String description, ImageDescriptor titleImage,
- List<EPackage> packages) {
+ List<EPackage> packages, Set<EPackage> changedPackages) {
super(pageName, pageName, titleImage);
setDescription(description);
this.packages = packages;
for (final EPackage ePackage : packages) {
packageToInferedSource.put(ePackage, inferSource(ePackage));
}
+ this.changedPackages = changedPackages;
}
/** Infer the label to be replaced from the package. */
@@ -126,8 +130,9 @@ public class ReleaseWizardPage extends WizardPage {
final Button updateButton = new Button(composite, SWT.CHECK);
updateButton.setToolTipText("Whether to update the NS-URI at all."); //$NON-NLS-1$
packageToUpdateButton.put(ePackage, updateButton);
- updateButton.setSelection(true);
+ updateButton.setSelection(changedPackages.contains(ePackage));
initUpdateButton(updateButton, ePackage);
+ setTextEnablement(updateButton, ePackage);
}
@@ -175,13 +180,17 @@ public class ReleaseWizardPage extends WizardPage {
updateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- packageToSourceText.get(ePackage).setEnabled(updateButton.getSelection());
- packageToTargetText.get(ePackage).setEnabled(updateButton.getSelection());
+ setTextEnablement(updateButton, ePackage);
checkIfPageComplete();
}
});
}
+ private void setTextEnablement(final Button updateButton, final EPackage ePackage) {
+ packageToSourceText.get(ePackage).setEnabled(updateButton.getSelection());
+ packageToTargetText.get(ePackage).setEnabled(updateButton.getSelection());
+ }
+
private void checkIfPageComplete() {
for (int i = 0; i < packages.size(); i++) {
final EPackage ePackage = packages.get(i);

Back to the top