geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bjr...@apache.org
Subject svn commit: r723875 [4/4] - in /geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins: org.apache.geronimo.jee.v21.jaxbmodel/META-INF/ org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/plugin/ org.apache.geronimo.st.core/src...
Date Fri, 05 Dec 2008 21:30:39 GMT
Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java?rev=723875&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
Fri Dec  5 13:30:38 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.v21.ui.wizards;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.wizards.AbstractWizard;
+import org.apache.geronimo.system.plugin.model.ArtifactType;
+import org.apache.geronimo.system.plugin.model.PrerequisiteType;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PrerequisiteWizard extends AbstractWizard {
+
+    protected PrerequisiteType prereq;
+    
+    protected Text group;
+    protected Text artifact;
+    protected Text version;
+    protected Text type;
+    protected Text description;
+    
+    public PrerequisiteWizard (PrerequisiteType oldPrereq) {
+        super();
+        prereq = oldPrereq;
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_Prerequisite;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_Prerequisite;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#addPages()
+     */
+    public void addPages() {
+        addPage(new MessageDestWizardPage("Page0"));
+    }
+
+    // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
+    // the values are brought in properly.
+    public class MessageDestWizardPage extends AbstractWizardPage {
+        public MessageDestWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            Composite composite = createComposite(parent);
+            createLabel (composite, CommonMessages.groupId);
+            group = createTextField (composite, "");
+            createLabel (composite, CommonMessages.artifactId);
+            artifact = createTextField (composite, "");
+            createLabel (composite, CommonMessages.version);
+            version = createTextField (composite, "");
+            createLabel (composite, CommonMessages.type);
+            type = createTextField (composite, "");
+            createLabel (composite, CommonMessages.description);
+            description = createTextField (composite, "");
+
+            if (prereq != null) {
+                group.setText(prereq.getId().getGroupId());
+                artifact.setText(prereq.getId().getArtifactId());
+                version.setText(prereq.getId().getVersion());
+                type.setText(prereq.getResourceType());
+                description.setText(prereq.getDescription());
+            }
+            setControl(composite);
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_Prerequisite;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_Prerequisite;
+        }
+    }
+    
+    public boolean performFinish() {
+        prereq = new PrerequisiteType();
+        ArtifactType artType = new ArtifactType();
+        artType.setGroupId(group.getText());
+        artType.setArtifactId(artifact.getText());
+        artType.setType(type.getText());
+        artType.setVersion(version.getText());
+        prereq.setId(artType);
+        prereq.setResourceType(type.getText());
+        prereq.setDescription(description.getText());
+
+        return true;
+    }
+    
+    public PrerequisiteType getPrerequisite() {
+        return prereq;
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerCustomAssemblyWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerCustomAssemblyWizard.java?rev=723875&r1=723874&r2=723875&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerCustomAssemblyWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerCustomAssemblyWizard.java
Fri Dec  5 13:30:38 2008
@@ -20,7 +20,7 @@
 
 import org.apache.geronimo.st.ui.CommonMessages;
 import org.apache.geronimo.st.ui.wizards.AbstractWizard;
-import org.apache.geronimo.st.v21.core.operations.GeronimoCustomServerAssembly;
+import org.apache.geronimo.st.v21.core.operations.GeronimoServerPluginManager;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
@@ -35,16 +35,16 @@
 public class ServerCustomAssemblyWizard extends AbstractWizard {
 
     private Table pluginTable;
-
+    
     protected Text group;
     protected Text artifact;
     protected Text version;
     protected Text type;
     protected Text serverPath;
 
-    protected GeronimoCustomServerAssembly customAssembly;
+    protected GeronimoServerPluginManager customAssembly;
 
-    public ServerCustomAssemblyWizard(GeronimoCustomServerAssembly customAssembly) {
+    public ServerCustomAssemblyWizard(GeronimoServerPluginManager customAssembly) {
         super();
         this.customAssembly = customAssembly;
     }
@@ -113,7 +113,7 @@
 
         public void populateTable() {
             List<String> pluginList = customAssembly.getPluginList();
-
+             
             for (int i = 0; i < pluginList.size(); ++i) {
                 TableItem tableItem = new TableItem(pluginTable, SWT.NONE);
                 String tableEntry = pluginList.get(i);
@@ -139,7 +139,7 @@
             isEmpty(serverPath.getText()) || pluginTable.getSelectionCount() == 0) {
             return false;
         }
-        customAssembly.assembleServer(group.getText(), artifact.getText(), version.getText(),
type.getText(),
+        customAssembly.assembleServer(group.getText(), artifact.getText(), version.getText(),
type.getText(), 
                 serverPath.getText(), pluginTable.getSelectionIndices());
         return true;
     }

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java?rev=723875&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
(added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
Fri Dec  5 13:30:38 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.v21.ui.wizards;
+
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServerPluginManagerDialog extends WizardDialog {
+    private ServerPluginManagerWizard wizard;
+    public ServerPluginManagerDialog(Shell parentShell, ServerPluginManagerWizard newWizard)
{
+        super(parentShell, newWizard);
+        wizard = newWizard;
+    }
+
+    @Override
+    protected void nextPressed() {
+        wizard.nextPressed();
+        super.nextPressed();
+    }
+
+    @Override
+    protected void backPressed() {
+        wizard.backPressed();
+        super.backPressed();
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerDialog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java?rev=723875&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
Fri Dec  5 13:30:38 2008
@@ -0,0 +1,754 @@
+/*
+ * 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.v21.ui.wizards;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geronimo.system.plugin.model.ArtifactType;
+import org.apache.geronimo.system.plugin.model.DependencyType;
+import org.apache.geronimo.system.plugin.model.LicenseType;
+import org.apache.geronimo.system.plugin.model.PluginArtifactType;
+import org.apache.geronimo.system.plugin.model.PluginListType;
+import org.apache.geronimo.system.plugin.model.PluginType;
+import org.apache.geronimo.system.plugin.model.PrerequisiteType;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.wizards.AbstractWizard;
+import org.apache.geronimo.st.v21.core.operations.GeronimoServerPluginManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+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.graphics.Color;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServerPluginManagerWizard extends AbstractWizard {
+
+    protected Text localRepoPath;
+    protected Button createPlugin;
+    protected Button installPlugin;
+    protected Combo createPluginCombo;
+    protected Label pluginCreatedStatus;
+    protected Table licenseTable;
+    protected Table prereqTable;
+    protected Table pluginLoadTable;
+    protected ServerPluginManagerWizardPage1 page1;
+    protected ServerPluginManagerWizardPage2 page2;
+    protected ServerPluginManagerWizardPage3 page3;
+    protected ServerPluginManagerWizardPage4 page4;
+
+    // pageVisible is used to keep track of exactly which page we are viewing
+    protected int pageVisible;
+    protected GeronimoServerPluginManager pluginManager;
+    protected PluginType metadata;
+
+    public ServerPluginManagerWizard(GeronimoServerPluginManager customAssembly) {
+        super();
+        this.pluginManager = customAssembly;
+        pageVisible = 0;
+    }
+
+    public void addPages() {
+        addPage(new ServerPluginManagerWizardPage0("page0"));
+        page1 = new ServerPluginManagerWizardPage1("page1");
+        addPage(page1);
+        page2 = new ServerPluginManagerWizardPage2("page2");
+        addPage(page2);
+        page3 = new ServerPluginManagerWizardPage3("page3");
+        addPage(page3);
+        page4 = new ServerPluginManagerWizardPage4("page4");
+        addPage(page4);
+    }
+
+    public void backPressed () {
+        if (pageVisible == 4) {
+            pageVisible = 0;
+        } else {
+            pageVisible--;
+        }
+    }
+
+    // perform any intermediate steps when next button is pressed
+    public void nextPressed () {
+        switch (pageVisible) {
+            case 0:
+                if (installPlugin.getSelection() == true) {
+                    page4.populateTable(pluginManager.readPluginList(localRepoPath.getText()));
+                    page1.setPageComplete(true);
+                    page2.setPageComplete(true);
+                    page3.setPageComplete(true);
+                    pageVisible = 4;
+                } else {
+                    pageVisible = 1;
+                }
+                break;
+            case 1:
+                metadata = pluginManager.getPluginMetadata(createPluginCombo.getItem(createPluginCombo.getSelectionIndex()));
+                page2.loadMetadata (metadata);
+                pageVisible++;
+                break;
+            case 2:
+                page3.loadMetadata (metadata);
+                pageVisible++;
+                break;
+            case 3:
+                boolean success = true;
+                try {
+                    metadata = page2.getMetadata();
+                    metadata = page3.getMetadata(metadata);
+                    pluginManager.savePluginXML (createPluginCombo.getItem(createPluginCombo.getSelectionIndex()),
metadata);
+                    // create the plugin in the proper directory
+                    pluginManager.exportCAR (localRepoPath.getText(), createPluginCombo.getItem(createPluginCombo.getSelectionIndex()));
+                    // update the plugin list that's in the base path
+                    pluginManager.updatePluginList (localRepoPath.getText(), metadata);
+                }
+                catch (Exception e) {
+                    pluginCreatedStatus.setText(CommonMessages.bind(CommonMessages.failedToSave,
createPluginCombo.getItem(createPluginCombo.getSelectionIndex())));
+                    Device device = pluginCreatedStatus.getForeground().getDevice();
+                    Color color = new Color (device, 255, 0, 0);
+                    pluginCreatedStatus.setForeground(color);
+                    success = false;
+                }
+                if (success == true) {
+                    pluginCreatedStatus.setText(CommonMessages.bind (CommonMessages.savedSuccess,
createPluginCombo.getItem(createPluginCombo.getSelectionIndex())));
+                    Device device = pluginCreatedStatus.getForeground().getDevice();
+                    Color color = new Color (device, 0, 0, 0);
+                    pluginCreatedStatus.setForeground(color);
+                }
+                pageVisible = 0;
+                break;
+        }
+    }
+    
+    public class ServerPluginManagerWizardPage0 extends AbstractWizardPage {
+
+        public ServerPluginManagerWizardPage0(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData(400, 300));
+            Composite composite = createComposite(parent);
+
+            createLabel(composite, CommonMessages.localPluginRepo);
+            createLabel(composite, "");
+            localRepoPath = createTextField(composite, "");
+            Button browseButton = createPushButton(composite, CommonMessages.browse);
+            browseButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent e) {
+                    DirectoryDialog dirDlg = new DirectoryDialog(getShell());
+                    dirDlg.setMessage(CommonMessages.localPluginRepo);
+                    dirDlg.setFilterPath(localRepoPath.getText());
+                    localRepoPath.setText(dirDlg.open());
+                }
+            });
+
+            localRepoPath.addModifyListener(new ModifyListener() {
+                public void modifyText(ModifyEvent arg0) {
+                    File temp = new File (localRepoPath.getText());
+                    setPageComplete(temp.isDirectory());
+                }
+            });
+
+            createPlugin = createButton(composite, CommonMessages.createPlugin);
+            installPlugin = createButton(composite, CommonMessages.installPlugins);
+            setPageComplete(false);
+            pluginCreatedStatus = createLabel (composite, "");
+
+            setControl(composite);
+        }
+
+        @Override
+        public IWizardPage getNextPage() {
+            IWizardPage[] pages = getPages();
+            if (createPlugin.getSelection() == true) {
+                return super.getNextPage();
+            } else {
+                return pages[4];
+            }
+        }
+
+        @Override
+        public void setPreviousPage(IWizardPage page) {
+            super.setPreviousPage(null);
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPage0Title_PluginManager;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPage0Description_PluginManager;
+        }
+    }
+
+    public class ServerPluginManagerWizardPage1 extends AbstractWizardPage {
+
+        public ServerPluginManagerWizardPage1(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData(400, 300));
+            Composite composite = createComposite(parent);
+
+            List<String> strList = pluginManager.getConfigurationList();
+            String[] strArray = new String[strList.size()];
+            strArray = strList.toArray(strArray);
+            createPluginCombo = createCombo(composite, strArray, false);
+            createPluginCombo.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    setPageComplete(createPluginCombo.getSelectionIndex() > -1);
+                }
+            });
+
+            setPageComplete(false);
+            setControl(composite);
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPage1Title_PluginManager;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPage1Description_PluginManager;
+        }
+    }
+
+    public class ServerPluginManagerWizardPage2 extends AbstractWizardPage {
+        Text name, downloadRepos, category, description, pluginURL, author;
+        Text geronimoVersions, jvmVersions, dependencies, obsoletes;
+        Label id;
+        
+        public ServerPluginManagerWizardPage2(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData(400, 300));
+            Composite composite = createComposite(parent);
+
+            createLabel (composite, CommonMessages.name);
+            name = createTextField (composite, "");
+            createLabel (composite, CommonMessages.id);
+            id = createLabel (composite, "");
+            createLabel (composite, CommonMessages.downloadRepos);
+            downloadRepos = createMultiTextField (composite, null);
+            createLabel (composite, CommonMessages.category);
+            category = createTextField (composite, "");
+            createLabel (composite, CommonMessages.description);
+            description = createMultiTextField (composite, null);
+            createLabel (composite, CommonMessages.pluginURL);
+            pluginURL = createTextField (composite, "");
+            createLabel (composite, CommonMessages.author);
+            author = createTextField (composite, "");
+            createLabel (composite, CommonMessages.geronimoVersions);
+            geronimoVersions = createMultiTextField (composite, null);
+            createLabel (composite, CommonMessages.jvmVersions);
+            jvmVersions = createMultiTextField (composite, null);
+            createLabel (composite, CommonMessages.dependencies);
+            dependencies = createMultiTextField (composite, null);
+            createLabel (composite, CommonMessages.obsoletes);
+            obsoletes = createMultiTextField (composite, null);
+
+            setControl(composite);
+        }
+
+        public void loadMetadata (PluginType metadata) {
+            PluginArtifactType instance = metadata.getPluginArtifact().get(0);
+            setText (name, metadata.getName());
+            id.setText (artifactToString(instance.getModuleId()));
+            setText (downloadRepos, combine (instance.getSourceRepository()));
+            setText (category, metadata.getCategory());
+            setText (description, metadata.getDescription());
+            setText (pluginURL, metadata.getUrl());
+            setText (author, metadata.getAuthor());
+            setText (geronimoVersions, combine(instance.getGeronimoVersion()));
+            setText (jvmVersions, combine(instance.getJvmVersion()));
+            setText (dependencies, artifactsToString(instance.getDependency()));
+            setText (obsoletes, artifactsToString(instance.getObsoletes()));
+        }
+
+        public PluginType getMetadata () {
+            metadata = pluginManager.getPluginMetadata(id.getText());
+            PluginArtifactType instance = metadata.getPluginArtifact().get(0);
+            metadata.setName(name.getText());
+            split (downloadRepos.getText(), instance.getSourceRepository());
+            metadata.setCategory(category.getText());
+            metadata.setDescription(description.getText());
+            metadata.setUrl(pluginURL.getText());
+            metadata.setAuthor(author.getText());
+            split (geronimoVersions.getText(), instance.getGeronimoVersion());
+            split (jvmVersions.getText(), instance.getJvmVersion());
+            stringToDependencies (split(dependencies.getText()), instance.getDependency());
+            stringToArtifacts (split(obsoletes.getText()), instance.getObsoletes());
+            return metadata;
+        }
+
+        private void stringToArtifacts(List<String> artifacts, List<ArtifactType>
result) {
+            result.clear();
+            for (String artifact : artifacts) {
+                result.add(pluginManager.toArtifactType(artifact));
+            }
+        }
+
+        private void stringToDependencies(List<String> artifacts, List<DependencyType>
result) {
+            result.clear();
+            for (String artifact : artifacts) {
+                result.add(pluginManager.toDependencyType(artifact));
+            }
+        }
+
+        private List<String> split(String deps) {
+            List<String> split = new ArrayList<String>();
+            if (deps != null && !deps.equals("")) {
+                split(deps, split);
+            }
+            return split;
+        }
+
+        private void split(String deps, List<String> split) {
+            split.clear();
+            BufferedReader in = new BufferedReader(new StringReader(deps));
+            String line;
+            try {
+                while ((line = in.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.equals("")) {
+                        split.add(line);
+                    }
+                }
+                in.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        private String artifactsToString(List<? extends ArtifactType> artifacts) {
+            if (artifacts == null || artifacts.size() == 0) {
+                return null;
+            }
+            StringBuffer buf = new StringBuffer();
+            boolean first = true;
+            for (ArtifactType artifactType : artifacts) {
+                if (!first) {
+                    buf.append("\n");
+                }
+                first = false;
+                buf.append(artifactToString(artifactType));
+            }
+            return buf.toString();
+         }
+        
+        private String artifactToString(ArtifactType artifact) {
+            StringBuffer buffer = new StringBuffer();
+
+            if (artifact.getGroupId() != null) {
+                buffer.append(artifact.getGroupId());
+            }
+            buffer.append("/");
+
+            if (artifact.getArtifactId() != null) {
+                buffer.append(artifact.getArtifactId());
+            }
+            buffer.append("/");
+
+            if (artifact.getVersion() != null) {
+                buffer.append(artifact.getVersion());
+            }
+            buffer.append("/");
+
+            if (artifact.getType() != null) {
+                buffer.append(artifact.getType());
+            }
+            return buffer.toString();
+        }
+        
+        private void setText (Text text, String value) {
+            if (value != null) {
+                text.setText(value);
+            } else {
+                text.setText("");
+            }
+        }
+
+        private String combine(List<String> strings) {
+            if (strings == null || strings.size() == 0) {
+                return null;
+            }
+            StringBuffer buf = new StringBuffer();
+            boolean first = true;
+            for (String string : strings) {
+                if (!first) {
+                    buf.append("\n");
+                }
+                first = false;
+                buf.append(string);
+            }
+            return buf.toString();
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPage2Title_PluginManager;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPage2Description_PluginManager;
+        }
+    }
+
+    public class ServerPluginManagerWizardPage3 extends AbstractWizardPage {
+        protected Button addLicenseButton, editLicenseButton, removeLicenseButton;
+        protected Button addPrereqButton, editPrereqButton, removePrereqButton;
+        protected PluginType pluginType;
+        
+        public ServerPluginManagerWizardPage3(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData(400, 300));
+            Composite composite = createComposite(parent);
+
+            String[] lColumnNames = {CommonMessages.license, CommonMessages.osiApproved};
+            int[] lColumnWidths = {300, 100};
+            licenseTable = createEditableTable(composite, lColumnNames, lColumnWidths);
+            licenseTable.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    activateButtons();
+                }
+            });
+            Composite licenseButtonComposite = createButtonComposite(composite);
+            addLicenseButton = createPushButton(licenseButtonComposite, CommonMessages.add);
+            addLicenseButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    LicenseWizard wizard = new LicenseWizard(null);
+                    if (wizard != null) {
+                        WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+                        dialog.open();
+                        if (dialog.getReturnCode() == Dialog.OK) {
+                            LicenseType newLicense = wizard.getLicense();
+                            pluginType.getLicense().add(newLicense);
+                            loadMetadata(pluginType);
+                            activateButtons();
+                        }
+                    }
+                }
+            });
+            editLicenseButton = createPushButton(licenseButtonComposite, CommonMessages.edit);
+            editLicenseButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    LicenseType oldLicense = (LicenseType)licenseTable.getItem(licenseTable.getSelectionIndex()).getData();
+                    LicenseWizard wizard = new LicenseWizard(oldLicense);
+                    if (wizard != null) {
+                        WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+                        dialog.open();
+                        if (dialog.getReturnCode() == Dialog.OK) {
+                            LicenseType newLicense = wizard.getLicense();
+                            int index = pluginType.getLicense().indexOf(oldLicense);
+                            pluginType.getLicense().remove(index);
+                            pluginType.getLicense().add(index, newLicense);
+                            loadMetadata(pluginType);
+                            activateButtons();
+                        }
+                    }
+                }
+            });
+            removeLicenseButton = createPushButton(licenseButtonComposite, CommonMessages.remove);
+            removeLicenseButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    LicenseType license;
+                    license = (LicenseType)licenseTable.getItem(licenseTable.getSelectionIndex()).getData();
+                    pluginType.getLicense().remove(license);
+                    loadMetadata(pluginType);
+                    activateButtons();
+                }
+            });
+
+            String[] pColumnNames = {CommonMessages.groupId, CommonMessages.artifactId, CommonMessages.version,
CommonMessages.type, CommonMessages.description};
+            int[] pColumnWidths = {50, 50, 50, 50, 200};
+            prereqTable = createEditableTable(composite, pColumnNames, pColumnWidths);
+            prereqTable.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    activateButtons();
+                }
+            });
+            Composite prereqButtonComposite = createButtonComposite(composite);
+            addPrereqButton = createPushButton(prereqButtonComposite, CommonMessages.add);
+            addPrereqButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    PrerequisiteWizard wizard = new PrerequisiteWizard(null);
+                    if (wizard != null) {
+                        WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+                        dialog.open();
+                        if (dialog.getReturnCode() == Dialog.OK) {
+                            PrerequisiteType newPrereq = wizard.getPrerequisite();
+                            pluginType.getPluginArtifact().get(0).getPrerequisite().add(newPrereq);
+                            loadMetadata(pluginType);
+                            activateButtons();
+                        }
+                    }
+                }
+            });
+            editPrereqButton = createPushButton(prereqButtonComposite, CommonMessages.edit);
+            editPrereqButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    PrerequisiteType oldPrereq = (PrerequisiteType)prereqTable.getItem(prereqTable.getSelectionIndex()).getData();
+                    PrerequisiteWizard wizard = new PrerequisiteWizard(oldPrereq);
+                    if (wizard != null) {
+                        WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+                        dialog.open();
+                        if (dialog.getReturnCode() == Dialog.OK) {
+                            PrerequisiteType newPrereq = wizard.getPrerequisite();
+                            int index = pluginType.getPluginArtifact().get(0).getPrerequisite().indexOf(oldPrereq);
+                            pluginType.getPluginArtifact().get(0).getPrerequisite().remove(index);
+                            pluginType.getPluginArtifact().get(0).getPrerequisite().add(index,
newPrereq);
+                            loadMetadata(pluginType);
+                            activateButtons();
+                        }
+                    }
+                }
+            });
+            removePrereqButton = createPushButton(prereqButtonComposite, CommonMessages.remove);
+            removePrereqButton.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    PrerequisiteType prereq;
+                    prereq = (PrerequisiteType)prereqTable.getItem(prereqTable.getSelectionIndex()).getData();
+                    pluginType.getPluginArtifact().get(0).getPrerequisite().remove(prereq);
+                    loadMetadata(pluginType);
+                    activateButtons();
+                }
+            });
+            activateButtons();
+            setControl(composite);
+        }
+
+        protected void activateButtons() {
+            editLicenseButton.setEnabled(licenseTable.getSelectionCount() > 0);
+            removeLicenseButton.setEnabled(licenseTable.getSelectionCount() > 0);
+            editPrereqButton.setEnabled(prereqTable.getSelectionCount() > 0);
+            removePrereqButton.setEnabled(prereqTable.getSelectionCount() > 0);
+        }
+        
+        protected Composite createButtonComposite(Composite parent) {
+            Composite buttonComp = new Composite(parent, SWT.NONE);
+            GridLayout layout = new GridLayout();
+            layout.horizontalSpacing = 2;
+            layout.verticalSpacing = 2;
+            layout.marginWidth = 0;
+            layout.marginHeight = 0;
+            layout.numColumns = 1;
+            buttonComp.setLayout(layout);
+            buttonComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
+            return buttonComp;
+        }
+
+        @Override
+        public IWizardPage getNextPage() {
+            return getPages()[0];
+        }
+
+        public void loadMetadata (PluginType metadata) {
+            pluginType = metadata;
+            PluginArtifactType instance = pluginType.getPluginArtifact().get(0);
+            licenseTable.removeAll();
+            List<LicenseType> licenses = pluginType.getLicense();
+            for (int i = 0; i < licenses.size(); i++) {
+                TableItem tabItem = new TableItem (licenseTable, SWT.NONE);
+                LicenseType license = licenses.get(i);
+                tabItem.setData(license);
+                tabItem.setText(licenseToStringArray(license));
+            }
+            prereqTable.removeAll();
+            List<PrerequisiteType> prereqs = instance.getPrerequisite();
+            for (int i = 0; i < prereqs.size(); i++) {
+                TableItem tabItem = new TableItem (prereqTable, SWT.NONE);
+                PrerequisiteType prereq = prereqs.get(i);
+                tabItem.setData(prereq);
+                tabItem.setText(prereqToStringArray(prereq));
+            }
+        }
+
+        // may not need this once the add/edit/delete buttons are available
+        public PluginType getMetadata (PluginType metadata) {
+            PluginArtifactType instance = metadata.getPluginArtifact().get(0);
+
+            metadata.getLicense().clear();
+            for (int i = 0; i < licenseTable.getItemCount(); i++) {
+                LicenseType license = (LicenseType)licenseTable.getItem (i).getData();
+                metadata.getLicense().add(license);
+            }
+            instance.getPrerequisite().clear();
+            for (int i = 0; i < prereqTable.getItemCount(); i++) {
+                PrerequisiteType prereq = (PrerequisiteType)prereqTable.getItem (i).getData();
+                instance.getPrerequisite().add(prereq);
+            }
+            return metadata;
+        }
+        
+        private String[] licenseToStringArray (LicenseType license) {
+            String[] stringArray = new String[licenseTable.getColumnCount()];
+            stringArray[0] = license.getValue();
+            stringArray[1] = String.valueOf(license.isOsiApproved());
+            return stringArray;
+        }
+        
+        private String[] prereqToStringArray (PrerequisiteType prereq) {
+            String[] stringArray = new String[prereqTable.getColumnCount()];
+            if (prereq.getId() != null) {
+                stringArray[0] = prereq.getId().getGroupId();
+                stringArray[1] = prereq.getId().getArtifactId();
+                stringArray[2] = prereq.getId().getVersion();
+            } else {
+                stringArray[0] = "";
+                stringArray[1] = "";
+                stringArray[2] = "";
+            }
+            stringArray[3] = prereq.getResourceType();
+            stringArray[4] = prereq.getDescription();
+            return stringArray;
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPage3Title_PluginManager;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPage3Description_PluginManager;
+        }
+    }
+
+    public class ServerPluginManagerWizardPage4 extends AbstractWizardPage {
+
+        public ServerPluginManagerWizardPage4(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData(400, 300));
+            Composite composite = createComposite(parent);
+
+            String[] columnNames = {CommonMessages.plugin, CommonMessages.version, CommonMessages.category,
CommonMessages.installable};
+            int[] columnWidths = {175, 75, 100, 75};
+            pluginLoadTable = this.createTable(composite, columnNames, columnWidths);
+            pluginLoadTable.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    TableItem tabItem = pluginLoadTable.getItem(pluginLoadTable.getSelectionIndex());
+                    if (tabItem.getText(3).equals("false")) {
+                        pluginLoadTable.deselect(pluginLoadTable.getSelectionIndex());
+                    }
+                    if (pluginLoadTable.getSelectionCount() > 0) {
+                        setPageComplete(true);
+                    } else {
+                        setPageComplete(false);
+                    }
+                }
+                
+            });
+            
+            setPageComplete(false);
+            setControl(composite);
+        }
+
+        @Override
+        public IWizardPage getPreviousPage() {
+            return getPages()[0];
+        }
+        
+        public void populateTable (PluginListType pluginList) {
+            String[] pluginValues;
+            pluginLoadTable.removeAll();
+            List<PluginType> plugins = pluginList.getPlugin();
+            for (int i = 0; i < plugins.size(); i++) {
+                TableItem tabItem = new TableItem (pluginLoadTable, SWT.NONE);
+                PluginType plugin = plugins.get(i);
+                tabItem.setData(plugin);
+                pluginValues = pluginToStringArray(plugin);
+                tabItem.setText(pluginValues);
+            }
+        }
+        
+        private String[] pluginToStringArray (PluginType plugin) {
+            String[] stringArray = new String[pluginLoadTable.getColumnCount()];
+            stringArray[0] = plugin.getName();
+            stringArray[1] = plugin.getPluginArtifact().get(0).getModuleId().getVersion();
+            stringArray[2] = plugin.getCategory();
+            stringArray[3] = String.valueOf(pluginManager.validatePlugin(plugin));
+            return stringArray;
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPage4Title_PluginManager;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPage4Description_PluginManager;
+        }
+    }
+
+    public boolean performFinish() {
+        // take each selected object in the pluginLoadTable and install and start 
+        List<PluginType> pluginList = new ArrayList<PluginType>();
+        for (int i = 0; i < pluginLoadTable.getSelectionCount(); i++) {
+            pluginList.add ((PluginType)pluginLoadTable.getItem(pluginLoadTable.getSelectionIndices()[i]).getData());
+        }
+        pluginManager.installPlugins(localRepoPath.getText(), pluginList);
+
+        return true;
+    }
+
+    @Override
+    protected String getAddWizardWindowTitle() {
+        return CommonMessages.wizardTitle_PluginManager;
+    }
+
+    @Override
+    protected String getEditWizardWindowTitle() {
+        return CommonMessages.wizardTitle_PluginManager;
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServerPluginManagerWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message