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
c65c5500
Commit
c65c5500
authored
13 years ago
by
Dongyue Mou
Browse files
Options
Downloads
Patches
Plain Diff
fixed random testing
refs 283
parent
f21097f3
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.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java
+107
-0
107 additions, 0 deletions
.../fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java
with
107 additions
and
0 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java
0 → 100644
+
107
−
0
View file @
c65c5500
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package
org.fortiss.tooling.base.ui.editor
;
import
java.util.Collection
;
import
java.util.List
;
import
org.eclipse.emf.common.notify.Adapter
;
import
org.eclipse.emf.common.notify.Notification
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.ecore.util.EContentAdapter
;
import
org.eclipse.jface.viewers.TreeViewer
;
import
org.eclipse.swt.widgets.Composite
;
import
org.fortiss.tooling.base.ui.dnd.jface.ViewerElementCompositionDropAdapter
;
import
org.fortiss.tooling.kernel.ui.extension.base.EditorBase
;
import
org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils
;
/**
* An editor which only consists of a tree viewer. It uses {@link TreeViewer},
* which also allows to define columns, i.e., use the tree and table at the same
* time.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 532479EDC4922A50828399F6761787F3
*/
public
abstract
class
TreeViewerEditorBase
<
T
extends
EObject
>
extends
EditorBase
<
T
>
{
/** Stores the {@link TreeViewer}. */
private
TreeViewer
treeViewer
;
/** The adapter used for dealing with changes of the */
private
final
Adapter
editedObjectChanged
=
new
EContentAdapter
()
{
@Override
public
void
notifyChanged
(
Notification
notification
)
{
super
.
notifyChanged
(
notification
);
if
(
notification
.
getEventType
()
!=
Notification
.
REMOVING_ADAPTER
&&
!
treeViewer
.
getTree
().
isDisposed
())
{
treeViewer
.
refresh
(
true
);
}
}
};
/** {@inheritDoc} */
@Override
public
void
createPartControl
(
Composite
parent
)
{
treeViewer
=
new
TreeViewer
(
parent
);
setupTreeViewer
(
treeViewer
);
ViewerElementCompositionDropAdapter
dndAdapter
=
new
ViewerElementCompositionDropAdapter
(
treeViewer
);
treeViewer
.
addDropSupport
(
dndAdapter
.
getSupportedDNDOperations
(),
dndAdapter
.
getPreferredTransfers
(),
dndAdapter
);
treeViewer
.
setInput
(
editedObject
);
getEditorSite
().
setSelectionProvider
(
treeViewer
);
editedObject
.
eAdapters
().
add
(
editedObjectChanged
);
}
/** {@inheritDoc} */
@Override
public
void
dispose
()
{
editedObject
.
eAdapters
().
remove
(
editedObjectChanged
);
super
.
dispose
();
}
/** Returns the elements currently selected in the tree. */
protected
Collection
<
EObject
>
getTreeSelection
()
{
List
<
EObject
>
result
=
EObjectSelectionUtils
.
getEObjectElements
(
treeViewer
.
getSelection
());
if
(
result
.
isEmpty
())
{
result
.
add
(
editedObject
);
}
return
result
;
}
/**
* This method is used to configure the tree viewer, e.g. set the content
* provider, and the label provider.
*/
protected
abstract
void
setupTreeViewer
(
TreeViewer
treeViewer
);
/** {@inheritDoc} */
@Override
public
void
setFocus
()
{
treeViewer
.
getTree
().
setFocus
();
}
}
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