Author: mareshkau
Date: 2010-10-19 06:56:18 -0400 (Tue, 19 Oct 2010)
New Revision: 25912
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.classpath
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.project
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.settings/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.settings/org.eclipse.jdt.core.prefs
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/META-INF/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/l10n/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/l10n/bundle.properties
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/SideBySideActivator.class
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/handlers/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/handlers/SideBySideHandler.class
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/build.properties
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/plugin.xml
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/SideBySideActivator.java
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/handlers/
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/handlers/SideBySideHandler.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/NewEditorSideBySideCommandTest.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
Log:
https://jira.jboss.org/browse/JBIDE-6685
Added: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.classpath
===================================================================
--- trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.classpath
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.classpath 2010-10-19 10:56:18
UTC (rev 25912)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.project
===================================================================
--- trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.project
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.project 2010-10-19 10:56:18
UTC (rev 25912)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.neweditor.sidebyside</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/.settings/org.eclipse.jdt.core.prefs 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,8 @@
+#Mon Oct 18 11:45:42 EEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/META-INF/MANIFEST.MF 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: NewEditorSideBySide
+Bundle-SymbolicName: org.jboss.tools.neweditor.sidebyside;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.sidebyside.SideBySideActivator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/l10n/bundle.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/l10n/bundle.properties
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/OSGI-INF/l10n/bundle.properties 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.sidebyside
+command.newEditor.sidebyside.name=New Editor (Side by Side)
+command.newEditor.sidebyside.description=Open New Editor Side by Side to active Editor
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin
___________________________________________________________________
Name: svn:ignore
+ target
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/SideBySideActivator.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/SideBySideActivator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/handlers/SideBySideHandler.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/bin/org/jboss/tools/sidebyside/handlers/SideBySideHandler.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/build.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/build.properties
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/build.properties 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ plugin.properties,\
+ OSGI-INF/l10n/bundle.properties
Added: trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/plugin.xml
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/plugin.xml 2010-10-19 10:56:18
UTC (rev 25912)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="%command.newEditor.sidebyside.description"
+ name="%command.newEditor.sidebyside.name"
+ categoryId="org.eclipse.ui.category.window"
+ id="org.jboss.tools.sidebyside.newEditor">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ commandId="org.jboss.tools.sidebyside.newEditor"
+ class="org.jboss.tools.sidebyside.handlers.SideBySideHandler">
+ <enabledWhen>
+ <with
+ variable="activeEditor">
+ <instanceof
+ value="org.eclipse.ui.IEditorPart">
+ </instanceof>
+ </with>
+ </enabledWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.jboss.tools.sidebyside.newEditor"
+ contextId="org.eclipse.ui.contexts.window"
+ sequence="M1+8"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="menu:window?after=newEditor">
+ <command
+ label="%command.newEditor.sidebyside.name"
+ commandId="org.jboss.tools.sidebyside.newEditor"
+ mnemonic="S"
+ id="org.jboss.tools.sidebyside.menus.newEditor">
+ </command>
+ </menuContribution>
+ </extension>
+</plugin>
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/SideBySideActivator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/SideBySideActivator.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/SideBySideActivator.java 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.sidebyside;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SideBySideActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.sidebyside";
//$NON-NLS-1$
+
+ // The shared instance
+ private static SideBySideActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public SideBySideActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static SideBySideActivator getDefault() {
+ return plugin;
+ }
+
+
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added:
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/handlers/SideBySideHandler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/handlers/SideBySideHandler.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.neweditor.sidebyside/src/org/jboss/tools/sidebyside/handlers/SideBySideHandler.java 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.sidebyside.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.EditorSashContainer;
+import org.eclipse.ui.internal.EditorStack;
+import org.eclipse.ui.internal.ILayoutContainer;
+import org.eclipse.ui.internal.LayoutPart;
+import org.eclipse.ui.internal.PartPane;
+import org.eclipse.ui.internal.PartSashContainer;
+import org.eclipse.ui.internal.PartSite;
+import org.eclipse.ui.internal.PartStack;
+import org.eclipse.ui.internal.WorkbenchPage;
+import org.eclipse.ui.internal.handlers.NewEditorHandler;
+
+/**
+ * Handler which split active editor vertically
+ * @see
https://jira.jboss.org/browse/JBIDE-6685
+ * @author mareshkau
+ */
+public class SideBySideHandler extends NewEditorHandler {
+
+ /**
+ * the command has been executed, so extract extract the needed information
+ * from the application context.
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ super.execute(event);
+ splitEditorArea();
+ return null;
+ }
+
+ private void splitEditorArea() {
+ IWorkbenchPage workbenchPage = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart part = workbenchPage.getActivePart();
+ PartPane partPane = ((PartSite) part.getSite()).getPane();
+ LayoutPart layoutPart = partPane.getPart();
+
+ // Get PartPane that correspond to the active editor
+ PartPane currentEditorPartPane = ((PartSite) workbenchPage
+ .getActiveEditor().getSite()).getPane();
+ EditorSashContainer editorSashContainer = null;
+ ILayoutContainer rootLayoutContainer = layoutPart.getContainer();
+ if (rootLayoutContainer instanceof LayoutPart) {
+ ILayoutContainer editorSashLayoutContainer = ((LayoutPart) rootLayoutContainer)
+ .getContainer();
+ if (editorSashLayoutContainer instanceof EditorSashContainer) {
+ editorSashContainer = ((EditorSashContainer) editorSashLayoutContainer);
+ }
+ }
+ /*
+ * Create a new part stack (i.e. a workbook) to home the
+ * currentEditorPartPane which hold the active editor
+ */
+ PartStack newPart = createStack(editorSashContainer);
+
+ editorSashContainer.stack(currentEditorPartPane, newPart);
+ if (rootLayoutContainer instanceof LayoutPart) {
+ ILayoutContainer cont = ((LayoutPart) rootLayoutContainer)
+ .getContainer();
+ if (cont instanceof PartSashContainer) {
+ // "Split" the editor area by adding the new part
+ ((PartSashContainer) cont).add(newPart);
+ }
+ }
+ }
+
+ /**
+ * A method to create a part stack container (a new workbook)
+ *
+ * @param editorSashContainer
+ * the <code>EditorSashContainer</code> to set for the returned
+ * <code>PartStack</code>
+ * @return a new part stack container
+ */
+ private PartStack createStack(EditorSashContainer editorSashContainer) {
+ WorkbenchPage workbenchPage = (WorkbenchPage) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ EditorStack newWorkbook = EditorStack.newEditorWorkbook(
+ editorSashContainer, workbenchPage);
+ return newWorkbook;
+ }
+}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2010-10-19
09:00:18 UTC (rev 25911)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2010-10-19
10:56:18 UTC (rev 25912)
@@ -15,6 +15,7 @@
import org.jboss.tools.jst.jsp.test.ca.ExternalizeCommandTest;
import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1641Test;
+import org.jboss.tools.jst.jsp.test.ca.NewEditorSideBySideCommandTest;
import org.jboss.tools.jst.jsp.test.ca.SelectionBarTest;
public class JstJspAllTests {
@@ -44,6 +45,7 @@
suite.addTestSuite(SelectionBarTest.class);
suite.addTestSuite(ExternalizeCommandTest.class);
+ suite.addTestSuite(NewEditorSideBySideCommandTest.class);
return suite;
}
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/NewEditorSideBySideCommandTest.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/NewEditorSideBySideCommandTest.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/NewEditorSideBySideCommandTest.java 2010-10-19
10:56:18 UTC (rev 25912)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.test.ca;
+
+import junit.framework.TestCase;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.jboss.tools.test.util.TestProjectProvider;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ *
+ * Junit test for
https://jira.jboss.org/browse/JBIDE-6685 command
+ * @author mareshkau
+ *
+ */
+public class NewEditorSideBySideCommandTest extends TestCase {
+
+ public static final String
NEW_EDITOR_SIDE_BY_SIDE_COMMAND_ID="org.jboss.tools.sidebyside.newEditor";
//$NON-NLS-1$
+ protected IProject project = null;
+ private TestProjectProvider provider = null;
+ private Command newEditorSideBySideCmd;
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test",
null, "JsfJbide1791Test",false); //$NON-NLS-1$ //$NON-NLS-2$
+ project = provider.getProject();
+ ICommandService commandService =
+ (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
+ newEditorSideBySideCmd = commandService.getCommand(
+ NEW_EDITOR_SIDE_BY_SIDE_COMMAND_ID);
+ }
+
+ protected void tearDown() throws Exception {
+ if(provider != null) {
+ provider.dispose();
+ }
+ }
+ /**
+ * Test Side by Side command
+ * @throws NotDefinedException
+ * @throws NotHandledException
+ * @throws NotEnabledException
+ * @throws ExecutionException
+ */
+ public void testExternalizeCommand() throws NotDefinedException, ExecutionException,
NotEnabledException, NotHandledException{
+ assertEquals(newEditorSideBySideCmd.getName()+ " should be disabled without
opened editor",false,newEditorSideBySideCmd.isEnabled()); //$NON-NLS-1$
+
WorkbenchUtils.openEditor(project.getName()+"/WebContent/pages/newSideBySideEditorTest.txt");
//$NON-NLS-1$
+ assertEquals(newEditorSideBySideCmd.getName()+ " should be enabled when editor
opened",true,newEditorSideBySideCmd.isEnabled()); //$NON-NLS-1$
+ }
+}