geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r818883 [7/7] - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.runtime.v11/ org.apache.geronimo.st.v11.core/ org.apache.geronimo.st.v11.core/src/main/ org.apache.geronimo.st.v11.core/src/main/java/ org.apache.geroni...
Date Fri, 25 Sep 2009 15:26:17 GMT
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServerCustomAssemblyWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServerCustomAssemblyWizard.java?rev=818883&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServerCustomAssemblyWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServerCustomAssemblyWizard.java
Fri Sep 25 15:26:14 2009
@@ -0,0 +1,156 @@
+/*
+ * 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.v11.ui.wizards;
+
+import java.util.List;
+
+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.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev: 723874 $ $Date: 2008-12-06 05:30:03 +0800 (Sat, 06 Dec 2008) $
+ */
+public class ServerCustomAssemblyWizard extends AbstractWizard {
+
+    private Table pluginTable;
+    
+    protected Text group;
+    protected Text artifact;
+    protected Text version;
+    protected Text type;
+    protected Text serverPath;
+
+    protected GeronimoServerPluginManager customAssembly;
+
+    public ServerCustomAssemblyWizard(GeronimoServerPluginManager customAssembly) {
+        super();
+        this.customAssembly = customAssembly;
+    }
+
+    public void addPages() {
+        addPage(new ServerCustomAssemblyWizardPage("page0"));
+    }
+
+    public class ServerCustomAssemblyWizardPage extends AbstractWizardPage {
+
+        public ServerCustomAssemblyWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            parent.setLayoutData(createGridData());
+            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, "1.0");
+            createLabel(composite, CommonMessages.type);
+            type = createTextField(composite, "tar.gz");
+            createLabel(composite, CommonMessages.path);
+            serverPath = createTextField(composite, "var/temp/assembly");
+            createTable(composite);
+            populateTable();
+
+            setControl(composite);
+        }
+
+        public GridData createGridData() {
+            GridData data = new GridData();
+            data.verticalAlignment = GridData.FILL;
+            data.horizontalAlignment = GridData.FILL;
+            data.grabExcessVerticalSpace = true;
+            data.grabExcessHorizontalSpace = true;
+            data.heightHint = 400;
+            data.widthHint = 300;
+            return data;
+        }
+
+        private void createTable(Composite composite) {
+            int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
+
+            pluginTable = new Table(composite, style);
+            GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
+            data.grabExcessHorizontalSpace = true;
+            data.grabExcessVerticalSpace = true;
+            data.horizontalSpan = 2;
+            data.horizontalAlignment = GridData.FILL;
+            data.heightHint = 250;
+            data.widthHint = 350;
+            pluginTable.setLayoutData(data);
+            pluginTable.setLinesVisible(false);
+            pluginTable.setHeaderVisible(true);
+
+            final TableColumn[] column = new TableColumn[1];
+            column[0] = new TableColumn(pluginTable, SWT.LEFT, 0);
+            column[0].setText(CommonMessages.plugin);
+            column[0].setWidth(400);
+        }
+
+        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);
+                tableItem.setData(tableEntry);
+                tableItem.setText(new String[] {tableEntry});
+            }
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_ServerCustomAssembly;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_ServerCustomAssembly;
+        }
+    }
+
+    public boolean performFinish() {
+        if (isEmpty(group.getText()) || isEmpty(artifact.getText()) ||
+            isEmpty(version.getText()) || isEmpty(type.getText()) ||
+            isEmpty(serverPath.getText()) || pluginTable.getSelectionCount() == 0) {
+            return false;
+        }
+        customAssembly.assembleServer(group.getText(), artifact.getText(), version.getText(),
type.getText(), 
+                serverPath.getText(), pluginTable.getSelectionIndices());
+        return true;
+    }
+
+    @Override
+    protected String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_ServerCustomAssembly;
+    }
+
+    @Override
+    protected String getEditWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_ServerCustomAssembly;
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServiceRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServiceRefWizard.java?rev=818883&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServiceRefWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/main/java/org/apache/geronimo/st/v11/ui/wizards/ServiceRefWizard.java
Fri Sep 25 15:26:14 2009
@@ -0,0 +1,241 @@
+/*
+ * 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.v11.ui.wizards;
+
+import javax.xml.bind.JAXBElement;
+import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.ui.wizards.AbstractTreeWizard;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.apache.geronimo.xml.ns.naming_1.PortCompletionType;
+import org.apache.geronimo.xml.ns.naming_1.PortType;
+import org.apache.geronimo.xml.ns.naming_1.ServiceCompletionType;
+import org.apache.geronimo.xml.ns.naming_1.ServiceRefType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceRefWizard extends AbstractTreeWizard {
+
+    private final int SERVICE_REF = 0;
+    private final int PORT = 1;
+    private final int PORT_COMPLETION = 2;
+
+    public ServiceRefWizard(AbstractTreeSection section) {
+        super(section, 3, 7);
+        elementTypes[SERVICE_REF] = "Service Reference";
+        elementTypes[PORT] = "Port";
+        elementTypes[PORT_COMPLETION] = "Port Completion";
+    }
+
+    public class ServiceRefWizardPage extends AbstractTreeWizardPage {
+
+        public ServiceRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        protected void initControl () {
+            if (eObject == null) {
+                element.select(SERVICE_REF);
+                ServiceRefType serviceRef = (ServiceRefType)section.getSelectedObject();
+                // use of ports and port completions are mutually exclusive
+                if (serviceRef == null) {
+                    element.setEnabled(false);
+                } else if (serviceRef.getServiceCompletion() == null) {
+                    element.remove(PORT_COMPLETION);
+                } else {
+                    element.remove(PORT);
+                }
+            }
+            else {
+                if (ServiceRefType.class.isInstance(eObject)) {
+                    textList.get(0).setText(((ServiceRefType)eObject).getServiceRefName());
+                    if (((ServiceRefType)eObject).getServiceCompletion() != null) {
+                        textList.get(1).setText(((ServiceRefType)eObject).getServiceCompletion().getServiceName());
+                    }
+                    element.select(SERVICE_REF);
+                }
+                else if (PortType.class.isInstance(eObject)) {
+                    textList.get(0).setText(((PortType)eObject).getPortName());
+                    textList.get(1).setText(((PortType)eObject).getProtocol());
+                    textList.get(2).setText(((PortType)eObject).getHost());
+                    textList.get(3).setText(((PortType)eObject).getPort().toString());
+                    textList.get(4).setText(((PortType)eObject).getUri());
+                    textList.get(5).setText(((PortType)eObject).getCredentialsName());
+                    element.select(PORT);
+                }
+                else if (PortCompletionType.class.isInstance(eObject)) {
+                    textList.get(0).setText(((PortCompletionType)eObject).getPort().getPortName());
+                    textList.get(1).setText(((PortCompletionType)eObject).getPort().getProtocol());
+                    textList.get(2).setText(((PortCompletionType)eObject).getPort().getHost());
+                    textList.get(3).setText(((PortCompletionType)eObject).getPort().getPort().toString());
+                    textList.get(4).setText(((PortCompletionType)eObject).getPort().getUri());
+                    textList.get(5).setText(((PortCompletionType)eObject).getPort().getCredentialsName());
+                    textList.get(6).setText(((PortCompletionType)eObject).getBindingName());
+                    element.select(PORT_COMPLETION);
+                }
+                element.setEnabled(false);
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            if (element.getText().equals(elementTypes[SERVICE_REF])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(i < 2 ? true : false);
+                    textList.get(i).setVisible(i < 2 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.serviceCompletionName);
+                // if we are doing an add, then we need to make sure that the longest
+                // text can be handled
+                labelList.get(2).setText(CommonMessages.protocol);
+                labelList.get(3).setText(CommonMessages.hostName);
+                labelList.get(4).setText(CommonMessages.portValue);
+                labelList.get(5).setText(CommonMessages.credential);
+                labelList.get(6).setText(CommonMessages.bindingName);
+            }
+            else if (element.getText().equals(elementTypes[PORT])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(i < 6 ? true : false);
+                    textList.get(i).setVisible(i < 6 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.protocol);
+                labelList.get(2).setText(CommonMessages.hostName);
+                labelList.get(3).setText(CommonMessages.portValue);
+                labelList.get(4).setText(CommonMessages.uri);
+                labelList.get(5).setText(CommonMessages.credential);
+            }
+            else if (element.getText().equals(elementTypes[PORT_COMPLETION])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(true);
+                    textList.get(i).setVisible(true);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.protocol);
+                labelList.get(2).setText(CommonMessages.hostName);
+                labelList.get(3).setText(CommonMessages.portValue);
+                labelList.get(4).setText(CommonMessages.uri);
+                labelList.get(5).setText(CommonMessages.credential);
+                labelList.get(6).setText(CommonMessages.bindingName);
+            }
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_ServiceRef;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_ServiceRef;
+        }
+    }
+
+    @Override
+    public void addPages() {
+        addPage(new ServiceRefWizardPage("Page0"));
+    }
+
+    @Override
+    public boolean performFinish() {
+        ServiceRefType serviceRef;
+        if (element.getText().equals(elementTypes[SERVICE_REF])) {
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
+            }
+            serviceRef = (ServiceRefType)eObject;
+            if (serviceRef == null) {
+                serviceRef = (ServiceRefType)getEFactory().create(ServiceRefType.class);
+                JAXBElement plan = section.getPlan();
+                JAXBModelUtils.getServiceRefs(plan).add(serviceRef);
+            }
+            serviceRef.setServiceRefName(textList.get(0).getText());
+            if (isEmpty(textList.get(1).getText())) {
+                serviceRef.setServiceCompletion(null);
+            }
+            else {
+                ServiceCompletionType serviceComp = serviceRef.getServiceCompletion();
+                if (serviceComp == null) {
+                    serviceComp = (ServiceCompletionType)getEFactory().create(ServiceCompletionType.class);
+                    serviceRef.setServiceCompletion(serviceComp);
+                }
+                serviceRef.getServiceCompletion().setServiceName(textList.get(1).getText());
+            }
+        }
+        else if (element.getText().equals(elementTypes[PORT])) {
+            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText()))
{
+                return false;
+            }
+            PortType port = (PortType)eObject;
+            if (port == null) {
+                port = (PortType)getEFactory().create(PortType.class);
+                serviceRef = (ServiceRefType)section.getSelectedObject();
+                serviceRef.getPort().add(port);
+            }
+            port.setPortName(textList.get(0).getText());
+            port.setProtocol(textList.get(1).getText());
+            port.setHost(textList.get(2).getText());
+            port.setPort(Integer.valueOf(textList.get(3).getText()));
+            port.setUri(textList.get(4).getText());
+            port.setCredentialsName(textList.get(5).getText());
+        }
+        else if (element.getText().equals(elementTypes[PORT_COMPLETION])) { 
+            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText())
||
+                isEmpty(textList.get(6).getText())) {
+                return false;
+            }
+            PortCompletionType portComp = (PortCompletionType)eObject;
+            if (portComp == null) {
+                portComp = (PortCompletionType)getEFactory().create(PortCompletionType.class);
+                serviceRef = (ServiceRefType)section.getSelectedObject();
+                serviceRef.getServiceCompletion().getPortCompletion().add(portComp);
+                PortType port = (PortType)getEFactory().create(PortType.class);
+                portComp.setPort (port);
+            }
+            portComp.getPort().setPortName(textList.get(0).getText());
+            portComp.getPort().setProtocol(textList.get(1).getText());
+            portComp.getPort().setHost(textList.get(2).getText());
+            portComp.getPort().setPort(Integer.valueOf(textList.get(3).getText()));
+            portComp.getPort().setUri(textList.get(4).getText());
+            portComp.getPort().setCredentialsName(textList.get(5).getText());
+            portComp.setBindingName(textList.get(6).getText());
+        }
+        return true;
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_ServiceRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_ServiceRef;
+    }
+}



Mime
View raw message