Author: rombert
Date: Fri Jul 19 15:04:17 2013
New Revision: 1504907
URL: http://svn.apache.org/r1504907
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure
Add a project property page for setting the directory to sync. Not yet
hooked up to the actualy sync process.
Added:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
(with props)
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
(with props)
Modified:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/plugin.xml
Modified:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF?rev=1504907&r1=1504906&r2=1504907&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
Fri Jul 19 15:04:17 2013
@@ -22,6 +22,7 @@ Import-Package: org.apache.sling.ide.ser
org.eclipse.jdt.launching,
org.eclipse.jface.action,
org.eclipse.jface.dialogs,
+ org.eclipse.jface.preference,
org.eclipse.jface.viewers,
org.eclipse.jface.window,
org.eclipse.jface.wizard,
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/plugin.xml
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/plugin.xml?rev=1504907&r1=1504906&r2=1504907&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/plugin.xml
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/plugin.xml Fri Jul
19 15:04:17 2013
@@ -201,6 +201,25 @@
</enablement>
</objectContribution>
</extension>
+
+ <!-- Property page for project to select directory to sync -->
+ <extension point="org.eclipse.ui.propertyPages">
+ <page
+ id="org.apache.sling.ide.eclipse.projectPropertyPage"
+ name="Sling"
+
class="org.apache.sling.ide.eclipse.wst.ui.internal.SlingProjectPropertyPage" >
+ <enabledWhen>
+ <and>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ <test
+
property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="sling.content"/>
+ </and>
+ </enabledWhen>
+ </page>
+ </extension>
<!--
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
Added:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java?rev=1504907&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
Fri Jul 19 15:04:17 2013
@@ -0,0 +1,26 @@
+/*
+ * 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.wst.ui.internal;
+
+public abstract class Constants {
+
+ public static final String PLUGIN_ID = "org.apache.sling.ide.eclipse.wst";
+
+ private Constants() {
+
+ }
+}
Propchange:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/Constants.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java?rev=1504907&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
Fri Jul 19 15:04:17 2013
@@ -0,0 +1,141 @@
+package org.apache.sling.ide.eclipse.wst.ui.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionValidator;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class SlingProjectPropertyPage extends PropertyPage {
+
+ private static final String PROPERTY_SYNC_ROOT = "sync_root";
+ private Text folderText;
+
+ @Override
+ protected Control createContents(Composite parent) {
+
+ Composite c = new Composite(parent, SWT.NONE);
+
+ c.setLayout(new GridLayout(3, false));
+
+ new Label(c, SWT.NONE).setText("Folder to sync");
+ folderText = new Text(c, SWT.BORDER);
+ folderText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ folderText.setText(getValueWithDefault());
+
+ folderText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ updateApplyButton();
+ }
+ });
+
+ Button browseButton = new Button(c, SWT.PUSH);
+ browseButton.setText("Browse...");
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ final IProject project = getProject();
+ ContainerSelectionDialog dialog = new
ContainerSelectionDialog(getShell(), project, false, null);
+ dialog.showClosedProjects(false);
+ dialog.setValidator(new ISelectionValidator() {
+
+ @Override
+ public String isValid(Object selection) {
+
+ if (!(selection instanceof IPath)) {
+ return null;
+ }
+
+ IPath path = (IPath) selection;
+ if (project.getFullPath().isPrefixOf(path)) {
+ return null;
+ }
+
+ return "The folder must be contained in the " +
project.getName() + " project";
+ }
+ });
+
+ dialog.open();
+
+ Object[] results = dialog.getResult();
+ if (results == null) {
+ return;
+ }
+
+ IPath selectedPath = (IPath) results[0];
+
folderText.setText(selectedPath.removeFirstSegments(1).toOSString());
+ }
+ });
+
+ Dialog.applyDialogFont(c);
+
+ return c;
+ }
+
+ private String getValueWithDefault() {
+
+ // TODO central place for defaults
+ String value = "jcr_root";
+ try {
+ value = getProject().getPersistentProperty(new
QualifiedName(Constants.PLUGIN_ID, PROPERTY_SYNC_ROOT));
+ } catch (CoreException e) {
+ // TODO error handling
+ }
+
+ return value;
+ }
+
+ @Override
+ public boolean isValid() {
+
+ String path = folderText.getText();
+ IResource member = getProject().findMember(path);
+
+ if (member == null) {
+ setErrorMessage("Resource " + path + " is not a part of project "
+ getProject().getName());
+ return false;
+ } else if (member.getType() != IResource.FOLDER) {
+ setErrorMessage("Resource " + path + " is not a folder");
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean performOk() {
+
+ IProject project = getProject();
+
+ try {
+ project.setPersistentProperty(new
QualifiedName(Constants.PLUGIN_ID, PROPERTY_SYNC_ROOT), folderText.getText());
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ }
+
+ return super.performOk();
+ }
+
+ private IProject getProject() {
+ IProject project = (IProject) getElement().getAdapter(IProject.class);
+ return project;
+ }
+}
Propchange:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/ui/internal/SlingProjectPropertyPage.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL