diff options
author | kwilk | 2011-04-18 20:52:20 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-04-18 20:52:20 +0000 |
commit | f64075fab6a3ce69694ab2664712106c6ac7caa5 (patch) | |
tree | 5c8789e9740196996bc00d6d60ce3a18c9040fe4 | |
parent | 870a4d560f09e2667044fc3f28ee8fea5a88df39 (diff) | |
download | org.eclipse.osee-f64075fab6a3ce69694ab2664712106c6ac7caa5.tar.gz org.eclipse.osee-f64075fab6a3ce69694ab2664712106c6ac7caa5.tar.xz org.eclipse.osee-f64075fab6a3ce69694ab2664712106c6ac7caa5.zip |
bug: ArtifactExplorerDragAndDrop import on correct selected item
4 files changed, 77 insertions, 47 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Wizards.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Wizards.java index b122885d080..1a6ba100046 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Wizards.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Wizards.java @@ -23,11 +23,16 @@ import org.eclipse.ui.IWorkbenchWizard; * @author Robert A. Fisher */ public final class Wizards { + public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart) { - initAndOpen(wizard, viewPart.getViewSite().getWorkbenchWindow()); + initAndOpen(wizard, viewPart, viewPart.getViewSite().getWorkbenchWindow()); + } + + public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart, IStructuredSelection selection) { + initAndOpen(wizard, viewPart.getViewSite().getWorkbenchWindow(), selection); } - public static final void initAndOpen(IWorkbenchWizard wizard, IWorkbenchWindow workbenchWindow) { + public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart, IWorkbenchWindow workbenchWindow) { IStructuredSelection selectionToPass; // get the current workbench selection @@ -38,11 +43,18 @@ public final class Wizards { selectionToPass = StructuredSelection.EMPTY; } - wizard.init(workbenchWindow.getWorkbench(), selectionToPass); + initAndOpen(wizard, viewPart.getViewSite().getWorkbenchWindow(), selectionToPass); + + } + + public static final void initAndOpen(IWorkbenchWizard wizard, IWorkbenchWindow workbenchWindow, IStructuredSelection selection) { + + wizard.init(workbenchWindow.getWorkbench(), selection); Shell parent = workbenchWindow.getShell(); WizardDialog dialog = new WizardDialog(parent, wizard); dialog.create(); dialog.open(); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java index 98ff1a3e9c7..ea8d2a03a51 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java @@ -1496,43 +1496,4 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent } return null; } - - public static final class ArtifactStructuredSelection implements IStructuredSelection { - - private final List<Artifact> selectedItems; - - public ArtifactStructuredSelection(List<Artifact> selectedItems) { - this.selectedItems = selectedItems; - } - - @Override - public boolean isEmpty() { - return selectedItems.isEmpty(); - } - - @Override - public Artifact getFirstElement() { - return isEmpty() ? null : selectedItems.get(0); - } - - @Override - public Iterator<Artifact> iterator() { - return selectedItems.iterator(); - } - - @Override - public int size() { - return selectedItems.size(); - } - - @Override - public Object[] toArray() { - return selectedItems.toArray(); - } - - @Override - public List<Artifact> toList() { - return selectedItems; - } - } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java index a858ab77a50..7f9f38b3d64 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java @@ -30,7 +30,6 @@ import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IViewPart; /** @@ -103,10 +102,8 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop { } private Artifact getSelectedArtifact(DropTargetEvent event) { - TreeItem selected = treeViewer.getTree().getItem(treeViewer.getTree().toControl(event.x, event.y)); - - if (selected != null && selected.getData() instanceof Artifact) { - return (Artifact) selected.getData(); + if (event.item != null && event.item.getData() instanceof Artifact) { + return (Artifact) event.item.getData(); } return null; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactStructuredSelection.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactStructuredSelection.java new file mode 100644 index 00000000000..451af471a2f --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactStructuredSelection.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2011 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.skynet; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; + +public final class ArtifactStructuredSelection implements IStructuredSelection { + + private final List<Artifact> selectedItems; + + public ArtifactStructuredSelection(Artifact... selectedItems) { + this(Arrays.asList(selectedItems)); + } + + public ArtifactStructuredSelection(List<Artifact> selectedItems) { + this.selectedItems = selectedItems; + } + + @Override + public boolean isEmpty() { + return selectedItems.isEmpty(); + } + + @Override + public Artifact getFirstElement() { + return isEmpty() ? null : selectedItems.iterator().next(); + } + + @Override + public Iterator<Artifact> iterator() { + return selectedItems.iterator(); + } + + @Override + public int size() { + return selectedItems.size(); + } + + @Override + public Object[] toArray() { + return selectedItems.toArray(); + } + + @Override + public List<Artifact> toList() { + return selectedItems; + } +} |