You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2008/02/01 23:12:30 UTC

svn commit: r617675 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/ org.apache.geronimo.st.ui/src/org/apache/geronimo/s...

Author: mcconne
Date: Fri Feb  1 14:12:25 2008
New Revision: 617675

URL: http://svn.apache.org/viewvc?rev=617675&view=rev
Log:
GERONIMODEVTOOLS-264 CheckboxViewer added to Test Environment section to contain workspace classpath containers

Added:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetClasspathContainersCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/ClasspathContainersHelper.java
Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoServer.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java?rev=617675&r1=617674&r2=617675&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java Fri Feb  1 14:12:25 2008
@@ -49,6 +49,8 @@
 
 	public static final String SERVER_INSTANCE_PROPERTIES = "geronimo_server_instance_properties";
 	
+	public static final String SERVER_CLASSPATH_CONTAINERS = "classpathContainers";
+	
 	public static final String RUNTIME_SOURCE= "runtime.source";
 
 	public static final int NO_IMAGE = 0;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerDelegate.java?rev=617675&r1=617674&r2=617675&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerDelegate.java Fri Feb  1 14:12:25 2008
@@ -75,6 +75,8 @@
 
 	public static final String PROPERTY_SELECT_CLASSPATH_CONTAINERS = "selectClasspathContainers";
 
+	public static final String PROPERTY_CLASSPATH_CONTAINERS = "classpathContainers";
+
 	public static final String CONSOLE_INFO = "--long";
 
 	public static final String CONSOLE_DEBUG = "-vv";
@@ -334,12 +336,28 @@
 		return getAttribute(PROPERTY_RUN_FROM_WORKSPACE, false);
 	}
 	
-	/* (non-Javadoc)
-	 * @see org.apache.geronimo.st.core.IGeronimoServer#isSelectClasspathContainers()
-	 */
+	
+    //
+	// PROPERTY_SELECT_CLASSPATH_CONTAINERS
+	//
 	public boolean isSelectClasspathContainers() {
 		return getAttribute(PROPERTY_SELECT_CLASSPATH_CONTAINERS, false);
 	}
+	public void setSelectClasspathContainers(boolean enable) {
+		setAttribute(PROPERTY_SELECT_CLASSPATH_CONTAINERS, enable);
+	}
+	
+	
+	//
+	// PROPERTY_CLASSPATH_CONTAINERS
+	//
+	public List<String> getClasspathContainers() {
+		return getAttribute(PROPERTY_CLASSPATH_CONTAINERS, new ArrayList<String>() );
+	}
+	public void setClasspathContainers( List<String> list ) {
+		setAttribute(PROPERTY_CLASSPATH_CONTAINERS, list);
+	}
+	
 	
 	public void setInPlaceSharedLib(boolean enable) {
 		setAttribute(PROPERTY_IN_PLACE_SHARED_LIB, enable);
@@ -349,10 +367,6 @@
 		setAttribute(PROPERTY_RUN_FROM_WORKSPACE, enable);
 	}
 	
-	public void setSelectClasspathContainers(boolean enable) {
-		setAttribute(PROPERTY_SELECT_CLASSPATH_CONTAINERS, enable);
-	}
-	
 	public String discoverDeploymentFactoryClassName(IPath jarPath) {
 		try {
 			JarFile deployerJar = new JarFile(jarPath.toFile());
@@ -400,4 +414,6 @@
 	public void setServerInstanceProperties(Map map) {
 		setAttribute(GeronimoRuntimeDelegate.SERVER_INSTANCE_PROPERTIES, map);
 	}
+
+	
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoServer.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoServer.java?rev=617675&r1=617674&r2=617675&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoServer.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoServer.java Fri Feb  1 14:12:25 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.geronimo.st.core;
 
+import java.util.List;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
@@ -50,6 +52,8 @@
 	public boolean isRunFromWorkspace();
 	
 	public boolean isSelectClasspathContainers();
+	
+	public List<String> getClasspathContainers();
 	
 	public int getPingDelay();
 	

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetClasspathContainersCommand.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetClasspathContainersCommand.java?rev=617675&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetClasspathContainersCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetClasspathContainersCommand.java Fri Feb  1 14:12:25 2008
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.ui.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.geronimo.st.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.ui.internal.Trace;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+
+
+public class SetClasspathContainersCommand extends ServerCommand {
+
+    private List<String> newList;
+    private List<String> oldList;
+
+
+    /*
+     * @param server
+     * @param checkList string array
+     */
+    public SetClasspathContainersCommand(IServerWorkingCopy server, Object[] checkList) {
+
+        super(server, "SetClasspathContainersCommand");
+        this.newList = createList( checkList );
+
+        Trace.tracePoint("ENTRY", "SetClasspathContainersCommand", checkList, checkList.length );
+        Trace.tracePoint("EXIT", "SetClasspathContainersCommand");
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.st.ui.commands.ServerCommand#execute()
+     */
+    public void execute() {
+        Trace.tracePoint("ENTRY", "SetClasspathContainersCommand.execute");
+
+        GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+        oldList = gs.getClasspathContainers();
+        gs.setClasspathContainers(newList);
+
+        Trace.tracePoint("EXIT", "SetClasspathContainersCommand.execute");
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.st.ui.commands.ServerCommand#undo()
+     */
+    public void undo() {
+        Trace.tracePoint("ENTRY", "SetClasspathContainersCommand.undo");
+
+        GeronimoServerDelegate gs = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+        gs.setClasspathContainers(oldList);
+
+        Trace.tracePoint("EXIT", "SetClasspathContainersCommand.undo");
+    }
+
+
+    //
+    // Convert object array to List<String>
+    //
+	public List<String> createList( Object[] checkList ) {
+        Trace.tracePoint("ENTRY", "SetClasspathContainersCommand.createList");
+    
+        List<String> containers = new ArrayList<String>();
+        for (Object container : checkList) {
+            containers.add( (String)container );
+        }
+
+        Trace.tracePoint("EXIT", "SetClasspathContainersCommand.createList", containers );
+        return containers;
+   }
+
+}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java?rev=617675&r1=617674&r2=617675&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java Fri Feb  1 14:12:25 2008
@@ -16,12 +16,20 @@
  */
 package org.apache.geronimo.st.ui.sections;
 
+import java.util.List;
 import org.apache.geronimo.st.core.IGeronimoServer;
 import org.apache.geronimo.st.ui.commands.SetInPlaceSharedLibCommand;
 import org.apache.geronimo.st.ui.commands.SetRunFromWorkspaceCommand;
+import org.apache.geronimo.st.ui.commands.SetClasspathContainersCommand;
 import org.apache.geronimo.st.ui.commands.SetSelectClasspathContainersCommand;
 import org.apache.geronimo.st.ui.internal.Messages;
 import org.apache.geronimo.st.ui.internal.Trace;
+import org.apache.geronimo.st.ui.util.ClasspathContainersHelper;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
@@ -45,6 +53,10 @@
     // Form widget(s)
     private FormToolkit toolkit;
 
+    // JFace viewer(s)
+    private CheckboxTableViewer checkbox;
+
+    private IGeronimoServer gs;
 
     /*
      * (non-Javadoc)
@@ -78,7 +90,7 @@
         composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
         section.setClient(composite);
 
-        IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+        gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
 
 
         //
@@ -125,6 +137,25 @@
 
             public void widgetSelected(SelectionEvent e) { 
                 execute(new SetSelectClasspathContainersCommand(server, selectClasspathContainers.getSelection())); 
+
+                createCheckbox();
+
+                //
+                // For any selection change the checkbox will be populated from the workspace. 
+                // Changes to individual elements in the checkbox will be handled with the 
+                // CheckStateListener below.
+                //
+                List<String> containers = ClasspathContainersHelper.queryWorkspace();
+                checkbox.setInput( containers );
+                checkbox.setAllChecked( false );
+                if ( selectClasspathContainers.getSelection() ) {
+                    checkbox.getTable().setEnabled( true );
+                }
+                else {
+                    checkbox.getTable().setEnabled( false );
+                    // Clear any previously selected classpath containers
+                    execute(new SetClasspathContainersCommand(server, new Object[] {} ));
+                }
             } 
 
             public void widgetDefaultSelected(SelectionEvent e) { 
@@ -132,6 +163,69 @@
 
         }); 
 
+
+        //
+        // checkbox CheckboxTableViewer
+        //
+        createCheckbox();
+
+        //
+        // Populate the checkbox from the list of classpath containers in the workspace. If 
+        // workspace classpath containers had been previously selected then use the list from the
+        // server's instance properties to populate the checkbox. One advantage of this approach
+        // is that it will handle cases where new classpath containers are added in the workspace
+        // or existing containers are deleted from the workspace. 
+        //
+        List<String> containers = ClasspathContainersHelper.queryWorkspace();
+        checkbox.setInput( containers );
+
+        if ( selectClasspathContainers.getSelection() ) {
+            checkbox.getTable().setEnabled( true );
+            List<String> checkedContainers = gs.getClasspathContainers();
+            for (String container: checkedContainers) {
+                checkbox.setChecked( container, true );
+            }
+        }
+        else {
+            checkbox.getTable().setEnabled( false );
+        }
+
         Trace.tracePoint("EXIT", "ServerEditorTestEnvSection.createSection");
     }
+
+
+    //
+    // CheckboxTableViewer: checkbox
+    //
+	public void createCheckbox() {
+        Trace.tracePoint("ENTRY", "ServerEditorTestEnvSection.createCheckbox");
+    
+        if ( checkbox == null ) {
+                    
+            checkbox = CheckboxTableViewer.newCheckList( composite, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );
+                    
+            GridData gridData = new GridData(GridData.FILL_BOTH);
+            gridData.heightHint = 250;
+            gridData.widthHint = 100;
+            checkbox.getTable().setLayoutData( gridData );
+                    
+            checkbox.addCheckStateListener( new ICheckStateListener() {
+
+                public void checkStateChanged(CheckStateChangedEvent event) {
+                    execute(new SetClasspathContainersCommand(server, checkbox.getCheckedElements()));
+                }
+
+            }); 
+
+            checkbox.setLabelProvider( new LabelProvider() {
+            });
+
+            checkbox.setContentProvider( new ArrayContentProvider() {
+            });
+
+        }
+
+        Trace.tracePoint("EXIT", "ServerEditorTestEnvSection.createCheckbox");
+	}
+
 }

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/ClasspathContainersHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/ClasspathContainersHelper.java?rev=617675&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/ClasspathContainersHelper.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/ClasspathContainersHelper.java Fri Feb  1 14:12:25 2008
@@ -0,0 +1,39 @@
+/*
+ * 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.geronimo.st.ui.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ *
+ * Helper class for ClasspathContainers support
+ *
+ */
+public class ClasspathContainersHelper {
+
+
+    //
+    // query()
+    //
+	public static List<String> queryWorkspace() {
+        // TODO Return set of Classpath Containers discovered in the workspace
+        return new ArrayList<String>();
+	}
+
+}