Author: dazarov
Date: 2008-06-30 05:47:12 -0400 (Mon, 30 Jun 2008)
New Revision: 9009
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesMultiPageContributor.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/plugin.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-2352
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/plugin.xml 2008-06-28 18:47:17 UTC
(rev 9008)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/plugin.xml 2008-06-30 09:47:12 UTC
(rev 9009)
@@ -5,7 +5,7 @@
<extension id="e" name="XML Editors"
point="org.jboss.tools.common.model.ui.xmlEditor">
<xmlEditor
class="org.jboss.tools.seam.ui.pages.editor.SeamPagesEditor"
-
contributorClass="org.jboss.tools.common.model.ui.texteditors.MultiPageContributor"
+
contributorClass="org.jboss.tools.seam.ui.pages.editor.PagesMultiPageContributor"
entities="FileSeamPages12,FileSeamPages20"
icon="images/xstudio/editors/seam-pages.gif"
name="Seam Pages">
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesMultiPageContributor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesMultiPageContributor.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesMultiPageContributor.java 2008-06-30
09:47:12 UTC (rev 9009)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor;
+
+import java.util.Iterator;
+import org.jboss.tools.common.model.ui.texteditors.AbstractMultiPageContributor;
+import org.jboss.tools.common.text.xml.xpl.ToggleOccurencesMarkUpAction;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
+import org.jboss.tools.common.gef.action.ActionRegistrySupport;
+
+/**
+ * @author Jeremy
+ */
+public class PagesMultiPageContributor extends AbstractMultiPageContributor {
+ protected FakeTextEditor fakeTextEditor = new FakeTextEditor();
+ ActionRegistrySupport registrySupport = new ActionRegistrySupport();
+
+ public PagesMultiPageContributor() {
+ fToggleOccurencesMarkUp = new ToggleOccurencesMarkUpAction();
+ }
+
+ public void dispose() {
+ registrySupport.dispose();
+ super.dispose();
+ }
+
+ public void init(IActionBars bars) {
+ if(registrySupport != null) registrySupport.dispose();
+ registrySupport = new ActionRegistrySupport();
+ registrySupport.setPage(getPage());
+ super.init(bars);
+ registrySupport.buildGEFActions();
+ //registrySupport.addRetargetAction(new CutRetargetAction());
+ registrySupport.declareGlobalActionKeys();
+ registrySupport.contributeGEFToToolBar(bars.getToolBarManager());
+ initEditMenu(bars);
+ }
+
+ public void setActivePage(IEditorPart part) {
+ cleanStatusLine();
+ fActiveEditorPart = part;
+ IActionBars actionBars = getActionBars();
+ if (actionBars != null) {
+
+ ActionRegistry registry = null;
+ if(fActiveEditorPart instanceof SeamPagesGuiEditor)
+ registry = (ActionRegistry)part.getAdapter(ActionRegistry.class);
+ Iterator<String> globalActionKeys = registrySupport.getGlobalActionKeys();
+ while(globalActionKeys.hasNext()) {
+ String id = (String)globalActionKeys.next();
+ actionBars.setGlobalActionHandler(id, (registry == null ? null :
registry.getAction(id)));
+ }
+ IToolBarManager tbm = actionBars.getToolBarManager();
+ IContributionItem [] items = tbm.getItems();
+ if(items != null){
+ for(int i = 0; i < items.length; i++){
+ String id = items[i].getId();
+ if(id == null) continue; //Separator
+ actionBars.setGlobalActionHandler(id, (registry==null ?
null:registry.getAction(id)));
+ }
+ }
+
+ ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
+
+ if (editor!=null) {
+
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), (registry != null) ?
registry.getAction(ActionFactory.DELETE.getId()) : (editor != null) ? getAction(editor,
ActionFactory.DELETE.getId()) : null);
+ actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor,
ActionFactory.UNDO.getId()));
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor,
ActionFactory.REDO.getId()));
+ actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), (registry != null) ?
registry.getAction(ActionFactory.CUT.getId()) : (editor != null) ? getAction(editor,
ActionFactory.CUT.getId()) : null);
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), (registry != null) ?
registry.getAction(ActionFactory.COPY.getId()) : (editor != null) ? getAction(editor,
ActionFactory.COPY.getId()) : null);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), (registry != null) ?
registry.getAction(ActionFactory.PASTE.getId()) : (editor != null) ? getAction(editor,
ActionFactory.PASTE.getId()) : null);
+ actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor,
ActionFactory.SELECT_ALL.getId()));
+ actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor,
ActionFactory.FIND.getId()));
+ actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(),
getAction(editor, IDEActionFactory.BOOKMARK.getId()));
+ actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(),
getAction(editor, IDEActionFactory.ADD_TASK.getId()));
+ actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), (registry != null) ?
registry.getAction("Print_Diagram") : (editor != null) ? getAction(editor,
ActionFactory.PRINT.getId()) : null);
+ actionBars.setGlobalActionHandler(ActionFactory.REVERT.getId(), getAction(editor,
ActionFactory.REVERT.getId()));
+ actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), getAction(editor,
ActionFactory.SAVE.getId()));
+ actionBars.setGlobalActionHandler(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS,
getAction(editor,
StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS));
+ } else {
+ actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null);
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null);
+ }
+ // re-register action on key binding service
+ IEditorPart localPart = (part!=null)?part:mainPart;
+ IHandlerService handler =
(IHandlerService)localPart.getEditorSite().getService(IHandlerService.class);
+ if(registry != null) {
+ registerKeyBindings(handler, ACTIONS_1, registry);
+ } else if (editor != null) {
+ // editor
+ registerKeyBindings(handler, ACTIONS_2, editor);
+ } else {
+ //fakeTextEditor
+ registerKeyBindings(handler, ACTIONS_1, fakeTextEditor);
+ }
+
+ cleanActionBarStatus();
+ actionBars.updateActionBars();
+ }
+
+ if(fToggleOccurencesMarkUp != null) {
+ fToggleOccurencesMarkUp.setEditor(getTextEditor(part));
+ fToggleOccurencesMarkUp.update();
+ }
+
+ updateStatus();
+ }
+
+ public void registerKeyBindings(IHandlerService handler, String[] actions,
ActionRegistry registry) {
+ for (int i = 0; i < actions.length; i++) {
+ IAction action = registry.getAction(actions[i]);
+ registerKeyBinding(handler, actions[i], action);
+ }
+ }
+
+ class FakeTextEditor extends AFakeTextEditor {
+ public boolean canDoOperation(int operation) {
+ return true;
+ }
+ public void doOperation(int operation) {
+ if(fActiveEditorPart instanceof SeamPagesGuiEditor){
+ ActionRegistry registry=
(ActionRegistry)fActiveEditorPart.getAdapter(ActionRegistry.class);
+ switch(operation){
+ case 3: // cut
+ registry.getAction(ActionFactory.CUT.getId()).run();
+ break;
+ case 4: // copy
+ registry.getAction(ActionFactory.COPY.getId()).run();
+ break;
+ case 5: // paste
+ registry.getAction(ActionFactory.PASTE.getId()).run();
+ break;
+ }
+ }
+ }
+ }
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesMultiPageContributor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain