continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r492067 [3/3] - in /maven/continuum/sandbox/continuum-eclipse-plugin: ./ .settings/ META-INF/ icons/ lib/ src/ src/org/ src/org/apache/ src/org/apache/continuum/ src/org/apache/continuum/internal/ src/org/apache/continuum/internal/model/ sr...
Date Wed, 03 Jan 2007 07:45:03 GMT
Added: maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java
URL: http://svn.apache.org/viewvc/maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java?view=auto&rev=492067
==============================================================================
--- maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java
(added)
+++ maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java
Tue Jan  2 23:45:01 2007
@@ -0,0 +1,193 @@
+/**
+ *    Copyright 2006  <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ *
+ * Licensed 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.continuum.ui.wizard;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.continuum.Activator;
+import org.apache.continuum.internal.ConnectionProfileManager;
+import org.apache.continuum.model.ConnectionProfile;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.rpc.ProjectsReader;
+import org.apache.xmlrpc.XmlRpcException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard to connection to a remote Continuum server and create a Connection
+ * Profile.
+ * 
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+public class CreateConnectionProfileWizard extends Wizard implements INewWizard {
+
+    /**
+     * Key under which the Continuum connection settings are captured by the
+     * wizard.
+     */
+    private static final String DIALOG_SETTINGS_KEY = "ContinuumConnectionSettings";
+
+    /**
+     * Wizard Page that captures data to create a Connection Profile.
+     */
+    private WizardPage connectionProfilePage = null;
+
+    /**
+     * Model class that holds the Continuum Connection Profile.
+     */
+    private ConnectionProfile connectionProfile;
+
+    private static List<ConnectionProfile> existingConnectionProfiles = null;
+
+    static {
+        try {
+            existingConnectionProfiles = ConnectionProfileManager.loadConnectionProfiles
();
+        } catch (CoreException e) {
+            Activator.getDefault ().getLog ().log (new Status (IStatus.ERROR, Activator.PLUGIN_ID,
-1, "Unable to load Continuum Connection Profiles.", e));
+        }
+    }
+
+    /**
+     * Determines if connection profiles settings available with the Connection
+     * wizard are new or old.
+     * <p>
+     * Has a value <code>false</code> if settings obtained are not-NULL, that
+     * is <em>not new</em>.
+     */
+    private boolean newConnectionSettings;
+
+
+    /**
+     * Setup an instance of a create connection wizard.
+     * <p>
+     * We obtain the dialog settings for our plug-in in context of current
+     * workbench.
+     */
+    public CreateConnectionProfileWizard() {
+        super ();
+        // Obtain the settings for our plug-in that hold persistent state data.
+        IDialogSettings wbSettings = Activator.getDefault ().getDialogSettings ();
+        // obtain section specific to continuum settings
+        IDialogSettings section = wbSettings.getSection (DIALOG_SETTINGS_KEY);
+        if (null != section) {
+            newConnectionSettings = false;
+        } else {
+            newConnectionSettings = true;
+            setDialogSettings (section);
+        }
+    }
+
+
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        connectionProfile = new ConnectionProfile ();
+        setWindowTitle ("Create New Continuumm Connection");
+        // we need a progress monitor if the wizard will attempt to connect to
+        // the specified Continuum Server.
+        // TODO: We could make this optional by having an checkbox option like
+        // 'validate connection on finish' similar to CVS repo setup wizard.
+        setNeedsProgressMonitor (false);
+    }
+
+
+    @Override
+    public void addPages() {
+        super.addPages ();
+        connectionProfilePage = new ConnectionProfilePage ("Create Continuum Connection Profile",
connectionProfile);
+        addPage (connectionProfilePage);
+    }
+
+
+    @Override
+    public boolean performFinish() {
+        // delegate to wrapped up pages to finish off.
+        IWizardPage [] pages = getPages ();
+        for (int i = 0; i < getPageCount (); i++) {
+            IWizardPage page = pages[i];
+            if (page instanceof ConnectionProfilePage) {
+                // we allow the wizard to finish only if the user supplied
+                // validated values.
+                ConnectionProfilePage cpPage = ((ConnectionProfilePage) page);
+                if (cpPage.validate ())
+                    cpPage.finish ();
+                else {
+                    MessageDialog.openError (getShell (), "Error", "Missing form fields.");
+                    return false;
+                }
+            }
+        }
+
+        if (existingConnectionProfiles.contains (connectionProfile)) {
+            // TODO: Implement a check if a profile with same name exists. Need
+            // to override equals().
+            MessageDialog.openError (getShell (), "Error", "Profile with name '" + connectionProfile.getLabel
() + "' already exists.");
+        }
+
+        // Attempt to test connect to the specified continuum server before
+        // saving the profile.
+        try {
+            testConnection ();
+            Activator.getDefault ().getLog ().log (new Status (IStatus.INFO, Activator.PLUGIN_ID,
0, "Saving Connection profile: " + connectionProfile.getLabel (), null));
+            // TODO: Run a create profile operation here
+            ConnectionProfileManager.saveConnectionProfile (connectionProfile);
+        } catch (CoreException e) {
+            MessageDialog.openError (getShell (), "Error", e.getMessage ());
+        }
+
+        MessageDialog.openInformation (getShell (), "Success", "Connection to Continuum was
successful. Profile '" + connectionProfile.getLabel () + "' saved!");
+        return true;
+    }
+
+
+    /**
+     * Ping test to the remote continuum instance.
+     * <p>
+     * FIXME: Update implemenatation when we have <b>Ping</b> and <b>Login</b>
+     * XML-RPC service available in Continuum.
+     * 
+     * @throws CoreException
+     *             if there was an error connection to the specified Continuum
+     *             Server.
+     */
+    private void testConnection() throws CoreException {
+        ProjectsReader pr = null;
+        try {
+            pr = new ProjectsReader (new URL (this.connectionProfile.getConnectionUrl ()));
+            Project [] projects = null;
+            projects = pr.readProjects ();
+        } catch (MalformedURLException e) {
+            throw new CoreException (new Status (IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getLocalizedMessage
(), e));
+        } catch (XmlRpcException e) {
+            throw new CoreException (new Status (IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getLocalizedMessage
(), e));
+        } catch (IOException e) {
+            throw new CoreException (new Status (IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getLocalizedMessage
(), e));
+        } finally {
+            // cleanup!
+        }
+    }
+
+}

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/src/org/apache/continuum/ui/wizard/CreateConnectionProfileWizard.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java
URL: http://svn.apache.org/viewvc/maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java?view=auto&rev=492067
==============================================================================
--- maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java
(added)
+++ maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java
Tue Jan  2 23:45:01 2007
@@ -0,0 +1,80 @@
+/**
+ *    Copyright 2006  <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ *
+ * Licensed 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.continuum.ui.views;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+public abstract class DialogTestSupport {
+
+    protected void run(String title) {
+
+        Display display = new Display ();
+        final Shell shell = new Shell (display);
+        shell.setText (title);
+        shell.setToolTipText (title);
+
+        // get the dialog contents and prepare for display.
+        final Dialog dlg = createDialog (shell);        
+        Button b1 = new Button (shell, SWT.PUSH);
+        b1.setText ("Show Dialog");
+        b1.setToolTipText (title);
+        b1.addSelectionListener (new SelectionAdapter () {
+
+            public void widgetSelected(SelectionEvent e) {
+                dlg.setBlockOnOpen (true);
+                dlg.open ();
+            }
+
+        });
+
+        // layout our test window.
+        final int insetX = 4, insetY = 4;
+        FormLayout formLayout = new FormLayout ();
+        formLayout.marginWidth = insetX;
+        formLayout.marginHeight = insetY;
+        FormData data = new FormData ();
+        data.left = new FormAttachment (0, 10);
+        data.top = new FormAttachment (0, 10);
+        b1.setLayoutData (data);
+
+        shell.setLayout (formLayout);
+
+        shell.pack ();
+        shell.open ();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ())
+                display.sleep ();
+        }
+        display.dispose ();
+
+    }
+
+
+    protected abstract Dialog createDialog(final Shell shell);
+}

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/DialogTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java?view=auto&rev=492067
==============================================================================
--- maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java
(added)
+++ maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java
Tue Jan  2 23:45:01 2007
@@ -0,0 +1,45 @@
+/**
+ *    Copyright 2006  <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ *
+ * Licensed 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.continuum.ui.views;
+
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+public class EditDefinitionDialogTest extends DialogTestSupport {
+
+    /**
+     * @param args
+     */
+    public static void main(String [] args) {
+        EditDefinitionDialogTest test = new EditDefinitionDialogTest ();
+        test.run ("Edit Build Definition Dialog");
+    }
+
+
+    @Override
+    protected Dialog createDialog(final Shell shell) {
+        BuildDefinition bd = new BuildDefinition ();
+        final EditBuildDefinitionDialog dlg = new EditBuildDefinitionDialog (shell, bd);
+        return dlg;
+    }
+
+}

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditDefinitionDialogTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java?view=auto&rev=492067
==============================================================================
--- maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java
(added)
+++ maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java
Tue Jan  2 23:45:01 2007
@@ -0,0 +1,44 @@
+/**
+ *    Copyright 2006  <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ *
+ * Licensed 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.continuum.ui.views;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+public class EditProjectDialogTest extends DialogTestSupport {
+
+    /**
+     * @param args
+     */
+    public static void main(String [] args) {
+        EditProjectDialogTest test = new EditProjectDialogTest ();
+        test.run ("Edit Project Dialog");
+    }
+
+
+    @Override
+    protected Dialog createDialog(final Shell shell) {
+        Project project = new Project ();
+        final EditProjectDialog dlg = new EditProjectDialog (shell, project);
+        return dlg;
+    }
+
+}

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/sandbox/continuum-eclipse-plugin/test/org/apache/continuum/ui/views/EditProjectDialogTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message