001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.printing.ui.internal.editor;
018:
019: import net.refractions.udig.printing.ui.internal.PrintingPlugin;
020:
021: import org.eclipse.gef.ContextMenuProvider;
022: import org.eclipse.gef.EditPartViewer;
023: import org.eclipse.gef.ui.actions.ActionRegistry;
024: import org.eclipse.gef.ui.actions.GEFActionConstants;
025: import org.eclipse.jface.action.IAction;
026: import org.eclipse.jface.action.IMenuManager;
027: import org.eclipse.ui.actions.ActionFactory;
028:
029: /**
030: * Provides ...TODO summary sentence
031: * <p>
032: * TODO Description
033: * </p><p>
034: * Responsibilities:
035: * <ul>
036: * <li>
037: * <li>
038: * </ul>
039: * </p><p>
040: * Example Use:<pre><code>
041: * PageContextMenuProvider x = new PageContextMenuProvider( ... );
042: * TODO code example
043: * </code></pre>
044: * </p>
045: * @author Richard Gould
046: * @since 0.3
047: */
048: public class PageContextMenuProvider extends ContextMenuProvider {
049:
050: private ActionRegistry registry;
051:
052: /**
053: * Construct <code>PageContextMenuProvider</code>.
054: *
055: * @param viewer
056: */
057: public PageContextMenuProvider(EditPartViewer viewer,
058: ActionRegistry registry) {
059: super (viewer);
060: setActionRegistry(registry);
061: }
062:
063: /**
064: * TODO summary sentence for buildContextMenu ...
065: *
066: * @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
067: * @param manager
068: */
069: @SuppressWarnings("unchecked")
070: public void buildContextMenu(IMenuManager manager) {
071: GEFActionConstants.addStandardActionGroups(manager);
072:
073: IAction action = getActionRegistry().getAction(
074: ActionFactory.UNDO.getId());
075: manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
076:
077: action = getActionRegistry().getAction(
078: ActionFactory.REDO.getId());
079: manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
080:
081: for (BoxAction boxAction : PrintingPlugin
082: .getBoxExtensionActions(null)) {
083: if (boxAction.isEnabled())
084: manager.appendToGroup(GEFActionConstants.GROUP_EDIT,
085: boxAction);
086: }
087: //
088: // DirectEditAction action2 = (DirectEditAction) getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT);
089: // action2.getText();
090: // if (action2.isEnabled())
091: // manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action2);
092: //
093: // action = getActionRegistry().getAction(EditMapAction.EDIT_MAP);
094: // if (action.isEnabled())
095: // manager.appendToGroup(, action);
096: //
097: action = getActionRegistry().getAction(
098: ActionFactory.DELETE.getId());
099: if (action.isEnabled())
100: manager
101: .appendToGroup(GEFActionConstants.GROUP_EDIT,
102: action);
103:
104: // Alignment Actions
105: /* MenuManager submenu = new MenuManager("Alignment Thing");
106:
107: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT);
108: if (action.isEnabled())
109: submenu.add(action);
110:
111: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER);
112: if (action.isEnabled())
113: submenu.add(action);
114:
115: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT);
116: if (action.isEnabled())
117: submenu.add(action);
118:
119: submenu.add(new Separator());
120:
121: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP);
122: if (action.isEnabled())
123: submenu.add(action);
124:
125: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE);
126: if (action.isEnabled())
127: submenu.add(action);
128:
129: action = getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM);
130: if (action.isEnabled())
131: submenu.add(action);
132:
133: if (!submenu.isEmpty())
134: manager.appendToGroup(GEFActionConstants.GROUP_REST, submenu);
135: */
136: }
137:
138: private ActionRegistry getActionRegistry() {
139: return registry;
140: }
141:
142: private void setActionRegistry(ActionRegistry registry) {
143: this.registry = registry;
144: }
145: }
|