incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1520001 - in /sling/trunk/tooling/ide/eclipse-ui: ./ src/org/apache/sling/ide/eclipse/ui/nav/ src/org/apache/sling/ide/eclipse/ui/nav/model/
Date Wed, 04 Sep 2013 13:01:30 GMT
Author: stefanegli
Date: Wed Sep  4 13:01:29 2013
New Revision: 1520001

URL: http://svn.apache.org/r1520001
Log:
SLING-2985 : link-with-editor support added for content browser

Added:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
  (with props)
Modified:
    sling/trunk/tooling/ide/eclipse-ui/plugin.xml
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/JcrContentContentProvider.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java

Modified: sling/trunk/tooling/ide/eclipse-ui/plugin.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/plugin.xml?rev=1520001&r1=1520000&r2=1520001&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-ui/plugin.xml Wed Sep  4 13:01:29 2013
@@ -151,6 +151,7 @@
 		<viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
 			<includes>
 				<contentExtension pattern="org.apache.sling.ide.eclipse-ui.navigatorJcrContent" />
+				<contentExtension pattern="org.apache.sling.ide.eclipse-ui.linkHelper"/>	
 			</includes>
 		</viewerContentBinding>
 	</extension>
@@ -374,6 +375,25 @@
             </and>
          </enablement>
       </decorator>
+   </extension>
+   <extension
+         point="org.eclipse.ui.navigator.linkHelper">
+      <linkHelper
+            class="org.apache.sling.ide.eclipse.ui.nav.model.LinkHelper"
+            id="org.apache.sling.ide.eclipse-ui.linkHelper">
+         <editorInputEnablement>
+         	<or>
+               <instanceof
+                     value="org.eclipse.ui.IEditorInput">
+               </instanceof>
+            </or>
+         </editorInputEnablement>
+         <selectionEnablement>
+               <instanceof
+                     value="org.apache.sling.ide.eclipse.ui.nav.model.JcrNode">
+               </instanceof>
+         </selectionEnablement>
+      </linkHelper>
    </extension> 
    
 </plugin>    

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/JcrContentContentProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/JcrContentContentProvider.java?rev=1520001&r1=1520000&r2=1520001&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/JcrContentContentProvider.java
(original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/JcrContentContentProvider.java
Wed Sep  4 13:01:29 2013
@@ -76,8 +76,14 @@ public class JcrContentContentProvider i
 
 	@Override
 	public Object getParent(Object element) {
-		// TODO Auto-generated method stub
-		return null;
+		if (!(element instanceof JcrNode)) {
+			return null;
+		} else if (element instanceof SyncDir) {
+			SyncDir syncDir = (SyncDir) element;
+			return syncDir.getFolder().getProject();
+		}
+		JcrNode node = (JcrNode) element;
+		return node.getParent();
 	}
 
 	@Override

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java?rev=1520001&r1=1520000&r2=1520001&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
(original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
Wed Sep  4 13:01:29 2013
@@ -522,4 +522,8 @@ public class JcrNode implements IAdaptab
 		return false;
 	}
 
+	public JcrNode getParent() {
+		return parent;
+	}
+
 }

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java?rev=1520001&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
(added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
Wed Sep  4 13:01:29 2013
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.sling.ide.eclipse.ui.nav.model;
+
+import org.apache.sling.ide.eclipse.core.ProjectUtil;
+import org.apache.sling.ide.eclipse.core.internal.ProjectHelper;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.navigator.ILinkHelper;
+import org.w3c.dom.Node;
+
+public class LinkHelper implements ILinkHelper {
+
+	@Override
+	public IStructuredSelection findSelection(IEditorInput anInput) {
+		IFile file = ResourceUtil.getFile(anInput);
+		IProject project = file.getProject();
+		if (!ProjectHelper.isContentProject(project)) {
+			return null;
+		}
+		IPath syncDirFullPath = ProjectUtil.getSyncDirectoryFullPath(project);
+		if (syncDirFullPath==null) {
+			return null;
+		}
+		if (!syncDirFullPath.isPrefixOf(file.getFullPath())) {
+			return null;
+		}
+		JcrNode selectedNode = createSelectionNode(file);
+		if (selectedNode!=null) {
+			return new StructuredSelection(selectedNode);
+		} else {
+			return null;
+		}
+	}
+
+	private JcrNode createSelectionNode(IResource resource) {
+		if (resource==null) {
+			return null;
+		}
+		final IContainer resourceParent = resource.getParent();
+		if (resource instanceof IFolder) {
+			IFolder container = (IFolder)resource;
+			IPath syncDirFullPath = ProjectUtil.getSyncDirectoryFullPath(resource.getProject());
+			if (syncDirFullPath.equals(container.getFullPath())) {
+				// then we've reached the syncdir
+				return new SyncDir(container);
+			}
+		} else if (!(resource instanceof IFile)) {
+			return null;
+		}
+		JcrNode parent = createSelectionNode(resourceParent);
+		if (parent==null) {
+			return null;
+		}
+		Node domNode = null;
+		JcrNode selectedNode = new JcrNode(parent, domNode, resource);
+		return selectedNode;
+	}
+
+	@Override
+	public void activateEditor(IWorkbenchPage aPage,
+			IStructuredSelection aSelection) {
+		// nothing done here at the moment. 
+		// PackageExplorerOpenActionProvider currently takes care of opening jcr nodes in an editor
+	}
+
+}

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message