Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
30e01e13
Commit
30e01e13
authored
10 years ago
by
Simon Barner
Browse files
Options
Downloads
Patches
Plain Diff
- Ensure that selection of NavigatorViewPart is never empty in order to work around #1491
refs 1491
parent
e6b78348
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java
+27
-0
27 additions, 0 deletions
...s/tooling/kernel/ui/internal/views/NavigatorViewPart.java
with
27 additions
and
0 deletions
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java
+
27
−
0
View file @
30e01e13
...
...
@@ -37,6 +37,8 @@ import org.eclipse.jface.viewers.ISelection;
import
org.eclipse.jface.viewers.ISelectionChangedListener
;
import
org.eclipse.jface.viewers.SelectionChangedEvent
;
import
org.eclipse.jface.viewers.StructuredSelection
;
import
org.eclipse.jface.viewers.TreePath
;
import
org.eclipse.jface.viewers.TreeSelection
;
import
org.eclipse.jface.viewers.TreeViewer
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
...
...
@@ -104,6 +106,9 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
/** Dialog setting ID for the link with editor action flag. */
private
static
final
String
LINK_WITH_EDITOR_FLAG
=
"navigatorSettingLinkWithEditor"
;
/** Element used to ensure that the selection of the {@link NavigatorViewPart} is not empty. */
private
EObject
backupElementToBeSelected
;
/** Stores the UI update job. */
private
final
UIJob
updateUI
=
new
UIJob
(
"Update Model Navigator"
)
{
@Override
...
...
@@ -114,6 +119,28 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
IActionService
.
INSTANCE
.
refresh
();
viewer
.
refresh
();
// Ensure that the selection of the {@link NavigatorViewPart} is not empty. Otherwise
// undo/redo (and also other global commands) is not enabled when model elements are
// added directly using the context menu of the model navigator.
ISelection
selection
=
viewer
.
getSelection
();
if
(
selection
instanceof
TreeSelection
&&
!
selection
.
isEmpty
())
{
Object
firstSelectedElement
=
((
TreeSelection
)
selection
).
getFirstElement
();
if
(
firstSelectedElement
instanceof
EObject
)
{
// Preserve container of current element. This is required to determine a valid
// model element in case the next operation is to delete the currently selected
// element
backupElementToBeSelected
=
((
EObject
)
firstSelectedElement
).
eContainer
();
}
}
else
if
(
backupElementToBeSelected
!=
null
)
{
// Selection would be empty. Use backup element to force selection to the container
// of the element that has been selected last.
viewer
.
setSelection
(
new
TreeSelection
(
new
TreePath
(
new
Object
[]
{
backupElementToBeSelected
})));
backupElementToBeSelected
=
null
;
}
firePropertyChange
(
IWorkbenchPartConstants
.
PROP_DIRTY
);
return
Status
.
OK_STATUS
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment