1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.geronimo.st.v11.ui.pages; 18 19 import org.apache.geronimo.st.ui.CommonMessages; 20 import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor; 21 import org.apache.geronimo.st.ui.pages.AbstractGeronimoFormPage; 22 import org.apache.geronimo.st.v11.core.GeronimoServerInfo; 23 import org.apache.geronimo.st.v11.ui.sections.EjbLocalRefSection; 24 import org.apache.geronimo.st.v11.ui.sections.EjbRefSection; 25 import org.apache.geronimo.st.v11.ui.sections.EjbRelationSection; 26 import org.apache.geronimo.st.v11.ui.sections.GBeanRefSection; 27 import org.apache.geronimo.st.v11.ui.sections.MessageDestSection; 28 import org.apache.geronimo.st.v11.ui.sections.ResourceEnvRefSection; 29 import org.apache.geronimo.st.v11.ui.sections.ResourceRefSection; 30 import org.apache.geronimo.st.v11.ui.sections.ServiceRefSection; 31 import org.apache.geronimo.xml.ns.j2ee.application_client_1.ApplicationClientType; 32 import org.apache.geronimo.xml.ns.j2ee.web_1.WebAppType; 33 import org.eclipse.swt.layout.GridLayout; 34 import org.eclipse.ui.forms.IManagedForm; 35 import org.eclipse.ui.forms.editor.FormEditor; 36 import org.openejb.xml.ns.openejb_jar_2.OpenejbJarType; 37 38 /** 39 * @version $Rev$ $Date$ 40 */ 41 public class NamingFormPage extends AbstractGeronimoFormPage { 42 43 public NamingFormPage(FormEditor editor, String id, String title) { 44 super(editor, id, title); 45 } 46 47 /* 48 * (non-Javadoc) 49 * 50 * @see org.apache.geronimo.ui.pages.AbstractGeronimoFormPage#fillBody(org.eclipse.ui.forms.IManagedForm) 51 */ 52 protected void fillBody(IManagedForm managedForm) { 53 if (WebAppType.class.isInstance (getDeploymentPlan().getValue())) { 54 WebAppType webapp = (WebAppType)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue(); 55 managedForm.addPart(new EjbRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getEjbRef())); 56 managedForm.addPart(new ResourceRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getResourceRef())); 57 managedForm.addPart(new ServiceRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getServiceRef())); 58 managedForm.addPart(new ResourceEnvRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getResourceEnvRef())); 59 managedForm.addPart(new EjbLocalRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getEjbLocalRef())); 60 managedForm.addPart(new GBeanRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getGbeanRef())); 61 managedForm.addPart(new MessageDestSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getMessageDestination())); 62 } 63 else if (ApplicationClientType.class.isInstance (getDeploymentPlan().getValue())){ 64 ApplicationClientType appClient = (ApplicationClientType)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue(); 65 managedForm.addPart(new EjbRefSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getEjbRef())); 66 managedForm.addPart(new ResourceRefSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getResourceRef())); 67 managedForm.addPart(new ServiceRefSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getServiceRef())); 68 managedForm.addPart(new ResourceEnvRefSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getResourceEnvRef())); 69 managedForm.addPart(new GBeanRefSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getGbeanRef())); 70 managedForm.addPart(new MessageDestSection(getDeploymentPlan(), body, toolkit, getStyle(), appClient.getMessageDestination())); 71 } 72 else if (OpenejbJarType.class.isInstance (getDeploymentPlan().getValue())){ 73 OpenejbJarType ejbJar = (OpenejbJarType)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue(); 74 managedForm.addPart(new EjbRelationSection(getDeploymentPlan(), body, toolkit, getStyle(), ejbJar.getRelationships())); 75 managedForm.addPart(new MessageDestSection(getDeploymentPlan(), body, toolkit, getStyle(), ejbJar.getMessageDestination())); 76 } 77 } 78 79 protected GridLayout getLayout() { 80 GridLayout layout = new GridLayout(); 81 layout.numColumns = 1; 82 layout.horizontalSpacing = 20; 83 return layout; 84 } 85 86 /* 87 * (non-Javadoc) 88 * 89 * @see org.apache.geronimo.ui.pages.AbstractGeronimoFormPage#getFormTitle() 90 */ 91 public String getFormTitle() { 92 return CommonMessages.namingFormPageTitle; 93 } 94 95 @Override 96 protected void triggerGeronimoServerInfoUpdate() { 97 GeronimoServerInfo.getInstance().updateInfo(); 98 } 99 }