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 2016/02/17 21:50:45 UTC

svn commit: r1730937 - in /sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui: internal/InstallEditorSection.java wizards/SetupServerWizardPage.java

Author: rombert
Date: Wed Feb 17 20:50:44 2016
New Revision: 1730937

URL: http://svn.apache.org/viewvc?rev=1730937&view=rev
Log:
SLING-4071 - Remove manual interactions related to the tooling support bundle

Remove UI affordances related to the tooling support bundle

- link to install the bundle from the server editor page
- checkbox to allow installation when a server is created

The bundle is unconditionally installed when the server connection is made.

Modified:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/InstallEditorSection.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java

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=1730937&r1=1730936&r2=1730937&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 Wed Feb 17 20:50:44 2016
@@ -18,31 +18,11 @@ 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.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;
@@ -52,18 +32,12 @@ 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;
@@ -71,13 +45,9 @@ public class InstallEditorSection extend
 
     private Button bundleLocalInstallButton;
     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) {
@@ -118,9 +88,6 @@ public class InstallEditorSection extend
         actionAreaLayout.center = true;
         actionArea.setLayout(actionAreaLayout);
 
-        supportBundleVersionLabel = toolkit.createLabel(actionArea, "");
-        installOrUpdateSupportBundleLink = toolkit.createHyperlink(actionArea, "(Install)", SWT.NONE);
-
         initialize();
     }
 
@@ -135,14 +102,6 @@ public class InstallEditorSection extend
                 if (ISlingLaunchpadServer.PROP_INSTALL_LOCALLY.equals(evt.getPropertyName())) {
             		quickLocalInstallButton.setSelection((Boolean)evt.getNewValue());
             		bundleLocalInstallButton.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);
                 }
             }
         };
@@ -155,9 +114,6 @@ public class InstallEditorSection extend
             launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class,
                     new NullProgressMonitor());
         }
-
-        artifactLocator = Activator.getDefault().getArtifactLocator();
-        osgiClientFactory = Activator.getDefault().getOsgiClientFactory();
     }
 
     private void initialize() {
@@ -177,127 +133,8 @@ public class InstallEditorSection extend
 
         quickLocalInstallButton.addSelectionListener(listener);
         bundleLocalInstallButton.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");
-                                    
-                                    try (InputStream contents = supportBundle.openInputStream() ){
-                                        client.installBundle(contents, supportBundle.getName());
-                                    }
-                                    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 | IOException | URISyntaxException 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 or outdated, deployment will not work");
-            installOrUpdateSupportBundleLink.setText("(Install)");
-            installOrUpdateSupportBundleLink.setEnabled(true);
-        } else {
-            supportBundleVersionLabel.setText("Installation support bundle is present and up to date.");
-            installOrUpdateSupportBundleLink.setText("(Reinstall)");
-            installOrUpdateSupportBundleLink.setEnabled(true);
-        }
-
-        actionArea.pack();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.wst.server.ui.editor.ServerEditorSection#dispose()
-     */
     @Override
     public void dispose() {
         if (server != null)

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java?rev=1730937&r1=1730936&r2=1730937&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java Wed Feb 17 20:50:44 2016
@@ -72,7 +72,6 @@ public class SetupServerWizardPage exten
     private Text newServerUsername;
     private Text newServerPassword;
 	private Text newServerDebugPort;
-	private Button installToolingSupportBundle;
 	
     private IServer server;
 
@@ -158,16 +157,6 @@ public class SetupServerWizardPage exten
         newLabel(container, "Debug Port:");
         newServerDebugPort = newText(container);
 	    
-	    {
-	    	installToolingSupportBundle = new Button(container, SWT.CHECK);
-		    GridData installToolingSupportBundleData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
-            installToolingSupportBundleData.horizontalIndent = HORIZONTAL_INDENT;
-		    installToolingSupportBundle.setLayoutData(installToolingSupportBundleData);
-		    installToolingSupportBundle.setText("Check/Install org.apache.sling.tooling.support.install bundle");
-		    installToolingSupportBundle.setSelection(true);
-	    }
-	    
-	    
 	    SelectionAdapter radioListener = new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
                 updateEnablements();
@@ -209,7 +198,6 @@ public class SetupServerWizardPage exten
         existingServerCombo.getWidget().setEnabled(existingServerCombo.hasServers());
         startExistingServerButton.setEnabled(existingServerCombo.hasServers());
         setupNewServer.setSelection(!existingServerCombo.hasServers());
-        installToolingSupportBundle.setSelection(true);
 
         updateEnablements();
 
@@ -281,31 +269,12 @@ public class SetupServerWizardPage exten
         newServerDebugPort.setEnabled(setupNewServer.getSelection());
         newServerUsername.setEnabled(setupNewServer.getSelection());
         newServerPassword.setEnabled(setupNewServer.getSelection());
-        installToolingSupportBundle.setEnabled(setupNewServer.getSelection());
     }
 
 	private void updateStatus(String message) {
 		setErrorMessage(message);
 		setPageComplete(message == null);
 	}
-	
-
-    private Version getToolingSupportBundleVersion() throws OsgiClientException {
-
-        return newOsgiClient().getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
-    }
-    
-    private OsgiClient newOsgiClient() {
-
-        String hostname = getHostname();
-        int launchpadPort = getPort();
-
-        OsgiClientFactory factory = Activator.getDefault().getOsgiClientFactory();
-
-        // TODO remove credential hardcoding
-        return factory.createOsgiClient(new RepositoryInfo("admin", "admin", "http://" + hostname + ":" + launchpadPort
-                + "/"));
-    }
     
     public boolean getStartServer() {
         if (!useExistingServer.getSelection()) {
@@ -344,35 +313,6 @@ public class SetupServerWizardPage exten
 				}
 			}
 			
-            Version finalVersion = null;
-			
-			if (installToolingSupportBundle.getSelection()) {
-                Version installedVersion;
-                try {
-                    installedVersion = getToolingSupportBundleVersion();
-                } catch (OsgiClientException e) {
-                    throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
-                            "Failed reading the tooling support bundle version", e));
-                }
-                finalVersion = installedVersion;
-                EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactLocator();
-                EmbeddedArtifact toolingSupportBundle = artifactsLocator.loadToolingSupportBundle();
-                Version ourVersion = new Version(toolingSupportBundle.getVersion());
-
-                if (installedVersion == null || ourVersion.compareTo(installedVersion) > 0) {
-					// then auto-install it if possible
-					try {
-                        try (InputStream contents = toolingSupportBundle.openInputStream()) {
-                            newOsgiClient().installBundle(contents, toolingSupportBundle.getName());
-                        }
-                        finalVersion = ourVersion;
-					} catch (IOException | OsgiClientException e) {
-                        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
-                                "Failed installing the tooling support bundle version", e));
-                    }
-				}
-			}
-			
 			IRuntimeType serverRuntime = ServerCore.findRuntimeType("org.apache.sling.ide.launchpadRuntimeType");
 			try {
                 // TODO there should be a nicer API for creating this, and also a central place for defaults
@@ -389,10 +329,6 @@ public class SetupServerWizardPage exten
                 
                 SlingLaunchpadConfigurationDefaults.applyDefaultValues(wc);
                 
-                if (finalVersion != null) {
-                    wc.setAttribute(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
-                        EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME), finalVersion.toString());
-                }
 				wc.setRuntime(runtime);
                 server = wc.save(true, monitor);
                 return server;