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/06/05 19:38:37 UTC
svn commit: r663673 [2/3] - in
/geronimo/devtools/eclipse-plugin/trunk/plugins:
org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/
org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/sections/
org.apache.geronimo....
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/CommonGeneralSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/CommonGeneralSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/CommonGeneralSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/CommonGeneralSection.java Thu Jun 5 10:38:37 2008
@@ -1,368 +1,378 @@
-/*
- * 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.sections;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.jee.web.WebApp;
-import org.apache.geronimo.jee.deployment.Artifact;
-import org.apache.geronimo.jee.deployment.Dependencies;
-import org.apache.geronimo.jee.deployment.Dependency;
-import org.apache.geronimo.jee.deployment.Environment;
-import org.apache.geronimo.jee.deployment.ObjectFactory;
-import org.apache.geronimo.jee.application.Application;
-import org.apache.geronimo.jee.connector.Connector;
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractSectionPart;
-import org.apache.geronimo.st.v21.ui.internal.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IFormColors;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-
-public abstract class CommonGeneralSection extends AbstractSectionPart {
-
- protected Text artifactId;
-
- protected Text groupId;
-
- protected Text version;
-
- protected Text type;
-
- protected Button inverseClassLoading;
-
- protected Button suppressDefaultEnv;
-
- protected Button sharedLibDepends;
-
- protected ObjectFactory deploymentObjectFactory = null;
-
- public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
- super(parent, toolkit, style, plan);
- }
-
- protected void createClient() {
-
- Section section = getSection();
-
- section.setText(CommonMessages.editorSectionGeneralTitle);
- section.setDescription(CommonMessages.editorSectionGeneralDescription);
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
- Composite composite = toolkit.createComposite(section);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 5;
- layout.marginWidth = 10;
- layout.verticalSpacing = 5;
- layout.horizontalSpacing = 15;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- section.setClient(composite);
-
- createLabel(composite, Messages.groupId);
-
- groupId = toolkit.createText(composite, getGroupId(), SWT.BORDER);
- groupId.setLayoutData(createTextFieldGridData());
- groupId.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getModuleId(true).setGroupId(groupId.getText());
- markDirty();
- }
- });
-
- createLabel(composite, Messages.artifactId);
-
- artifactId = toolkit.createText(composite, getArtifactId(), SWT.BORDER);
- artifactId.setLayoutData(createTextFieldGridData());
- artifactId.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getModuleId(true).setArtifactId(artifactId.getText());
- markDirty();
- }
- });
-
- createLabel(composite, Messages.version);
-
- version = toolkit.createText(composite, getVersion(), SWT.BORDER);
- version.setLayoutData(createTextFieldGridData());
- version.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getModuleId(true).setVersion(version.getText());
- markDirty();
- }
- });
-
- createLabel(composite, Messages.artifactType);
-
- type = toolkit.createText(composite, getArtifact(), SWT.BORDER);
- type.setLayoutData(createTextFieldGridData());
- type.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getModuleId(true).setType(type.getText());
- markDirty();
- }
- });
-
- inverseClassLoading = toolkit.createButton(composite, Messages.inverseClassloading, SWT.CHECK);
- inverseClassLoading.setSelection(isInverseClassloading());
- GridData data = new GridData();
- data.horizontalSpan = 2;
- inverseClassLoading.setLayoutData(data);
-
- inverseClassLoading.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- setInverseClassloading(inverseClassLoading.getSelection());
- markDirty();
- }
- });
-
- suppressDefaultEnv = toolkit.createButton(composite, Messages.supressDefaultEnv, SWT.CHECK);
- suppressDefaultEnv.setSelection(isSuppressDefaultEnvironment());
- data = new GridData();
- data.horizontalSpan = 2;
- suppressDefaultEnv.setLayoutData(data);
-
- suppressDefaultEnv.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- setSuppressDefaultEnvironment(suppressDefaultEnv.getSelection());
- markDirty();
- }
- });
-
- sharedLibDepends = toolkit.createButton(composite, Messages.sharedLibDepends, SWT.CHECK);
- sharedLibDepends.setSelection(isSharedLibDependency());
- data = new GridData();
- data.horizontalSpan = 2;
- sharedLibDepends.setLayoutData(data);
-
- sharedLibDepends.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- setSharedLibDependency(sharedLibDepends.getSelection());
- markDirty();
- }
- });
- }
-
- protected Label createLabel(Composite parent, String text) {
- Label label = toolkit.createLabel(parent, text);
- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- return label;
- }
-
- protected GridData createTextFieldGridData() {
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- data.widthHint = 150;
- return data;
- }
-
- protected String getGroupId() {
- Artifact moduleId = getModuleId(false);
- if (moduleId != null
- && moduleId.getGroupId() != null)
- return moduleId.getGroupId();
- return "";
- }
-
- protected String getArtifactId() {
- Artifact moduleId = getModuleId(false);
- if (moduleId != null
- && moduleId.getArtifactId() != null)
- return moduleId.getArtifactId();
- return "";
- }
-
- protected String getVersion() {
- Artifact moduleId = getModuleId(false);
- if (moduleId != null
- && moduleId.getVersion() != null)
- return moduleId.getVersion();
- return "";
- }
-
- protected String getArtifact() {
- Artifact moduleId = getModuleId(false);
- if (moduleId != null
- && moduleId.getType() != null)
- return moduleId.getType();
- return "";
- }
-
- protected boolean isInverseClassloading() {
- Environment type = getEnvironment(false);
- return type != null && type.getInverseClassloading() != null;
- }
-
- protected boolean isSuppressDefaultEnvironment() {
- Environment type = getEnvironment(false);
- return type != null && type.getSuppressDefaultEnvironment() != null;
- }
-
- protected boolean isSharedLibDependency() {
- Dependencies depType = getDependencies(false);
- if(depType != null) {
- return getSharedLibDependency(depType) != null;
- }
- return false;
- }
-
- protected void setInverseClassloading(boolean enable) {
- if (enable) {
- Environment type = getEnvironment(true);
- type.setInverseClassloading(getDeploymentObjectFactory().createEmpty());
- } else {
- Environment type = getEnvironment(false);
- if (type != null) {
- type.setInverseClassloading(null);
- }
- }
- }
-
- protected void setSuppressDefaultEnvironment(boolean enable) {
- if (enable) {
- Environment type = getEnvironment(true);
- type.setSuppressDefaultEnvironment(getDeploymentObjectFactory().createEmpty());
- } else {
- Environment type = getEnvironment(false);
- if (type != null) {
- type.setSuppressDefaultEnvironment(null);
- }
- }
- }
-
- protected void setSharedLibDependency(boolean enable) {
- if (enable) {
- Dependencies deptype = getDependencies(true);
- Dependency sharedLib = getDeploymentObjectFactory().createDependency();
- sharedLib.setGroupId("org.apache.geronimo.configs");
- sharedLib.setArtifactId("sharedlib");
- sharedLib.setType("car");
- deptype.getDependency().add(sharedLib);
- } else {
- Dependencies deptype = getDependencies(false);
- if (deptype != null) {
- Artifact artifact = getSharedLibDependency(deptype);
- if(artifact != null) {
- deptype.getDependency().remove(artifact);
- }
- }
- }
- }
-
- private Artifact getSharedLibDependency(Dependencies dependencies) {
- Dependencies depType = getDependencies(false);
- List dependenciesList = depType.getDependency();
- Iterator i = dependenciesList.iterator();
- while(i.hasNext()) {
- Artifact artifact = (Artifact) i.next();
- if("org.apache.geronimo.configs".equals(artifact.getGroupId()) && "sharedlib".equals(artifact.getArtifactId()) && "car".equals(artifact.getType())) {
- return artifact;
- }
- }
- return null;
- }
-
-
- //
- // Need to support both WebApp and Connector
- //
- private Environment getEnvironment(boolean create) {
- Environment type = null;
- Object plan = getPlan().getValue();
- if (WebApp.class.isInstance(plan)) {
- type = ((WebApp) plan).getEnvironment();
- if (type == null && create) {
- type = getDeploymentObjectFactory().createEnvironment();
- ((WebApp) plan).setEnvironment(type);
- }
- } else if (Connector.class.isInstance(plan)) {
- type = ((Connector) plan).getEnvironment();
- if (type == null && create) {
- type = getDeploymentObjectFactory().createEnvironment();
- ((Connector) plan).setEnvironment(type);
- }
- } else if (Application.class.isInstance(plan)) {
- type = ((Application) plan).getEnvironment();
- if (type == null && create) {
- type = getDeploymentObjectFactory().createEnvironment();
- ((Application) plan).setEnvironment(type);
- }
- }
- // TODO add support for open-ejb & app-client clients
- return type;
- }
-
- private Dependencies getDependencies(boolean create) {
- Environment env = getEnvironment(create);
- if(env != null) {
- Dependencies dep = env.getDependencies();
- if (dep == null && create) {
- dep = getDeploymentObjectFactory().createDependencies();
- env.setDependencies(dep);
- }
- return dep;
- }
- return null;
- }
-
- private Artifact getModuleId(boolean create) {
- Environment type = getEnvironment(create);
- if (type != null) {
- Artifact moduleId = type.getModuleId();
- if (moduleId == null && create) {
- moduleId = getDeploymentObjectFactory().createArtifact();
- type.setModuleId(moduleId);
- }
- return moduleId;
- }
- return null;
- }
-
- private org.apache.geronimo.jee.deployment.ObjectFactory getDeploymentObjectFactory() {
- if ( deploymentObjectFactory == null ) {
- deploymentObjectFactory = new org.apache.geronimo.jee.deployment.ObjectFactory();
- }
- return deploymentObjectFactory;
- }
-
- protected abstract JAXBElement getEnvironmentEReference();
-
-}
+/*
+ * 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.sections;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.web.WebApp;
+import org.apache.geronimo.jee.deployment.Artifact;
+import org.apache.geronimo.jee.deployment.Dependencies;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.deployment.Environment;
+import org.apache.geronimo.jee.deployment.ObjectFactory;
+import org.apache.geronimo.jee.application.Application;
+import org.apache.geronimo.jee.applicationclient.ApplicationClient;
+import org.apache.geronimo.jee.connector.Connector;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractSectionPart;
+import org.apache.geronimo.st.v21.ui.internal.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+public abstract class CommonGeneralSection extends AbstractSectionPart {
+
+ protected Text artifactId;
+
+ protected Text groupId;
+
+ protected Text version;
+
+ protected Text type;
+
+ protected Button inverseClassLoading;
+
+ protected Button suppressDefaultEnv;
+
+ protected Button sharedLibDepends;
+
+ protected ObjectFactory deploymentObjectFactory = null;
+
+ public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
+ super(parent, toolkit, style, plan);
+ }
+
+ protected void createClient() {
+
+ Section section = getSection();
+
+ section.setText(CommonMessages.editorSectionGeneralTitle);
+ section.setDescription(CommonMessages.editorSectionGeneralDescription);
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+ Composite composite = toolkit.createComposite(section);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 5;
+ layout.marginWidth = 10;
+ layout.verticalSpacing = 5;
+ layout.horizontalSpacing = 15;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ section.setClient(composite);
+
+ createLabel(composite, Messages.groupId);
+
+ groupId = toolkit.createText(composite, getGroupId(), SWT.BORDER);
+ groupId.setLayoutData(createTextFieldGridData());
+ groupId.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getModuleId(true).setGroupId(groupId.getText());
+ markDirty();
+ }
+ });
+
+ createLabel(composite, Messages.artifactId);
+
+ artifactId = toolkit.createText(composite, getArtifactId(), SWT.BORDER);
+ artifactId.setLayoutData(createTextFieldGridData());
+ artifactId.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getModuleId(true).setArtifactId(artifactId.getText());
+ markDirty();
+ }
+ });
+
+ createLabel(composite, Messages.version);
+
+ version = toolkit.createText(composite, getVersion(), SWT.BORDER);
+ version.setLayoutData(createTextFieldGridData());
+ version.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getModuleId(true).setVersion(version.getText());
+ markDirty();
+ }
+ });
+
+ createLabel(composite, Messages.artifactType);
+
+ type = toolkit.createText(composite, getArtifact(), SWT.BORDER);
+ type.setLayoutData(createTextFieldGridData());
+ type.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getModuleId(true).setType(type.getText());
+ markDirty();
+ }
+ });
+
+ inverseClassLoading = toolkit.createButton(composite, Messages.inverseClassloading, SWT.CHECK);
+ inverseClassLoading.setSelection(isInverseClassloading());
+ GridData data = new GridData();
+ data.horizontalSpan = 2;
+ inverseClassLoading.setLayoutData(data);
+
+ inverseClassLoading.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ setInverseClassloading(inverseClassLoading.getSelection());
+ markDirty();
+ }
+ });
+
+ suppressDefaultEnv = toolkit.createButton(composite, Messages.supressDefaultEnv, SWT.CHECK);
+ suppressDefaultEnv.setSelection(isSuppressDefaultEnvironment());
+ data = new GridData();
+ data.horizontalSpan = 2;
+ suppressDefaultEnv.setLayoutData(data);
+
+ suppressDefaultEnv.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ setSuppressDefaultEnvironment(suppressDefaultEnv.getSelection());
+ markDirty();
+ }
+ });
+
+ sharedLibDepends = toolkit.createButton(composite, Messages.sharedLibDepends, SWT.CHECK);
+ sharedLibDepends.setSelection(isSharedLibDependency());
+ data = new GridData();
+ data.horizontalSpan = 2;
+ sharedLibDepends.setLayoutData(data);
+
+ sharedLibDepends.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ setSharedLibDependency(sharedLibDepends.getSelection());
+ markDirty();
+ }
+ });
+ }
+
+ protected Label createLabel(Composite parent, String text) {
+ Label label = toolkit.createLabel(parent, text);
+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ return label;
+ }
+
+ protected GridData createTextFieldGridData() {
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ data.widthHint = 150;
+ return data;
+ }
+
+ protected String getGroupId() {
+ Artifact moduleId = getModuleId(false);
+ if (moduleId != null
+ && moduleId.getGroupId() != null)
+ return moduleId.getGroupId();
+ return "";
+ }
+
+ protected String getArtifactId() {
+ Artifact moduleId = getModuleId(false);
+ if (moduleId != null
+ && moduleId.getArtifactId() != null)
+ return moduleId.getArtifactId();
+ return "";
+ }
+
+ protected String getVersion() {
+ Artifact moduleId = getModuleId(false);
+ if (moduleId != null
+ && moduleId.getVersion() != null)
+ return moduleId.getVersion();
+ return "";
+ }
+
+ protected String getArtifact() {
+ Artifact moduleId = getModuleId(false);
+ if (moduleId != null
+ && moduleId.getType() != null)
+ return moduleId.getType();
+ return "";
+ }
+
+ protected boolean isInverseClassloading() {
+ Environment type = getEnvironment(false);
+ return type != null && type.getInverseClassloading() != null;
+ }
+
+ protected boolean isSuppressDefaultEnvironment() {
+ Environment type = getEnvironment(false);
+ return type != null && type.getSuppressDefaultEnvironment() != null;
+ }
+
+ protected boolean isSharedLibDependency() {
+ Dependencies depType = getDependencies(false);
+ if(depType != null) {
+ return getSharedLibDependency(depType) != null;
+ }
+ return false;
+ }
+
+ protected void setInverseClassloading(boolean enable) {
+ if (enable) {
+ Environment type = getEnvironment(true);
+ type.setInverseClassloading(getDeploymentObjectFactory().createEmpty());
+ } else {
+ Environment type = getEnvironment(false);
+ if (type != null) {
+ type.setInverseClassloading(null);
+ }
+ }
+ }
+
+ protected void setSuppressDefaultEnvironment(boolean enable) {
+ if (enable) {
+ Environment type = getEnvironment(true);
+ type.setSuppressDefaultEnvironment(getDeploymentObjectFactory().createEmpty());
+ } else {
+ Environment type = getEnvironment(false);
+ if (type != null) {
+ type.setSuppressDefaultEnvironment(null);
+ }
+ }
+ }
+
+ protected void setSharedLibDependency(boolean enable) {
+ if (enable) {
+ Dependencies deptype = getDependencies(true);
+ Dependency sharedLib = getDeploymentObjectFactory().createDependency();
+ sharedLib.setGroupId("org.apache.geronimo.configs");
+ sharedLib.setArtifactId("sharedlib");
+ sharedLib.setType("car");
+ deptype.getDependency().add(sharedLib);
+ } else {
+ Dependencies deptype = getDependencies(false);
+ if (deptype != null) {
+ Artifact artifact = getSharedLibDependency(deptype);
+ if(artifact != null) {
+ deptype.getDependency().remove(artifact);
+ }
+ }
+ }
+ }
+
+ private Artifact getSharedLibDependency(Dependencies dependencies) {
+ Dependencies depType = getDependencies(false);
+ List dependenciesList = depType.getDependency();
+ Iterator i = dependenciesList.iterator();
+ while(i.hasNext()) {
+ Artifact artifact = (Artifact) i.next();
+ if("org.apache.geronimo.configs".equals(artifact.getGroupId()) && "sharedlib".equals(artifact.getArtifactId()) && "car".equals(artifact.getType())) {
+ return artifact;
+ }
+ }
+ return null;
+ }
+
+
+ //
+ // Need to support both WebApp and Connector
+ //
+ private Environment getEnvironment(boolean create) {
+ Environment type = null;
+ Object plan = getPlan().getValue();
+ if (WebApp.class.isInstance(plan)) {
+ type = ((WebApp) plan).getEnvironment();
+ if (type == null && create) {
+ type = getDeploymentObjectFactory().createEnvironment();
+ ((WebApp) plan).setEnvironment(type);
+ }
+ } else if (Connector.class.isInstance(plan)) {
+ type = ((Connector) plan).getEnvironment();
+ if (type == null && create) {
+ type = getDeploymentObjectFactory().createEnvironment();
+ ((Connector) plan).setEnvironment(type);
+ }
+ } else if (Application.class.isInstance(plan)) {
+ type = ((Application) plan).getEnvironment();
+ if (type == null && create) {
+ type = getDeploymentObjectFactory().createEnvironment();
+ ((Application) plan).setEnvironment(type);
+ }
+ } else if (OpenejbJar.class.isInstance(plan)) {
+ type = ((OpenejbJar) plan).getEnvironment();
+ if (type == null && create) {
+ type = getDeploymentObjectFactory().createEnvironment();
+ ((OpenejbJar) plan).setEnvironment(type);
+ }
+ }
+ // TODO add support for application client
+ // figure out if this is client or server environment
+
+ return type;
+ }
+
+ private Dependencies getDependencies(boolean create) {
+ Environment env = getEnvironment(create);
+ if(env != null) {
+ Dependencies dep = env.getDependencies();
+ if (dep == null && create) {
+ dep = getDeploymentObjectFactory().createDependencies();
+ env.setDependencies(dep);
+ }
+ return dep;
+ }
+ return null;
+ }
+
+ private Artifact getModuleId(boolean create) {
+ Environment type = getEnvironment(create);
+ if (type != null) {
+ Artifact moduleId = type.getModuleId();
+ if (moduleId == null && create) {
+ moduleId = getDeploymentObjectFactory().createArtifact();
+ type.setModuleId(moduleId);
+ }
+ return moduleId;
+ }
+ return null;
+ }
+
+ private org.apache.geronimo.jee.deployment.ObjectFactory getDeploymentObjectFactory() {
+ if ( deploymentObjectFactory == null ) {
+ deploymentObjectFactory = new org.apache.geronimo.jee.deployment.ObjectFactory();
+ }
+ return deploymentObjectFactory;
+ }
+
+ protected abstract JAXBElement getEnvironmentEReference();
+
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/DependencySection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/DependencySection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/DependencySection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/DependencySection.java Thu Jun 5 10:38:37 2008
@@ -1,139 +1,118 @@
-/*
- * 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.sections;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.providers.AdapterFactory;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
-import org.apache.geronimo.st.v21.ui.Activator;
-import org.apache.geronimo.st.v21.ui.wizards.DependencyWizard;
-import org.apache.geronimo.jee.deployment.Dependencies;
-import org.apache.geronimo.jee.deployment.Dependency;
-import org.apache.geronimo.jee.deployment.Environment;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class DependencySection extends AbstractTableSection {
-
- private Environment environment;
-
- /**
- * @param plan
- * @param parent
- * @param toolkit
- * @param style
- */
- public DependencySection(JAXBElement plan, Environment environment, Composite parent, FormToolkit toolkit, int style) {
- super(plan, parent, toolkit, style);
- this.environment = environment;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorSectionDependenciesTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorSectionDependenciesDescription;
- }
-
- public List getObjectContainer() {
- if ( environment.getDependencies() == null ) {
- Dependencies dependencies = (Dependencies)JAXBObjectFactoryImpl.getInstance().create(Dependencies.class);
- environment.setDependencies(dependencies);
- }
- return environment.getDependencies().getDependency();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new DependencyWizard(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#isHeaderVisible()
- */
- public boolean isHeaderVisible() {
- return false;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return Activator.imageDescriptorFromPlugin("org.eclipse.jdt.ui", "icons/full/obj16/jar_obj.gif");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return Dependency.class;
- }
-
-
- public Object getInput() {
- if (environment != null) {
- return environment.getDependencies();
- }
- return super.getInput();
- }
-
- public AdapterFactory getAdapterFactory() {
- return new AdapterFactory() {
- public Object[] getElements(Object inputElement) {
- if (!Dependencies.class.isInstance(inputElement)) {
- return new String[] { "" };
- }
- Dependencies plan = (Dependencies)inputElement;
- return plan.getDependency().toArray();
- }
- public String getColumnText(Object element, int columnIndex) {
- if (Dependency.class.isInstance(element)) {
- Dependency dependency = (Dependency)element;
- switch (columnIndex) {
- case 0: return dependency.getGroupId();
- case 1: return dependency.getArtifactId();
- }
- }
- return null;
- }
- };
- }
-}
+/*
+ * 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.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.DependencyWizard;
+import org.apache.geronimo.jee.deployment.Dependencies;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.deployment.Environment;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class DependencySection extends AbstractTableSection {
+
+ private Environment environment;
+
+ /**
+ * @param plan
+ * @param parent
+ * @param toolkit
+ * @param style
+ */
+ public DependencySection(JAXBElement plan, Environment environment, Composite parent, FormToolkit toolkit, int style) {
+ super(plan, parent, toolkit, style);
+ this.environment = environment;
+ this.COLUMN_NAMES = new String[] {
+ CommonMessages.artifactId, CommonMessages.groupId, CommonMessages.version, CommonMessages.type
+ };
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorSectionDependenciesTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorSectionDependenciesDescription;
+ }
+
+ public List getObjectContainer() {
+ if (environment == null) {
+ environment = (Environment)JAXBObjectFactoryImpl.getInstance().create(Environment.class);
+ }
+
+ if ( environment.getDependencies() == null ) {
+ Dependencies dependencies = (Dependencies)JAXBObjectFactoryImpl.getInstance().create(Dependencies.class);
+ environment.setDependencies(dependencies);
+ }
+ return environment.getDependencies().getDependency();
+ }
+
+ public Wizard getWizard() {
+ return new DependencyWizard(this);
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin("org.eclipse.jdt.ui", "icons/full/obj16/jar_obj.gif");
+ }
+
+ public Class getTableEntryObjectType() {
+ return Dependency.class;
+ }
+
+ public Object getInput() {
+ if (environment != null) {
+ return environment.getDependencies();
+ }
+ return super.getInput();
+ }
+
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!Dependencies.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ Dependencies plan = (Dependencies)inputElement;
+ return plan.getDependency().toArray();
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ if (Dependency.class.isInstance(element)) {
+ Dependency dependency = (Dependency)element;
+ switch (columnIndex) {
+ case 0: return dependency.getGroupId();
+ case 1: return dependency.getArtifactId();
+ case 2: return dependency.getVersion();
+ case 3: return dependency.getType();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbLocalRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbLocalRefSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbLocalRefSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbLocalRefSection.java Thu Jun 5 10:38:37 2008
@@ -1,113 +1,90 @@
-/*
- * 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.sections;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.ui.Activator;
-import org.apache.geronimo.st.v21.ui.wizards.EjbLocalRefWizard;
-import org.apache.geronimo.jee.naming.EjbLocalRef;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class EjbLocalRefSection extends AbstractTableSection {
-
- List ejbLocalRefERef;
-
- private static final String[] COLUMN_NAMES = new String[] {
- CommonMessages.name,
- CommonMessages.editorEjbRefEjbLink };
-
- public EjbLocalRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List ejbLocalRefERef) {
- super(plan, parent, toolkit, style);
- this.ejbLocalRefERef = ejbLocalRefERef;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorEjbLocalRefTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorEjbLocalRefDescription;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableColumnNames()
- */
- public String[] getTableColumnNames() {
- return COLUMN_NAMES;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.ui.sections.AbstractTableSection#getEReference()
-// */
-// public JAXBElement getEReference() {
-// return ejbLocalRefERef;
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new EjbLocalRefWizard(this);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/ejb_local_ref_obj.gif");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return EjbLocalRef.class;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
-// */
-// public AdapterFactory getAdapterFactory() {
-// return EMFEditorContext.getFactory();
-// }
-}
+/*
+ * 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.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.EjbLocalRefWizard;
+import org.apache.geronimo.jee.naming.EjbLocalRef;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class EjbLocalRefSection extends AbstractTableSection {
+
+ public EjbLocalRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List ejbLocalRefs) {
+ super(plan, parent, toolkit, style);
+ this.objectContainer = ejbLocalRefs;
+ COLUMN_NAMES = new String[] {
+ CommonMessages.name, CommonMessages.editorEjbRefEjbLink };
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorEjbLocalRefTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorEjbLocalRefDescription;
+ }
+
+ public Wizard getWizard() {
+ return new EjbLocalRefWizard(this);
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/ejb_local_ref_obj.gif");
+ }
+
+ public Class getTableEntryObjectType() {
+ return EjbLocalRef.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
+ */
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!JAXBElement.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ return getObjectContainer().toArray();
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (EjbLocalRef.class.isInstance(element)) {
+ EjbLocalRef ejbLocalRef = (EjbLocalRef)element;
+ switch (columnIndex) {
+ case 0: return ejbLocalRef.getRefName();
+ case 1: return ejbLocalRef.getEjbLink();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRefSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRefSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRefSection.java Thu Jun 5 10:38:37 2008
@@ -1,119 +1,96 @@
-/*
- * 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.sections;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.ui.Activator;
-import org.apache.geronimo.st.v21.ui.wizards.EjbRefWizard;
-import org.apache.geronimo.jee.naming.EjbRef;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class EjbRefSection extends AbstractTableSection {
-
- List ejbRefERef;
-
- private static final String[] COLUMN_NAMES = new String[] {
- CommonMessages.name,
- CommonMessages.editorEjbRefEjbLink };
-
- /**
- * @param plan
- * @param parent
- * @param toolkit
- * @param style
- */
- public EjbRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List ejbRefERef) {
- super(plan, parent, toolkit, style);
- this.ejbRefERef = ejbRefERef;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorEjbRefTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorEjbRefDescription;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableColumnNames()
- */
- public String[] getTableColumnNames() {
- return COLUMN_NAMES;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.ui.sections.AbstractTableSection#getEReference()
-// */
-// public JAXBElement getEReference() {
-// return ejbRefERef;
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new EjbRefWizard(this);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/ejbRef_obj.gif");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return EjbRef.class;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
-// */
-// public AdapterFactory getAdapterFactory() {
-// return EMFEditorContext.getFactory();
-// }
-}
+/*
+ * 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.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.EjbRefWizard;
+import org.apache.geronimo.jee.naming.EjbRef;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class EjbRefSection extends AbstractTableSection {
+
+ /**
+ * @param plan
+ * @param parent
+ * @param toolkit
+ * @param style
+ */
+ public EjbRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List ejbRefs) {
+ super(plan, parent, toolkit, style);
+ this.objectContainer = ejbRefs;
+ COLUMN_NAMES = new String[] {
+ CommonMessages.name, CommonMessages.editorEjbRefEjbLink };
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorEjbRefTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorEjbRefDescription;
+ }
+
+ public Wizard getWizard() {
+ return new EjbRefWizard(this);
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/ejbRef_obj.gif");
+ }
+
+ public Class getTableEntryObjectType() {
+ return EjbRef.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
+ */
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!JAXBElement.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ return getObjectContainer().toArray();
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (EjbRef.class.isInstance(element)) {
+ EjbRef ejbRef = (EjbRef)element;
+ switch (columnIndex) {
+ case 0: return ejbRef.getRefName();
+ case 1: return ejbRef.getEjbLink();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java Thu Jun 5 10:38:37 2008
@@ -1,131 +1,136 @@
-/*
- * 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.sections;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.jee.web.WebApp;
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.providers.AdapterFactory;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.ui.wizards.GBeanWizard;
-import org.apache.geronimo.jee.deployment.Gbean;
-import org.apache.geronimo.jee.naming.ResourceRef;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class GBeanSection extends AbstractTableSection {
-
- private List gbeans;
-
- private static final String[] COLUMN_NAMES = new String[] {
- CommonMessages.name, CommonMessages.className };
-
- /**
- * @param plan
- * @param parent
- * @param toolkit
- * @param style
- */
- public GBeanSection(JAXBElement plan, List gbeans, Composite parent, FormToolkit toolkit, int style) {
- super(plan, parent, toolkit, style);
- this.gbeans = gbeans;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorSectionGBeanTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorSectionGBeanDescription;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableColumnNames()
- */
- public String[] getTableColumnNames() {
- return COLUMN_NAMES;
- }
-
- public List getObjectContainer() {
- return gbeans;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new GBeanWizard(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return Gbean.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
- */
- public AdapterFactory getAdapterFactory() {
- return new AdapterFactory() {
- public Object[] getElements(Object inputElement) {
- if (!JAXBElement.class.isInstance(inputElement)) {
- return new String[] { "" };
- }
- JAXBElement plan = (JAXBElement)inputElement;
- if (plan.getDeclaredType().equals(WebApp.class)) {
- return ((WebApp)plan.getValue()).getResourceRef().toArray();
- }
- return new String[] { "" };
- }
- public String getColumnText(Object element, int columnIndex) {
- if (ResourceRef.class.isInstance(element)) {
- ResourceRef resourceRef = (ResourceRef)element;
- switch (columnIndex) {
- case 0: return resourceRef.getRefName();
- case 1: return resourceRef.getResourceLink();
- }
- }
- return null;
- }
- };
- }
-}
+/*
+ * 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.sections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.deployment.Gbean;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.apache.geronimo.st.v21.ui.wizards.GBeanWizard;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class GBeanSection extends AbstractTableSection {
+
+ /**
+ * @param plan
+ * @param parent
+ * @param toolkit
+ * @param style
+ */
+ public GBeanSection(JAXBElement plan, List gbeans, Composite parent, FormToolkit toolkit, int style) {
+ super(plan, parent, toolkit, style);
+ this.objectContainer = gbeans;
+ this.COLUMN_NAMES = new String[] {
+ CommonMessages.name, CommonMessages.className };
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorSectionGBeanTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorSectionGBeanDescription;
+ }
+
+ public List getObjectContainer() {
+ //NOTE this is a list of JAXBElements of GBeans, not just GBeans
+ if (objectContainer == null) {
+ objectContainer = (List)JAXBObjectFactoryImpl.getInstance().create(List.class);
+ }
+ return objectContainer;
+ }
+
+ public Wizard getWizard() {
+ return new GBeanWizard(this);
+ }
+
+ public Class getTableEntryObjectType() {
+ return Gbean.class;
+ }
+
+ public Object getInput() {
+ if (objectContainer != null) {
+ return objectContainer;
+ }
+ return super.getInput();
+ }
+
+ // overwrite this method.
+ // The item is a GBean and the list is a list of JAXBElements of GBean
+ public void removeItem (Object anItem) {
+ JAXBElement element;
+ Gbean gbean, removeItem;
+ removeItem = (Gbean)anItem;
+ for (int i = 0; i < objectContainer.size(); i++)
+ {
+ element = (JAXBElement)objectContainer.get(i);
+ gbean = (Gbean)element.getValue();
+ if (removeItem.getName().equals(gbean.getName()) &&
+ removeItem.getClazz().equals(gbean.getClazz()))
+ {
+ getObjectContainer().remove(i);
+ return;
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
+ */
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!List.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ // convert the list of JAXBElements into regular GBeans
+ List elementList = (List)inputElement;
+ ArrayList gbeanList = new ArrayList();
+ JAXBElement element;
+ Gbean gbean;
+ for (int i = 0; i < elementList.size(); i++) {
+ element = (JAXBElement)elementList.get(i);
+ gbean = (Gbean)element.getValue();
+ gbeanList.add(gbean);
+ }
+ return gbeanList.toArray();
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (Gbean.class.isInstance(element)) {
+ Gbean gbean = (Gbean)element;
+ switch (columnIndex) {
+ case 0: return gbean.getName();
+ case 1: return gbean.getClazz();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceEnvRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceEnvRefSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceEnvRefSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceEnvRefSection.java Thu Jun 5 10:38:37 2008
@@ -1,113 +1,91 @@
-/*
- * 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.sections;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.ui.Activator;
-import org.apache.geronimo.st.v21.ui.wizards.ResourceEnvRefWizard;
-import org.apache.geronimo.jee.naming.ResourceEnvRef;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class ResourceEnvRefSection extends AbstractTableSection {
-
- List resourceEnvRefERef;
-
- private static final String[] COLUMN_NAMES = new String[] {
- CommonMessages.editorResEnvRefNameTitle,
- CommonMessages.editorResEnvRefMsgDestTitle };
-
- public ResourceEnvRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceEnvRefERef) {
- super(plan, parent, toolkit, style);
- this.resourceEnvRefERef = resourceEnvRefERef;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorResourceEnvRefTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorResourceEnvRefDescription;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableColumnNames()
- */
- public String[] getTableColumnNames() {
- return COLUMN_NAMES;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.ui.sections.AbstractTableSection#getEReference()
-// */
-// public JAXBElement getEReference() {
-// return resourceEnvRefERef;
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new ResourceEnvRefWizard(this);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/res_env_ref_obj.gif");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return ResourceEnvRef.class;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
-// */
-// public AdapterFactory getAdapterFactory() {
-// return EMFEditorContext.getFactory();
-// }
-}
+/*
+ * 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.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.ResourceEnvRefWizard;
+import org.apache.geronimo.jee.naming.ResourceEnvRef;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ResourceEnvRefSection extends AbstractTableSection {
+
+
+ public ResourceEnvRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceEnvRefs) {
+ super(plan, parent, toolkit, style);
+ this.objectContainer = resourceEnvRefs;
+ COLUMN_NAMES = new String[] {
+ CommonMessages.editorResEnvRefNameTitle, CommonMessages.editorResEnvRefMsgDestTitle };
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorResourceEnvRefTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorResourceEnvRefDescription;
+ }
+
+ public Wizard getWizard() {
+ return new ResourceEnvRefWizard(this);
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/res_env_ref_obj.gif");
+ }
+
+ public Class getTableEntryObjectType() {
+ return ResourceEnvRef.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
+ */
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!JAXBElement.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ return getObjectContainer().toArray();
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (ResourceEnvRef.class.isInstance(element)) {
+ ResourceEnvRef resourceEnvRef = (ResourceEnvRef)element;
+ switch (columnIndex) {
+ case 0: return resourceEnvRef.getRefName();
+ case 1: return resourceEnvRef.getMessageDestinationLink();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceRefSection.java?rev=663673&r1=663672&r2=663673&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceRefSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ResourceRefSection.java Thu Jun 5 10:38:37 2008
@@ -1,141 +1,90 @@
-/*
- * 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.sections;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.geronimo.jee.web.WebApp;
-import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.providers.AdapterFactory;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.v21.ui.Activator;
-import org.apache.geronimo.st.v21.ui.wizards.ResourceRefWizard;
-import org.apache.geronimo.jee.naming.ResourceRef;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class ResourceRefSection extends AbstractTableSection {
-
- List resourceRefERefs;
-
- private static final String[] COLUMN_NAMES = new String[] {
- CommonMessages.editorResRefNameTitle,
- CommonMessages.editorResRefLinkTitle};
-
- public ResourceRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceRefERefs) {
- super(plan, parent, toolkit, style);
- this.resourceRefERefs = resourceRefERefs;
- createClient();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTitle()
- */
- public String getTitle() {
- return CommonMessages.editorResourceRefTitle;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getDescription()
- */
- public String getDescription() {
- return CommonMessages.editorResourceRefDescription;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableColumnNames()
- */
- public String[] getTableColumnNames() {
- return COLUMN_NAMES;
- }
-
-// /*
-// * (non-Javadoc)
-// *
-// * @see org.apache.geronimo.ui.sections.AbstractTableSection#getEReference()
-// */
-// public JAXBElement getEReference() {
-// return resourceRefERef;
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.DynamicTableSection#getWizard()
- */
- public Wizard getWizard() {
- return new ResourceRefWizard(this);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/resourceRef_obj.gif");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.ui.sections.AbstractTableSection#getTableEntryObjectType()
- */
- public Class getTableEntryObjectType() {
- return ResourceRef.class;
- }
-
- public List getObjectContainer() {
- return resourceRefERefs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
- */
- public AdapterFactory getAdapterFactory() {
- return new AdapterFactory() {
- public Object[] getElements(Object inputElement) {
- if (!JAXBElement.class.isInstance(inputElement)) {
- return new String[] { "" };
- }
- JAXBElement plan = (JAXBElement)inputElement;
- if (plan.getDeclaredType().equals(WebApp.class)) {
- return ((WebApp)plan.getValue()).getResourceRef().toArray();
- }
- return new String[] { "" };
- }
- public String getColumnText(Object element, int columnIndex) {
- if (ResourceRef.class.isInstance(element)) {
- ResourceRef resourceRef = (ResourceRef)element;
- switch (columnIndex) {
- case 0: return resourceRef.getRefName();
- case 1: return resourceRef.getResourceLink();
- }
- }
- return null;
- }
- };
- }
-}
+/*
+ * 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.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.providers.AdapterFactory;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.ResourceRefWizard;
+import org.apache.geronimo.jee.naming.ResourceRef;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ResourceRefSection extends AbstractTableSection {
+
+ public ResourceRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceRefs) {
+ super(plan, parent, toolkit, style);
+ this.objectContainer = resourceRefs;
+ COLUMN_NAMES = new String[] {
+ CommonMessages.editorResRefNameTitle, CommonMessages.editorResRefLinkTitle};
+ createClient();
+ }
+
+ public String getTitle() {
+ return CommonMessages.editorResourceRefTitle;
+ }
+
+ public String getDescription() {
+ return CommonMessages.editorResourceRefDescription;
+ }
+
+ public Wizard getWizard() {
+ return new ResourceRefWizard(this);
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/resourceRef_obj.gif");
+ }
+
+ public Class getTableEntryObjectType() {
+ return ResourceRef.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.ui.sections.AbstractTableSection#getAdapterFactory()
+ */
+ public AdapterFactory getAdapterFactory() {
+ return new AdapterFactory() {
+ public Object[] getElements(Object inputElement) {
+ if (!JAXBElement.class.isInstance(inputElement)) {
+ return new String[] { "" };
+ }
+ return getObjectContainer().toArray();
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (ResourceRef.class.isInstance(element)) {
+ ResourceRef resourceRef = (ResourceRef)element;
+ switch (columnIndex) {
+ case 0: return resourceRef.getRefName();
+ case 1: return resourceRef.getResourceLink();
+ }
+ }
+ return null;
+ }
+ };
+ }
+}