summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Johnson2014-03-20 11:40:42 (EDT)
committerDaniel Johnson2014-03-20 11:40:42 (EDT)
commit1b6452d9042cc7e142236e6989f00cb83509b7f2 (patch)
tree9a95ece763e761fef5adb0dcbcb46bc462c30da4
parentbdb1dfe08063e5e35feb055872acabfe0533a385 (diff)
downloadorg.eclipse.tigerstripe-1b6452d9042cc7e142236e6989f00cb83509b7f2.zip
org.eclipse.tigerstripe-1b6452d9042cc7e142236e6989f00cb83509b7f2.tar.gz
org.eclipse.tigerstripe-1b6452d9042cc7e142236e6989f00cb83509b7f2.tar.bz2
Fix add dependency to not add duplicates.
-rw-r--r--plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/TigerstripeProjectSelectionDialog.java4
-rw-r--r--plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/descriptor/dependencies/ReferencedProjectsSection.java31
2 files changed, 19 insertions, 16 deletions
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/TigerstripeProjectSelectionDialog.java b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/TigerstripeProjectSelectionDialog.java
index 0303eda..b64f380 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/TigerstripeProjectSelectionDialog.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/TigerstripeProjectSelectionDialog.java
@@ -337,7 +337,7 @@ public class TigerstripeProjectSelectionDialog extends SelectionStatusDialog {
KIND_RESOLVER));
fTableViewer.getControl().setFont(font);
- Button checkbox = new Button(composite, SWT.CHECK);
+ final Button checkbox = new Button(composite, SWT.CHECK);
checkbox.setText("Add Transitive dependencies");
checkbox.setSelection(isIncludeTransitiveDependencies());
checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true,
@@ -345,7 +345,7 @@ public class TigerstripeProjectSelectionDialog extends SelectionStatusDialog {
checkbox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- setIncludeTransitiveDependencies(true);
+ setIncludeTransitiveDependencies(checkbox.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/descriptor/dependencies/ReferencedProjectsSection.java b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/descriptor/dependencies/ReferencedProjectsSection.java
index 049a2f4..a02b496 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/descriptor/dependencies/ReferencedProjectsSection.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/descriptor/dependencies/ReferencedProjectsSection.java
@@ -608,7 +608,7 @@ public class ReferencedProjectsSection extends TigerstripeDescriptorSectionPart
viewer.setChecked(ref, true); // NM: Check newly added dependency
markPageModified();
if (dialog.isIncludeTransitiveDependencies()){
- addMissingTransitiveDependencies( new ModelReference[]{ref});
+ addMissingTransitiveDependencies(new ModelReference[] { ref });
}
} catch (TigerstripeException e) {
EclipsePlugin.log(e);
@@ -646,8 +646,8 @@ public class ReferencedProjectsSection extends TigerstripeDescriptorSectionPart
//Add the ones found, and highlight any not found in a dialog.
try {
- ModelReference[] existingReferences = getTSProject().getModelReferences();
- addMissingTransitiveDependencies(existingReferences);
+ ModelReference[] references = getTSProject().getModelReferences();
+ addMissingTransitiveDependencies(references);
} catch (TigerstripeException e) {
EclipsePlugin.log(e);
}
@@ -655,24 +655,27 @@ public class ReferencedProjectsSection extends TigerstripeDescriptorSectionPart
}
- protected void addMissingTransitiveDependencies(ModelReference[] existingReferences){
+ protected void addMissingTransitiveDependencies(ModelReference[] references){
try {
+ Set<String> existingModels = new HashSet<String>();
+ ModelReference[] existingReferences = getTSProject().getModelReferences();
+ for (ModelReference ref : existingReferences) {
+ existingModels.add(ref.getToModelId());
+ }
+
List<ModelReference> newRefs = new ArrayList<ModelReference>();
- Set<String> existingModels = new HashSet<String>();
- for (ModelReference ref : existingReferences) {
- newRefs.addAll(getTransitiveRefs(ref));
- existingModels.add(ref.getToModelId());
+ for (ModelReference ref : references) {
+ newRefs.addAll(getTransitiveRefs(ref));
}
// deDuplicate
Set<String> referencedModels = new HashSet<String>();
- for (ModelReference ref : newRefs) {
- if (! existingModels.contains(ref.getToModelId())){
- referencedModels.add(ref.getToModelId());
- }
- }
-
+ for (ModelReference ref : newRefs) {
+ if (!existingModels.contains(ref.getToModelId())) {
+ referencedModels.add(ref.getToModelId());
+ }
+ }
// set on the model...
for (String ref : referencedModels) {