You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2013/08/28 17:05:31 UTC
svn commit: r1518242 - in
/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui:
nav/model/ properties/
Author: stefanegli
Date: Wed Aug 28 15:05:31 2013
New Revision: 1518242
URL: http://svn.apache.org/r1518242
Log:
SLING-2985 : add modifiable properties support (in the properties view) to the content-browser
Added:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java (with props)
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java (with props)
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java (with props)
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java (with props)
Removed:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ReadOnlyProperties.java
Modified:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/SyncDir.java
Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java?rev=1518242&r1=1518241&r2=1518242&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java Wed Aug 28 15:05:31 2013
@@ -16,6 +16,8 @@
*/
package org.apache.sling.ide.eclipse.ui.nav.model;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@@ -23,12 +25,18 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -36,7 +44,7 @@ import org.xml.sax.SAXException;
/** WIP: model object for a [.content.xml] shown in the content package view in project explorer **/
public class GenericJcrRootFile extends JcrNode {
- private final IFile file;
+ final IFile file;
private final Document document;
public GenericJcrRootFile(JcrNode parent, IFile file) throws ParserConfigurationException, SAXException, IOException, CoreException {
@@ -45,7 +53,6 @@ public class GenericJcrRootFile extends
}
this.file = file;
setResource(file);
- this.underlying = this;
if (parent==null) {
throw new IllegalArgumentException("parent must not be null");
}
@@ -56,6 +63,20 @@ public class GenericJcrRootFile extends
this.document = docBuilder.parse(file.getContents());
handleJcrRoot(this.document.getFirstChild());
}
+
+ @Override
+ public int hashCode() {
+ return file.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof GenericJcrRootFile) {
+ GenericJcrRootFile other = (GenericJcrRootFile) obj;
+ return file.equals(other.file);
+ }
+ return false;
+ }
private void handleJcrRoot(Node domNode) {
NodeList children = domNode.getChildNodes();
@@ -77,12 +98,13 @@ public class GenericJcrRootFile extends
return file.getName().equals(".content.xml");
}
- private void handleProperties(Node domNode, ReadOnlyProperties properties) {
- NamedNodeMap attributes = domNode.getAttributes();
- for(int i=0; i<attributes.getLength(); i++) {
- Node attr = attributes.item(i);
- properties.add(attr.getNodeName(), attr.getNodeValue());
- }
+ private void handleProperties(Node domNode, ModifiableProperties properties) {
+ properties.setNode(this, domNode);
+// NamedNodeMap attributes = domNode.getAttributes();
+// for(int i=0; i<attributes.getLength(); i++) {
+// Node attr = attributes.item(i);
+// properties.add(attr.getNodeName(), attr.getNodeValue());
+// }
}
@Override
@@ -124,8 +146,7 @@ public class GenericJcrRootFile extends
// as primaryType doesn't help a lot
return;
}
- JcrNode childJcrNode = new JcrNode(parent, domNode);
- childJcrNode.init();
+ JcrNode childJcrNode = new JcrNode(parent, domNode, this, null);
handleProperties(domNode, childJcrNode.properties);
NodeList children = domNode.getChildNodes();
for(int i=0; i<children.getLength(); i++) {
@@ -134,7 +155,7 @@ public class GenericJcrRootFile extends
}
public void pickResources(List<Object> membersList) {
- for (Iterator it = membersList.iterator(); it.hasNext();) {
+ for (Iterator<Object> it = membersList.iterator(); it.hasNext();) {
final IResource resource = (IResource) it.next();
final String resName = resource.getName();
Iterator it2;
@@ -156,4 +177,31 @@ public class GenericJcrRootFile extends
}
+ @Override
+ public boolean canBeOpenedInEditor() {
+ return false;
+ }
+
+ public void save() {
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ DOMSource source = new DOMSource(document);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ StreamResult result = new StreamResult(out);
+ transformer.transform(source, result);
+ file.setContents(new ByteArrayInputStream(out.toByteArray()), true, true, new NullProgressMonitor());
+ } catch (TransformerConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TransformerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
}
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=1518242&r1=1518241&r2=1518242&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 Aug 28 15:05:31 2013
@@ -30,7 +30,7 @@ import javax.xml.parsers.ParserConfigura
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.sling.ide.eclipse.ui.internal.SharedImages;
+import org.apache.sling.ide.eclipse.ui.WhitelabelSupport;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -46,6 +46,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IContributorResourceAdapter;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.w3c.dom.Node;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@@ -83,7 +84,7 @@ public class JcrNode implements IAdaptab
private final static WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
- GenericJcrRootFile underlying;
+ final GenericJcrRootFile underlying;
JcrNode parent;
@@ -95,20 +96,31 @@ public class JcrNode implements IAdaptab
private boolean resourceChildrenAdded = false;
- final ReadOnlyProperties properties = new ReadOnlyProperties();
+ final ModifiableProperties properties = new ModifiableProperties(this);
JcrNode() {
// for subclass use only
+ if (this instanceof GenericJcrRootFile) {
+ this.underlying = (GenericJcrRootFile) this;
+ } else {
+ this.underlying = null;
+ }
+ }
+
+ JcrNode(JcrNode parent, Node domNode, IResource resource) {
+ this(parent, domNode, parent.underlying, resource);
}
- JcrNode(JcrNode parent, Node domNode) {
+
+ JcrNode(JcrNode parent, Node domNode, GenericJcrRootFile underlying, IResource resource) {
if (parent == null) {
throw new IllegalArgumentException("parent must not be null");
}
this.parent = parent;
// domNode can be null
this.domNode = domNode;
- this.underlying = parent.underlying;
+ this.underlying = underlying;
+ this.resource = resource;
parent.addChild(this);
}
@@ -116,6 +128,60 @@ public class JcrNode implements IAdaptab
public String toString() {
return "JcrNode[dom:"+domNode+", file:"+resource+"]";
}
+
+ @Override
+ public int hashCode() {
+ if (underlying==null) {
+ if (resource==null) {
+ if (domNode==null) {
+ return toString().hashCode();
+ } else {
+ return domNode.toString().hashCode() + parent.hashCode();
+ }
+ } else {
+ return resource.getFullPath().hashCode();
+ }
+ } else {
+ return underlying.hashCode() + domNode.toString().hashCode();
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this==obj) {
+ return true;
+ }
+ if (!(obj instanceof JcrNode)) {
+ return false;
+ }
+ JcrNode other = (JcrNode) obj;
+ if (other.underlying==null && underlying!=null) {
+ return false;
+ } else if (other.underlying!=null && underlying==null) {
+ return false;
+ }
+ if (underlying!=null && !underlying.equals(other.underlying)) {
+ return false;
+ }
+ if (resource!=null && other.resource!=null) {
+ if (resource.equals(other.resource)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (resource!=null && other.resource==null) {
+ return false;
+ } else if (resource==null && other.resource!=null) {
+ return false;
+ }
+ if (parent!=null && other.parent!=null) {
+ if (!parent.equals(other.parent)) {
+ return false;
+ }
+ return domNode.toString().equals(other.domNode.toString());
+ }
+ return toString().equals(obj.toString());
+ }
protected void addChild(JcrNode jcrNode) {
children.add(jcrNode);
@@ -188,9 +254,8 @@ public class JcrNode implements IAdaptab
}
for (Iterator it = membersList.iterator(); it.hasNext();) {
IResource iResource = (IResource) it.next();
- JcrNode node = new JcrNode(this, (Node)null);
- node.setResource(iResource);
- node.init();
+ JcrNode node = new JcrNode(this, (Node)null, iResource);
+// node.setResource(iResource);
// load the children - to make sure we get vault files loaded too
node.getChildren();
resultMap.put(node.getName(), node);
@@ -212,10 +277,6 @@ public class JcrNode implements IAdaptab
}
}
- protected void init() {
- // placeholder for initializing any common properties
- }
-
private boolean isVaultFile(IResource iResource)
throws ParserConfigurationException, SAXException, IOException,
CoreException {
@@ -276,7 +337,7 @@ public class JcrNode implements IAdaptab
// return workbenchLabelProvider.getImage(domNode);
//}
- return SharedImages.SLING_ICON.createImage();
+ return WhitelabelSupport.JCR_NODE_ICON.createImage();
}
public String getName() {
@@ -305,14 +366,23 @@ public class JcrNode implements IAdaptab
@Override
public Object getAdapter(Class adapter) {
final Object result = doGetAdapter(adapter);
- if (result==null) {
- // System.out.println("adapter looked for: "+adapter+", result: "+result);
- }
+ //if (result==null) {
+ //System.out.println("adapter looked for: "+adapter+", result: "+result);
+ //}
return result;
}
private Object doGetAdapter(Class adapter) {
- if (adapter==IPropertySource.class) {
+ if (adapter==ITabbedPropertySheetPageContributor.class && "christmas".equals("christmas")) {
+ return new ITabbedPropertySheetPageContributor() {
+
+ @Override
+ public String getContributorId() {
+ return "org.apache.sling.ide.eclipse-ui.propertyContributor1";
+ }
+
+ };
+ } else if (adapter==IPropertySource.class) {
return properties;
} else if (adapter == IFile.class) {
if (resource instanceof IFile) {
@@ -378,4 +448,55 @@ public class JcrNode implements IAdaptab
return null;
}
+ public boolean canBeOpenedInEditor() {
+ if (resource==null) {
+ return false;
+ }
+
+ if (resource instanceof IFolder) {
+ return false;
+ } else {
+ try {
+ if (!isVaultFile(resource)) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ public void rename(String string) {
+ if (domNode!=null && underlying!=null) {
+ domNode.getOwnerDocument().renameNode(domNode, domNode.getNamespaceURI(), string);
+ underlying.save();
+ }
+ }
+
+ public boolean canBeRenamed() {
+ if (resource!=null) {
+ return false;
+ }
+ if (domNode!=null && underlying!=null) {
+ if (domNode.getNodeName().equals("jcr:content")) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
}
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java?rev=1518242&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java Wed Aug 28 15:05:31 2013
@@ -0,0 +1,101 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class ModifiableProperties implements IPropertySource {
+
+ private Map<String, String> properties = new HashMap<String, String>();
+ private JcrNode node;
+ private Node domNode;
+ private GenericJcrRootFile genericJcrRootFile;
+
+ public ModifiableProperties(JcrNode node) {
+ this.node = node;
+ }
+
+ public void setJcrNode(JcrNode node) {
+ if (node==null) {
+ throw new IllegalArgumentException("node must not be null");
+ }
+ this.node = node;
+ }
+
+ @Override
+ public Object getEditableValue() {
+ return this;
+ }
+
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ final List<IPropertyDescriptor> result = new LinkedList<IPropertyDescriptor>();
+ for (Iterator<Map.Entry<String, String>> it = properties.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<String, String> entry = it.next();
+ TextPropertyDescriptor pd = new TextPropertyDescriptor(entry, entry.getKey());
+ result.add(pd);
+ }
+ return result.toArray(new IPropertyDescriptor[] {});
+ }
+
+ @Override
+ public Object getPropertyValue(Object id) {
+ Map.Entry<String, String> entry = (Map.Entry<String, String>)id;
+ return entry.getValue();
+ }
+
+ @Override
+ public boolean isPropertySet(Object id) {
+ return properties.containsKey(String.valueOf(id));
+ }
+
+ @Override
+ public void resetPropertyValue(Object id) {
+
+ }
+
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+ Map.Entry<String, String> entry = (Map.Entry<String, String>)id;
+ entry.setValue(String.valueOf(value));
+ NamedNodeMap attributes = domNode.getAttributes();
+ Node n = attributes.getNamedItem(entry.getKey());
+ n.setNodeValue(String.valueOf(value));
+ genericJcrRootFile.save();
+ }
+
+ public void setNode(GenericJcrRootFile genericJcrRootFile, Node domNode) {
+ this.domNode = domNode;
+ NamedNodeMap attributes = domNode.getAttributes();
+ for(int i=0; i<attributes.getLength(); i++) {
+ Node attr = attributes.item(i);
+ properties.put(attr.getNodeName(), attr.getNodeValue());
+ }
+ this.genericJcrRootFile = genericJcrRootFile;
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/SyncDir.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/SyncDir.java?rev=1518242&r1=1518241&r2=1518242&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/SyncDir.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/SyncDir.java Wed Aug 28 15:05:31 2013
@@ -34,6 +34,20 @@ public class SyncDir extends JcrNode {
}
@Override
+ public int hashCode() {
+ return folder.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof SyncDir) {
+ SyncDir other = (SyncDir) obj;
+ return folder.equals(other.folder);
+ }
+ return false;
+ }
+
+ @Override
public Image getImage() {
return SharedImages.SLING_ICON.createImage();
}
@@ -55,5 +69,10 @@ public class SyncDir extends JcrNode {
public String getName() {
return "/";
}
+
+ @Override
+ public boolean canBeOpenedInEditor() {
+ return false;
+ }
}
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java?rev=1518242&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java Wed Aug 28 15:05:31 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.properties;
+
+import org.apache.sling.ide.eclipse.ui.nav.model.JcrNode;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.graphics.Image;
+
+public class TabbedPropertiesLabelProvider implements ILabelProvider {
+
+ @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) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ IStructuredSelection iss = (IStructuredSelection)element;
+ JcrNode node = (JcrNode) iss.getFirstElement();
+ return node.getDescription();
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesLabelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java?rev=1518242&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java Wed Aug 28 15:05:31 2013
@@ -0,0 +1,92 @@
+/*
+ * 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.properties;
+
+import java.util.List;
+
+import org.apache.sling.ide.eclipse.ui.nav.model.JcrNode;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection;
+import org.eclipse.ui.views.properties.tabbed.ISection;
+import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
+import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider;
+
+public class TabbedPropertiesSectionDescriptor implements
+ ISectionDescriptorProvider {
+
+ @Override
+ public ISectionDescriptor[] getSectionDescriptors() {
+ return new ISectionDescriptor[] {new ISectionDescriptor() {
+
+ @Override
+ public String getTargetTab() {
+ return null;
+ }
+
+ @Override
+ public ISection getSectionClass() {
+ return new AdvancedPropertySection();
+ }
+
+ @Override
+ public List getInputTypes() {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return "org.apache.sling.ide.eclipse-ui.propertySection1";
+ }
+
+ @Override
+ public IFilter getFilter() {
+ return null;
+ }
+
+ @Override
+ public int getEnablesFor() {
+ return 0;
+ }
+
+ @Override
+ public String getAfterSection() {
+ return null;
+ }
+
+ @Override
+ public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
+ if (!(selection instanceof IStructuredSelection)) {
+ return false;
+ }
+ IStructuredSelection iss = (IStructuredSelection) selection;
+ Object first = iss.getFirstElement();
+ if (first==null) {
+ return false;
+ }
+ if (!(first instanceof JcrNode)) {
+ return false;
+ }
+ return true;
+ }
+ }
+ };
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesSectionDescriptor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java?rev=1518242&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java Wed Aug 28 15:05:31 2013
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+/*
+ * 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.properties;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.AbstractTabDescriptor;
+import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
+import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider;
+
+public class TabbedPropertiesTabDescriptor implements ITabDescriptorProvider {
+
+ @Override
+ public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part,
+ ISelection selection) {
+ AbstractTabDescriptor td = new AbstractTabDescriptor() {
+
+ @Override
+ public String getLabel() {
+ return "JCR Properties";
+ }
+
+ @Override
+ public String getId() {
+ return "org.apache.sling.ide.eclipse-ui.propertyTab1";
+ }
+
+ @Override
+ public String getCategory() {
+ return "org.apache.sling.ide.eclipse-ui.myCategory";
+ }
+ };
+ List sectionDescriptors = new LinkedList();
+ sectionDescriptors.addAll(Arrays.asList(new TabbedPropertiesSectionDescriptor().getSectionDescriptors()));
+ td.setSectionDescriptors(sectionDescriptors);
+ return new ITabDescriptor[] {td};
+ }
+
+}
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/properties/TabbedPropertiesTabDescriptor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain