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/03/02 17:34:30 UTC

svn commit: r1733328 - in /sling/trunk/tooling/ide: eclipse-core/src/org/apache/sling/ide/eclipse/core/ eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ eclipse-ui/ eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/

Author: rombert
Date: Wed Mar  2 16:34:30 2016
New Revision: 1733328

URL: http://svn.apache.org/viewvc?rev=1733328&view=rev
Log:
SLING-3605 - Debug based on bundles deployed on the server 

Make resolving sources in debug mode configurable.

Added:
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SetResolveSourcesCommand.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/DebugEditorSection.java
Modified:
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadConfiguration.java
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadServer.java
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadConfiguration.java
    sling/trunk/tooling/ide/eclipse-ui/plugin.xml

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadConfiguration.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadConfiguration.java?rev=1733328&r1=1733327&r2=1733328&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadConfiguration.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadConfiguration.java Wed Mar  2 16:34:30 2016
@@ -29,4 +29,6 @@ public interface ISlingLaunchpadConfigur
     String getPassword();
 
     boolean bundleInstallLocally();
+    
+    boolean resolveSourcesInDebugMode();
 }
\ No newline at end of file

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadServer.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadServer.java?rev=1733328&r1=1733327&r2=1733328&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadServer.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ISlingLaunchpadServer.java Wed Mar  2 16:34:30 2016
@@ -28,6 +28,7 @@ public interface ISlingLaunchpadServer {
     public static final String PROP_DEBUG_PORT = "launchpad.debugPort";
 
     public static final String PROP_INSTALL_LOCALLY = "launchpad.installLocally";
+    public static final String PROP_RESOLVE_SOURCES = "launchpad.resolveSources";
     public static final String PROP_BUNDLE_VERSION_FORMAT = "launchpad.bundle.%s.version";
 
     ISlingLaunchpadConfiguration getConfiguration();

Added: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SetResolveSourcesCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SetResolveSourcesCommand.java?rev=1733328&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SetResolveSourcesCommand.java (added)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SetResolveSourcesCommand.java Wed Mar  2 16:34:30 2016
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.eclipse.core;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+public class SetResolveSourcesCommand extends AbstractOperation {
+
+    private IServerWorkingCopy server;
+    private boolean oldValue;
+	private boolean resolveSources;
+
+    public SetResolveSourcesCommand(IServerWorkingCopy server, boolean resolveSources) {
+        super("Setting resolve sources parameter...");
+        this.server = server;
+        this.resolveSources = resolveSources;
+    }
+
+    @Override
+    public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+        oldValue = server.getAttribute(ISlingLaunchpadServer.PROP_RESOLVE_SOURCES, true);
+
+        server.setAttribute(ISlingLaunchpadServer.PROP_RESOLVE_SOURCES, resolveSources);
+
+        return Status.OK_STATUS;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor,
+     * org.eclipse.core.runtime.IAdaptable)
+     */
+    @Override
+    public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+        return execute(monitor, info);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor,
+     * org.eclipse.core.runtime.IAdaptable)
+     */
+    @Override
+    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+        server.setAttribute(ISlingLaunchpadServer.PROP_RESOLVE_SOURCES, oldValue);
+
+        return Status.OK_STATUS;
+    }
+
+}

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java?rev=1733328&r1=1733327&r2=1733328&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java Wed Mar  2 16:34:30 2016
@@ -111,11 +111,13 @@ public class JVMDebuggerConnection {
         // 2. add the other modules deployed on server
         ProgressUtils.advance(monitor, 5); // 5/30
         
+        int workTicksForReferences = 24; // 30 - 5 - 1
+        
         SourceReferenceResolver resolver = Activator.getDefault().getSourceReferenceResolver();
-        if ( resolver != null ) {
+        if ( resolver != null  && configuration.resolveSourcesInDebugMode()) {
             try {
                 List<SourceReference> references = osgiClient.findSourceReferences();
-                SubMonitor subMonitor = SubMonitor.convert(monitor, "Resolving source references", 24).setWorkRemaining(references.size());
+                SubMonitor subMonitor = SubMonitor.convert(monitor, "Resolving source references", workTicksForReferences).setWorkRemaining(references.size());
                 for ( SourceReference reference :  references ) {
                     try {
                         subMonitor.setTaskName("Resolving source reference: " + reference);
@@ -134,6 +136,8 @@ public class JVMDebuggerConnection {
             } catch (OsgiClientException e1) {
                 throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, e1.getMessage(), e1));
             }
+        } else {
+            monitor.worked(workTicksForReferences);
         }
         
         // 3. add the JRE entry

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadConfiguration.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadConfiguration.java?rev=1733328&r1=1733327&r2=1733328&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadConfiguration.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadConfiguration.java Wed Mar  2 16:34:30 2016
@@ -88,4 +88,9 @@ public class SlingLaunchpadConfiguration
         workingCopy().setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, password);
     }
 
+    @Override
+    public boolean resolveSourcesInDebugMode() {
+        return workingCopy().getAttribute(ISlingLaunchpadServer.PROP_RESOLVE_SOURCES, true);
+    }
+
 }

Modified: sling/trunk/tooling/ide/eclipse-ui/plugin.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/plugin.xml?rev=1733328&r1=1733327&r2=1733328&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-ui/plugin.xml Wed Mar  2 16:34:30 2016
@@ -70,6 +70,13 @@
          typeIds="org.apache.sling.ide.launchpadServer"
          class="org.apache.sling.ide.eclipse.ui.internal.InstallEditorSection">
       </section>
+      <section
+         id="org.apache.sling.ide.launchpadConfigurationEditorSection"
+         order="15"
+         insertionId="org.eclipse.wst.server.editor.overview.right"
+         typeIds="org.apache.sling.ide.launchpadServer"
+         class="org.apache.sling.ide.eclipse.ui.internal.DebugEditorSection">
+      </section>
    </extension>
    
    <!-- hook in the server creation wizard -->

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/DebugEditorSection.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/DebugEditorSection.java?rev=1733328&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/DebugEditorSection.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/DebugEditorSection.java Wed Mar  2 16:34:30 2016
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.eclipse.ui.internal;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration;
+import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
+import org.apache.sling.ide.eclipse.core.SetResolveSourcesCommand;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+
+public class DebugEditorSection extends ServerEditorSection {
+    protected boolean _updating;
+    protected PropertyChangeListener _listener;
+
+    private Button resolveSourcesButton;
+    private ISlingLaunchpadServer launchpadServer;
+    private PropertyChangeListener serverListener;
+    private Composite actionArea;
+
+    @Override
+    public void createSection(Composite parent) {
+        super.createSection(parent);
+        FormToolkit toolkit = getFormToolkit(parent.getDisplay());
+
+        Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
+                | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE);
+        section.setText("Debug");
+        section.setDescription("Resolving sources when connecting in debug mode ensure that you have up-to-date source attachments which reflect the "
+                + "bundles running in the remote instance. However, initial resolve can be slow.");
+        section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
+
+        // ports
+        Composite composite = toolkit.createComposite(section);
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        layout.marginHeight = 8;
+        layout.marginWidth = 8;
+        composite.setLayout(layout);
+        GridData gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
+        composite.setLayoutData(gridData);
+        toolkit.paintBordersFor(composite);
+        section.setClient(composite);
+
+        
+        resolveSourcesButton = toolkit.createButton(composite, "Resolve sources when connecting", SWT.CHECK);
+        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+        resolveSourcesButton.setLayoutData(data);
+        
+        actionArea = toolkit.createComposite(composite);
+        RowLayout actionAreaLayout = new RowLayout();
+        actionAreaLayout.center = true;
+        actionArea.setLayout(actionAreaLayout);
+
+        initialize();
+    }
+
+    public void init(IEditorSite site, IEditorInput input) {
+        super.init(site, input);
+
+        serverListener = new PropertyChangeListener() {
+
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+
+                if (ISlingLaunchpadServer.PROP_RESOLVE_SOURCES.equals(evt.getPropertyName())) {
+            		resolveSourcesButton.setSelection((Boolean)evt.getNewValue());
+                }
+            }
+        };
+
+        server.addPropertyChangeListener(serverListener);
+
+        launchpadServer = (ISlingLaunchpadServer) server.getAdapter(ISlingLaunchpadServer.class);
+        if (launchpadServer == null) {
+            // TODO progress monitor
+            launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class,
+                    new NullProgressMonitor());
+        }
+    }
+
+    private void initialize() {
+
+        final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();
+
+        resolveSourcesButton.setSelection(config.resolveSourcesInDebugMode());
+
+        SelectionListener listener = new SelectionAdapter() {
+        	
+        	@Override
+        	public void widgetSelected(SelectionEvent e) {
+        		execute(new SetResolveSourcesCommand(server, resolveSourcesButton.getSelection()));
+        	}
+		};
+
+        resolveSourcesButton.addSelectionListener(listener);
+    }
+
+    @Override
+    public void dispose() {
+        if (server != null)
+            server.removePropertyChangeListener(serverListener);
+
+        super.dispose();
+    }
+
+}