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
33f98f9e
Commit
33f98f9e
authored
13 years ago
by
David Trachtenherz
Browse files
Options
Downloads
Patches
Plain Diff
Added menu structuring
refs 451
parent
4fb00ea0
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/extension/base/ContextMenuSubMenuContributorBase.java
+51
-1
51 additions, 1 deletion
.../ui/extension/base/ContextMenuSubMenuContributorBase.java
with
51 additions
and
1 deletion
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/base/ContextMenuSubMenuContributorBase.java
+
51
−
1
View file @
33f98f9e
...
...
@@ -18,6 +18,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
package
org.fortiss.tooling.kernel.ui.extension.base
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -27,6 +28,7 @@ import org.eclipse.jface.action.Action;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.resource.ImageDescriptor
;
import
org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor
;
import
org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase.EObjectActionFactory
;
...
...
@@ -48,7 +50,7 @@ import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
* @author trachtenherz
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating
GREEN
Hash:
2564CE1D9646C694F694AB86ECF50DDD
* @ConQAT.Rating
YELLOW
Hash:
C9D77819956A4B95AC544B63F2BADF2A
*/
public
abstract
class
ContextMenuSubMenuContributorBase
<
T
extends
EObject
>
implements
IContextMenuContributor
{
...
...
@@ -82,8 +84,31 @@ public abstract class ContextMenuSubMenuContributorBase<T extends EObject>
protected
IMenuManager
createMenu
(
Collection
<
Action
>
actions
)
{
IMenuManager
menu
=
new
MenuManager
(
getMenuName
(),
getMenuIcon
(),
getMenuId
());
// Prepare menu structure hints
MenuStructureHints
[]
hints
;
if
(
getMenuStructureHints
()
!=
null
)
{
hints
=
Arrays
.
copyOf
(
getMenuStructureHints
(),
actions
.
size
());
}
else
{
hints
=
new
MenuStructureHints
[
actions
.
size
()];
Arrays
.
fill
(
hints
,
null
);
}
// Now the hints array contains all elements from
// getMenuStructureHints(). It
// also has at least as many elements as the actions collection. If
// getMenuStructureHints() has less elements (or is null),
// than all other elements of the hints array are null.
int
i
=
0
;
for
(
Action
a
:
actions
)
{
if
(
hints
[
i
]
==
MenuStructureHints
.
SEPARATOR_BEFORE
)
{
menu
.
add
(
new
Separator
());
}
menu
.
add
(
a
);
if
(
hints
[
i
]
==
MenuStructureHints
.
SEPARATOR_AFTER
)
{
menu
.
add
(
new
Separator
());
}
++
i
;
}
return
menu
;
}
...
...
@@ -107,6 +132,31 @@ public abstract class ContextMenuSubMenuContributorBase<T extends EObject>
/** Returns the action factories for the actions to be shown in the menu */
protected
abstract
Collection
<
EObjectActionFactory
<?
super
T
>>
getActionFactories
();
/**
* Constants for menu structure hints.
*
* @see ContextMenuSubMenuContributorBase#getMenuStructureHints()
*/
protected
static
enum
MenuStructureHints
{
/** Insert a separator before current menu item. */
SEPARATOR_BEFORE
,
/** Insert a separator after current menu item. */
SEPARATOR_AFTER
;
// Further future hints may be e.g.: Begin new sub-menu, End new
// sub-menu
}
/**
* Returns additional informations about the structure of the menu. If
* {@code null}, the actions are linearly shown in a menu.
*
* @see #getActionFactories()
* @see #createMenu(Collection)
*/
protected
MenuStructureHints
[]
getMenuStructureHints
()
{
return
null
;
}
/** The image for the sub-menu */
protected
ImageDescriptor
getMenuIcon
()
{
return
null
;
...
...
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