Author: scabanovich
Date: 2010-03-10 10:24:16 -0500 (Wed, 10 Mar 2010)
New Revision: 20739
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppListsFormLayoutData.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppFormLayoutData.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5975
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppFormLayoutData.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppFormLayoutData.java 2010-03-10
15:23:33 UTC (rev 20738)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppFormLayoutData.java 2010-03-10
15:24:16 UTC (rev 20739)
@@ -11,6 +11,9 @@
package org.jboss.tools.jst.web.ui.editors.webapp.form;
import java.util.*;
+
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
import org.jboss.tools.common.model.util.ClassLoaderUtil;
import org.jboss.tools.common.model.ui.forms.*;
@@ -65,7 +68,7 @@
WebAppFileFormLayoutData.FILE_WEB_APP_30_DEFINITION,
};
- private static Map FORM_LAYOUT_DEFINITION_MAP = Collections.unmodifiableMap(new
ArrayToMap(FORM_LAYOUT_DEFINITIONS));
+ private static Map FORM_LAYOUT_DEFINITION_MAP = Collections.synchronizedMap(new
ArrayToMap(FORM_LAYOUT_DEFINITIONS));
private static WebAppFormLayoutData INSTANCE = new WebAppFormLayoutData();
@@ -76,7 +79,42 @@
private WebAppFormLayoutData() {}
public IFormData getFormData(String entityName) {
- return (IFormData)FORM_LAYOUT_DEFINITION_MAP.get(entityName);
+ IFormData data = (IFormData)FORM_LAYOUT_DEFINITION_MAP.get(entityName);
+ if(data == null) {
+ data = generateDefaultFormData(entityName);
+ }
+ return data;
}
+
+ private IFormData generateDefaultFormData(String entityName) {
+ IFormData data = null;
+ XModelEntity entity = XModelMetaDataImpl.getInstance().getEntity(entityName);
+ if(entity != null) {
+ data = generateDefaultFormData(entity);
+ }
+ if(data != null) {
+ FORM_LAYOUT_DEFINITION_MAP.put(entityName, data);
+ }
+ return data;
+ }
+
+ public IFormData generateDefaultFormData(XModelEntity entity) {
+ String entityName = entity.getName();
+ List<IFormData> list = new ArrayList<IFormData>();
+ IFormData g = ModelFormLayoutData.createGeneralFormData(entity);
+ if(g != null) list.add(g);
+ for (int i = 0; i < entity.getChildren().length; i++) {
+ String ce = entity.getChildren()[i].getName();
+ if(WebAppListsFormLayoutData.singleChildLists.containsKey(ce)) {
+ list.add(WebAppListsFormLayoutData.singleChildLists.get(ce));
+ }
+ }
+ IFormData a = ModelFormLayoutData.createAdvancedFormData(entityName);
+ if(a != null) list.add(a);
+ IFormData[] ds = list.toArray(new IFormData[0]);
+ IFormData data = new FormData(entityName, new String[0], ds);
+ return data;
+ }
+
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppListsFormLayoutData.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppListsFormLayoutData.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppListsFormLayoutData.java 2010-03-10
15:24:16 UTC (rev 20739)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.ui.editors.webapp.form;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.common.model.ui.forms.FormAttributeData;
+import org.jboss.tools.common.model.ui.forms.FormData;
+import org.jboss.tools.common.model.ui.forms.FormLayoutDataUtil;
+import org.jboss.tools.common.model.ui.forms.IFormData;
+import org.jboss.tools.common.model.ui.forms.ModelFormLayoutData;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class WebAppListsFormLayoutData {
+
+ static Map<String, IFormData> singleChildLists = new HashMap<String,
IFormData>();
+
+ static IFormData createOneAttributeSingleChildList(String header, String attrName,
String childEntity, String actionPath) {
+ IFormData result = new FormData(
+ header,
+ ModelFormLayoutData.EMPTY_DESCRIPTION,
+ new FormAttributeData[]{new FormAttributeData(attrName, 100)},
+ new String[]{childEntity},
+ FormLayoutDataUtil.createDefaultFormActionData(actionPath)
+ );
+ singleChildLists.put(childEntity, result);
+ return result;
+ }
+
+ static IFormData createTwoAttributeSingleChildList(String header, String attrName, int
width, String attr2Name, String childEntity, String actionPath) {
+ IFormData result = new FormData(
+ header,
+ ModelFormLayoutData.EMPTY_DESCRIPTION,
+ new FormAttributeData[]{new FormAttributeData(attrName, width), new
FormAttributeData(attr2Name, 100 - width)},
+ new String[]{childEntity},
+ FormLayoutDataUtil.createDefaultFormActionData(actionPath)
+ );
+ singleChildLists.put(childEntity, result);
+ return result;
+ }
+
+ static {
+ createOneAttributeSingleChildList(
+ "Properties", "name", "WebAppProperty30",
"CreateActions.CreateProperty" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+ createOneAttributeSingleChildList(
+ "Data Sources", "name", "WebAppDataSource30",
"CreateActions.CreateDataSource" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+ createTwoAttributeSingleChildList(
+ "Services", "service-ref-name", 40, "service-interface",
"WebAppServiceRef30", "CreateActions.CreateServiceRef" //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ );
+ createTwoAttributeSingleChildList(
+ "Init Params", "param-name", 40, "param-value",
"WebAppInitParam", "CreateActions.CreateInitParam" //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ );
+ createOneAttributeSingleChildList(
+ "SOAP Headers", "header", "WebAppSoapHeader30",
"CreateActions.CreateSoapHeader" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+ createOneAttributeSingleChildList(
+ "SOAP Roles", "role", "WebAppSoapRole30",
"CreateActions.CreateSoapRole" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+ createOneAttributeSingleChildList(
+ "Port Names", "name", "WebAppPortName30",
"CreateActions.CreatePortName" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+
+ createOneAttributeSingleChildList(
+ "Port Component Refs", "service-endpoint-interface",
"WebAppPortComponentRef30", "CreateActions.CreatePortComponentRef"
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ );
+ createTwoAttributeSingleChildList(
+ "Handlers", "handler-name", 50, "handler-class",
"WebAppHandler30", "CreateActions.CreatePortComponentRef"
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ );
+
+ createOneAttributeSingleChildList(
+ "Cookie Configs", "name", "WebAppCookieConfig",
"CreateActions.CreateCookieConfig" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ );
+ }
+
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editors/webapp/form/WebAppListsFormLayoutData.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain