You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2016/11/01 17:49:33 UTC
svn commit: r1767532 - in /sling/trunk/tooling/ide/eclipse-ui: ./
src/org/apache/sling/ide/eclipse/ui/nav/
src/org/apache/sling/ide/eclipse/ui/nav/model/
Author: kwin
Date: Tue Nov 1 17:49:32 2016
New Revision: 1767532
URL: http://svn.apache.org/viewvc?rev=1767532&view=rev
Log:
SLING-3626 add dedicated entry point in the project explorer for the META-INF/vault
Added:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java (with props)
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java (with props)
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java (with props)
Modified:
sling/trunk/tooling/ide/eclipse-ui/plugin.xml
Modified: sling/trunk/tooling/ide/eclipse-ui/plugin.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/plugin.xml?rev=1767532&r1=1767531&r2=1767532&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-ui/plugin.xml Tue Nov 1 17:49:32 2016
@@ -229,6 +229,7 @@
<includes>
<contentExtension pattern="org.apache.sling.ide.eclipse-ui.javaEEFilter" />
<contentExtension pattern="org.apache.sling.ide.eclipse-ui.navigatorJcrContent" />
+ <contentExtension pattern="org.apache.sling.ide.eclipse-ui.navigatorVaultMetaInf" />
<contentExtension pattern="org.apache.sling.ide.eclipse-ui.linkHelper"/>
</includes>
</viewerContentBinding>
@@ -243,7 +244,7 @@
activeByDefault="true">
</commonFilter>
<navigatorContent
- appearsBefore="org.eclipse.jst.jee.ui.ejb"
+ appearsBefore="org.apache.sling.ide.eclipse-ui.navigatorVaultMetaInf"
contentProvider="org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider"
icon="icons/obj16/sling_misc.gif"
id="org.apache.sling.ide.eclipse-ui.navigatorJcrContent"
@@ -298,6 +299,7 @@
</actionProvider>
<override
policy="InvokeAlwaysRegardlessOfSuppressedExt"
+
suppressedExtensionId="org.eclipse.ui.navigator.resourceContent">
</override>
<commonSorter
@@ -317,6 +319,37 @@
</dropAssistant>
</navigatorContent>
+ <!-- dedicated content provider which lists the META-INF/filevault directly below the projects -->
+ <navigatorContent id="org.apache.sling.ide.eclipse-ui.navigatorVaultMetaInf"
+ name="FileVault Synchronization/Packaging Settings"
+ appearsBefore="org.eclipse.jst.jee.ui.ejb"
+ contentProvider="org.apache.sling.ide.eclipse.ui.nav.FileVaultMetaInfContentProvider"
+ labelProvider="org.apache.sling.ide.eclipse.ui.nav.FileVaultMetaInfLabelProvider"
+ icon="icons/obj16/sling_misc.gif">
+ <triggerPoints>
+ <and>
+ <!-- only trigger for Sling Content Projects -->
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="sling.content"/>
+ </adapt>
+ <or>
+ <!-- and either IProject or FileVaultMetaInfRootFolder -->
+ <instanceof value="org.eclipse.core.resources.IProject" />
+ <instanceof value="org.apache.sling.ide.eclipse.ui.nav.model.FileVaultMetaInfRootFolder" />
+ </or>
+ </and>
+ </triggerPoints>
+ <possibleChildren>
+ <and>
+ <!-- only trigger for Sling Content Projects -->
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="sling.content"/>
+ </adapt>
+ <instanceof
+ value="org.eclipse.core.resources.IResource" />
+ </and>
+ </possibleChildren>
+ </navigatorContent>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java?rev=1767532&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java Tue Nov 1 17:49:32 2016
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+import org.apache.sling.ide.eclipse.core.ProjectUtil;
+import org.apache.sling.ide.eclipse.core.internal.ProjectHelper;
+import org.apache.sling.ide.eclipse.ui.internal.Activator;
+import org.apache.sling.ide.eclipse.ui.nav.model.FileVaultMetaInfRootFolder;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class FileVaultMetaInfContentProvider implements ITreeContentProvider {
+
+ private static final String FILEVAULT_METAINF_PATH = "META-INF/vault";
+ private static final Object[] NO_CHILDREN = new Object[0];
+
+ private FileVaultMetaInfRootFolder getFileVaultMetaInfFolder(IProject project) {
+ if (ProjectHelper.isContentProject(project)) {
+ IFolder syncDir = ProjectUtil.getSyncDirectory(project);
+ if (syncDir != null) {
+ IFolder metaInfFolder = syncDir.getParent().getFolder(new Path(FILEVAULT_METAINF_PATH));
+ if (metaInfFolder.exists()) {
+ return new FileVaultMetaInfRootFolder(metaInfFolder);
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ final Object[] children;
+ // expose the filevault meta-inf directly below the project
+ if (parentElement instanceof IProject) {
+ IProject project = (IProject) parentElement;
+ FileVaultMetaInfRootFolder folder = getFileVaultMetaInfFolder(project);
+ if (folder != null) {
+ children = new Object[1];
+ children[0] = folder;
+ return children;
+ }
+ } else if (parentElement instanceof FileVaultMetaInfRootFolder) {
+ FileVaultMetaInfRootFolder fileVaultMetaInfRootFolder = (FileVaultMetaInfRootFolder) parentElement;
+ try {
+ return fileVaultMetaInfRootFolder.getFolder().members();
+ } catch (CoreException e) {
+ Activator.getDefault().getPluginLogger().error(
+ "Could not list members of folder " + fileVaultMetaInfRootFolder.getFolder().getName(), e);
+ }
+ }
+ return NO_CHILDREN;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof IResource) {
+ IResource resource = (IResource) element;
+ FileVaultMetaInfRootFolder fileVaultMetaInfoFolder = getFileVaultMetaInfFolder(resource.getProject());
+ if (fileVaultMetaInfoFolder != null) {
+ return fileVaultMetaInfoFolder.getFolder().findMember(resource.getFullPath()) != null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object parentElement) {
+ // the getChildren is not expensive, therefore we leverage that here
+ return getChildren(parentElement) != null;
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfContentProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java?rev=1767532&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java Tue Nov 1 17:49:32 2016
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import org.apache.sling.ide.eclipse.ui.nav.model.FileVaultMetaInfRootFolder;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Mostly copied from org.eclipse.ui.internal.ide.dialogs.FileFolderSelectionDialog.FileLabelProvider.
+ *
+ */
+public class FileVaultMetaInfLabelProvider implements ILabelProvider {
+
+ private static final Image IMG_FOLDER = PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJ_FOLDER);
+
+ public FileVaultMetaInfLabelProvider() {
+ super();
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof FileVaultMetaInfRootFolder) {
+ return IMG_FOLDER;
+ }
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof FileVaultMetaInfRootFolder) {
+ FileVaultMetaInfRootFolder fileVaultMetaInfRootFolder = (FileVaultMetaInfRootFolder) element;
+ return fileVaultMetaInfRootFolder.getFolder().getProjectRelativePath().toPortableString();
+ }
+ return null;
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/FileVaultMetaInfLabelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java?rev=1767532&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java Tue Nov 1 17:49:32 2016
@@ -0,0 +1,37 @@
+/*
+ * 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.eclipse.core.resources.IFolder;
+
+public class FileVaultMetaInfRootFolder {
+
+ private final IFolder folder;
+
+ public FileVaultMetaInfRootFolder(IFolder folder) {
+ this.folder = folder;
+ }
+
+ @Override
+ public String toString() {
+ return folder.getProjectRelativePath().toString();
+ }
+
+ public IFolder getFolder() {
+ return folder;
+ }
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/FileVaultMetaInfRootFolder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain