forked from eclipse-vorto/vorto
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open a shared model in the editor when it is clicked from the model r…
…epository browser. Closes eclipse-vorto#91 Signed-off-by: Erle Czar Mantos <[email protected]>
- Loading branch information
Erle Czar Mantos
committed
Apr 13, 2016
1 parent
5fdaffc
commit ac4dca9
Showing
2 changed files
with
150 additions
and
37 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...es/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/util/ViewPartUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.eclipse.vorto.perspective.util; | ||
|
||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.jface.viewers.SelectionChangedEvent; | ||
|
||
public class ViewPartUtil { | ||
|
||
public static Object getFirstSelectedObject(final Class<?> selectionClass, SelectionChangedEvent event) { | ||
if (event.getSelection().isEmpty()) { | ||
return null; | ||
} | ||
|
||
if (event.getSelection() instanceof IStructuredSelection) { | ||
IStructuredSelection selection = (IStructuredSelection) event.getSelection(); | ||
if (selection.size() > 0) { | ||
if (selectionClass.isInstance(selection.getFirstElement())) { | ||
return selection.getFirstElement(); | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters