You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2013/09/30 12:28:10 UTC

svn commit: r1527508 [2/4] - in /sling/trunk/tooling/ide: ./ api-test/ api/ api/META-INF/ api/OSGI-INF/ api/src/org/apache/sling/ide/filter/ api/src/org/apache/sling/ide/osgi/ api/src/org/apache/sling/ide/serialization/ api/src/org/apache/sling/ide/tra...

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java Mon Sep 30 10:28:08 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.sling.ide.eclipse.ui.wizards.np;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -27,27 +25,27 @@ import java.util.Properties;
 import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.model.Model;
 import org.apache.sling.ide.eclipse.core.ConfigurationHelper;
-import org.apache.sling.ide.eclipse.core.MavenLaunchHelper;
+import org.apache.sling.ide.eclipse.m2e.internal.Activator;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.m2e.core.MavenPlugin;
 import org.eclipse.m2e.core.project.MavenUpdateRequest;
 import org.eclipse.m2e.core.project.ProjectImportConfiguration;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.wst.server.core.IModule;
@@ -89,6 +87,40 @@ public abstract class AbstractNewSlingAp
 		addPage(setupServerWizardPage);
 	}
 	
+    /**
+     * 
+     * @return the current wizard page, possibly null
+     */
+    protected WizardPage getCurrentWizardPage() {
+        IWizardPage currentPage = getContainer().getCurrentPage();
+        if (currentPage instanceof WizardPage) {
+            return (WizardPage) currentPage;
+        }
+
+        return null;
+    }
+
+    protected void reportError(CoreException e) {
+        WizardPage currentPage = getCurrentWizardPage();
+        if (currentPage != null) {
+            currentPage.setMessage(e.getMessage(), IMessageProvider.ERROR);
+        } else {
+            MessageDialog.openError(getShell(), "Unexpected error", e.getMessage());
+        }
+
+        Activator.getDefault().getLog().log(e.getStatus());
+    }
+
+    protected void reportError(Throwable t) {
+        if ( t instanceof CoreException ) {
+            reportError((CoreException) t);
+            return;
+        }
+        
+        IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, t.getMessage(), t);
+        reportError(new CoreException(status));
+    }
+
 	public ChooseArchetypeWizardPage getChooseArchetypePage() {
 		return chooseArchetypePage;
 	}
@@ -99,6 +131,9 @@ public abstract class AbstractNewSlingAp
 	 * using wizard as execution context.
 	 */
 	public boolean performFinish() {
+
+        // TODO - should probably rely on exception handling here
+        final boolean[] success = new boolean[1];
         try {
 			getContainer().run(false, true, new IRunnableWithProgress() {
 
@@ -106,50 +141,20 @@ public abstract class AbstractNewSlingAp
 				public void run(IProgressMonitor monitor)
 						throws InvocationTargetException, InterruptedException {
 					try {
-						performFinish(monitor);
+                        success[0] = performFinish(monitor);
 					} catch (Exception e) {
-						// TODO proper logging
-						e.printStackTrace();
-						MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), 
-			                    SWT.OK | SWT.ICON_ERROR);
-			            messageBox.setText("Creating application failed");
-			            StringBuffer sb = new StringBuffer();
-			            Throwable t = e;
-			            while(t!=null) {
-			            	if (sb.length()!=0) {
-			            		sb.append(System.getProperty("line.separator"));
-			            	}
-			            	sb.append(t.getMessage());
-			            	t = t.getCause();
-			            }
-			            messageBox.setMessage(sb.toString());
-			            messageBox.open();
+                        throw new InvocationTargetException(e);
 					}
 				}
 				
 			});
-			return true;
+            return success[0];
         } catch (InterruptedException e) {
-        	// that's fine, the user interrupted - dont complain
+            Thread.currentThread().interrupt();
         	return false;
 		} catch (InvocationTargetException e) {
-			// TODO proper logging
-			e.printStackTrace();
-			MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), 
-                    SWT.OK | SWT.ICON_ERROR);
-            messageBox.setText("Creating application failed");
-            StringBuffer sb = new StringBuffer();
-            Throwable t = e;
-            while(t!=null) {
-            	if (sb.length()!=0) {
-            		sb.append(System.getProperty("line.separator"));
-            	}
-            	sb.append(t.getMessage());
-            	t = t.getCause();
-            }
-            messageBox.setMessage(sb.toString());
-            messageBox.open();
-			return false;
+            reportError(e.getTargetException());
+            return false;
 		}
 	}
         
@@ -168,9 +173,9 @@ public abstract class AbstractNewSlingAp
 		if (monitor.isCanceled()) {
 			return false;
 		}
-		IServer server = setupServerWizardPage.getOrCreateServer();
+        IServer server = setupServerWizardPage.getOrCreateServer(monitor);
 		monitor.worked(1);
-		if (monitor.isCanceled()) {
+        if (monitor.isCanceled() || server == null) {
 			return false;
 		}
 		
@@ -269,19 +274,6 @@ public abstract class AbstractNewSlingAp
 			return false;
 		}
 		
-		if (reactorProject!=null) {
-			ILaunchConfiguration launchConfig = 
-					DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(reactorProject.getFolder(".settings").getFolder(".launches").getFile("initial_install.launch"));
-			if (launchConfig!=null) {
-				ILaunch theLaunch = launchConfig.launch(ILaunchManager.RUN_MODE, monitor, true);
-				monitor.setTaskName("mvn install");
-				while(!theLaunch.isTerminated()) {
-					Thread.sleep(500);
-					monitor.worked(1);
-				}
-			}
-		}
-		
 		wc.getOriginal().publish(IServer.PUBLISH_FULL, monitor);
 		
 		// also add 'java 1.6' and 'jst.ejb 3.1'
@@ -307,6 +299,7 @@ public abstract class AbstractNewSlingAp
 		for (Iterator<IProject> it = projects.iterator(); it.hasNext();) {
 			IProject project = it.next();
 			MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(new MavenUpdateRequest(project, /*mavenConfiguration.isOffline()*/false, forceDependencyUpdate), monitor);
+			project.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
 		}
 	}
 
@@ -321,14 +314,7 @@ public abstract class AbstractNewSlingAp
 	}
 	
 	protected void configureReactorProject(IProject reactorProject, IProgressMonitor monitor) throws CoreException {
-		// temp hack: install the launch file
-		IFolder dotLaunches = reactorProject.getFolder(".settings").getFolder(".launches");
-		dotLaunches.create(true, true, monitor);
-		IFile launchFile = dotLaunches.getFile("initial_install.launch");
-		String l = MavenLaunchHelper.createMavenLaunchConfigMemento(reactorProject.getLocation().toOSString(), 
-				"install", null, false, null);
-		InputStream in = new ByteArrayInputStream(l.getBytes());
-		launchFile.create(in, true, monitor);
+		// nothing to be done
 	}
 	
 	public void init(IWorkbench workbench, IStructuredSelection selection) {

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ArchetypeParametersWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ArchetypeParametersWizardPage.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ArchetypeParametersWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ArchetypeParametersWizardPage.java Mon Sep 30 10:28:08 2013
@@ -19,6 +19,7 @@ package org.apache.sling.ide.eclipse.ui.
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import java.util.StringTokenizer;
 
 import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.archetype.metadata.RequiredProperty;
@@ -101,9 +102,9 @@ public class ArchetypeParametersWizardPa
 				dialogChanged();
 				if (!javaPackageModified) {
 					if (artifactId.getText().length()==0) {
-						javaPackage.setText(groupId.getText());
+						javaPackage.setText(getDefaultJavaPackage(groupId.getText(), ""));
 					} else {
-						javaPackage.setText(groupId.getText()+"."+artifactId.getText());
+						javaPackage.setText(getDefaultJavaPackage(groupId.getText(), artifactId.getText()));
 					}
 				}
 			}
@@ -118,10 +119,13 @@ public class ArchetypeParametersWizardPa
 		artifactId.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				dialogChanged();
+				if (javaPackageModified) {
+					return;
+				}
 				if (groupId.getText().length()==0) {
-					javaPackage.setText(artifactId.getText());
+					javaPackage.setText(getDefaultJavaPackage("", artifactId.getText()));
 				} else {
-					javaPackage.setText(groupId.getText()+"."+artifactId.getText());
+					javaPackage.setText(getDefaultJavaPackage(groupId.getText(), artifactId.getText()));
 				}
 			}
 		});
@@ -327,5 +331,25 @@ public class ArchetypeParametersWizardPa
 		}
 		return p;
 	}
+	
+	public static String getDefaultJavaPackage(String groupId, String artifactId) {
+		String name = (artifactId.isEmpty()) ? groupId : groupId+"."+artifactId;
+		StringBuffer sb = new StringBuffer();
+		StringTokenizer st = new StringTokenizer(name.replaceAll("-", "_"), ".");
+		while(st.hasMoreTokens()) {
+			String part = st.nextToken();
+			while(part.length()>0 && !Character.isJavaIdentifierStart(part.charAt(0))) {
+				part = part.substring(1);
+			}
+			if (part.length()==0) {
+				continue;
+			}
+			if (sb.length()!=0) {
+				sb.append(".");
+			}
+			sb.append(part);
+		}
+		return sb.toString();
+	}
 
 }
\ No newline at end of file

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java Mon Sep 30 10:28:08 2013
@@ -20,16 +20,16 @@ import java.lang.reflect.InvocationTarge
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.archetype.catalog.ArchetypeCatalog;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.m2e.core.internal.MavenPluginActivator;
@@ -51,8 +51,6 @@ import org.eclipse.swt.widgets.Directory
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.List;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.progress.IProgressService;
 
 @SuppressWarnings("restriction")
 public class ChooseArchetypeWizardPage extends WizardPage {
@@ -63,16 +61,19 @@ public class ChooseArchetypeWizardPage e
 	private Button useDefaultWorkspaceLocationButton;
 	private Label locationLabel;
 	private Combo locationCombo;
-	private final AbstractNewSlingApplicationWizard parent;
 
 	public ChooseArchetypeWizardPage(AbstractNewSlingApplicationWizard parent) {
 		super("chooseArchetypePage");
-		this.parent = parent;
 		setTitle("Choose Project Location and Archetype");
 		setDescription("This step defines the project location and archetype");
 		setImageDescriptor(parent.getLogo());
 	}
 
+    @Override
+    public AbstractNewSlingApplicationWizard getWizard() {
+        return (AbstractNewSlingApplicationWizard) super.getWizard();
+    }
+
 	public void createControl(Composite parent) {
 		Composite container = new Composite(parent, SWT.NULL);
 		GridLayout layout = new GridLayout();
@@ -156,7 +157,6 @@ public class ChooseArchetypeWizardPage e
 			}
 		});
 		
-		initialize();
 		setPageComplete(false);
 		setControl(container);
 	}
@@ -171,12 +171,25 @@ public class ChooseArchetypeWizardPage e
 		return a;
 	}
 	
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(boolean visible) {
+        super.setVisible(visible);
+        if (visible && knownArchetypesList.getItemCount() == 0) {
+            // initialize as late as possible to take advantage of the error reporting
+            // and progress from the parent wizard
+            initialize();
+        }
+    }
+
 	private void initialize() {
 		knownArchetypesList.add(LOADING_PLEASE_WAIT);
-		IWorkbench workbench = DebugUIPlugin.getDefault().getWorkbench();
-		IProgressService progressService = workbench.getProgressService();
 		try {
-			progressService.run(true, false, new IRunnableWithProgress() {
+            getContainer().run(true, false, new IRunnableWithProgress() {
 					
 				@Override
 				public void run(IProgressMonitor monitor) throws InvocationTargetException,
@@ -186,42 +199,46 @@ public class ChooseArchetypeWizardPage e
 				    monitor.worked(1);
 					
 				    // optionally allow the parent to install any archetypes
-				    parent.installArchetypes();
+                    getWizard().installArchetypes();
 				    
 				    Collection<ArchetypeCatalogFactory> archetypeCatalogs = manager.getArchetypeCatalogs();
 				    monitor.worked(2);
 				    ArrayList<Archetype> list = new ArrayList<Archetype>();
-				    for(ArchetypeCatalogFactory catalog : archetypeCatalogs) {
+                    for (ArchetypeCatalogFactory catalogFactory : archetypeCatalogs) {
 				        try {
-						  @SuppressWarnings("unchecked")
-						  java.util.List<Archetype> arcs = catalog.getArchetypeCatalog().getArchetypes();
+                            ArchetypeCatalog catalog = catalogFactory.getArchetypeCatalog();
+                            @SuppressWarnings("unchecked")
+                            java.util.List<Archetype> arcs = catalog.getArchetypes();
+                            for (Archetype a : arcs) {
+                                if (a.getVersion().endsWith("SNAPSHOT")) {
+                                    System.out.println("got SNAPSHOT archetype " + a);
+                                }
+                            }
+
 				          if(arcs != null) {
 				            list.addAll(arcs);
 				          }
-				        } catch(Exception ce) {
-				        	ce.printStackTrace();
+                        } catch (CoreException ce) {
+                            throw new InvocationTargetException(ce);
 				        }
 				      }
 				    monitor.worked(1);
-				    for (Iterator<Archetype> it = list
-							.iterator(); it.hasNext();) {
-						Archetype archetype2 = it.next();
-						if (parent.acceptsArchetype(archetype2)) {
-							String key = keyFor(archetype2);
-							archetypesMap.put(key, archetype2);
-						}
-						
-					}
+                    for (Archetype archetype2 : list) {
+                        if (getWizard().acceptsArchetype(archetype2)) {
+                            String key = keyFor(archetype2);
+                            System.out.println("Got archetype match for archetype " + archetype2 + ", key " + key);
+                            archetypesMap.put(key, archetype2);
+                        }
+                    }
+
 				    monitor.worked(1);
 			        Display.getDefault().asyncExec(new Runnable() {
 			            public void run() {
 			            	Set<String> keys = archetypesMap.keySet();
 			            	knownArchetypesList.removeAll();
-			            	for (Iterator<String> it = keys.iterator(); it
-									.hasNext();) {
-								String aKey = it.next();
-								knownArchetypesList.add(aKey);
-							}
+                            for (String aKey : keys) {
+                                knownArchetypesList.add(aKey);
+                            }
 			            	knownArchetypesList.pack();
 			            }
 			          });
@@ -230,11 +247,9 @@ public class ChooseArchetypeWizardPage e
 				}
 			});
 		} catch (InvocationTargetException e) {
-			// TODO proper logging
-			e.printStackTrace();
+            getWizard().reportError(e.getTargetException());
 		} catch (InterruptedException e) {
-			// TODO proper logging
-			e.printStackTrace();
+		    Thread.currentThread().interrupt();
 		}
 	}
 
@@ -266,6 +281,7 @@ public class ChooseArchetypeWizardPage e
 		setPageComplete(message == null);
 	}
 
+
 	public IPath getLocation() {
 		if (!useDefaultWorkspaceLocationButton.getSelection() && 
 				locationCombo.getText().length()>0) {

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java Mon Sep 30 10:28:08 2013
@@ -23,6 +23,7 @@ import org.apache.maven.archetype.catalo
 import org.apache.sling.ide.eclipse.m2e.EmbeddedArchetypeInstaller;
 import org.apache.sling.ide.eclipse.m2e.internal.Activator;
 import org.apache.sling.ide.eclipse.m2e.internal.SharedImages;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.resource.ImageDescriptor;
 
 public class NewSlingBundleWizard extends AbstractNewSlingApplicationWizard {
@@ -52,9 +53,10 @@ public class NewSlingBundleWizard extend
 			
 			archetypeInstaller.installArchetype();
 		} catch (IOException e) {
-			// TODO proper logging
-			e.printStackTrace();
-		}
+            reportError(e);
+        } catch (CoreException e) {
+            reportError(e);
+        }
 	}
 
 	@Override

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java Mon Sep 30 10:28:08 2013
@@ -16,34 +16,22 @@
  */
 package org.apache.sling.ide.eclipse.ui.wizards.np;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.PartSource;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
+import org.apache.sling.ide.artifacts.EmbeddedArtifact;
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
 import org.apache.sling.ide.eclipse.m2e.internal.Activator;
+import org.apache.sling.ide.osgi.OsgiClient;
+import org.apache.sling.ide.osgi.OsgiClientException;
+import org.apache.sling.ide.osgi.OsgiClientFactory;
+import org.apache.sling.ide.transport.RepositoryInfo;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
@@ -65,10 +53,11 @@ import org.eclipse.wst.server.core.IServ
 import org.eclipse.wst.server.core.IServerType;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.ServerCore;
+import org.osgi.framework.Version;
 
 public class SetupServerWizardPage extends WizardPage {
 	
-	private Button useExistingServer;
+    private Button useExistingServer;
 	private Combo existingServerCombo;
 	private Button setupNewServer;
 	private Text newServerName;
@@ -86,6 +75,11 @@ public class SetupServerWizardPage exten
 		setImageDescriptor(parent.getLogo());
 	}
 
+    @Override
+    public AbstractNewSlingApplicationWizard getWizard() {
+        return (AbstractNewSlingApplicationWizard) super.getWizard();
+    }
+
 	public void createControl(Composite parent) {
 		Composite container = new Composite(parent, SWT.NULL);
 		GridLayout layout = new GridLayout();
@@ -210,6 +204,7 @@ public class SetupServerWizardPage exten
 		useExistingServer.addSelectionListener(radioListener);
 		setupNewServer.addSelectionListener(radioListener);
 	    useExistingServer.setSelection(false);
+	    existingServerCombo.setEnabled(false);
 	    setupNewServer.setSelection(true);
 	    installToolingSupportBundle.setSelection(true);
 	    
@@ -284,90 +279,24 @@ public class SetupServerWizardPage exten
 	}
 	
 
-	private boolean containsToolingSupportBundle() {
-        String hostname = getHostname();
-        int launchpadPort = getPort();
-        GetMethod method = new GetMethod("http://"+hostname+":"+launchpadPort+"/system/console/bundles/org.apache.sling.tooling.support.install");
-        
-        try {
-			return getHttpClient("admin", "admin").executeMethod(method) == 200;
-		} catch (IOException e) {
-			// TODO proper logging
-			e.printStackTrace();
-			return false;
-		}
-    }
-    
-    /**
-     * Get the http client
-     * @param user 
-     * @param password 
-     */
-    protected HttpClient getHttpClient(String user, String password) {
-        final HttpClient client = new HttpClient();
-        client.getHttpConnectionManager().getParams().setConnectionTimeout(
-            5000);
-
-        // authentication stuff
-        client.getParams().setAuthenticationPreemptive(true);
-        Credentials defaultcreds = new UsernamePasswordCredentials(user,
-            password);
-        client.getState().setCredentials(AuthScope.ANY, defaultcreds);
-
-        return client;
-    }
+    private Version getToolingSupportBundleVersion() throws OsgiClientException {
 
-    protected int post(String targetURL, String user, String passwd, InputStream in, String fileName) throws IOException {
-        // append pseudo path after root URL to not get redirected for nothing
-        final PostMethod filePost = new PostMethod(targetURL + "/install");
-
-        try {
-            // set referrer
-            filePost.setRequestHeader("referer", "about:blank");
-
-            List<Part> partList = new ArrayList<Part>();
-            partList.add(new StringPart("action", "install"));
-            partList.add(new StringPart("_noredir_", "_noredir_"));
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            copyStream(in, baos);
-			PartSource partSource = new ByteArrayPartSource(fileName, baos.toByteArray());
-            partList.add(new FilePart("bundlefile", partSource));
-            partList.add(new StringPart("bundlestart", "start"));
-
-            Part[] parts = partList.toArray(new Part[partList.size()]);
-
-            filePost.setRequestEntity(new MultipartRequestEntity(parts,
-                filePost.getParams()));
-
-            int status = getHttpClient(user, passwd).executeMethod(filePost);
-            return status;
-        } finally {
-            filePost.releaseConnection();
-        }
+        return newOsgiClient().getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
     }
+    
+    private OsgiClient newOsgiClient() {
 
-    private void copyStream(InputStream in, OutputStream os) throws IOException {
-		final byte[] bytes = new byte[4*1024];
-		while (true) {
-			final int numRead = in.read(bytes);
-			if (numRead < 0) {
-				break;
-			}
-			os.write(bytes, 0, numRead);
-		}
-	}
-
-    private int installToolingSupportBundle() throws IOException {
         String hostname = getHostname();
         int launchpadPort = getPort();
-        String targetURL = "http://"+hostname+":"+launchpadPort+"/system/console";
-    	String fileName = "org.apache.sling.tooling.support.install-0.0.1-SNAPSHOT.jar";
-		URL jarUrl = Activator.getDefault().getBundle().getResource(
-    			"target/sling-tooling-support-install/"+fileName);
-		return post(targetURL, "admin", "admin", jarUrl.openStream(), fileName);
+
+        OsgiClientFactory factory = Activator.getDefault().getOsgiClientFactory();
+
+        // TODO remove credential hardcoding
+        return factory.createOsgiClient(new RepositoryInfo("admin", "admin", "http://" + hostname + ":" + launchpadPort
+                + "/"));
     }
 	
-	IServer getOrCreateServer() {
+    IServer getOrCreateServer(IProgressMonitor monitor) {
 		if (useExistingServer.getSelection()) {
 			String key = existingServerCombo.getItem(existingServerCombo.getSelectionIndex());
 			return serversMap.get(key);
@@ -383,48 +312,65 @@ public class SetupServerWizardPage exten
 				}
 			}
 			
-			boolean installedLocally = false;
+            Version finalVersion = null;
+			
 			if (installToolingSupportBundle.getSelection()) {
-				if (containsToolingSupportBundle()) {
-					// then nothing to overwrite
-					installedLocally = true;
-				} else {
+                Version installedVersion;
+                try {
+                    installedVersion = getToolingSupportBundleVersion();
+                } catch (OsgiClientException e) {
+                    getWizard().reportError(e);
+                    return null;
+                }
+                finalVersion = installedVersion;
+                EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
+                EmbeddedArtifact toolingSupportBundle = artifactsLocator.loadToolingSupportBundle();
+                Version ourVersion = new Version(toolingSupportBundle.getVersion());
+
+                if (installedVersion == null || ourVersion.compareTo(installedVersion) > 0) {
 					// then auto-install it if possible
 					try {
-						int status = installToolingSupportBundle();
-						
-						if (status!=HttpStatus.SC_OK) {
-							MessageDialog.openError(getShell(), "Could not install sling tooling support bundle", 
-									"Could not install sling tooling support bundle: "+status);
-						} else {
-							installedLocally = true;
-						}
+
+                        InputStream contents = null;
+                        try {
+                            contents = toolingSupportBundle.openInputStream();
+                            newOsgiClient().installBundle(contents, toolingSupportBundle.getName());
+                        } finally {
+                            IOUtils.closeQuietly(contents);
+                        }
+                        finalVersion = ourVersion;
 					} catch (IOException e) {
-						//TODO proper logging
-						e.printStackTrace();
-						MessageDialog.openError(getShell(), "Could not install sling tooling support bundle", 
-								"Could not install sling tooling support bundle: "+e.getMessage());
-					}
+                        getWizard().reportError(e);
+                        return null;
+                    } catch (OsgiClientException e) {
+                        getWizard().reportError(e);
+                        return null;
+                    }
 				}
 			}
 			
 			IRuntimeType serverRuntime = ServerCore.findRuntimeType("org.apache.sling.ide.launchpadRuntimeType");
 			try {
-				IRuntime runtime = serverRuntime.createRuntime(null, new NullProgressMonitor());
-				runtime = runtime.createWorkingCopy().save(true, new NullProgressMonitor());
-				IServerWorkingCopy wc = serverType.createServer(null, null, runtime, new NullProgressMonitor());
+                // TODO pass in username and password
+                // TODO there should be a nicer API for creating this, and also a central place for defaults
+                IRuntime runtime = serverRuntime.createRuntime(null, monitor);
+                runtime = runtime.createWorkingCopy().save(true, monitor);
+                IServerWorkingCopy wc = serverType.createServer(null, null, runtime, monitor);
 				wc.setHost(getHostname());
 				wc.setName(newServerName.getText() + " (external)");
 				wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, getPort());
 				wc.setAttribute(ISlingLaunchpadServer.PROP_DEBUG_PORT, Integer.parseInt(newServerDebugPort.getText()));
-				wc.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installedLocally);
-				wc.setAttribute("auto-publish-setting", 2); // 2: automatically publish when resources change
-				wc.setAttribute("auto-publish-time", 0);    // 0: zero delay after a resource change (and the builder was kicked, I guess)
+                wc.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installToolingSupportBundle.getSelection());
+                wc.setAttribute("auto-publish-setting", ISlingLaunchpadServer.PUBLISH_STATE_RESOURCE_CHANGE);
+                wc.setAttribute("auto-publish-time", 0);
+                if (finalVersion != null) {
+                    wc.setAttribute(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
+                        EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME), finalVersion.toString());
+                }
 				wc.setRuntime(runtime);
-				return wc.save(true, new NullProgressMonitor());
+                return wc.save(true, monitor);
 			} catch (CoreException e) {
-				// TODO proper logging
-				e.printStackTrace();
+                getWizard().reportError(e);
 			}
 			return null;
 		}

Modified: sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF Mon Sep 30 10:28:08 2013
@@ -5,16 +5,19 @@ Bundle-SymbolicName: org.apache.sling.id
 Bundle-Activator: org.apache.sling.ide.eclipse.ui.internal.Activator
 Bundle-Version: 0.0.1.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ClassPath: .
+Bundle-ClassPath: .,
+ lib/decentxml-1.4.jar
 Import-Package: org.apache.commons.httpclient;version="3.1.0",
  org.apache.commons.httpclient.auth;version="3.1.0",
  org.apache.commons.httpclient.methods;version="3.1.0",
  org.apache.commons.httpclient.methods.multipart;version="3.1.0",
  org.apache.commons.httpclient.params;version="3.1.0",
- org.apache.maven.artifact.repository,
- org.apache.maven.model,
+ org.apache.commons.io;version="2.0.1",
+ org.apache.jackrabbit.util,
+ org.apache.sling.ide.artifacts,
  org.apache.sling.ide.eclipse.core,
  org.apache.sling.ide.filter,
+ org.apache.sling.ide.osgi,
  org.apache.sling.ide.serialization,
  org.apache.sling.ide.transport,
  org.apache.sling.ide.util,
@@ -46,7 +49,6 @@ Import-Package: org.apache.commons.httpc
  org.eclipse.jface.wizard,
  org.eclipse.jst.common.project.facet.core,
  org.eclipse.jst.server.core,
- org.eclipse.m2e.core.internal.archetype,
  org.eclipse.swt,
  org.eclipse.swt.events,
  org.eclipse.swt.layout,
@@ -66,8 +68,7 @@ Import-Package: org.apache.commons.httpc
  org.osgi.framework,
  org.osgi.service.component,
  org.osgi.service.event;version="1.3.0",
- org.osgi.util.tracker;version="1.5.0",
- org.sonatype.aether.repository
+ org.osgi.util.tracker;version="1.5.0"
 Bundle-ActivationPolicy: lazy
 Require-Bundle: org.eclipse.wst.common.project.facet.ui,
  org.eclipse.ui.navigator;bundle-version="3.5.101",
@@ -76,12 +77,13 @@ Require-Bundle: org.eclipse.wst.common.p
  org.eclipse.core.resources,
  org.eclipse.ui.ide,
  org.eclipse.core.runtime,
- org.eclipse.m2e.core;bundle-version="1.4.0",
- org.eclipse.m2e.archetype.common;bundle-version="1.4.0",
  org.eclipse.ui.console,
  org.eclipse.jdt.ui,
  org.apache.sling.ide.eclipse-core,
- org.eclipse.ui.views.properties.tabbed
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.ui.workbench,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors
 Service-Component: OSGI-INF/*.xml
 Export-Package: org.apache.sling.ide.eclipse.ui,
  org.apache.sling.ide.eclipse.ui.wizards

Modified: sling/trunk/tooling/ide/eclipse-ui/build.properties
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/build.properties?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/build.properties (original)
+++ sling/trunk/tooling/ide/eclipse-ui/build.properties Mon Sep 30 10:28:08 2013
@@ -2,5 +2,6 @@ bin.includes = plugin.xml,\
                META-INF/,\
                .,\
                icons/,\
-               OSGI-INF/
+               OSGI-INF/,\
+               lib/decentxml-1.4.jar
 source.. = src/

Modified: sling/trunk/tooling/ide/eclipse-ui/plugin.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/plugin.xml?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-ui/plugin.xml Mon Sep 30 10:28:08 2013
@@ -220,6 +220,16 @@
            policy="InvokeAlwaysRegardlessOfSuppressedExt"
            suppressedExtensionId="org.eclipse.ui.navigator.resourceContent">
      </override>
+     <commonSorter
+           class="org.apache.sling.ide.eclipse.ui.nav.Sorter">
+        <parentExpression>
+           <or>
+              <adapt
+                    type="org.apache.sling.ide.eclipse.ui.nav.model.JcrNode">
+              </adapt>
+           </or>
+        </parentExpression>
+     </commonSorter>
         
       </navigatorContent>
    </extension>
@@ -337,11 +347,10 @@
    </extension>
 
    <extension
-         id="org.apache.sling.ide.eclipse.ui.pluginJcrNodeToolSet"
          point="org.eclipse.ui.popupMenus">
       <objectContribution
             adaptable="true"
-            id="org.apache.sling.ide.eclipse.ui.pluginJcrNodeToolSet"
+            id="org.apache.sling.ide.eclipse.ui.pluginDomNodeToolSet"
             objectClass="org.apache.sling.ide.eclipse.ui.nav.model.JcrNode">
          <action
                class="org.apache.sling.ide.eclipse.ui.actions.JcrNewNodeAction"
@@ -374,6 +383,28 @@
    </extension>
 
    <extension
+         point="org.eclipse.ui.popupMenus">
+      <objectContribution
+            adaptable="true"
+            id="org.apache.sling.ide.eclipse.ui.pluginGeneralToolSet"
+            objectClass="org.apache.sling.ide.eclipse.ui.nav.model.JcrNode">
+         <action
+               class="org.apache.sling.ide.eclipse.ui.actions.OpenHtmlInBrowserAction"
+               icon="icons/obj16/sling.gif"
+               id="org.apache.sling.ide.eclipse.ui.actionsOpenHtmlInBrowserAction"
+               label="&amp;Open .html (on server) in browser"
+               menubarPath="jcr">
+         </action>
+         <visibility>
+               <objectState
+                     name="browseableNode"
+                     value="true">
+               </objectState>
+         </visibility>
+      </objectContribution>
+   </extension>
+
+   <extension
          id="org.apache.sling.ide.eclipse.ui.pluginNonJcrNodeToolSet"
          point="org.eclipse.ui.popupMenus">
       <objectContribution
@@ -401,6 +432,13 @@
                label="&amp;Delete JCR Node"
                toolbarPath="common.new.menu/jcr">
          </action>
+         <action
+               class="org.apache.sling.ide.eclipse.ui.actions.OpenHtmlInBrowserAction"
+               icon="icons/obj16/sling.gif"
+               id="org.apache.sling.ide.eclipse.ui.actionsOpenHtmlInBrowserAction"
+               label="&amp;Open .html (on server) in browser"
+               menubarPath="common.open.menu/jcr">
+         </action>
          <visibility>
                <objectState
                      name="nonDomNode"
@@ -431,6 +469,20 @@
             </and>
          </enablement>
       </decorator>
+      <decorator
+            adaptable="true"
+            class="org.apache.sling.ide.eclipse.ui.internal.ServerModuleDecorator"
+            id="org.apache.sling.ide.eclipse-ui.serverModuleDecorator"
+            label="ServerModule Decorator"
+            lightweight="true"
+            location="BOTTOM_LEFT"
+            state="true">
+         <enablement>
+           <objectClass
+                 name="org.eclipse.wst.server.ui.IServerModule">
+           </objectClass>
+         </enablement>
+      </decorator>
    </extension>
    <extension
          point="org.eclipse.ui.navigator.linkHelper">
@@ -450,6 +502,14 @@
                </instanceof>
          </selectionEnablement>
       </linkHelper>
+   </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.apache.sling.ide.eclipse.ui.editors.WebBrowser"
+            id="org.apache.sling.ide.eclipse.ui.editors.WebBrowser"
+            name="WebBrowser">
+      </editor>
    </extension> 
    
 </plugin>    

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/WhitelabelSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/WhitelabelSupport.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/WhitelabelSupport.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/WhitelabelSupport.java Mon Sep 30 10:28:08 2013
@@ -22,6 +22,6 @@ import org.eclipse.jface.resource.ImageD
 public class WhitelabelSupport {
 
 	// allow customization of the JCR NODE ICON
-    public static ImageDescriptor JCR_NODE_ICON = SharedImages.SLING_ICON;
+    public static ImageDescriptor JCR_NODE_ICON = SharedImages.NT_UNSTRUCTURED_ICON;
 
 }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java Mon Sep 30 10:28:08 2013
@@ -16,8 +16,10 @@
  */
 package org.apache.sling.ide.eclipse.ui.internal;
 
+import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
 import org.apache.sling.ide.eclipse.core.ServiceUtil;
 import org.apache.sling.ide.filter.FilterLocator;
+import org.apache.sling.ide.osgi.OsgiClientFactory;
 import org.apache.sling.ide.serialization.SerializationManager;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -32,6 +34,8 @@ public class Activator extends AbstractU
     private ServiceTracker<SerializationManager, SerializationManager> serializationManager;
     private ServiceTracker<FilterLocator, FilterLocator> filterLocator;
     private ServiceTracker<EventAdmin, EventAdmin> eventAdmin;
+    private ServiceTracker<EmbeddedArtifactLocator, EmbeddedArtifactLocator> artifactLocator;
+    private ServiceTracker<OsgiClientFactory, OsgiClientFactory> osgiClientFactory;
 
     public static Activator getDefault() {
 
@@ -52,6 +56,14 @@ public class Activator extends AbstractU
         eventAdmin = new ServiceTracker<EventAdmin, EventAdmin>(context, EventAdmin.class, null);
         eventAdmin.open();
 
+        artifactLocator = new ServiceTracker<EmbeddedArtifactLocator, EmbeddedArtifactLocator>(context,
+                EmbeddedArtifactLocator.class, null);
+        artifactLocator.open();
+
+        osgiClientFactory = new ServiceTracker<OsgiClientFactory, OsgiClientFactory>(context, OsgiClientFactory.class,
+                null);
+        osgiClientFactory.open();
+
         INSTANCE = this;
     }
 
@@ -61,6 +73,8 @@ public class Activator extends AbstractU
         serializationManager.close();
         filterLocator.close();
         eventAdmin.close();
+        artifactLocator.close();
+        osgiClientFactory.close();
 
         super.stop(context);
     }
@@ -76,4 +90,13 @@ public class Activator extends AbstractU
     public EventAdmin getEventAdmin() {
         return ServiceUtil.getNotNull(eventAdmin);
     }
+
+    public EmbeddedArtifactLocator getArtifactLocator() {
+
+        return ServiceUtil.getNotNull(artifactLocator);
+    }
+
+    public OsgiClientFactory getOsgiClientFactory() {
+        return ServiceUtil.getNotNull(osgiClientFactory);
+    }
 }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ConnectionEditorSection.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ConnectionEditorSection.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ConnectionEditorSection.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ConnectionEditorSection.java Mon Sep 30 10:28:08 2013
@@ -54,6 +54,7 @@ public class ConnectionEditorSection ext
     private Text passwordText;
     private ISlingLaunchpadServer launchpadServer;
     private PropertyChangeListener serverListener;
+    private boolean updating = false;
 
     @Override
     public void createSection(Composite parent) {
@@ -128,18 +129,25 @@ public class ConnectionEditorSection ext
 
             @Override
             public void propertyChange(PropertyChangeEvent evt) {
-
-                if (ISlingLaunchpadServer.PROP_PORT.equals(evt.getPropertyName())) {
-                    portText.setText(((Integer) evt.getNewValue()).toString());
-                } else if (ISlingLaunchpadServer.PROP_DEBUG_PORT.equals(evt.getPropertyName())) {
-                    debugPortText.setText(((Integer) evt.getNewValue()).toString());
-                } else if (ISlingLaunchpadServer.PROP_CONTEXT_PATH.equals(evt.getPropertyName())) {
-                    contextPathText.setText((String) evt.getNewValue());
-                } else if (ISlingLaunchpadServer.PROP_USERNAME.equals(evt.getPropertyName())) {
-                    usernameText.setText((String) evt.getNewValue());
-                } else if (ISlingLaunchpadServer.PROP_PASSWORD.equals(evt.getPropertyName())) {
-                    passwordText.setText((String) evt.getNewValue());
-                }
+            	if (updating) {
+            		return;
+            	}
+            	updating = true;
+            	try{
+	                if (ISlingLaunchpadServer.PROP_PORT.equals(evt.getPropertyName())) {
+	                    portText.setText(((Integer) evt.getNewValue()).toString());
+	                } else if (ISlingLaunchpadServer.PROP_DEBUG_PORT.equals(evt.getPropertyName())) {
+	                    debugPortText.setText(((Integer) evt.getNewValue()).toString());
+	                } else if (ISlingLaunchpadServer.PROP_CONTEXT_PATH.equals(evt.getPropertyName())) {
+	                    contextPathText.setText((String) evt.getNewValue());
+	                } else if (ISlingLaunchpadServer.PROP_USERNAME.equals(evt.getPropertyName())) {
+	                    usernameText.setText((String) evt.getNewValue());
+	                } else if (ISlingLaunchpadServer.PROP_PASSWORD.equals(evt.getPropertyName())) {
+	                    passwordText.setText((String) evt.getNewValue());
+	                }
+            	} finally {
+            		updating = false;
+            	}
             }
         };
 
@@ -167,28 +175,36 @@ public class ConnectionEditorSection ext
         ModifyListener listener = new ModifyListener() {
             @Override
             public void modifyText(ModifyEvent e) {
-            	if (e.getSource() == portText) {
-                    try {
-                        int port = Integer.parseInt(portText.getText());
-                        execute(new SetServerPortCommand(server, port));
-                    } catch (NumberFormatException ex) {
-                        // shucks
-                    }
-                } else if (e.getSource() == debugPortText) {
-                    try {
-                        int debugPort = Integer.parseInt(debugPortText.getText());
-                        execute(new SetServerDebugPortCommand(server, debugPort));
-                    } catch (NumberFormatException ex) {
-                        // shucks
-                    	ex.printStackTrace();
-                    }
-                } else if (e.getSource() == contextPathText) {
-                    execute(new SetServerContextPathCommand(server, contextPathText.getText()));
-                } else if (e.getSource() == usernameText) {
-                    execute(new SetServerUsernameCommand(server, usernameText.getText()));
-                } else if (e.getSource() == passwordText) {
-                    execute(new SetServerPasswordCommand(server, passwordText.getText()));
-                }
+            	if (updating) {
+            		return;
+            	}
+            	updating = true;
+            	try{
+	            	if (e.getSource() == portText) {
+	                    try {
+	                        int port = Integer.parseInt(portText.getText());
+	                        execute(new SetServerPortCommand(server, port));
+	                    } catch (NumberFormatException ex) {
+	                        // shucks
+	                    }
+	                } else if (e.getSource() == debugPortText) {
+	                    try {
+	                        int debugPort = Integer.parseInt(debugPortText.getText());
+	                        execute(new SetServerDebugPortCommand(server, debugPort));
+	                    } catch (NumberFormatException ex) {
+	                        // shucks
+	                    	ex.printStackTrace();
+	                    }
+	                } else if (e.getSource() == contextPathText) {
+	                    execute(new SetServerContextPathCommand(server, contextPathText.getText()));
+	                } else if (e.getSource() == usernameText) {
+	                    execute(new SetServerUsernameCommand(server, usernameText.getText()));
+	                } else if (e.getSource() == passwordText) {
+	                    execute(new SetServerPasswordCommand(server, passwordText.getText()));
+	                }
+            	} finally {
+            		updating = false;
+            	}
             }
         };
 

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportContentAction.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportContentAction.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportContentAction.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportContentAction.java Mon Sep 30 10:28:08 2013
@@ -56,6 +56,10 @@ public class ImportContentAction impleme
 
                 IModule module = ServerUtil.getModule(project);
 
+                if (module == null) {
+                    continue;
+                }
+
                 if (!module.getModuleType().getId().equals("sling.content")) {
                     continue;
                 }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java Mon Sep 30 10:28:08 2013
@@ -16,29 +16,13 @@
  */
 package org.apache.sling.ide.eclipse.ui.internal;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
 
-import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
-import org.apache.sling.ide.eclipse.core.ServerUtil;
-import org.apache.sling.ide.filter.Filter;
-import org.apache.sling.ide.filter.FilterLocator;
-import org.apache.sling.ide.filter.FilterResult;
+import org.apache.sling.ide.serialization.SerializationException;
 import org.apache.sling.ide.serialization.SerializationManager;
-import org.apache.sling.ide.transport.Command;
-import org.apache.sling.ide.transport.Repository;
-import org.apache.sling.ide.transport.RepositoryException;
-import org.apache.sling.ide.transport.ResourceProxy;
-import org.apache.sling.ide.transport.Result;
 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.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Status;
@@ -54,7 +38,8 @@ import org.eclipse.wst.server.core.IServ
  * import.
  */
 public class ImportWizard extends Wizard implements IImportWizard {
-	private ImportWizardPage mainPage;
+
+    private ImportWizardPage mainPage;
     private SerializationManager serializationManager;
 
 	/**
@@ -80,79 +65,27 @@ public class ImportWizard extends Wizard
         final IServer server = mainPage.getServer();
 
         IPath destinationPath = mainPage.getResourcePath();
-		
+
         final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(destinationPath.segments()[0]);
         final IPath projectRelativePath = destinationPath.removeFirstSegments(1);
-        final String repositoryPath = mainPage.getRepositoryPath();
         final IFile filterFile = mainPage.getFilterFile();
-        try {
-            getContainer().run(false, true, new IRunnableWithProgress() {
-
-                @Override
-                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-                    Repository repository = ServerUtil.getRepository(server, monitor);
-
-                    monitor.setTaskName("Loading configuration...");
-                    ISlingLaunchpadServer launchpad = (ISlingLaunchpadServer) server.loadAdapter(
-                            ISlingLaunchpadServer.class, monitor);
-
-                    int oldPublishState = launchpad.getPublishState();
-                    // TODO disabling publish does not work; since the publish is done async
-                    // Not sure if there is a simple workaround. Anyway, the only side effect is that we
-                    // make too many calls after the import, functionality is not affected
-                    if (server.canPublish().isOK() && oldPublishState != ISlingLaunchpadServer.PUBLISH_STATE_NEVER) {
-                        launchpad.setPublishState(ISlingLaunchpadServer.PUBLISH_STATE_NEVER, monitor);
-                    }
-
-                    Filter filter = null;
-                    if (filterFile != null && filterFile.exists()) {
-                        FilterLocator filterLocator = Activator.getDefault().getFilterLocator();
-                        InputStream contents = null;
-                        try {
-                            contents = filterFile.getContents();
-                            filter = filterLocator.loadFilter(contents);
-                        } catch (IOException e) {
-                            throw new InvocationTargetException(e);
-                        } catch (CoreException e) {
-                            throw new InvocationTargetException(e);
-                        } finally {
-                            if (contents != null) {
-                                try {
-                                    contents.close();
-                                } catch (IOException e) {
-                                    // don't care
-                                }
-                            }
-                        }
-                    }
-                    monitor.worked(5);
-
-                    try {
-
-                        // TODO: We should try to make this give 'nice' progress feedback (aka here's what I'm
-                        // processing)
-                        monitor.setTaskName("Importing...");
-                        monitor.worked(10);
-
-                        // we create the root node and assume this is a folder
-                        createRoot(project, projectRelativePath, repositoryPath);
-
-                        crawlChildrenAndImport(repository, filter, repositoryPath, project, projectRelativePath);
-
-                        monitor.setTaskName("Import Complete");
-                        monitor.worked(100);
-                    } catch (Exception e) {
-                        throw new InvocationTargetException(e);
-                    } finally {
-                        if (oldPublishState != ISlingLaunchpadServer.PUBLISH_STATE_NEVER) {
-                            launchpad.setPublishState(oldPublishState, monitor);
-                        }
-                        monitor.done();
-                        }
-
+        IRunnableWithProgress runnable = new IRunnableWithProgress() {
+            @Override
+            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+
+                try {
+                    new ImportRepositoryContentAction(server, filterFile, projectRelativePath, project,
+                            serializationManager).run(monitor);
+                } catch (SerializationException e) {
+                    throw new InvocationTargetException(e);
+                } finally {
+                    serializationManager.destroy();
                 }
+            }
+        };
 
-            });
+        try {
+            getContainer().run(false, true, runnable);
         } catch (InvocationTargetException e) {
             Throwable cause = e.getCause();
             mainPage.setErrorMessage("Import error : " + cause.getMessage()
@@ -191,110 +124,4 @@ public class ImportWizard extends Wizard
 		super.addPages();
 		addPage(mainPage);
 	}
-	
-    private void createRoot(final IProject project, final IPath projectRelativePath, final String repositoryPath)
-            throws CoreException {
-
-        IPath rootImportPath = projectRelativePath.append(repositoryPath);
-
-        for (int i = rootImportPath.segmentCount() - 1; i > 0; i--)
-            createFolder(project, rootImportPath.removeLastSegments(i));
-    }
-
-	        /**
-     * Crawls the repository and recursively imports founds resources
-     * 
-     * @param repository the sling repository to import from
-     * @param filter
-     * @param path the current path to import from
-     * @param project the project to create resources in
-     * @param projectRelativePath the path, relative to the project root, where the resources should be created
-     * @param tracer
-     * @throws JSONException
-     * @throws RepositoryException
-     * @throws CoreException
-     * @throws IOException
-     */
-	// TODO: This probably should be pushed into the service layer	
-    private void crawlChildrenAndImport(Repository repository, Filter filter, String path, IProject project,
-            IPath projectRelativePath) throws RepositoryException, CoreException, IOException {
-
-        System.out.println("crawlChildrenAndImport(" + repository + ", " + path + ", " + project + ", "
-                + projectRelativePath + ")");
-
-        ResourceProxy resource = executeCommand(repository.newListChildrenNodeCommand(path));
-        String primaryType = (String) resource.getProperties().get(Repository.JCR_PRIMARY_TYPE);
- 
-		if (Repository.NT_FILE.equals(primaryType)){
-            importFile(repository, path, project, projectRelativePath);
-		}else if (Repository.NT_FOLDER.equals(primaryType)){
-			createFolder(project, projectRelativePath.append(path));
-		}else if(Repository.NT_RESOURCE.equals(primaryType)){
-			//DO NOTHING
-        } else {
-			createFolder(project, projectRelativePath.append(path));
-            Map<String, Object> content = executeCommand(repository.newGetNodeContentCommand(path));
-            
-            String out = serializationManager.buildSerializationData(content);
-            if (out != null) {
-                createFile(project, projectRelativePath.append(serializationManager.getSerializationFilePath(path)),
-                    out.getBytes("UTF-8"));
-            }
-		}
-
-        System.out.println("Children: " + resource.getChildren());
-
-        for (ResourceProxy child : resource.getChildren()) {
-
-            if (Repository.NT_RESOURCE.equals(child.getProperties().get(Repository.JCR_PRIMARY_TYPE))) {
-                continue;
-            }
-
-            if (filter != null) {
-                FilterResult filterResult = filter.filter(child.getPath());
-                if (filterResult == FilterResult.DENY) {
-                    continue;
-                }
-            }
-
-            crawlChildrenAndImport(repository, filter, child.getPath(), project,
-                    projectRelativePath);
-		}
-	}
-
-    private <T> T executeCommand(Command<T> command) throws RepositoryException {
-		
-		Result<T> result = command.execute();
-		return result.get();
-	}	
-	
-    private void importFile(Repository repository, String path, IProject project, IPath destinationPath)
-            throws RepositoryException, CoreException {
-
-        System.out.println("importFile: " + path + " -> " + destinationPath);
-
-        byte[] node = executeCommand(repository.newGetNodeCommand(path));
-			createFile(project, destinationPath.append(path), node );
-	}
-	
-	private void createFolder(IProject project, IPath destinationPath) throws CoreException{
-
-		IFolder destinationFolder = project.getFolder(destinationPath);
-		if ( destinationFolder.exists() )
-			return;
-
-		destinationFolder.create(true, true, null /* TODO progress monitor */);
-	}
-	
-    private void createFile(IProject project, IPath path, byte[] node) throws CoreException {
-		
-		IFile destinationFile = project.getFile(path);
-		if ( destinationFile.exists() ) {
-            /* TODO progress monitor */
-            destinationFile.setContents(new ByteArrayInputStream(node), IResource.KEEP_HISTORY, null);
-		} else {
-            /* TODO progress monitor */
-            destinationFile.create(new ByteArrayInputStream(node), true, null);
-		}
-	}
 }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java Mon Sep 30 10:28:08 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.sling.ide.eclipse.ui.internal;
 
-
 import java.io.File;
 import java.util.List;
 
@@ -35,13 +34,12 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 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.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
@@ -61,14 +59,6 @@ import org.eclipse.wst.server.core.Serve
  */
 public class ImportWizardPage extends WizardDataTransferPage {
 
-	private Text path;
-	private ModifyListener modifyListener = new ModifyListener() {
-		@Override
-		public void modifyText(ModifyEvent event) {
-            determinePageCompletion();
-            updateWidgetEnablements();
-		}
-	};
     private Combo repositoryCombo;
     private Label importLabel;
 	private Button containerBrowseButton;
@@ -160,12 +150,6 @@ public class ImportWizardPage extends Wi
 		});
         updateRepositoryList();
 
-        Label pathLabel = new Label(container, SWT.NONE);
-        pathLabel.setText("Repository Path:");
-        path = new Text(container, SWT.BORDER);
-        path.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-        path.addModifyListener(modifyListener);
-        
         Composite containerGroup = new Composite(composite, SWT.NONE);
         GridLayout layout = new GridLayout();
         layout.numColumns = 3;
@@ -200,14 +184,16 @@ public class ImportWizardPage extends Wi
         	setErrorMessage("Select a project first");
         }
         
-        adjustJcrRootText = new Label(composite, SWT.NONE);
+        Composite adjustComposite = new Composite(composite, SWT.NONE);
+        adjustComposite.setLayout(new RowLayout());
+
+        adjustJcrRootText = new Label(adjustComposite, SWT.NONE);
         adjustJcrRootText.setFont(containerGroup.getFont());
         adjustJcrRootText();
         
-        Link openPropertiesLink = new Link(composite, SWT.NONE);
-        openPropertiesLink.setText("<a>Modify location here</a>");
+        Link openPropertiesLink = new Link(adjustComposite, SWT.NONE);
+        openPropertiesLink.setText("(<a>change</a>)");
         openPropertiesLink.addSelectionListener(new SelectionAdapter() {
-			
 			public void widgetSelected(SelectionEvent e) {
 				PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), project, 
 						"org.apache.sling.ide.projectPropertyPage", 
@@ -217,13 +203,11 @@ public class ImportWizardPage extends Wi
 			}
 		});
         
-        
-        
         createOptionsGroup(composite);
         
         setControl(composite);
 
-        setPageComplete(false);
+        updateWidgetEnablements();
 	}
 
 	private void updateRepositoryList() {
@@ -241,14 +225,6 @@ public class ImportWizardPage extends Wi
         }
 	}
 
-    /**
-	 * Returns the path from which to import from the Sling Repository.
-	 * 
-	 * @return the repository path
-	 */
-	public String getRepositoryPath() {
-		return path != null ? path.getText() : null;
-	}
 
 	public void handleEvent(Event event) {
 		if (event.widget == containerBrowseButton) {
@@ -327,12 +303,7 @@ public class ImportWizardPage extends Wi
             setErrorMessage("Please select a valid index");
 			return false;
 		}
-		
-		if ( !getRepositoryPath().startsWith("/") ) {
-			setErrorMessage("The repository path needs to be absolute");
-			return false;
-		}
-		
+
         String syncDirectoryPath = ProjectUtil.getSyncDirectoryValue(project);
         IFolder syncFolder = project.getFolder(syncDirectoryPath);
 
@@ -373,8 +344,7 @@ public class ImportWizardPage extends Wi
         if (filterFile!=null && filterFile.exists()) {
             importLabel.setText("Will apply import filter from /" + filterFile.getProjectRelativePath() + ".");
         } else {
-            importLabel.setText("No filter found at /" + filterFile.getProjectRelativePath()
-                    + ", will import all resources.");
+            importLabel.setText("No filter definition found, will import all resources.");
         }
         importLabel.setVisible(true);
         importLabel.getParent().layout();
@@ -394,6 +364,9 @@ public class ImportWizardPage extends Wi
 
         FilterLocator filterLocator = Activator.getDefault().getFilterLocator();
         File filterLocation = filterLocator.findFilterLocation(syncLocation.getLocation().toFile());
+        if (filterLocation == null) {
+            return null;
+        }
         IPath filterPath = Path.fromOSString(filterLocation.getAbsolutePath());
         return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filterPath);
     }
@@ -411,7 +384,7 @@ public class ImportWizardPage extends Wi
 		}
         if (project!=null && adjustJcrRootText!=null) {
             adjustJcrRootText();
-            adjustJcrRootText.pack();
+            adjustJcrRootText.getParent().pack();
         }
         if (repositoryCombo.getItemCount() == 0 && project != null) {
         	setErrorMessage("The selected project is not configured with/added to any Sling server");
@@ -422,11 +395,6 @@ public class ImportWizardPage extends Wi
         	setErrorMessage("Please select a repository");
         	return false;
         }
-		if (getRepositoryPath() == null
-				|| getRepositoryPath().trim().length() == 0) {
-			setErrorMessage("Please enter a valid Sling Repository path");
-			return false;
-		}
 		return true;
 	}
 

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/InstallEditorSection.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/InstallEditorSection.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/InstallEditorSection.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/InstallEditorSection.java Mon Sep 30 10:28:08 2013
@@ -18,25 +18,53 @@ package org.apache.sling.ide.eclipse.ui.
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.ide.artifacts.EmbeddedArtifact;
+import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration;
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
+import org.apache.sling.ide.eclipse.core.ServerUtil;
 import org.apache.sling.ide.eclipse.core.SetBundleInstallLocallyCommand;
+import org.apache.sling.ide.eclipse.core.SetBundleVersionCommand;
+import org.apache.sling.ide.osgi.OsgiClient;
+import org.apache.sling.ide.osgi.OsgiClientException;
+import org.apache.sling.ide.osgi.OsgiClientFactory;
+import org.apache.sling.ide.transport.RepositoryInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.ExpandableComposite;
 import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+import org.osgi.framework.Version;
 
 public class InstallEditorSection extends ServerEditorSection {
     protected boolean _updating;
@@ -44,8 +72,13 @@ public class InstallEditorSection extend
 
     private Button mvnSlingInstallButton;
     private Button quickLocalInstallButton;
+    private Hyperlink installOrUpdateSupportBundleLink;
     private ISlingLaunchpadServer launchpadServer;
     private PropertyChangeListener serverListener;
+    private Label supportBundleVersionLabel;
+    private Composite actionArea;
+    private EmbeddedArtifactLocator artifactLocator;
+    private OsgiClientFactory osgiClientFactory;
 
     @Override
     public void createSection(Composite parent) {
@@ -72,16 +105,23 @@ public class InstallEditorSection extend
         section.setClient(composite);
 
         
-        mvnSlingInstallButton = new Button(composite, SWT.RADIO);
-        mvnSlingInstallButton.setText("Install bundles via mvn sling:install");
+        mvnSlingInstallButton = toolkit.createButton(composite, "Install bundles via mvn sling:install", SWT.RADIO);
         GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
         mvnSlingInstallButton.setLayoutData(data);
         
-        quickLocalInstallButton = new Button(composite, SWT.RADIO);
-        quickLocalInstallButton.setText("Install bundles directly from local directory");
+        quickLocalInstallButton = toolkit.createButton(composite, "Install bundles directly from local directory",
+                SWT.RADIO);
         data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
         quickLocalInstallButton.setLayoutData(data);
 
+        actionArea = toolkit.createComposite(composite);
+        RowLayout actionAreaLayout = new RowLayout();
+        actionAreaLayout.center = true;
+        actionArea.setLayout(actionAreaLayout);
+
+        supportBundleVersionLabel = toolkit.createLabel(actionArea, "");
+        installOrUpdateSupportBundleLink = toolkit.createHyperlink(actionArea, "(Install)", SWT.NONE);
+
         initialize();
     }
 
@@ -96,6 +136,14 @@ public class InstallEditorSection extend
                 if (ISlingLaunchpadServer.PROP_INSTALL_LOCALLY.equals(evt.getPropertyName())) {
             		quickLocalInstallButton.setSelection((Boolean)evt.getNewValue());
             		mvnSlingInstallButton.setSelection(!(Boolean)evt.getNewValue());
+                } else if (evt.getPropertyName().equals(
+                        String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
+                                EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME))) {
+
+                    Version launchpadVersion = new Version((String) evt.getNewValue());
+                    Version embeddedVersion = new Version(artifactLocator.loadToolingSupportBundle().getVersion());
+
+                    updateActionArea(launchpadVersion, embeddedVersion);
                 }
             }
         };
@@ -108,6 +156,9 @@ public class InstallEditorSection extend
             launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class,
                     new NullProgressMonitor());
         }
+
+        artifactLocator = Activator.getDefault().getArtifactLocator();
+        osgiClientFactory = Activator.getDefault().getOsgiClientFactory();
     }
 
     private void initialize() {
@@ -127,6 +178,125 @@ public class InstallEditorSection extend
 
         quickLocalInstallButton.addSelectionListener(listener);
         mvnSlingInstallButton.addSelectionListener(listener);
+
+        Version serverVersion = launchpadServer.getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
+        final EmbeddedArtifact supportBundle = artifactLocator.loadToolingSupportBundle();
+
+        final Version embeddedVersion = new Version(supportBundle.getVersion());
+
+        updateActionArea(serverVersion, embeddedVersion);
+
+        installOrUpdateSupportBundleLink.addHyperlinkListener(new HyperlinkAdapter() {
+
+            @Override
+            public void linkActivated(HyperlinkEvent e) {
+
+                ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
+                dialog.setCancelable(true);
+                try {
+                    dialog.run(true, false, new IRunnableWithProgress() {
+
+                        @Override
+                        public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                                InterruptedException {
+                            final Version remoteVersion;
+                            monitor.beginTask("Installing support bundle", 3);
+                            // double-check, just in case
+                            monitor.setTaskName("Getting remote bundle version");
+
+                            Version deployedVersion;
+                            final String message;
+                            try {
+                                RepositoryInfo repositoryInfo = ServerUtil.getRepositoryInfo(server.getOriginal(),
+                                        monitor);
+                                OsgiClient client = osgiClientFactory.createOsgiClient(repositoryInfo);
+                                remoteVersion = client
+                                        .getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
+                                deployedVersion = remoteVersion;
+
+                                monitor.worked(1);
+
+                                if (remoteVersion != null && remoteVersion.compareTo(embeddedVersion) >= 0) {
+                                    // version already up-to-date, due to bundle version
+                                    // changing between startup check and now
+                                    message = "Bundle is already installed and up to date";
+                                } else {
+                                    monitor.setTaskName("Installing bundle");
+                                    InputStream contents = null;
+                                    try {
+                                        contents = supportBundle.openInputStream();
+                                        client.installBundle(contents, supportBundle.getName());
+                                    } finally {
+                                        IOUtils.closeQuietly(contents);
+                                    }
+                                    deployedVersion = embeddedVersion;
+                                    message = "Bundle version " + embeddedVersion + " installed";
+
+                                }
+                                monitor.worked(1);
+
+                                monitor.setTaskName("Updating server configuration");
+                                final Version finalDeployedVersion = deployedVersion;
+                                Display.getDefault().syncExec(new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        execute(new SetBundleVersionCommand(server,
+                                                EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME,
+                                                finalDeployedVersion.toString()));
+                                        try {
+                                            server.save(false, new NullProgressMonitor());
+                                        } catch (CoreException e) {
+                                            Activator.getDefault().getLog().log(e.getStatus());
+                                        }
+                                    }
+                                });
+                                monitor.worked(1);
+
+                            } catch (OsgiClientException e) {
+                                throw new InvocationTargetException(e);
+                            } catch (URISyntaxException e) {
+                                throw new InvocationTargetException(e);
+                            } catch (IOException e) {
+                                throw new InvocationTargetException(e);
+                            } finally {
+                                monitor.done();
+                            }
+
+                            Display.getDefault().asyncExec(new Runnable() {
+                                @Override
+                                public void run() {
+                                    MessageDialog.openInformation(getShell(), "Support bundle install operation",
+                                            message);
+                                }
+                            });
+                        }
+                    });
+                } catch (InvocationTargetException e1) {
+
+                    IStatus status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+                            "Error while installing support bundle: " + e1.getTargetException().getMessage(), e1
+                                    .getTargetException());
+
+                    ErrorDialog.openError(getShell(), "Error while installing support bundle", e1.getMessage(), status);
+                } catch (InterruptedException e1) {
+                    Thread.currentThread().interrupt();
+                    return;
+                }
+            }
+        });
+    }
+
+    private void updateActionArea(Version serverVersion, final Version embeddedVersion) {
+        if (serverVersion == null || embeddedVersion.compareTo(serverVersion) > 0) {
+            supportBundleVersionLabel
+                    .setText("Installation support bundle is not present our outdated, local deployment will not work");
+            installOrUpdateSupportBundleLink.setEnabled(true);
+        } else {
+            supportBundleVersionLabel.setText("Installation support bundle is present and up to date.");
+            installOrUpdateSupportBundleLink.setEnabled(false);
+        }
+
+        actionArea.pack();
     }
 
     /*

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/SharedImages.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/SharedImages.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/SharedImages.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/SharedImages.java Mon Sep 30 10:28:08 2013
@@ -31,6 +31,7 @@ public final class SharedImages {
     
     public static final ImageDescriptor SLING_LOG = ImageDescriptor.createFromFile(SharedImages.class, "sling-logo.png");
     public static final ImageDescriptor SLING_ICON = ImageDescriptor.createFromFile(SharedImages.class, "sling.gif");
+    public static final ImageDescriptor NT_UNSTRUCTURED_ICON = ImageDescriptor.createFromFile(SharedImages.class, "unstructured.png");
     
     public static final ImageDescriptor DISCONNECT = DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT);
     public static final ImageDescriptor RUN_CONNECT = new DecorationOverlayIcon(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ACT_RUN).createImage(), ImageDescriptor.createFromFile(SharedImages.class, "connectOverlay.png"), IDecoration.BOTTOM_RIGHT);

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=1527508&r1=1527507&r2=1527508&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 Mon Sep 30 10:28:08 2013
@@ -114,7 +114,7 @@ public class JcrContentContentProvider i
 			return projectGetChildren((IProject)parentElement);
 		} else if (parentElement instanceof JcrNode) {
 			JcrNode node = (JcrNode)parentElement;
-			return node.getChildren();
+			return node.getChildren(true);
 		} else {
 			return null;
 		}

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java?rev=1527508&r1=1527507&r2=1527508&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java Mon Sep 30 10:28:08 2013
@@ -24,7 +24,8 @@ import org.eclipse.core.resources.IConta
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IResource;
-import org.w3c.dom.Node;
+
+import de.pdark.decentxml.Element;
 
 public class DirNode extends JcrNode {
 	
@@ -66,7 +67,7 @@ public class DirNode extends JcrNode {
 		return true;
 	}
 	
-	DirNode(JcrNode parent, Node domNode, IResource resource) {
+	DirNode(JcrNode parent, Element domNode, IResource resource) {
 		super(parent, domNode, resource);
 		if (!isDirNode(resource)) {
 			throw new IllegalArgumentException("resource is not a DirNode: "+resource);
@@ -83,7 +84,25 @@ public class DirNode extends JcrNode {
 	}
 	
 	@Override
+	String getJcrPathName() {
+		return getDecodedName();
+	}
+	
+	@Override
 	protected void addChild(JcrNode jcrNode) {
+		JcrNode effectiveSibling = getEffectiveSibling();
+		if (effectiveSibling!=this && effectiveSibling!=null) {
+			// excellent, the parent contains a child which 
+			// matches the .dir/_jcr_content pattern, so add this child there
+			effectiveSibling.addChild(jcrNode);
+			// but also hide this node from my parent
+			effectiveSibling.getParent().hide(this);
+			return;
+		}
+		super.addChild(jcrNode);
+	}
+	
+	JcrNode getEffectiveSibling() {
 		final String decodedName = getDecodedName();
 		JcrNode nonDirNodeParent = parent;
 		outerloop:while(nonDirNodeParent!=null && (nonDirNodeParent instanceof DirNode)) {
@@ -100,21 +119,9 @@ public class DirNode extends JcrNode {
 			}
 			nonDirNodeParent = nonDirNodeParent.parent;
 		}
-		Set<JcrNode> c = new HashSet<JcrNode>(nonDirNodeParent.children);
-		for (Iterator<JcrNode> it = c.iterator(); it.hasNext();) {
-			JcrNode node = it.next();
-			if (node.getName().equals(decodedName)) {
-				// excellent, the parent contains a child which 
-				// matches the .dir/_jcr_content pattern, so add this child there
-				node.addChild(jcrNode);
-				// but also hide this node from my parent
-				nonDirNodeParent.hide(this);
-				return;
-			}
-		}
-		super.addChild(jcrNode);
+		return nonDirNodeParent.getChild(decodedName);
 	}
-	
+
 	@Override
 	public IFile getFileForEditor() {
 		return null;