JBoss Tools SVN: r2462 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 08:33:41 -0400 (Tue, 17 Jul 2007)
New Revision: 2462
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
Log:
EXIN-217 seam.properties files processed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-17 12:32:44 UTC (rev 2461)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-17 12:33:41 UTC (rev 2462)
@@ -29,12 +29,6 @@
public class SeamCoreBuilder extends IncrementalProjectBuilder {
public static String BUILDER_ID = "org.jboss.tools.seam.core.seambuilder";
- static IFileScanner[] FILE_SCANNERS = {
- new JavaScanner(),
- new XMLScanner(),
-// new LibraryScanner()
- };
-
SeamResourceVisitor resourceVisitor = null;
SeamProject getSeamProject() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-17 12:32:44 UTC (rev 2461)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-17 12:33:41 UTC (rev 2462)
@@ -18,12 +18,11 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
+import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
/**
@@ -33,6 +32,7 @@
static IFileScanner[] FILE_SCANNERS = {
new JavaScanner(),
new XMLScanner(),
+ new PropertiesScanner(),
};
SeamProject p;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-17 12:32:44 UTC (rev 2461)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-17 12:33:41 UTC (rev 2462)
@@ -11,9 +11,6 @@
package org.jboss.tools.seam.internal.core.scanner.lib;
import java.io.ByteArrayInputStream;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -27,7 +24,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
@@ -36,9 +32,9 @@
import org.jboss.tools.common.model.util.XModelObjectUtil;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
-import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
/**
@@ -113,26 +109,9 @@
if(ds1 != null) ds.add(ds1);
}
if(seamProperties != null) {
- XModelObject[] properties = seamProperties.getChildren();
- Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String, SeamPropertiesDeclaration>();
- for (int i = 0; i < properties.length; i++) {
- String name = properties[i].getAttributeValue("name");
- String value = properties[i].getAttributeValue("value");
- int q = name.lastIndexOf('.');
- if(q < 0) continue;
- String componentName = name.substring(0, q);
- String propertyName = name.substring(q + 1);
- SeamPropertiesDeclaration d = ds1.get(componentName);
- if(d == null) {
- d = new SeamPropertiesDeclaration();
- d.setId(properties[i]);
- d.setSourcePath(path);
- d.setName(componentName);
- ds1.put(componentName, d);
- }
- d.addStringProperty(propertyName, value);
- }
- ds.getComponents().addAll(ds1.values());
+ PropertiesScanner scanner = new PropertiesScanner();
+ LoadedDeclarations ds1 = scanner.parse(seamProperties, path);
+ if(ds1 != null) ds.add(ds1);
}
return ds;
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-17 12:33:41 UTC (rev 2462)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.scanner.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.internal.core.InnerModelHelper;
+import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
+import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+
+public class PropertiesScanner implements IFileScanner {
+
+ public PropertiesScanner() {}
+
+ /**
+ * Returns true if file is probable component source -
+ * has components.xml name or *.component.xml mask.
+ * @param resource
+ * @return
+ */
+ public boolean isRelevant(IFile resource) {
+ if(resource.getName().equals("seam.properties")) return true;
+ return false;
+ }
+
+ /**
+ * This method should be called only if isRelevant returns true;
+ * Makes simple check if this java file contains annotation Name.
+ * @param resource
+ * @return
+ */
+ public boolean isLikelyComponentSource(IFile f) {
+ if(!f.isSynchronized(IFile.DEPTH_ZERO) || !f.exists()) return false;
+ if(f.getName().equals("seam.properties")) return true;
+ return false;
+ }
+
+ /**
+ * Returns list of components
+ * @param f
+ * @return
+ * @throws Exception
+ */
+ public LoadedDeclarations parse(IFile f) throws Exception {
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return null;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ return parse(o, f.getFullPath());
+ }
+
+ public LoadedDeclarations parse(XModelObject o, IPath source) {
+ if(o == null) return null;
+ LoadedDeclarations ds = new LoadedDeclarations();
+
+ XModelObject[] properties = o.getChildren();
+ Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String, SeamPropertiesDeclaration>();
+ for (int i = 0; i < properties.length; i++) {
+ String name = properties[i].getAttributeValue("name");
+ String value = properties[i].getAttributeValue("value");
+ int q = name.lastIndexOf('.');
+ if(q < 0) continue;
+ String componentName = name.substring(0, q);
+ String propertyName = name.substring(q + 1);
+ SeamPropertiesDeclaration d = ds1.get(componentName);
+ if(d == null) {
+ d = new SeamPropertiesDeclaration();
+ d.setId(properties[i]);
+ d.setSourcePath(source);
+ d.setName(componentName);
+ ds1.put(componentName, d);
+ }
+ d.addStringProperty(propertyName, value);
+ }
+ return ds;
+ }
+
+}
17 years, 5 months
JBoss Tools SVN: r2461 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 08:32:44 -0400 (Tue, 17 Jul 2007)
New Revision: 2461
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java
Log:
EXIN-218 - double click implemented
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java 2007-07-17 12:18:02 UTC (rev 2460)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java 2007-07-17 12:32:44 UTC (rev 2461)
@@ -13,8 +13,10 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
import org.jboss.tools.seam.core.IOpenableElement;
import org.jboss.tools.seam.core.ISeamElement;
@@ -42,4 +44,20 @@
}
}
+ public void fillActionBars(IActionBars actionBars) {
+ ActionContext c = getContext();
+ ISelection s = c.getSelection();
+ if(s == null || s.isEmpty() || !(s instanceof IStructuredSelection)) return;
+ Object e = ((IStructuredSelection)s).getFirstElement();
+ if(e instanceof ISeamElement) {
+ ISeamElement element = (ISeamElement)e;
+
+ if(element instanceof IOpenableElement) {
+ SeamOpenAction action = new SeamOpenAction((IOpenableElement)element);
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, action);
+ }
+
+ }
+
+ }
}
17 years, 5 months
JBoss Tools SVN: r2460 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-07-17 08:18:02 -0400 (Tue, 17 Jul 2007)
New Revision: 2460
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
Log:
add functionality for http://jira.jboss.com/jira/browse/JBIDE-531
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-07-17 12:08:02 UTC (rev 2459)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-07-17 12:18:02 UTC (rev 2460)
@@ -65,6 +65,7 @@
private EditorPart multiPageEditor;
private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName("", "splitter_position1");
private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName("", "splitter_position2");
+ private static final QualifiedName SPLITTER_POSITION_KEY3 = new QualifiedName("", "splitter_position3");
private int controlCount = 0;
/** default web-browser */
@@ -220,7 +221,7 @@
}
protected int[] loadSplitterPosition() {
- int[] sizes = new int[2];
+ int[] sizes = new int[3];
try {
IEditorInput input = getEditorInput();
if(!(input instanceof IFileEditorInput)) return null;
@@ -233,6 +234,10 @@
if (s != null) {
sizes[1] = Integer.parseInt(s);
}else return null;
+ s = file.getPersistentProperty(SPLITTER_POSITION_KEY3);
+ if (s != null) {
+ sizes[2] = Integer.parseInt(s);
+ }else return null;
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
return null;
@@ -249,6 +254,8 @@
file.setPersistentProperty(SPLITTER_POSITION_KEY1, s);
s = String.valueOf(weights[1]);
file.setPersistentProperty(SPLITTER_POSITION_KEY2, s);
+ s = String.valueOf(weights[2]);
+ file.setPersistentProperty(SPLITTER_POSITION_KEY3, s);
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
}
17 years, 5 months
JBoss Tools SVN: r2459 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-07-17 08:08:02 -0400 (Tue, 17 Jul 2007)
New Revision: 2459
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
bug fixing(http://jira.jboss.com/jira/browse/JBIDE-524?page=all) in progress, we need adjust behavior of
some keyboards shortcats like 'CTRL+M'
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-07-17 11:42:32 UTC (rev 2458)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-07-17 12:08:02 UTC (rev 2459)
@@ -45,6 +45,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
@@ -74,7 +75,6 @@
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
-import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
import org.jboss.tools.common.model.ui.editors.dnd.DropData;
@@ -125,6 +125,7 @@
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
import org.jboss.tools.vpe.mozilla.browser.util.DOMTreeDumper;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.XPCOM;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMEvent;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMKeyEvent;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMMouseEvent;
@@ -858,6 +859,39 @@
sourceSelectionChanged(true);
visualSelectionController.setCaretEnabled(true);
switcher.stopActiveEditor();
+ } else {
+ //adding calls of core event handlers, for example 'CTR+H' or 'CTRL+M' event handler dialog
+ Event keyboardEvent = new Event ();
+ //widget where event occur
+ keyboardEvent.widget=browser;
+ int rc=0;
+ boolean[] aAltKey = new boolean[1];
+ boolean[] aCtrlKey = new boolean[1];
+ boolean[] aShiftKey = new boolean[1];
+ boolean[] aMetaKey = new boolean[1];
+
+ rc = keyEvent.GetAltKey (aAltKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetCtrlKey (aCtrlKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetShiftKey (aShiftKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetMetaKey (aMetaKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+
+ keyboardEvent.stateMask = (aAltKey[0] ? SWT.ALT : 0) | (aCtrlKey[0] ? SWT.CTRL : 0) | (aShiftKey[0] ? SWT.SHIFT : 0) | (aMetaKey[0] ? SWT.MOD1 : 0);
+ keyboardEvent.x=0;
+ keyboardEvent.y=0;
+ keyboardEvent.type=1;
+
+ if(keyEvent.getKeyCode()==0) {
+
+ keyboardEvent.keyCode=keyEvent.getCharCode();
+ } else{
+
+ keyboardEvent.keyCode=keyEvent.getKeyCode();
+ }
+ browser.notifyListeners(keyboardEvent.type, keyboardEvent);
}
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
17 years, 5 months
JBoss Tools SVN: r2458 - in trunk/seam/plugins/org.jboss.tools.seam.xml.ui: src/org/jboss/tools/seam/xml/ui/editor/form and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 07:42:32 -0400 (Tue, 17 Jul 2007)
New Revision: 2458
Modified:
trunk/seam/plugins/org.jboss.tools.seam.xml.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamComponentFormLayoutData.java
trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamXMLFormLayoutData.java
Log:
EXIN-217 .component.xml files processed
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml.ui/plugin.xml 2007-07-17 11:41:53 UTC (rev 2457)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml.ui/plugin.xml 2007-07-17 11:42:32 UTC (rev 2458)
@@ -21,7 +21,7 @@
<xmlEditor
class="org.jboss.tools.jst.web.ui.editors.WebCompoundEditor"
contributorClass="org.jboss.tools.common.model.ui.texteditors.MultiPageContributor"
- entities="FileSeamComponents11,FileSeamComponents12"
+ entities="FileSeamComponents11,FileSeamComponents12,FileSeamComponent12"
icon="images/xstudio/editors/seam-components.gif"
name="%editors.spring-beans.name">
</xmlEditor>
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamComponentFormLayoutData.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamComponentFormLayoutData.java 2007-07-17 11:41:53 UTC (rev 2457)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamComponentFormLayoutData.java 2007-07-17 11:42:32 UTC (rev 2458)
@@ -43,4 +43,20 @@
final static IFormData SEAM_COMPONENT_FORM_DEFINITION = new FormData(
ENT_SEAM_COMPONENT, new String[]{null}, SEAM_COMPONENT_DEFINITIONS);
+ private final static IFormData[] COMPONENT_FILE_12_DEFINITIONS = new IFormData[] {
+ new FormData(
+ "Seam Component File",
+ SeamXMLFormLayoutData.EMPTY_DESCRIPTION,
+ FormLayoutDataUtil.createGeneralFormAttributeData(ENT_SEAM_COMPONENT_12)
+ ),
+ SEAM_PROPERTY_LIST_DEFINITION,
+ new FormData(
+ "Advanced",
+ SeamXMLFormLayoutData.EMPTY_DESCRIPTION,
+ FormLayoutDataUtil.createAdvancedFormAttributeData(ENT_SEAM_COMPONENT_12)
+ )
+ };
+
+ final static IFormData SEAM_COMPONENT_FILE_FORM_DEFINITION = new FormData(
+ ENT_SEAM_COMPONENT_12, new String[]{null}, COMPONENT_FILE_12_DEFINITIONS);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamXMLFormLayoutData.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamXMLFormLayoutData.java 2007-07-17 11:41:53 UTC (rev 2457)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml.ui/src/org/jboss/tools/seam/xml/ui/editor/form/SeamXMLFormLayoutData.java 2007-07-17 11:42:32 UTC (rev 2458)
@@ -24,14 +24,14 @@
private final static IFormData[] FORM_LAYOUT_DEFINITIONS = new IFormData[] {
SeamComponentsFileFormLayoutData.FILE_12_FORM_DEFINITION,
SeamComponentsFileFormLayoutData.FILE_11_FORM_DEFINITION,
+ SeamComponentFormLayoutData.SEAM_COMPONENT_FILE_FORM_DEFINITION,
SeamComponentFormLayoutData.SEAM_COMPONENT_FORM_DEFINITION,
SeamPropertyFormLayoutData.SEAM_PROPERTY_LIST_FORM_DEFINITION,
SeamPropertyFormLayoutData.SEAM_PROPERTY_MAP_FORM_DEFINITION,
SeamFactoryFormLayoutData.SEAM_FACTORY_FORM_DEFINITION,
SeamEventFormLayoutData.SEAM_EVENT_FORM_DEFINITION,
- SeamEventFormLayoutData.SEAM_ACTION_FORM_DEFINITION,
+ SeamEventFormLayoutData.SEAM_ACTION_FORM_DEFINITION,
-
};
private static Map<String,IFormData> FORM_LAYOUT_DEFINITION_MAP = Collections.synchronizedMap(new ArrayToMap(FORM_LAYOUT_DEFINITIONS));
17 years, 5 months
JBoss Tools SVN: r2457 - in trunk/seam/plugins/org.jboss.tools.seam.xml: src/org/jboss/tools/seam/xml/components/model and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 07:41:53 -0400 (Tue, 17 Jul 2007)
New Revision: 2457
Modified:
trunk/seam/plugins/org.jboss.tools.seam.xml/resources/meta/seam-components.meta
trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentConstants.java
trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java
Log:
EXIN-217 .component.xml files processed
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/resources/meta/seam-components.meta
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/resources/meta/seam-components.meta 2007-07-17 11:41:15 UTC (rev 2456)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/resources/meta/seam-components.meta 2007-07-17 11:41:53 UTC (rev 2457)
@@ -55,6 +55,224 @@
</ICONS>
<GlobalActions kind="list"/>
<XModelEntity
+ ImplementationLoadingClass="org.jboss.tools.seam.xml.components.model.SeamComponentsFileLoader"
+ ImplementingClass="org.jboss.tools.seam.xml.components.model.FileSeamComponentsImpl"
+ ObjectEditorClass="%XML%"
+ PROPERTIES="formFactoryClassName=org.jboss.tools.common.model.ui.forms.LayouredFormFactory;formLayoutDataClassName=org.jboss.tools.seam.xml.ui.editor.form.SeamXMLFormLayoutData"
+ XMLSUBPATH="component" name="FileSeamComponent12">
+ <XChildrenEntities>
+ <XChildEntity name="SeamProperty"/>
+ <XChildEntity name="SeamPropertyList"/>
+ <XChildEntity name="SeamPropertyMap"/>
+ </XChildrenEntities>
+ <XEntityRenderer>
+ <ICONS>
+ <ICON info="main.seam.file" type="main"/>
+ </ICONS>
+ </XEntityRenderer>
+ <XModelAttributes>
+ <XModelAttribute default="components" loader="ElementType" name="element type">
+ <Constraint/>
+ <Editor name="Uneditable"/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="category=general" name="name" xmlname="NAME">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="id=true;category=general"
+ name="component-name" xmlname="name">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttributeReference
+ attributes="class,scope,precedence,installed,auto-create,jndi-name"
+ entity="SeamComponent" name="component"/>
+ <XModelAttribute default="xml" name="extension" xmlname="EXTENSION">
+ <Constraint/>
+ <Editor name="Uneditable"/>
+ </XModelAttribute>
+ <XModelAttribute TRIM="no" name="comment" visibility="false" xmlname="#comment">
+ <Constraint/>
+ <Editor name="Note"/>
+ </XModelAttribute>
+ <XModelAttribute loader="ElementType" name="_lateload" visibility="false">
+ <Constraint/>
+ <Editor name="Uneditable"/>
+ </XModelAttribute>
+ <XModelAttribute default="no" name="isIncorrect" visibility="false">
+ <Constraint loader="List">
+ <value name="yes"/>
+ <value name="no"/>
+ </Constraint>
+ <Editor name="Uneditable"/>
+ </XModelAttribute>
+ <XModelAttribute name="incorrectBody" visibility="false">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="save=always"
+ default="http://jboss.com/products/seam/components" name="xmlns" xmlname="xmlns">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="save=always"
+ default="http://www.w3.org/2001/XMLSchema-instance" name="xmlns:xsi" xmlname="xmlns:xsi">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="save=always"
+ default="http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.2.xsd"
+ name="xsi:schemaLocation" xmlname="xsi:schemaLocation">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute name="namespaceMapping">
+ <Constraint/>
+ <Editor/>
+ </XModelAttribute>
+ <XModelAttribute name="encoding">
+ <Constraint loader="ListString">
+ <value name="ISO-8859-1"/>
+ <value name="UTF-8"/>
+ </Constraint>
+ <Editor name="ListString"/>
+ </XModelAttribute>
+ </XModelAttributes>
+ <XActionItem kind="list">
+ <XActionItem BaseActionName="Open" HandlerClassName="%Open%"
+ ICON="action.empty" displayName="Open" kind="action" name="Open"/>
+ <XActionItem displayName="Open With" group="1" kind="list" name="OpenWith">
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.common.meta.action.impl.handlers.OpenWithExternalHandler"
+ ICON="action.empty" PROPERTIES="extension=struts-config"
+ displayName="Open with External Program" kind="action" name="OpenWithSelected"/>
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.common.meta.action.impl.handlers.OpenWithChoiceHandler"
+ ICON="action.empty" PROPERTIES="extension=struts-config"
+ displayName="Choose Program..." kind="action" name="OpenWithChoice">
+ <EntityData EntityName="OpenWithHelper">
+ <AttributeData AttributeName="name"/>
+ <AttributeData AttributeName="default"/>
+ </EntityData>
+ </XActionItem>
+ </XActionItem>
+ <XActionItem kind="list" name="EditActions">
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.jsf.model.handlers.RenameFacesConfigHandler"
+ ICON="action.empty" PROPERTIES="validator.edit=true"
+ WizardClassName="%Default%" displayName="Rename..." kind="action" name="Rename">
+ <EntityData EntityName="FacesConfig">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem
+ HandlerClassName="org.jboss.tools.common.model.filesystems.impl.handlers.RenameEclipseFileHandler"
+ ICON="action.empty" displayName="Rename..." kind="action" name="RenameEclipse"/>
+ </XActionItem>
+ <XActionItem kind="list" name="SaveActions">
+ <XActionItem HIDE="always" HandlerClassName="%SaveFile%"
+ ICON="action.save" displayName="Save" kind="action" name="Save"/>
+ </XActionItem>
+ <XActionItem ICON="action.newclass" displayName="New" group="1"
+ kind="list" name="CreateActions">
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add Simple Property..."
+ kind="action" name="AddProperty">
+ <EntityData EntityName="SeamProperty">
+ <AttributeData AttributeName="name"/>
+ <AttributeData AttributeName="value" Mandatory="no"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add List Property..."
+ kind="action" name="AddListProperty">
+ <EntityData EntityName="SeamPropertyList">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add Map Property..."
+ kind="action" name="AddMapProperty">
+ <EntityData EntityName="SeamPropertyMap">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.common.meta.action.impl.handlers.ShowMenuHandler"
+ PROPERTIES="actionList=CreateActions" displayName="Property..."
+ kind="action" name="AddAnyProperty"/>
+ </XActionItem>
+ <XActionItem ICON="action.copy" displayName="Copy" kind="list" name="CopyActions">
+ <XActionItem BaseActionName="Copy" HandlerClassName="%Copy%"
+ ICON="action.copy" displayName="Copy" kind="action" name="Copy"/>
+ <XActionItem BaseActionName="Cut" HandlerClassName="%Cut%"
+ ICON="action.cut" displayName="Cut" kind="action" name="Cut"/>
+ <XActionItem BaseActionName="Paste" HandlerClassName="%Paste%"
+ ICON="action.paste" displayName="Paste" kind="action" name="Paste"/>
+ </XActionItem>
+ <XActionItem ICON="action.delete" displayName="Delete" kind="list" name="DeleteActions">
+ <XActionItem BaseActionName="Delete"
+ HandlerClassName="org.jboss.tools.jsf.model.handlers.DeleteFacesConfigHandler"
+ ICON="action.delete" displayName="Delete" kind="action" name="Delete"/>
+ </XActionItem>
+ <XActionItem ICON="action.empty" kind="list" name="Properties">
+ <XActionItem HandlerClassName="%Properties%" ICON="action.empty"
+ displayName="Properties..." kind="action" name="Properties"/>
+ </XActionItem>
+ <XActionItem kind="list" name="DiscardActions">
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.jsf.model.handlers.DiscardConfigHandler"
+ ICON="action.delete"
+ PROPERTIES="significanceMessageClass=org.jboss.tools.common.model.filesystems.impl.DiscardFileSignificanceMessage"
+ displayName="Discard Changes" kind="action" name="Discard"/>
+ </XActionItem>
+ </XActionItem>
+ <XDependencies/>
+ </XModelEntity>
+ <XModelEntity name="FileSeamComponent12_EditorActionList">
+ <XChildrenEntities/>
+ <XEntityRenderer/>
+ <XModelAttributes/>
+ <XActionItem kind="list">
+ <XActionItem displayName="New" group="1" kind="list" name="CreateActions">
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add Simple Property..."
+ kind="action" name="AddProperty">
+ <EntityData EntityName="SeamProperty">
+ <AttributeData AttributeName="name"/>
+ <AttributeData AttributeName="value" Mandatory="no"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add List Property..."
+ kind="action" name="AddListProperty">
+ <EntityData EntityName="SeamPropertyList">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HandlerClassName="%Create%" ICON="action.empty"
+ WizardClassName="%Default%" displayName="Add Map Property..."
+ kind="action" name="AddMapProperty">
+ <EntityData EntityName="SeamPropertyMap">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ <XActionItem HIDE="always"
+ HandlerClassName="org.jboss.tools.common.meta.action.impl.handlers.ShowMenuHandler"
+ PROPERTIES="actionList=CreateActions" displayName="Property..."
+ kind="action" name="AddAnyProperty"/>
+ </XActionItem>
+ <XActionItem ICON="action.empty" kind="list" name="Properties">
+ <XActionItem HandlerClassName="%Properties%" ICON="action.empty"
+ displayName="Properties..." kind="action" name="Properties"/>
+ </XActionItem>
+ <XActionItem kind="list" name="VerifyActions">
+ <XActionItem kind="list" name="StaticActions"/>
+ </XActionItem>
+ </XActionItem>
+ <XDependencies/>
+ </XModelEntity>
+ <XModelEntity
ImplementationLoadingClass="org.jboss.tools.seam.xml.components.model.SeamComponents11FileLoader"
ImplementingClass="org.jboss.tools.seam.xml.components.model.FileSeamComponentsImpl"
ObjectEditorClass="%XML%"
@@ -1041,6 +1259,7 @@
<XChildrenEntities>
<XChildEntity name="FileSeamComponents11"/>
<XChildEntity name="FileSeamComponents12"/>
+ <XChildEntity name="FileSeamComponent12"/>
</XChildrenEntities>
<XActionItem kind="list">
<XActionItem ICON="action.empty" displayName="New" group="1"
@@ -1068,6 +1287,7 @@
<XChildrenEntities>
<XChildEntity name="FileSeamComponents11"/>
<XChildEntity name="FileSeamComponents12"/>
+ <XChildEntity name="FileSeamComponent12"/>
</XChildrenEntities>
<XActionItem kind="list">
<XActionItem ICON="action.empty" displayName="New" group="1"
@@ -1095,6 +1315,7 @@
<XChildrenEntities>
<XChildEntity name="FileSeamComponents12"/>
<XChildEntity name="FileSeamComponents11"/>
+ <XChildEntity name="FileSeamComponent12"/>
</XChildrenEntities>
<XActionItem kind="list"/>
</XEntityExtension>
@@ -1102,6 +1323,7 @@
<XChildrenEntities>
<XChildEntity name="FileSeamComponents11"/>
<XChildEntity name="FileSeamComponents12"/>
+ <XChildEntity name="FileSeamComponent12"/>
</XChildrenEntities>
<XActionItem kind="list"/>
</XEntityExtension>
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentConstants.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentConstants.java 2007-07-17 11:41:15 UTC (rev 2456)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentConstants.java 2007-07-17 11:41:53 UTC (rev 2457)
@@ -17,6 +17,7 @@
public String ENT_SEAM_COMPONENTS = "FileSeamComponents";
public String ENT_SEAM_COMPONENTS_11 = ENT_SEAM_COMPONENTS + "11";
public String ENT_SEAM_COMPONENTS_12 = ENT_SEAM_COMPONENTS + "12";
+ public String ENT_SEAM_COMPONENT_12 = "FileSeamComponent" + "12";
public String ENT_SEAM_COMPONENT = "SeamComponent";
public String ENT_SEAM_FACTORY = "SeamFactory";
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java 2007-07-17 11:41:15 UTC (rev 2456)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java 2007-07-17 11:41:53 UTC (rev 2457)
@@ -19,7 +19,7 @@
static {
try {
- Class c = SeamComponentsEntityRecognizer.class;
+ Class<?> c = SeamComponentsEntityRecognizer.class;
XMLEntityResolver.registerPublicEntity(PUBLIC_ID_11, FileLocator.resolve(c.getResource("/meta/components-1.1.dtd")).toString());
} catch (Exception e) {
SeamXMLPlugin.log(e);
@@ -34,6 +34,7 @@
return ENT_SEAM_COMPONENTS_11;
}
if(is12(body)) return ENT_SEAM_COMPONENTS_12;
+ if(is12Component(body)) return ENT_SEAM_COMPONENT_12;
return null;
}
@@ -46,4 +47,13 @@
return s.indexOf("\"http://jboss.com/products/seam/components\"") > 0;
}
+ private boolean is12Component(String body) {
+ int i = body.indexOf("<component");
+ int is = body.indexOf("<components");
+ if(i < 0 || is >= 0) return false;
+ int j = body.indexOf(">", i);
+ if(j < 0) return false;
+ String s = body.substring(i, j);
+ return s.indexOf("\"http://jboss.com/products/seam/components\"") > 0;
+ }
}
17 years, 5 months
JBoss Tools SVN: r2456 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: scanner/xml and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 07:41:15 -0400 (Tue, 17 Jul 2007)
New Revision: 2456
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 .component.xml files processed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-17 08:33:03 UTC (rev 2455)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-17 11:41:15 UTC (rev 2456)
@@ -40,7 +40,7 @@
public ScopeType getScope() {
if(scope == null || scope.length() == 0) return ScopeType.UNSPECIFIED;
try {
- return ScopeType.valueOf(scope);
+ return ScopeType.valueOf(scope.toUpperCase());
} catch (Exception e) {
return ScopeType.UNSPECIFIED;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-17 08:33:03 UTC (rev 2455)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-17 11:41:15 UTC (rev 2456)
@@ -18,6 +18,8 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.XModelEntity;
@@ -60,9 +62,7 @@
if(model == null) return false;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
if(o == null) return false;
- if(o.getModelEntity().getName().startsWith("FileSeamComponents")) return true;
- //TODO Above does not include .component.xml with root element <component>
- // and missing xmlns.
+ if(o.getModelEntity().getName().startsWith("FileSeamComponent")) return true;
return false;
}
@@ -94,66 +94,15 @@
public LoadedDeclarations parse(XModelObject o, IPath source) {
if(o == null) return null;
LoadedDeclarations ds = new LoadedDeclarations();
+ if(o.getModelEntity().getName().equals("FileSeamComponent12")) {
+ parseComponent(o, source, ds);
+ return ds;
+ }
XModelObject[] os = o.getChildren();
for (int i = 0; i < os.length; i++) {
XModelEntity componentEntity = os[i].getModelEntity();
if(componentEntity.getAttribute("class") != null) {
- SeamXmlComponentDeclaration component = new SeamXmlComponentDeclaration();
-
- component.setSourcePath(source);
- component.setId(os[i]);
-
- component.setName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.NAME));
- component.setClassName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.CLASS));
- component.setScope(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.SCOPE));
- component.setPrecedence(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.PRECEDENCE));
- component.setInstalled(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.INSTALLED));
- component.setAutoCreate(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.AUTO_CREATE));
- component.setJndiName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.JNDI_NAME));
-
- XAttribute[] attributes = componentEntity.getAttributes();
- for (int ia = 0; ia < attributes.length; ia++) {
- XAttribute a = attributes[ia];
- String xml = a.getXMLName();
- if(xml == null) continue;
- if(COMMON_ATTRIBUTES.contains(xml)) continue;
- String stringValue = os[i].getAttributeValue(a.getName());
- component.addStringProperty(xml, stringValue);
- }
-
- XModelObject[] properties = os[i].getChildren();
- for (int j = 0; j < properties.length; j++) {
- XModelEntity entity = properties[j].getModelEntity();
- String propertyName = properties[j].getAttributeValue("name");
- if(entity.getAttribute("value") != null) {
- //this is simple value;
- String value = properties[j].getAttributeValue("value");
- component.addStringProperty(propertyName, value);
- } else {
- XModelObject[] entries = properties[j].getChildren();
- if(entity.getChild("SeamListEntry") != null
- || "list".equals(entity.getProperty("childrenLoader"))) {
- //this is list value
- List<String> listValues = new ArrayList<String>();
- for (int k = 0; k < entries.length; k++) {
- listValues.add(entries[k].getAttributeValue("value"));
- }
- component.addProperty(new SeamProperty(propertyName, listValues));
- } else {
- //this is map value
- Map<String,String> mapValues = new HashMap<String, String>();
- for (int k = 0; k < entries.length; k++) {
- String entryKey = entries[k].getAttributeValue("key");
- String entryValue = entries[k].getAttributeValue("value");
- mapValues.put(entryKey, entryValue);
- }
- component.addProperty(new SeamProperty(propertyName, mapValues));
- }
- }
- //TODO assign positioning attributes to created ISeamProperty object
- }
-
- ds.getComponents().add(component);
+ parseComponent(os[i], source, ds);
} else if(os[i].getModelEntity().getName().startsWith("SeamFactory")) {
SeamXmlFactory factory = new SeamXmlFactory();
factory.setId(os[i]);
@@ -163,9 +112,110 @@
factory.setValue(new XMLValueInfo(os[i], "value"));
factory.setMethod(new XMLValueInfo(os[i], "method"));
ds.getFactories().add(factory);
- //TODO assign positioning attributes to created ISeamProperty object
}
}
return ds;
}
+
+ private void parseComponent(XModelObject c, IPath source, LoadedDeclarations ds) {
+ SeamXmlComponentDeclaration component = new SeamXmlComponentDeclaration();
+
+ component.setSourcePath(source);
+ component.setId(c);
+
+ component.setName(new XMLValueInfo(c, getComponentAttribute(c)));
+ if(isClassAttributeSet(c)) {
+ component.setClassName(new XMLValueInfo(c, ISeamXmlComponentDeclaration.CLASS));
+ } else if(c.getModelEntity().getName().equals("FileSeamComponent12")) {
+ component.setClassName(getImpliedComponentName(c, source));
+ }
+ component.setScope(new XMLValueInfo(c, ISeamXmlComponentDeclaration.SCOPE));
+ component.setPrecedence(new XMLValueInfo(c, ISeamXmlComponentDeclaration.PRECEDENCE));
+ component.setInstalled(new XMLValueInfo(c, ISeamXmlComponentDeclaration.INSTALLED));
+ component.setAutoCreate(new XMLValueInfo(c, ISeamXmlComponentDeclaration.AUTO_CREATE));
+ component.setJndiName(new XMLValueInfo(c, ISeamXmlComponentDeclaration.JNDI_NAME));
+
+ XAttribute[] attributes = c.getModelEntity().getAttributes();
+ for (int ia = 0; ia < attributes.length; ia++) {
+ XAttribute a = attributes[ia];
+ String xml = a.getXMLName();
+ if(xml == null) continue;
+ if(COMMON_ATTRIBUTES.contains(xml)) continue;
+ String stringValue = c.getAttributeValue(a.getName());
+ component.addStringProperty(xml, stringValue);
+ }
+
+ XModelObject[] properties = c.getChildren();
+ for (int j = 0; j < properties.length; j++) {
+ XModelEntity entity = properties[j].getModelEntity();
+ String propertyName = properties[j].getAttributeValue("name");
+ if(entity.getAttribute("value") != null) {
+ //this is simple value;
+ String value = properties[j].getAttributeValue("value");
+ component.addStringProperty(propertyName, value);
+ } else {
+ XModelObject[] entries = properties[j].getChildren();
+ if(entity.getChild("SeamListEntry") != null
+ || "list".equals(entity.getProperty("childrenLoader"))) {
+ //this is list value
+ List<String> listValues = new ArrayList<String>();
+ for (int k = 0; k < entries.length; k++) {
+ listValues.add(entries[k].getAttributeValue("value"));
+ }
+ component.addProperty(new SeamProperty(propertyName, listValues));
+ } else {
+ //this is map value
+ Map<String,String> mapValues = new HashMap<String, String>();
+ for (int k = 0; k < entries.length; k++) {
+ String entryKey = entries[k].getAttributeValue("key");
+ String entryValue = entries[k].getAttributeValue("value");
+ mapValues.put(entryKey, entryValue);
+ }
+ component.addProperty(new SeamProperty(propertyName, mapValues));
+ }
+ }
+ //TODO assign positioning attributes to created ISeamProperty object
+ }
+
+ ds.getComponents().add(component);
+ }
+
+ private String getComponentAttribute(XModelObject c) {
+ if(c.getModelEntity().getAttribute("component-name") != null) {
+ return "component-name";
+ }
+ return ISeamXmlComponentDeclaration.NAME;
+ }
+
+ private boolean isClassAttributeSet(XModelObject c) {
+ String value = c.getAttributeValue(ISeamXmlComponentDeclaration.CLASS);
+ return value != null && value.length() > 0;
+ }
+
+ private String getImpliedComponentName(XModelObject c, IPath path) {
+ if(path.toString().endsWith(".jar")) {
+ String suffix = ".component";
+ String cn = c.getAttributeValue("name");
+ if(cn.endsWith(suffix)) cn = cn.substring(0, cn.length() - suffix.length());
+ XModelObject p = c.getParent();
+ while(p != null && p.getFileType() == XModelObject.FOLDER) {
+ cn = p.getAttributeValue("name") + "." + cn;
+ p = p.getParent();
+ }
+ return cn;
+ } else {
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if(!f.exists()) return "";
+ IResource root = EclipseResourceUtil.getJavaSourceRoot(f.getProject());
+ if(!root.getLocation().isPrefixOf(f.getLocation())) return "";
+ String relative = f.getLocation().toString().substring(root.getLocation().toString().length());
+ String suffix = ".component.xml";
+ if(!relative.endsWith(suffix)) return null;
+ relative = relative.substring(0, relative.length() - suffix.length());
+ relative = relative.replace('\\', '/');
+ if(relative.startsWith("/")) relative = relative.substring(1);
+ return relative.replace('/', '.');
+ }
+ }
+
}
\ No newline at end of file
17 years, 5 months
JBoss Tools SVN: r2455 - in trunk/seam/plugins: org.jboss.tools.seam.core/src/org/jboss/tools/seam/core and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-07-17 04:33:03 -0400 (Tue, 17 Jul 2007)
New Revision: 2455
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPostInstallDelegate.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamGuiPlugin.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/TextField.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFofrmWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.org/jira/browse/EXIN-222
Action for WAR configuration is finished
Validation is added
http://jira.jboss.org/jira/browse/EXIN-223
Form for WAR configuration is finished
Validation is added
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-07-17 08:33:03 UTC (rev 2455)
@@ -48,7 +48,7 @@
</project-facet>
<project-facet-version
facet="jst.seam"
- version="2.0">
+ version="1.2">
<constraint>
<and>
<requires
@@ -68,9 +68,9 @@
</project-facet-version>
<action
facet="jst.seam"
- id="jst.seam.2.0.install"
+ id="jst.seam.1.2.install"
type="install"
- version="2.0">
+ version="1.2">
<delegate
class="org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDelegete">
</delegate>
@@ -80,37 +80,54 @@
</action>
<action
facet="jst.seam"
- id="jst.seam.2.0.uninstall"
+ id="jst.seam.1.2.uninstall"
type="uninstall"
- version="2.0">
+ version="1.2">
<delegate
class="org.jboss.tools.seam.internal.core.project.facet.SeamFacetUninstallDelegate">
</delegate>
</action>
+ <event-handler
+ facet="jst.seam"
+ type="POST_INSTALL"
+ version="[1.2">
+ <delegate
+ class="org.jboss.tools.seam.internal.core.project.facet.SeamFacetPostInstallDelegate">
+ </delegate>
+ </event-handler>
</extension>
<extension
point="org.eclipse.wst.common.project.facet.core.runtimes">
<supported>
+ <runtime-component
+ id="org.eclipse.jst.server.generic.runtime.jboss"
+ version="4.2">
+ </runtime-component>
+ <runtime-component
+ id="org.jboss.ide.eclipse.as.runtime.component.40"
+ version="4.0">
+ </runtime-component>
+ <runtime-component
+ id="org.jboss.ide.eclipse.as.runtime.component.42"
+ version="4.2">
+ </runtime-component>
<facet
id="jst.seam"
- version="2.0">
+ version="1.2">
</facet>
- <runtime-component
- any="true">
- </runtime-component>
</supported>
</extension>
<extension
point="org.eclipse.wst.common.project.facet.core.presets">
<static-preset
- id="preset.jst.seam.v2_0">
- <label>Seam 2.0 project</label>
+ id="preset.jst.seam.v1_2">
+ <label>Seam 1.2 project</label>
<facet id="jst.java" version="5.0" />
<facet id="jst.web" version="2.4"/>
<facet id="jst.jsf" version="1.1" />
- <facet id="jst.seam" version="2.0"/>
+ <facet id="jst.seam" version="1.2"/>
<description>
- Seam 2.0 project
+ Seam 1.2 project
</description>
</static-preset>
</extension>
@@ -145,5 +162,5 @@
<super
type="org.eclipse.wst.validation.problemmarker">
</super>
- </extension>
+ </extension>
</plugin>
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -11,10 +11,18 @@
package org.jboss.tools.seam.core;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.internal.FacetedProject;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamCoreConstants;
import org.osgi.framework.BundleContext;
/**
@@ -108,4 +116,14 @@
return null;
}
+ public static IEclipsePreferences getSeamFacetPreferences(IProject project) {
+ FacetedProject facetedProject = (FacetedProject) project.getAdapter(IFacetedProject.class);
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(ISeamCoreConstants.SEAM_CORE_FACET_ID);
+ if(facetedProject.hasProjectFacet(facet)) {
+ IScopeContext projectScope = new ProjectScope(project);
+ return projectScope.getNode(PLUGIN_ID);
+ }
+
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -23,13 +23,13 @@
*/
public interface ISeamFacetDataModelProperties extends IActionConfigFactory {
- public static final String PREFIX = "ISeamFacetDataModelProperties.";
-
- public static final String SEAM_PROJECT_NAME = "project.name";
+ public static final String SEAM_PROJECT_NAME = "seam.project.name";
+ public static final String SEAM_PROJECT_INSTANCE = "seam.project.instance";
+
public static final String JBOSS_AS_HOME = "jboss.home";
- public static final String JBOSS_AS_DEPLOY_AS = "JBOSS_AS_DEPLOY_AS";
+ public static final String JBOSS_AS_DEPLOY_AS = "seam.project.deployment.type";
public static final String DB_TYPE = "database.type";
@@ -59,8 +59,8 @@
public static final String TEST_CASES_PACKAGE_NAME = "test.package";
- public static final String JBOSS_SEAM_HOME = "JBOSS_SEAM_HOME";
+ public static final String JBOSS_SEAM_HOME = "seam.jbossas.home.folder";
- public static final String WEB_CONTENTS_FOLDER = PREFIX + "WEB_CONTENTS_FOLDER";
+ public static final String WEB_CONTENTS_FOLDER = "seam.project.web.root.folder";
}
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import java.util.Map;
+
+import org.apache.tools.ant.types.FilterSet;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+/**
+ *
+ * @author eskimo
+ *
+ */
+public class SeamFacetFilterSetFactory {
+
+ public static FilterSet JDBC_TEMPLATE;
+ public static FilterSet PROJECT_TEMPLATE;
+ public static FilterSet FILTERS_TEMPLATE;
+ public static FilterSet HIBERNATE_DIALECT_TEMPLATE;
+
+ static {
+ JDBC_TEMPLATE = new FilterSet();
+ JDBC_TEMPLATE.addFilter("jdbcUrl","${hibernate.connection.url}");
+ JDBC_TEMPLATE.addFilter("driverClass","${hibernate.connection.driver_class}");
+ JDBC_TEMPLATE.addFilter("username","${hibernate.connection.username}");
+ JDBC_TEMPLATE.addFilter("password","${hibernate.connection.password}");
+ JDBC_TEMPLATE.addFilter("catalogProperty","${catalog.property}");
+ JDBC_TEMPLATE.addFilter("schemaProperty","${schema.property}");
+
+ PROJECT_TEMPLATE = new FilterSet();
+ PROJECT_TEMPLATE.addFilter("projectName","${project.name}");
+ PROJECT_TEMPLATE.addFilter("jbossHome","${jboss.home}");
+ PROJECT_TEMPLATE.addFilter("hbm2ddl","${hibernate.hbm2ddl.auto}");
+ PROJECT_TEMPLATE.addFilter("driverJar","${driver.file}");
+ PROJECT_TEMPLATE.addFilter("jndiPattern","${project.name}/#{ejbName}/local");
+ PROJECT_TEMPLATE.addFilter("embeddedEjb","false");
+
+ FILTERS_TEMPLATE = new FilterSet();
+ FILTERS_TEMPLATE.addFilter("interfaceName","${interface.name}");
+ FILTERS_TEMPLATE.addFilter("beanName","${bean.name}");
+ FILTERS_TEMPLATE.addFilter("entityName","${entity.name}");
+ FILTERS_TEMPLATE.addFilter("methodName","${method.name}");
+ FILTERS_TEMPLATE.addFilter("componentName","${component.name}");
+ FILTERS_TEMPLATE.addFilter("pageName","${page.name}");
+ FILTERS_TEMPLATE.addFilter("masterPageName","${masterPage.name}");
+ FILTERS_TEMPLATE.addFilter("actionPackage","${action.package}");
+ FILTERS_TEMPLATE.addFilter("modelPackage","${model.package}");
+ FILTERS_TEMPLATE.addFilter("testPackage","${test.package}");
+ FILTERS_TEMPLATE.addFilter("listName","${component.name}List");
+ FILTERS_TEMPLATE.addFilter("homeName","${component.name}Home");
+ FILTERS_TEMPLATE.addFilter("query","${query.text}");
+
+
+ HIBERNATE_DIALECT_TEMPLATE = new FilterSet();
+ HIBERNATE_DIALECT_TEMPLATE.addFilter("hibernate.dialect","${hibernate.dialect}");
+
+
+ }
+
+ public static FilterSet createJdbcFilterSet(IDataModel values) {
+ return aplayProperties((FilterSet)JDBC_TEMPLATE.clone(), values);
+ }
+ public static FilterSet createProjectFilterSet(IDataModel values){
+ return aplayProperties((FilterSet)PROJECT_TEMPLATE.clone(), values);
+ }
+
+ public static FilterSet createFiltersFilterSet(IDataModel values) {
+ return aplayProperties((FilterSet)FILTERS_TEMPLATE.clone(), values);
+ }
+
+ public static FilterSet createHibernateDialectFilterSet(IDataModel values) {
+ return aplayProperties((FilterSet)HIBERNATE_DIALECT_TEMPLATE.clone(), values);
+ }
+
+ public static FilterSet createFiltersFilterSet(Map values) {
+ return aplayProperties((FilterSet)FILTERS_TEMPLATE.clone(), values);
+ }
+
+ private static FilterSet aplayProperties(FilterSet template,IDataModel values) {
+ FilterSet result = new FilterSet();
+ for (Object filter : template.getFilterHash().keySet()) {
+ String value = template.getFilterHash().get(filter).toString();
+ for (Object property : values.getAllProperties()) {
+ if(value.contains("${"+property.toString()+"}")) {
+ value = value.replace("${"+property.toString()+"}",values.getProperty(property.toString()).toString());
+ }
+ }
+ result.addFilter(filter.toString(), value);
+ }
+ return result;
+ }
+
+ private static FilterSet aplayProperties(FilterSet template,Map values) {
+ FilterSet result = new FilterSet();
+ for (Object filter : template.getFilterHash().keySet()) {
+ String value = template.getFilterHash().get(filter).toString();
+ for (Object property : values.keySet()){
+ if(value.contains("${"+property.toString()+"}")) {
+ value = value.replace("${"+property.toString()+"}",values.get(property.toString()).toString());
+ }
+ }
+ result.addFilter(filter.toString(), value);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -98,7 +98,8 @@
.include("jbpm.*\\.jar")
.include("jsf-facelets\\.jar")
.include("oscache.*\\.jar")
- .include("stringtemplate.*\\.jar");
+ .include("stringtemplate.*\\.jar")
+ .include("testng-.*\\.jar");
public static FileSet EAR_LIB_FILESET = new FileSet()
.include("jboss-aop-jdk50\\.jar")
@@ -131,8 +132,6 @@
.include("security\\.drl")
.include("seam\\.properties")
.include("messages_en\\.properties");
- // .include(project.getName()+"ds\\.xml")
- // .include("META-INF/persistence-" + PROFILE + "\\.xml" )
public static String DROOLS_LIB_SEAM_RELATED_PATH = "drools/lib";
@@ -177,9 +176,9 @@
File hibernateConsolePref = new File(seamGenHomeFolder, "hibernatetools/.settings/org.hibernate.eclipse.console.prefs");
File persistenceFile = new File(seamGenResFolder,"META-INF/persistence-" + PROFILE + ".xml");
- FilterSet jdbcFilterSet = FilterSetFactory.createJdbcFilterSet(model);
- FilterSet projectFilterSet = FilterSetFactory.createProjectFilterSet(model);
- FilterSet filtersFilterSet = FilterSetFactory.createFiltersFilterSet(model);
+ FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
+ FilterSet projectFilterSet = SeamFacetFilterSetFactory.createProjectFilterSet(model);
+ FilterSet filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
// ****************************************************************
// Copy view folder from seam-gen installation to WebContent folder
@@ -227,7 +226,7 @@
FilterSetCollection hibernateDialectFilterSet = new FilterSetCollection();
hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
- hibernateDialectFilterSet.addFilterSet(FilterSetFactory.createHibernateDialectFilterSet(model));
+ hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
@@ -423,82 +422,6 @@
}
}
- public static class FilterSetFactory {
-
- public static FilterSet JDBC_TEMPLATE;
- public static FilterSet PROJECT_TEMPLATE;
- public static FilterSet FILTERS_TEMPLATE;
- public static FilterSet HIBERNATE_DIALECT_TEMPLATE;
-
- static {
- JDBC_TEMPLATE = new FilterSet();
- JDBC_TEMPLATE.addFilter("jdbcUrl","${hibernate.connection.url}");
- JDBC_TEMPLATE.addFilter("driverClass","${hibernate.connection.driver_class}");
- JDBC_TEMPLATE.addFilter("username","${hibernate.connection.username}");
- JDBC_TEMPLATE.addFilter("password","${hibernate.connection.password}");
- JDBC_TEMPLATE.addFilter("catalogProperty","${catalog.property}");
- JDBC_TEMPLATE.addFilter("schemaProperty","${schema.property}");
-
- PROJECT_TEMPLATE = new FilterSet();
- PROJECT_TEMPLATE.addFilter("projectName","${project.name}");
- PROJECT_TEMPLATE.addFilter("jbossHome","${jboss.home}");
- PROJECT_TEMPLATE.addFilter("hbm2ddl","${hibernate.hbm2ddl.auto}");
- PROJECT_TEMPLATE.addFilter("driverJar","${driver.file}");
- PROJECT_TEMPLATE.addFilter("jndiPattern","${project.name}/#{ejbName}/local");
- PROJECT_TEMPLATE.addFilter("embeddedEjb","false");
-
- FILTERS_TEMPLATE = new FilterSet();
- FILTERS_TEMPLATE.addFilter("interfaceName","${interface.name}");
- FILTERS_TEMPLATE.addFilter("beanName","${bean.name}");
- FILTERS_TEMPLATE.addFilter("entityName","${entity.name}");
- FILTERS_TEMPLATE.addFilter("methodName","${method.name}");
- FILTERS_TEMPLATE.addFilter("componentName","${component.name}");
- FILTERS_TEMPLATE.addFilter("pageName","${page.name}");
- FILTERS_TEMPLATE.addFilter("masterPageName","${masterPage.name}");
- FILTERS_TEMPLATE.addFilter("actionPackage","${action.package}");
- FILTERS_TEMPLATE.addFilter("modelPackage","${model.package}");
- FILTERS_TEMPLATE.addFilter("testPackage","${test.package}");
- FILTERS_TEMPLATE.addFilter("listName","${component.name}List");
- FILTERS_TEMPLATE.addFilter("homeName","${component.name}Home");
- FILTERS_TEMPLATE.addFilter("query","${query.text}");
-
-
- HIBERNATE_DIALECT_TEMPLATE = new FilterSet();
- HIBERNATE_DIALECT_TEMPLATE.addFilter("hibernate.dialect","${hibernate.dialect}");
-
-
- }
-
- public static FilterSet createJdbcFilterSet(IDataModel values) {
- return aplayProperties(JDBC_TEMPLATE, values);
- }
- public static FilterSet createProjectFilterSet(IDataModel values){
- return aplayProperties(PROJECT_TEMPLATE, values);
- }
-
- public static FilterSet createFiltersFilterSet(IDataModel values) {
- return aplayProperties(FILTERS_TEMPLATE, values);
- }
-
- public static FilterSet createHibernateDialectFilterSet(IDataModel values) {
- return aplayProperties(HIBERNATE_DIALECT_TEMPLATE, values);
- }
-
- private static FilterSet aplayProperties(FilterSet template,IDataModel values) {
- FilterSet result = new FilterSet();
- for (Object filter : template.getFilterHash().keySet()) {
- String value = template.getFilterHash().get(filter).toString();
- for (Object property : values.getAllProperties()) {
- if(value.contains("${"+property.toString()+"}")) {
- value = value.replace("${"+property.toString()+"}",values.getProperty(property.toString()).toString());
- }
- }
- result.addFilter(filter.toString(), value);
- }
- return result;
- }
- }
-
private void writeXModel(IProject project, IDataModel model) {
String projectName = project.getName();
String webContent = "WebContent";
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPostInstallDelegate.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPostInstallDelegate.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPostInstallDelegate.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * @author eskimo
+ *
+ */
+public class SeamFacetPostInstallDelegate implements
+ IDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ IEclipsePreferences prefs = SeamCorePlugin.getSeamFacetPreferences(project);
+ IDataModel model = (IDataModel)config;
+ for (Object propertyName : model.getAllProperties()) {
+ Object value = model.getProperty(propertyName.toString());
+ prefs.put(propertyName.toString(), value==null?"":value.toString());
+ }
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-07-17 08:33:03 UTC (rev 2455)
@@ -38,7 +38,9 @@
org.eclipse.emf.ecore,
org.eclipse.jst.j2ee.ui,
org.eclipse.jst.j2ee.web,
- org.eclipse.wst.xml.ui
+ org.eclipse.wst.xml.ui,
+ org.apache.ant,
+ org.jboss.ide.eclipse.jdt.core
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.seam.ui,
org.jboss.tools.seam.ui.views,
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-07-17 08:33:03 UTC (rev 2455)
@@ -77,7 +77,7 @@
</extension>
<extension
point="org.eclipse.wst.common.project.facet.ui.wizardPages">
- <wizard-pages action="jst.seam.2.0.install">
+ <wizard-pages action="jst.seam.1.2.install">
<page class="org.jboss.tools.seam.ui.internal.project.facet.SeamInstallWizardPage"/>
</wizard-pages>
</extension>
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamGuiPlugin.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamGuiPlugin.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamGuiPlugin.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -69,5 +69,4 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -29,6 +29,7 @@
*/
protected IDataModel model = null;
+
/**
*
*/
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -12,6 +12,8 @@
import java.util.Map;
+import org.eclipse.core.runtime.IAdaptable;
+
/**
*
* @author eskimo
@@ -19,6 +21,8 @@
*/
public interface IValidator {
+ public static final String DEFAULT_ERROR = "default.error";
+
/**
*
* @param value
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -11,11 +11,28 @@
package org.jboss.tools.seam.ui.internal.project.facet;
import java.io.File;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.corext.util.Messages;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.wizard.IParameter;
/**
*
@@ -24,6 +41,8 @@
*/
public class ValidatorFactory {
+
+
/**
*
*/
@@ -69,7 +88,7 @@
*/
public static Map<String,String> createErrormessage(String text) {
Map<String,String> map = createErrorMap();
- map.put("", text);
+ map.put(IValidator.DEFAULT_ERROR, text);
return map;
}
@@ -145,7 +164,15 @@
*/
public static IValidator CLASS_QNAME_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
-
+ String classDecl = "class " + value.toString() + " {}";
+ ASTParser parser= ASTParser.newParser(AST.JLS3);
+ parser.setSource(classDecl.toCharArray());
+ parser.setProject((IJavaProject)context);
+ CompilationUnit compilationUnit= (CompilationUnit) parser.createAST(null);
+ IProblem[] problems= compilationUnit.getProblems();
+ if (problems.length > 0) {
+ return createErrormessage(Messages.format("Component name is not invalid.", problems[0].getMessage()));
+ }
return ValidatorFactory.NO_ERRORS;
}
};
@@ -158,5 +185,126 @@
return ValidatorFactory.NO_ERRORS;
};
};
+ /**
+ *
+ * @author eskimo
+ *
+ */
+ public static IValidator SEAM_COMPONENT_NAME_VALIDATOR = new IValidator() {
+
+ public Map<String, String> validate(Object value, Object context) {
+ String targetName = null;
+ IProject project = null;
+ if(context instanceof Object[]) {
+ Object[] contextArray = ((Object[])context);
+ targetName = contextArray[0].toString();
+ project = (IProject)contextArray[1];
+ }
+
+ String classDecl = "class " + value + " {}";
+ ASTParser parser= ASTParser.newParser(AST.JLS3);
+ parser.setSource(classDecl.toCharArray());
+ parser.setProject(JavaCore.create(project));
+ CompilationUnit compilationUnit= (CompilationUnit) parser.createAST(null);
+ IProblem[] problems= compilationUnit.getProblems();
+
+ if (problems.length > 0) {
+ return createErrormessage(targetName + " name is not valid.");
+ }
+
+ return NO_ERRORS;
+ }
+ };
+ /**
+ *
+ * @author eskimo
+ *
+ */
+ public static IValidator SEAM_JAVA_INTEFACE_NAME_CONVENTION_VALIDATOR = new IValidator() {
+
+ public Map<String, String> validate(Object value, Object context) {
+ String targetName = null;
+ IProject project = null;
+ if(context instanceof Object[]) {
+ Object[] contextArray = ((Object[])context);
+ targetName = contextArray[0].toString();
+ project = (IProject)contextArray[1];
+ }
+ IJavaProject jProject = JavaCore.create(project);
+
+ String sourceLevel= jProject.getOption(JavaCore.COMPILER_SOURCE, true);
+ String compliance= jProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ IStatus status = JavaConventions.validateJavaTypeName(value.toString(), sourceLevel, compliance);
+ if(status.getSeverity() == IStatus.WARNING) {
+ return createErrormessage("Local Interface name is not valid.\n" + status.getMessage());
+ }
+ return NO_ERRORS;
+ }
+ };
+
+ public static IValidator SEAM_METHOD_NAME_VALIDATOR = new IValidator() {
+
+ public Map<String, String> validate(Object value, Object context) {
+ String targetName = null;
+ IProject project = null;
+
+ if(context instanceof Object[]) {
+ Object[] contextArray = ((Object[])context);
+ targetName = contextArray[0].toString();
+ project = (IProject)contextArray[1];
+ }
+
+ String classDecl = "class ClassName {public void " + value.toString() + "() {}}";
+ ASTParser parser= ASTParser.newParser(AST.JLS3);
+ parser.setSource(classDecl.toCharArray());
+ parser.setProject(JavaCore.create(project));
+ CompilationUnit compilationUnit= (CompilationUnit) parser.createAST(null);
+ IProblem[] problems= compilationUnit.getProblems();
+
+ if (problems.length > 0) {
+ return createErrormessage(targetName + " name is not valid.");
+ }
+
+ return NO_ERRORS;
+ }
+ };
+
+ public static IValidator FILE_NAME_VALIDATOR = new IValidator() {
+
+ public Map<String, String> validate(Object value, Object context) {
+ String targetName = null;
+ IProject project = null;
+
+ if(context instanceof Object[]) {
+ Object[] contextArray = ((Object[])context);
+ targetName = contextArray[0].toString();
+ project = (IProject)contextArray[1];
+ }
+ if("".equals(value) || !project.getLocation().isValidSegment(value.toString()))
+ return createErrormessage(targetName + " name is not valid.");
+
+ return NO_ERRORS;
+ }
+ };
+
+ public static IValidator SEAM_PROJECT_NAME_VALIDATOR = new IValidator() {
+ public Map<String, String> validate(Object value, Object context) {
+
+ IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(value.toString());
+
+ if(project==null || !(project instanceof IProject) || !project.exists()) {
+ return createErrormessage("Project '" + value + "' does'n exist.");
+ } else {
+ try {
+ if(!((IProject)project).hasNature(ISeamProject.NATURE_ID)) {
+ return createErrormessage("Project '" + project.getName()+ "' has no Seam nature.");
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ return NO_ERRORS;
+ }
+ };
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -182,8 +182,9 @@
* @param newValue
*/
public void setValue(Object newValue) {
- pcs.firePropertyChange(nameText,value,newValue);
+ Object oldValue = value;
value = newValue;
+ pcs.firePropertyChange(nameText,oldValue,newValue);
}
/**
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/TextField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/TextField.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/TextField.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -31,7 +31,7 @@
}
public void modifyText(ModifyEvent e) {
- firePropertyChange("",((Text)e.widget).getText());
+ firePropertyChange(new Object(),((Text)e.widget).getText());
}
public Text getTextControl() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -18,11 +18,11 @@
public interface IParameter {
public static String SEAM_PROJECT_NAME = "seam.project.name";
- public static String SEAM_COMPONENT_NAME = "seam.component.name";
- public static String SEAM_LOCAL_INTERFACE_NAME = "seam.local.interface.name.";
- public static String SEAM_BEAN_NAME = "seam.bean.name";
- public static String SEAM_METHOD_NAME = "seam.method.name";
- public static String SEAM_PAGE_NAME = "seam.page.name";
- public static String SEAM_MASTER_PAGE_NAME = "seam.master.page.name";
- public static String SEAM_ENTITY_CLASS_NAME = "seam.entity.class.name";
+ public static String SEAM_COMPONENT_NAME = "component.name";
+ public static String SEAM_LOCAL_INTERFACE_NAME = "interface.name";
+ public static String SEAM_BEAN_NAME = "bean.name";
+ public static String SEAM_METHOD_NAME = "method.name";
+ public static String SEAM_PAGE_NAME = "page.name";
+ public static String SEAM_MASTER_PAGE_NAME = "masterPage.name";
+ public static String SEAM_ENTITY_CLASS_NAME = "entity.name";
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -10,18 +10,40 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
import java.util.Map;
+import org.apache.tools.ant.types.FilterSet;
+import org.apache.tools.ant.types.FilterSetCollection;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.INewWizard;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.AntCopyUtils;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.SeamFacetFilterSetFactory;
+/**
+ *
+ * @author eskimo
+ *
+ */
public class SeamActionWizard extends SeamBaseWizard implements INewWizard {
+ /**
+ *
+ */
public SeamActionWizard() {
super(CREATE_SEAM_ACTION);
setWindowTitle("New Seam Action");
@@ -29,17 +51,27 @@
addPage(new SeamActionWizardPage1());
}
- // TODO move operations to core plugin
+ /**
+ *
+ * TODO move operations to core plugin
+ */
public static final IUndoableOperation CREATE_SEAM_ACTION = new SeamBaseOperation("Action creating operation"){
-
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- Map params = (Map)info.getAdapter(Map.class);
-
- return Status.OK_STATUS;
+
+
+ public File getBeanFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"src/ActionJavaBean.java");
}
+ public File getTestClassFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/ActionTest.java");
+ }
+
+ public File getTestngXmlFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/testng.xml");
+ }
+
+ public File getPageXhtml(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"view/action.xhtml");
+ }
};
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -11,18 +11,39 @@
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tools.ant.types.FilterSetCollection;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.AntCopyUtils;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.SeamFacetFilterSetFactory;
+import org.jboss.tools.seam.ui.widget.editor.INamedElement;
+import org.osgi.service.prefs.BackingStoreException;
/**
* @author eskimo
*
*/
-public class SeamBaseOperation extends AbstractOperation {
+public abstract class SeamBaseOperation extends AbstractOperation {
/**
* @param label
@@ -38,9 +59,81 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- throw new IllegalStateException("Execute method should be overiden");
+ Map<String, INamedElement> params = (Map)info.getAdapter(Map.class);
+ Map<String, Object> vars = new HashMap<String, Object>();
+ IEclipsePreferences seamFacetPrefs = SeamCorePlugin.getSeamFacetPreferences(
+ ResourcesPlugin.getWorkspace().getRoot().getProject(params.get(IParameter.SEAM_PROJECT_NAME).getValueAsString()));
+ try {
+
+ for (String key : seamFacetPrefs.keys()) {
+ vars.put(key, seamFacetPrefs.get(key, ""));
+ }
+
+ for (Object valueHolder : params.values()) {
+ INamedElement elem = (INamedElement)valueHolder;
+ vars.put(elem.getName(),elem.getValue().toString());
+ }
+ vars.put(ISeamFacetDataModelProperties.SEAM_PROJECT_INSTANCE,
+ ResourcesPlugin.getWorkspace().getRoot().getProject(
+ vars.get(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME).toString()));
+
+ return execute(monitor, vars);
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return Status.OK_STATUS;
}
+ /**
+ *
+ * @param monitor
+ * @param params
+ * @return
+ * @throws ExecutionException
+ */
+ public IStatus execute(IProgressMonitor monitor, Map<String,Object> vars)
+ throws ExecutionException {
+
+ // Target Project
+ IProject targetProject = (IProject)vars.get(ISeamFacetDataModelProperties.SEAM_PROJECT_INSTANCE);
+
+ IVirtualComponent com = ComponentCore.createComponent(targetProject);
+ IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
+ IContainer webRootContainer = webRootFolder.getUnderlyingFolder();
+
+ FilterSetCollection filters = new FilterSetCollection(SeamFacetFilterSetFactory.createFiltersFilterSet(vars));
+
+ // Input data
+// String beanName = vars.get(IParameter.SEAM_BEAN_NAME).toString();
+ String actionFolder = vars.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString();
+ String interfaceName = vars.get(IParameter.SEAM_LOCAL_INTERFACE_NAME).toString();
+ String testFolder = vars.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME).toString();
+ String pageName = vars.get(IParameter.SEAM_PAGE_NAME).toString();
+
+ File seamTargetInterfaceFile = new File(targetProject.getLocation().toFile().toString()
+ + "/src/" + actionFolder.replace('.','/') + "/" + interfaceName + ".java");
+ AntCopyUtils.copyFileToFile(getBeanFile(vars),seamTargetInterfaceFile,filters,true);
+
+ File seamTargetActionTestFile = new File(targetProject.getLocation().toFile().toString()
+ + "/src/" + testFolder.replace('.','/') + "/" + interfaceName + "Test.java");
+ AntCopyUtils.copyFileToFile(getTestClassFile(vars),seamTargetActionTestFile,filters,true);
+
+ File seamTargetTestinFile = new File(targetProject.getLocation().toFile().toString()
+ + "/src/" + testFolder.replace('.','/') + "/" + interfaceName + "Test.xml");
+ AntCopyUtils.copyFileToFile(getTestngXmlFile(vars),seamTargetTestinFile,filters,true);
+
+ File seamTargetActionPageFile = new File(webRootContainer.getLocation().toFile().toString()
+ + "/" + pageName + ".xhtml");
+ AntCopyUtils.copyFileToFile(getPageXhtml(vars),seamTargetActionPageFile,filters,true);
+
+ try {
+ targetProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return Status.OK_STATUS;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
*/
@@ -68,4 +161,16 @@
public boolean canUndo() {
return false;
}
+
+ public File getSeamFolder(Map<String, Object> vars) {
+ return new File(vars.get(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME).toString(),"seam-gen");
+ }
+
+ public abstract File getBeanFile(Map<String, Object> vars);
+
+ public abstract File getTestClassFile(Map<String, Object> vars);
+
+ public abstract File getTestngXmlFile(Map<String, Object> vars);
+
+ public abstract File getPageXhtml(Map<String, Object> vars);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -11,24 +11,37 @@
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
+import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
/**
* @author eskimo
*
*/
-public class SeamBaseWizardPage extends WizardPage implements IAdaptable {
+public class SeamBaseWizardPage extends WizardPage implements IAdaptable, PropertyChangeListener {
/**
*
@@ -63,6 +76,16 @@
*/
public void createControl(Composite parent) {
setControl(new GridLayoutComposite(parent));
+
+ if (!"".equals(editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue())){
+ Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ }
+ }
+ setPageComplete(false);
}
/* (non-Javadoc)
@@ -82,7 +105,9 @@
public void addEditor(IFieldEditor editor) {
editorRegistry.put(editor.getName(), editor);
editorOrder.add(editor);
+ editor.addPropertyChangeListener(this);
}
+
/**
*
* @param id
@@ -90,13 +115,21 @@
*/
public void addEditors(IFieldEditor[] editors) {
for (IFieldEditor fieldEditor : editors) {
- editorRegistry.put(fieldEditor.getName(), fieldEditor);
- editorOrder.add(fieldEditor);
+ addEditor(fieldEditor);
}
}
/**
*
+ * @param name
+ * @return
+ */
+ public IFieldEditor getEditor(String name) {
+ return editorRegistry.get(name);
+ }
+
+ /**
+ *
* @author eskimo
*
*/
@@ -122,7 +155,76 @@
public GridLayoutComposite(Composite parent) {
this(parent, SWT.NONE);
-
}
}
+
+ /* (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ // TODO - finish validation
+
+ Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(
+ editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValueAsString());
+
+
+ errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_COMPONENT_NAME).getValue(), new Object[]{"Seam component",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_LOCAL_INTERFACE_NAME).getValue(), new Object[]{"Local interface",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.SEAM_METHOD_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_METHOD_NAME).getValue(), new Object[]{"Method",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.FILE_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_PAGE_NAME).getValue(), (Object)new Object[]{"Page",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.SEAM_JAVA_INTEFACE_NAME_CONVENTION_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_LOCAL_INTERFACE_NAME).getValue(), new Object[]{"Local interface",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(null);
+ setMessage(errors.get(IValidator.DEFAULT_ERROR).toString(),IMessageProvider.WARNING);
+ setPageComplete(true);
+ return;
+ }
+
+ setErrorMessage(null);
+ setMessage(null);
+ setPageComplete(true);
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
@@ -30,14 +31,22 @@
public static final IUndoableOperation CREATE_SEAM_CONVERSATION = new SeamBaseOperation("Action creating operation"){
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- Map params = (Map)info.getAdapter(Map.class);
-
- return Status.OK_STATUS;
+ public File getBeanFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"src/ActionJavaBean.java");
}
+ public File getTestClassFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/ActionTest.java");
+ }
+
+ public File getTestngXmlFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/testng.xml");
+ }
+
+ public File getPageXhtml(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"view/action.xhtml");
+ }
+
};
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
@@ -38,15 +39,23 @@
// TODO move operations to core plugin
public static final IUndoableOperation CREATE_SEAM_ENTITY = new SeamBaseOperation("Action creating operation"){
-
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- Map params = (Map)info.getAdapter(Map.class);
-
- return Status.OK_STATUS;
+
+ public File getBeanFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"src/ActionJavaBean.java");
}
+ public File getTestClassFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/ActionTest.java");
+ }
+
+ public File getTestngXmlFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/testng.xml");
+ }
+
+ public File getPageXhtml(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"view/action.xhtml");
+ }
+
};
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -30,7 +30,7 @@
*
*/
protected void createEditors() {
- addEditor(SeamWizardFactory.createSeamProjctSelectionFieldEditor(SeamWizardUtils.getSelectedProjectName()));
+ addEditor(SeamWizardFactory.createSeamProjectSelectionFieldEditor(SeamWizardUtils.getSelectedProjectName()));
addEditor(SeamWizardFactory.createSeamEntityClasNameFieldEditor());
addEditor(SeamWizardFactory.createSeamMasterPageNameFieldEditor());
addEditor(SeamWizardFactory.createSeamPageNameFieldEditor());
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFofrmWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFofrmWizard.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFofrmWizard.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
@@ -27,22 +28,32 @@
*/
public class SeamFofrmWizard extends SeamBaseWizard implements INewWizard {
+ /**
+ *
+ */
public SeamFofrmWizard() {
super(CREATE_SEAM_FORM);
setWindowTitle("New Seam Form");
addPage(new SeamFormWizardPage1());
}
- private static IUndoableOperation CREATE_SEAM_FORM = new SeamBaseOperation("Action creating operation"){
+ private static IUndoableOperation CREATE_SEAM_FORM = new SeamBaseOperation("Form creating operation"){
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- Map params = (Map)info.getAdapter(Map.class);
-
- return Status.OK_STATUS;
+
+ public File getBeanFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"src/FormActionJavaBean.java");
}
+ public File getTestClassFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/FormTest.java");
+ }
+
+ public File getTestngXmlFile(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"test/testng.xml");
+ }
+
+ public File getPageXhtml(Map<String, Object> vars) {
+ return new File(getSeamFolder(vars),"view/form.xhtml");
+ }
};
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -11,7 +11,11 @@
package org.jboss.tools.seam.ui.wizard;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -20,6 +24,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ListDialog;
import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.SeamProject;
/**
* @author eskimo
@@ -38,7 +44,17 @@
setInput(new Object());
setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<IProject> seamProjects = new ArrayList<IProject>();
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ try {
+ if(project.hasNature(SeamProject.NATURE_ID)) {
+ seamProjects.add(project);
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ return seamProjects.toArray();
}
public void dispose() {
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -58,7 +58,7 @@
@Override
public void createPageControls(Composite container) {
super.createPageControls(container);
- getModel().setSelectedPreset("preset.jst.seam.v2_0");
+ getModel().setSelectedPreset("preset.jst.seam.v1_2");
Control control = findControlByClass((Composite)getShell(), PresetSelectionPanel.class);
control.setVisible(false);
control = findGroupByText((Composite)getShell(), "EAR Membership");
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-07-17 08:29:11 UTC (rev 2454)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-07-17 08:33:03 UTC (rev 2455)
@@ -20,7 +20,7 @@
*
*/
public class SeamWizardFactory {
- public static IFieldEditor createSeamProjctSelectionFieldEditor(
+ public static IFieldEditor createSeamProjectSelectionFieldEditor(
String defaultSelection) {
return SwtFieldEditorFactory.INSTANCE.createButtonFieldEditor(
IParameter.SEAM_PROJECT_NAME, "Seam Project:", defaultSelection,
@@ -72,9 +72,10 @@
public static final IFieldEditor[] createDefaultWizardEditors(String defaultSelection) {
return new IFieldEditor[]{
- SeamWizardFactory.createSeamProjctSelectionFieldEditor(SeamWizardUtils.getSelectedProjectName()),
+ SeamWizardFactory.createSeamProjectSelectionFieldEditor(SeamWizardUtils.getSelectedProjectName()),
+ SeamWizardFactory.createSeamComponentNameFieldEditor(),
SeamWizardFactory.createSeamLocalInterfaceNameFieldEditor(),
- SeamWizardFactory.createSeamBeanNameFieldEditor(),
+// SeamWizardFactory.createSeamBeanNameFieldEditor(),
SeamWizardFactory.createSeamMethodNameFieldEditor(),
SeamWizardFactory.createSeamPageNameFieldEditor()
};
@@ -83,6 +84,15 @@
/**
* @return
*/
+ public static IFieldEditor createSeamComponentNameFieldEditor() {
+ // TODO Auto-generated method stub
+ return SwtFieldEditorFactory.INSTANCE.createTextEditor(
+ IParameter.SEAM_COMPONENT_NAME, "Seam component name:", "");
+ }
+
+ /**
+ * @return
+ */
public static IFieldEditor createSeamEntityClasNameFieldEditor() {
return SwtFieldEditorFactory.INSTANCE.createTextEditor(
IParameter.SEAM_ENTITY_CLASS_NAME, "Seam entity class name:", "");
17 years, 5 months
JBoss Tools SVN: r2454 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-17 04:29:11 -0400 (Tue, 17 Jul 2007)
New Revision: 2454
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
EXIN-217 Merge of variables improved
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-17 08:02:36 UTC (rev 2453)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-17 08:29:11 UTC (rev 2454)
@@ -269,24 +269,8 @@
String oldClassName = c == null ? null : c.getClassName();
if(current != null) {
- Set<ISeamContextVariable> oldVariables = current.getDeclaredVariables();
List<Change> changes = current.merge(loaded);
if(changes != null && changes.size() > 0) {
-
- Set<ISeamContextVariable> newVariables = current.getDeclaredVariables();
- if(oldVariables != null && newVariables != null) {
- for (ISeamContextVariable v : oldVariables) {
- if(!newVariables.contains(v)) {
- allVariables.remove(v);
- }
- }
- for (ISeamContextVariable v : newVariables) {
- if(!oldVariables.contains(v)) {
- allVariables.add(v);
- }
- }
- }
-
Change cc = new Change(c, null, null, null);
cc.addChildren(changes);
List<Change> cchanges = Change.addChange(null, cc);
17 years, 5 months
JBoss Tools SVN: r2453 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: mozilla and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-07-17 04:02:36 -0400 (Tue, 17 Jul 2007)
New Revision: 2453
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
Log:
resolve http://jira.jboss.com/jira/browse/JBIDE-531.
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-07-17 08:02:36 UTC (rev 2453)
@@ -0,0 +1,1793 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
+import org.jboss.tools.vpe.VpeDebug;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.css.CSSReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefaultPseudoContentCreator;
+import org.jboss.tools.vpe.editor.template.VpeTagDescription;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
+import org.jboss.tools.vpe.editor.util.MozillaSupports;
+import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.VpeDnD;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMMouseEvent;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMNode;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMRange;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * class VpePreviewDomBuilder for create DOM-tree for Mozilla preview
+ * @author A. Yukhovich
+ */
+public class VpePreviewDomBuilder extends VpeVisualDomBuilder {
+ private static final String PSEUDO_ELEMENT = "br";
+ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
+ private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
+ private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
+ private static final String COMMENT_STYLE = "font-style:italic; color:green";
+ private static final String COMMENT_PREFIX = "";
+ private static final String COMMENT_SUFFIX = "";
+ private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
+ private static final int DRAG_AREA_WIDTH = 10;
+ private static final int DRAG_AREA_HEIGHT = 10;
+ private static final String ATTR_XMLNS = "xmlns";
+
+ private MozillaEditor visualEditor;
+ private MozillaBrowser browser;
+ private Document visualDocument;
+ private Element visualContentArea;
+ private VpePageContext pageContext;
+ private VpeDnD dnd;
+ private Node headNode;
+ private List includeStack;
+ boolean rebuildFlag = false;
+
+ private static final String EMPTY_STRING = "";
+
+ private static final String TAG_BODY = "body";
+ private static final String TAG_HEAD = "head";
+ private static final String TAG_HTML = "html";
+ private static final String TAG_LINK = "link";
+ private static final String TAG_STYLE = "style";
+ private static final String TAG_TABLE = "table";
+ private static final String TAG_TBODY = "tbody";
+ private static final String TAG_THEAD = "thead";
+ private static final String TAG_TR = "tr";
+ private static final String TAG_TD = "td";
+ private static final String TAG_COL = "col";
+ private static final String TAG_COLS = "cols";
+ private static final String TAG_COLGROUP = "colgroup";
+ private static final String TAG_BR = "br";
+ private static final String TAG_LI = "li";
+ private static final String TAG_IMG = "img";
+ private static final String TAG_DIV = "div";
+ private static final String TAG_SPAN = "span";
+ private static final String TAG_P = "p";
+
+ private static final String ATTR_VPE = "vpe";
+ private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
+
+ private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
+
+ private static final String YES_STRING = "yes";
+ private static final String NO_STRING = "no";
+
+ /**
+ *
+ * @param domMapping
+ * @param sorceAdapter
+ * @param templateManager
+ * @param visualEditor
+ * @param pageContext
+ */
+ public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter, VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, templateManager, visualEditor, pageContext);
+ this.visualEditor = visualEditor;
+ browser = (MozillaBrowser)visualEditor.getControl();
+ this.visualDocument = visualEditor.getDomDocument();
+ this.visualContentArea = visualEditor.getContentArea();
+ this.dnd = visualEditor.getLocalDnD();
+ this.pageContext = pageContext;
+ this.headNode = visualEditor.getHeadNode();
+ }
+
+ /**
+ *
+ */
+ public void buildDom(Document sourceDocument) {
+ includeStack = new ArrayList();
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput)input).getFile();
+ if (file != null) {
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext.getSourceBuilder().getSourceDocument()));
+ }
+ }
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ addChildren(null, sourceDocument, visualContentArea);
+ registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+ }
+
+ /**
+ *
+ */
+ public void rebuildDom(Document sourceDocument) {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
+
+ NodeList children = visualContentArea.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node child = children.item(i);
+ Node visualRemovedNode = visualContentArea.removeChild(child);
+ MozillaSupports.release(child, visualRemovedNode);
+ }
+ MozillaSupports.release(children);
+
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
+ }
+
+ rebuildFlag = true;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @param visualNextNode
+ * @param visualContainer
+ * @return
+ */
+ private boolean addNode(Node sourceNode, Node visualNextNode, Node visualContainer) {
+ Node visualNewNode = createNode(sourceNode, visualContainer);
+ if (visualNewNode != null) {
+ Node visualAddedNode = visualNextNode == null ?
+ visualContainer.appendChild(visualNewNode) :
+ visualContainer.insertBefore(visualNewNode, visualNextNode);
+ MozillaSupports.release(visualAddedNode);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @param visualOldContainer
+ * @return
+ */
+ private Node createNode(Node sourceNode, Node visualOldContainer) {
+ boolean registerFlag = isCurrentMainDocument();
+ switch (sourceNode.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Map xmlnsMap = createXmlns((Element)sourceNode);
+ Set ifDependencySet = new HashSet();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext, (Element)sourceNode, ifDependencySet);
+ VpeCreationData creationData;
+
+ if ( template.isHaveVisualPreview() ) {
+ creationData = template.create(pageContext, sourceNode, visualDocument);
+ } else {
+ Element tempHTMLElement = visualDocument.createElement(TAG_DIV);
+ creationData = new VpeCreationData(tempHTMLElement);
+ }
+
+ pageContext.setCurrentVisualNode(null);
+ Element visualNewElement;
+ visualNewElement = (Element)creationData.getNode();
+ setTooltip((Element)sourceNode, visualNewElement);
+
+ if (!isCurrentMainDocument() && visualNewElement != null) {
+ setReadOnlyElement(visualNewElement);
+ }
+
+ if (template.isChildren()) {
+ List childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode, visualNewElement != null ? visualNewElement : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
+ }
+ }
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ template.validate(pageContext, (Element)sourceNode, visualDocument, creationData);
+ pageContext.setCurrentVisualNode(null);
+ return visualNewElement;
+ case Node.TEXT_NODE:
+ String sourceText = sourceNode.getNodeValue();
+ if (sourceText.trim().length() <= 0) {
+ registerNodes(new VpeNodeMapping(sourceNode, null));
+ return null;
+ }
+ String visualText = TextUtil.visualText(sourceText);
+ Node visualNewTextNode = visualDocument.createTextNode(visualText);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewTextNode));
+ }
+ return visualNewTextNode;
+ case Node.COMMENT_NODE:
+ if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
+ return null;
+ }
+ Element visualNewComment = createComment(sourceNode);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
+ }
+ return visualNewComment;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private Element createComment(Node sourceNode) {
+ Element div = visualDocument.createElement(TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
+ String value = COMMENT_PREFIX + sourceNode.getNodeValue() + COMMENT_SUFFIX;
+ Node text = visualDocument.createTextNode(value);
+ div.appendChild(text);
+ return div;
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualContainer
+ */
+ private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if (addNode(sourceNode, null, visualContainer)) {
+ childrenCount++;
+ }
+ }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer, visualContainer);
+ }
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualOldContainer
+ * @param childrenInfoList
+ */
+ private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualOldContainer, List childrenInfoList) {
+ for (int i = 0; i < childrenInfoList.size(); i++) {
+ VpeChildrenInfo info = (VpeChildrenInfo)childrenInfoList.get(i);
+ Node visualParent = info.getVisualParent();
+ if (visualParent == null) visualParent = visualOldContainer;
+ List sourceChildren = info.getSourceChildren();
+ int childrenCount = 0;
+ if (sourceChildren != null) {
+ for (int j = 0; j < sourceChildren.size(); j++) {
+ if (addNode((Node)sourceChildren.get(j), null, visualParent)) {
+ childrenCount++;
+ }
+ }
+ }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer, visualParent);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public Node addStyleNodeToHead(String styleText){
+ Node newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if(styleText != null){
+ Node newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ MozillaSupports.release(newText);
+ }
+ headNode.appendChild(newStyle);
+ return newStyle;
+ }
+
+ /**
+ *
+ */
+ public Node replaceStyleNodeToHead(Node oldStyleNode, String styleText){
+ Node newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if(styleText != null){
+ Node newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ MozillaSupports.release(newText);
+ }
+
+ headNode.replaceChild(newStyle, oldStyleNode);
+ MozillaSupports.release(oldStyleNode);
+ return newStyle;
+ }
+
+ /**
+ *
+ */
+ public void removeStyleNodeFromHead(Node oldStyleNode){
+ headNode.removeChild(oldStyleNode);
+ MozillaSupports.release(oldStyleNode);
+ }
+
+ /**
+ *
+ */
+ void addExternalLinks() {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput)input).getFile();
+ }
+ ResourceReference[] l = null;
+ if (file != null) {
+ l = CSSReferenceList.getInstance().getAllResources(file);
+ }
+ if (l != null) {
+ for (int i = 0; i < l.length; i++) {
+ ResourceReference item = l[i];
+ addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ void removeExternalLinks() {
+ NodeList childs = headNode.getChildNodes();
+ int length = childs.getLength();
+ for (int i = length - 1; i >= 0; i--) {
+ Node node = childs.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if((isLink = TAG_LINK.equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = TAG_STYLE.equalsIgnoreCase(node.getNodeName()))) {
+ Element element = (Element)node;
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING.equalsIgnoreCase(element.getAttribute("ext"))) {
+ headNode.removeChild(node);
+ }
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(childs);
+ }
+
+ /**
+ *
+ */
+ void refreshExternalLinks() {
+ removeExternalLinks();
+ addExternalLinks();
+ }
+
+ /**
+ *
+ */
+ void resetPseudoElement(Node visualNode) {
+ if (visualNode != null) {
+ Node visualParent = visualNode.getParentNode();
+ if (visualParent != null) {
+ PseudoInfo info = getPseudoInfo(visualParent);
+ if (info.pseudoNode == null && !info.isElements) {
+ addPseudoElementImpl(visualParent);
+ } else if (info.pseudoNode != null && info.isElements) {
+ visualParent.removeChild(info.pseudoNode);
+ MozillaSupports.release(info.pseudoNode);
+ }
+ MozillaSupports.release(visualParent);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualParent
+ * @return
+ */
+ private PseudoInfo getPseudoInfo(Node visualParent) {
+ Node pseudoNode = null;
+ boolean isElements = false;
+
+ if (visualParent == null) return new PseudoInfo();
+ NodeList visualNodes = visualParent.getChildNodes();
+ if (visualNodes == null) return new PseudoInfo();
+
+ int length = visualNodes.getLength();
+ for (int i = 0; i < length; i++) {
+ Node visualNode = visualNodes.item(i);
+ if (pseudoNode == null && isPseudoElement(visualNode)) {
+ pseudoNode = visualNode;
+ } else if (!isEmptyText(visualNode)) {
+ isElements = true;
+ }
+ if (visualNode != pseudoNode) {
+ MozillaSupports.release(visualNode);
+ }
+ if (pseudoNode != null && isElements) {
+ break;
+ }
+ }
+ MozillaSupports.release(visualNodes);
+ return new PseudoInfo(pseudoNode, isElements);
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ static boolean isInitElement(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) return false;
+ if (YES_STRING.equalsIgnoreCase(((Element)visualNode).getAttribute(INIT_ELEMENT_ATTR))) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ static boolean isPseudoElement(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) return false;
+ if (YES_STRING.equalsIgnoreCase(((Element)visualNode).getAttribute(PSEUDO_ELEMENT_ATTR))) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualContainer
+ */
+ private void setPseudoContent(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ } else {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ }
+ }
+
+ /**
+ *
+ * @param visualParent
+ */
+ private void addPseudoElementImpl(Node visualParent) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent.getNodeName())) {
+ if (VpeDebug.visualAddPseudoElement) {
+ System.out.println("-------------------- addPseudoElement: " + visualParent.getNodeName());
+ }
+ Element visualPseudoElement = visualDocument.createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
+ visualParent.appendChild(visualPseudoElement);
+ MozillaSupports.release(visualPseudoElement);
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean isEmptyElement(Node visualParent) {
+ boolean empty = false;
+ NodeList visualNodes = visualParent.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len == 0) {
+ empty = true;
+ } else if (len == 1) {
+ Node visualNode = visualNodes.item(0);
+ if (isEmptyText(visualNode)) {
+ empty = true;
+ }
+ MozillaSupports.release(visualNode);
+ }
+ MozillaSupports.release(visualNodes);
+ return empty;
+ }
+
+ /**
+ *
+ */
+ public boolean isEmptyDocument() {
+ boolean empty = false;
+ NodeList visualNodes = visualContentArea.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len == 0) {
+ empty = true;
+ } else if (len == 1) {
+ Node visualNode = visualNodes.item(0);
+ if (isEmptyText(visualNode) || isPseudoElement(visualNode)) {
+ empty = true;
+ }
+ MozillaSupports.release(visualNode);
+ }
+ MozillaSupports.release(visualNodes);
+ return empty;
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ private boolean isEmptyText(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.TEXT_NODE) return false;
+ if (visualNode.getNodeValue().trim().length() == 0) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ */
+ private void updateComment(Node sourceNode) {
+ VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
+ if (mapping != null && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
+ Node visualCommentFrame = mapping.getVisualNode();
+ NodeList visualNodes = visualCommentFrame.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len > 0) {
+ Node visualText = visualNodes.item(0);
+ visualText.setNodeValue(sourceNode.getNodeValue());
+ MozillaSupports.release(visualText);
+ }
+ MozillaSupports.release(visualNodes);
+ }
+ }
+
+ /**
+ *
+ * @param sourceNode
+ */
+ private void updateElement(Node sourceNode) {
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping)nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate().getNodeForUptate(pageContext, elementMapping.getSourceNode(), elementMapping.getVisualNode(), elementMapping.getData());
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
+ }
+ }
+ }
+ Node visualOldNode = domMapping.remove(sourceNode);
+ if (visualOldNode != null) {
+ if(elementMapping != null){
+ Element border = elementMapping.getBorder();
+ if(border != null){
+ MozillaSupports.release(visualOldNode);
+ visualOldNode = border;
+ }
+ }
+ Node visualContainer = visualOldNode.getParentNode();
+ Node visualNextNode = visualOldNode.getNextSibling();
+ if (visualContainer != null) {
+ visualContainer.removeChild(visualOldNode);
+ addNode(sourceNode, visualNextNode, visualContainer);
+ }
+ MozillaSupports.release(visualOldNode, visualNextNode, visualContainer);
+ } else {
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void removeNode(Node sourceNode) {
+ Node visualNode = domMapping.remove(sourceNode);
+ if (visualNode != null) {
+ MozillaSupports.release(visualNode);
+ }
+ }
+
+ /**
+ *
+ */
+ public void setText(Node sourceText) {
+ Node sourceParent = sourceText.getParentNode();
+ if (sourceParent != null && sourceParent.getLocalName() != null) {
+ String sourceParentName = sourceParent.getLocalName();
+ if ("textarea".equalsIgnoreCase(sourceParentName) || "option".equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return;
+ }
+ }
+ Node visualText = domMapping.getVisualNode(sourceText);
+ if (visualText != null) {
+ String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ visualText.setNodeValue(visualValue);
+ } else {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceParent);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ VpeTemplate template = ((VpeElementMapping)nodeMapping).getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return;
+ }
+ }
+ }
+ updateNode(sourceText);
+ }
+ }
+
+ /**
+ *
+ */
+ public void setAttribute(Element sourceElement, String name, String value) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping.getBorder() != null) {
+ updateElement(sourceElement);
+ } else if (template.isRecreateAtAttrChange(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name, value)) {
+ updateElement(sourceElement);
+ } else {
+ Element visualElement = (Element)elementMapping.getVisualNode();
+ if (visualElement != null) {
+ String visualElementName = visualElement.getNodeName().toLowerCase();
+ if ("select".equals(visualElementName)) {
+ updateElement(sourceElement);
+ return;
+ } else if ("option".equals(visualElementName)) {
+ updateElement(sourceElement.getParentNode());
+ return;
+ }
+ }
+ setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement, visualDocument, visualElement, elementMapping.getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void stopToggle(Node sourceNode) {
+ if (!(sourceNode instanceof Element))
+ return;
+
+ Element sourceElement = (Element)sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate)template).stopToggling(sourceElement);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean doToggle(Node visualNode) {
+ if (visualNode == null) return false;
+
+ Element visualElement = (Element) (visualNode instanceof Element ?
+ visualNode : visualNode.getParentNode());
+
+ if (visualElement == null) return false;
+
+ Attr toggleIdAttr = visualElement.getAttributeNode("vpe-user-toggle-id");
+ if (toggleIdAttr == null) return false;
+ String toggleId = toggleIdAttr.getNodeValue();
+ MozillaSupports.release(toggleIdAttr);
+
+ if (toggleId == null) return false;
+
+ boolean toggleLookup = false;
+ Attr toggleLookupAttr = visualElement.getAttributeNode("vpe-user-toggle-lookup-parent");
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ MozillaSupports.release(toggleIdAttr);
+ }
+
+
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(getLastSelectedElement());
+ Node sourceNode = (Node)domMapping.getSourceNode(getLastSelectedElement());
+ if (sourceNode == null) return false;
+
+ Element sourceElement = (Element)(sourceNode instanceof Element ?
+ sourceNode : sourceNode.getParentNode());
+
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+
+ while (toggleLookup && sourceElement != null && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element)sourceElement.getParentNode();
+ if (sourceElement == null) break;
+ elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping == null) continue;
+ template = elementMapping.getTemplate();
+ }
+
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate)template).toggle(this, sourceElement, toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public void removeAttribute(Element sourceElement, String name) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template.isRecreateAtAttrChange(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name, null)) {
+ updateElement(sourceElement);
+ } else {
+ removeXmlnsAttribute(elementMapping, name);
+ template.removeAttribute(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name);
+ resetTooltip(sourceElement, (Element)elementMapping.getVisualNode());
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void refreshBundleValues(Element sourceElement) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ template.refreshBundleValues(pageContext, sourceElement, elementMapping.getData());
+ }
+ }
+
+ /**
+ *
+ */
+ boolean isContentArea(Node visualNode) {
+ return visualContentArea.equals(visualNode);
+ }
+
+ /**
+ *
+ */
+ Element getContentArea() {
+ return visualContentArea;
+ }
+
+ /**
+ *
+ */
+ void setSelectionRectangle(Element visualElement) {
+ setSelectionRectangle(visualElement, true);
+ }
+
+ /**
+ *
+ */
+ void setSelectionRectangle(Element visualElement, boolean scroll) {
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains, scroll);
+ }
+
+ /**
+ *
+ */
+ public Node addLinkNodeToHead(String href_val, String ext_val) {
+ Element newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.appendChild(newNode);
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public Node replaceLinkNodeToHead(Node oldNode, String href_val, String ext_val) {
+ Node newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.replaceChild(newNode, oldNode);
+ MozillaSupports.release(oldNode);
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public Node replaceLinkNodeToHead(String href_val, String ext_val) {
+ Node newNode = null;
+ Node oldNode = getLinkNode(href_val, ext_val);
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
+ }
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public void removeLinkNodeFromHead(Node node){
+ headNode.removeChild(node);
+ MozillaSupports.release(node);
+ }
+
+ /**
+ *
+ * @param href_val
+ * @param rel_val
+ * @param ext_val
+ * @return
+ */
+ private Element createLinkNode(String href_val, String rel_val, String ext_val) {
+ Element linkNode = null;
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
+ && href_val.startsWith("file:")) {
+ /* Because of the Mozilla caches the linked css files we replace
+ * tag <link rel="styleseet" href="file://..."> with tag
+ * <style vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style>
+ * It is LinkReplacer
+ */
+ linkNode = visualDocument.createElement(TAG_STYLE);
+ linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
+
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ BufferedReader in = new BufferedReader(new FileReader((new Path(href_val)).setDevice("").toOSString()));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
+ }
+ in.close();
+ Node textNode = visualDocument.createTextNode(styleText.toString());
+ linkNode.appendChild(textNode);
+ return linkNode;
+ } catch (FileNotFoundException fnfe) {
+ MozillaSupports.release(linkNode);
+ /* File which was pointed by user is not exists. Do nothing. */
+ } catch (IOException ioe) {
+ MozillaSupports.release(linkNode);
+ VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
+ }
+ }
+
+ linkNode = visualDocument.createElement(TAG_LINK);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+
+ return linkNode;
+ }
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ private boolean isLinkReplacer(Node node) {
+ return TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(((Element)node).getAttribute(ATTR_VPE));
+ }
+
+ /**
+ *
+ * @param href_val
+ * @param ext_val
+ * @return
+ */
+ private Node getLinkNode(String href_val, String ext_val) {
+ NodeList children = headNode.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (TAG_LINK.equalsIgnoreCase(node.getNodeName())
+ || isLinkReplacer(node) ) {
+ Element element = (Element)node;
+ if (ext_val.equalsIgnoreCase(element.getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
+ && href_val.equalsIgnoreCase(element.getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
+ MozillaSupports.release(children);
+ return node;
+ }
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(children);
+ return null;
+ }
+
+ /**
+ *
+ */
+ private void cleanHead() {
+ NodeList children = headNode.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String name = node.getNodeName();
+ if (TAG_LINK.equalsIgnoreCase(name) || isLinkReplacer(node) ) {
+ if (NO_STRING.equalsIgnoreCase(((Element)node).getAttribute("ext"))) {
+ node = headNode.removeChild(node);
+ }
+ } else if (TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING.equalsIgnoreCase(((Element)node).getAttribute(ATTR_VPE)))) {
+ node = headNode.removeChild(node);
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @author A. Yukhovich
+ */
+ private class PseudoInfo {
+ private Node pseudoNode;
+ private boolean isElements;
+
+ private PseudoInfo() {
+ this(null, false);
+ }
+
+ private PseudoInfo(Node pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
+ }
+ }
+
+ /**
+ *
+ */
+ void showDragCaret(Node node, int offset) {
+ browser.showDragCaret((nsIDOMNode)node, offset);
+ }
+
+ /**
+ *
+ */
+ void hideDragCaret() {
+ browser.hideDragCaret();
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ private int getResizerConstrains(Node visualNode) {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ return ((VpeElementMapping)nodeMapping).getTemplate().getTagDescription(pageContext, (Element)nodeMapping.getSourceNode(), visualDocument, (Element)nodeMapping.getVisualNode(), ((VpeElementMapping)nodeMapping).getData()).getResizeConstrains();
+ }
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
+
+ /**
+ *
+ */
+ public void resize(Element element, int resizerConstrains, int top, int left, int width, int height) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(element);
+ if (elementMapping != null) {
+ elementMapping.getTemplate().resize(pageContext, (Element)elementMapping.getSourceNode(), visualDocument, element, elementMapping.getData(), resizerConstrains, top, left, width, height);
+ }
+ }
+
+ static boolean isAnonElement(Node visualNode) {
+ if (visualNode != null && visualNode.getNodeType() == Node.ELEMENT_NODE) {
+ String attrValue = ((Element)visualNode).getAttribute(MOZ_ANONCLASS_ATTR);
+ return attrValue != null && attrValue.length() > 0;
+ }
+ return false;
+ }
+
+ boolean canInnerDrag(Element visualDragElement) {
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if(node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping)node;
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().canInnerDrag(pageContext, (Element)elementMapping.getSourceNode(), visualDocument, visualDragElement, elementMapping.getData());
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode, VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
+ Node visualDropContainer = visualDropInfo.getDropContainer();
+ int visualDropOffset = visualDropInfo.getDropOffset();
+ Node sourceDropContainer = null;
+ int sourceDropOffset = 0;
+
+ switch (visualDropContainer.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Node visualOffsetNode = null;
+ boolean afterFlag = false;
+ int visualChildCount = MozillaSupports.getChildCount(visualDropContainer);
+ if (visualDropOffset < visualChildCount) {
+ visualOffsetNode = MozillaSupports.getChildNode(visualDropContainer, visualDropOffset);
+ if (isPseudoElement(visualOffsetNode) || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = true;
+ }
+ } else {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = visualChildCount != 0;
+ }
+ if (visualOffsetNode != null) {
+ Node sourceOffsetNode = domMapping.getSourceNode(visualOffsetNode);
+ if (sourceOffsetNode != null) {
+ sourceDropContainer = sourceOffsetNode.getParentNode();
+ sourceDropOffset = ((NodeImpl)sourceOffsetNode).getIndex();
+ if (afterFlag) {
+ sourceDropOffset++;
+ }
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping.getNearSourceNode(visualDropContainer);
+ if (sourceDropContainer != null) {
+ sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ }
+ }
+ if (sourceDropContainer == null){
+ sourceDropContainer = domMapping.getNearSourceNode(visualContentArea);
+ sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ }
+ break;
+ case Node.TEXT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualDropContainer);
+ switch (nodeMapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ sourceDropContainer = nodeMapping.getSourceNode();
+ sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer.getNodeValue(), visualDropOffset);
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ // it's attribute
+ if (isTextEditable(visualDropContainer)) {
+ String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element)nodeMapping.getSourceNode();
+ sourceDropContainer = sourceElement.getAttributeNode(atributeNames[0]);
+ sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer.getNodeValue(), visualDropOffset);
+ }
+ }
+ nodeMapping.getVisualNode();
+ }
+ break;
+ }
+ if (sourceDropContainer != null) {
+ return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer, sourceDropOffset, checkParentTemplates);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, false);
+ }
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode, Node container, int offset, boolean checkParentsTemplates) {
+ //Thread.dumpStack();
+ boolean canDrop = false;
+ switch (container.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ canDrop = ((VpeElementMapping)nodeMapping).getTemplate().canInnerDrop(pageContext, container, dragNode);
+ }
+ if (!canDrop) {
+ if(!checkParentsTemplates) return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ offset = ((NodeImpl)container).getIndex();
+ container = container.getParentNode();
+ return getSourceInnerDropInfo(dragNode, container, offset, false);
+ }
+ break;
+ case Node.TEXT_NODE:
+ case Node.DOCUMENT_NODE:
+ canDrop = true;
+ break;
+ case Node.ATTRIBUTE_NODE:
+ canDrop = true;
+ break;
+ }
+ if (canDrop) {
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ }
+ }
+
+ /**
+ *
+ */
+ public void innerDrop(Node dragNode, Node container, int offset) {
+ VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
+ if (mapping != null) {
+ Node visualDropContainer = mapping.getVisualNode();
+ switch (mapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ Node visualParent = visualDropContainer.getParentNode();
+ VpeNodeMapping oldMapping = mapping;
+ mapping = domMapping.getNearNodeMapping(visualParent);
+ MozillaSupports.release(visualParent);
+ if (mapping != null && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ ((VpeElementMapping)mapping).getTemplate().innerDrop(pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ } else {
+ ((VpeElementMapping)oldMapping).getTemplate().innerDrop(pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ }
+ }
+
+ }
+ }
+
+ /**
+ *
+ */
+ Element getNearDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
+ while (elementMapping != null) {
+ if (canInnerDrag((Element)elementMapping.getVisualNode())) {
+ return (Element)elementMapping.getVisualNode();
+ }
+ elementMapping = domMapping.getNearElementMapping(elementMapping.getVisualNode().getParentNode());
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ Element getDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
+ if (elementMapping != null && canInnerDrag((Element)elementMapping.getVisualNode())) {
+ return (Element)elementMapping.getVisualNode();
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public boolean isTextEditable(Node visualNode) {
+ if (visualNode != null) {
+ Node parent = visualNode.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element)parent;
+ Attr style = element.getAttributeNode("style");
+ if (style != null) {
+ String styleValue = style.getNodeValue();
+ MozillaSupports.release(style);
+ String [] items = styleValue.split(";");
+ for (int i = 0; i < items.length; i++) {
+ String[] item = items[i].split(":");
+ if ("-moz-user-modify".equals(item[0].trim()) && "read-only".equals(item[1].trim())) {
+ MozillaSupports.release(parent);
+ return false;
+ }
+ }
+ }
+ Attr classAttr = element.getAttributeNode("class");
+ if (classAttr != null) {
+ String classValue = classAttr.getNodeValue().trim();
+ MozillaSupports.release(classAttr);
+ if ("__any__tag__caption".equals(classValue)) {
+ MozillaSupports.release(parent);
+ return false;
+ }
+ }
+ }
+ MozillaSupports.release(parent);
+ }
+ return true;
+ }
+ /**
+ *
+ */
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer, int sourceDropOffset) {
+ Node visualDropContainer = null;
+ int visualDropOffset = 0;
+
+ switch (sourceDropContainer.getNodeType()) {
+ case Node.TEXT_NODE:
+ visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer.getNodeValue(), sourceDropOffset);
+ break;
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList sourceChildren = sourceDropContainer.getChildNodes();
+ if (sourceDropOffset < sourceChildren.getLength()) {
+ Node sourceChild = sourceChildren.item(sourceDropOffset);
+ Node visualChild = domMapping.getVisualNode(sourceChild);
+ if (visualChild != null) {
+ visualDropContainer = visualChild.getParentNode();
+ visualDropOffset = MozillaSupports.getOffset(visualChild);
+ }
+ }
+ if (visualDropContainer == null) {
+ visualDropContainer = domMapping.getNearVisualNode(sourceDropContainer);
+ Node visualChild = getLastAppreciableVisualChild(visualDropContainer);
+ if (visualChild != null) {
+ visualDropOffset = MozillaSupports.getOffset(visualChild) + 1;
+ } else {
+ visualDropOffset = 0;
+ }
+ }
+ break;
+ case Node.ATTRIBUTE_NODE:
+ Element sourceElement = ((Attr)sourceDropContainer).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
+ Node textNode = elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ if (textNode != null) {
+ visualDropContainer = textNode;
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer.getNodeValue(), sourceDropOffset);
+ }
+ break;
+ }
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer, visualDropOffset, 0, 0);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param visualElement
+ */
+ private void setTooltip(Element sourceElement, Element visualElement) {
+ if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
+ if ("HTML".equalsIgnoreCase(sourceElement.getNodeName())) return;
+ String titleValue = getTooltip(sourceElement);
+
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
+
+ if (titleValue != null) {
+ setTooltip(visualElement, titleValue);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @param titleValue
+ */
+ private void setTooltip(Element visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ NodeList children = visualElement.getChildNodes();
+ int len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ setTooltip((Element)child, titleValue);
+ }
+ MozillaSupports.release(child);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param visualElement
+ */
+ private void resetTooltip(Element sourceElement, Element visualElement) {
+ if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
+ if ("HTML".equalsIgnoreCase(sourceElement.getNodeName())) return;
+ String titleValue = getTooltip(sourceElement);
+
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
+
+ if (titleValue != null) {
+ resetTooltip(visualElement, titleValue);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @param titleValue
+ */
+ private void resetTooltip(Element visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ NodeList children = visualElement.getChildNodes();
+ int len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ if (domMapping.getNodeMapping(child) == null) {
+ resetTooltip((Element)child, titleValue);
+ }
+ }
+ MozillaSupports.release(child);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private String getTooltip(Element sourceElement) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++){
+ if (i == 7)
+ {
+ return buffer.append("\n\t... ").toString();
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0,15) + " ... "
+ + attrs.item(i).getNodeValue().substring(valueLength - 15,valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
+ }
+ else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + attrs.item(i).getNodeValue());
+
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ *
+ */
+ Rectangle getNodeBounds(Node visualNode) {
+ return dnd.getBounds((nsIDOMNode)visualNode);
+ }
+
+ /**
+ *
+ * @param x
+ * @param y
+ * @param rect
+ * @return
+ */
+ static boolean canInsertAfter(int x, int y, Rectangle rect) {
+ if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
+ return true;
+ }
+ return y >= rect.x && x > (rect.x + rect.width / 2);
+ }
+
+ /**
+ *
+ * @param visualParent
+ * @return
+ */
+ static Node getLastAppreciableVisualChild(Node visualParent) {
+ Node visualLastChild = null;
+ NodeList visualChildren = visualParent.getChildNodes();
+ int len = visualChildren.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node visualChild = visualChildren.item(i);
+ if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
+ visualLastChild = visualChild;
+ break;
+ }
+ MozillaSupports.release(visualChild);
+ }
+ MozillaSupports.release(visualChildren);
+ return visualLastChild;
+ }
+
+ /**
+ *
+ */
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo, VpeVisualInnerDropInfo oldVisualDropInfo) {
+ Node newVisualDropContainer = newVisualDropInfo.getDropContainer();
+ Node oldVisualDropContainer = oldVisualDropInfo.getDropContainer();
+
+ if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+ newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+ return;
+ }
+
+ Node child = oldVisualDropContainer;
+ while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
+ Node parent = child.getParentNode();
+ if (newVisualDropContainer.equals(parent)) {
+ int offset = MozillaSupports.getOffset(child);
+ Rectangle rect = getNodeBounds(child);
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(), oldVisualDropInfo.getMouseY(), rect)) {
+ offset++;
+ }
+ newVisualDropInfo.setDropOffset(offset);
+ }
+ child = parent;
+ }
+ }
+
+ /**
+ *
+ */
+ public nsIDOMRange createDOMRange() {
+ return browser.createDOMRange();
+ }
+
+ /**
+ *
+ */
+ public nsIDOMRange createDOMRange(Node selectedNode) {
+ nsIDOMRange range = createDOMRange();
+ range.selectNode((nsIDOMNode)selectedNode);
+ return range;
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @return
+ */
+ public static boolean isIncludeElement(Element visualElement) {
+ return YES_STRING.equalsIgnoreCase(visualElement.getAttribute(INCLUDE_ELEMENT_ATTR));
+ }
+
+ /**
+ *
+ * @param visualElement
+ */
+ public static void markIncludeElement(Element visualElement) {
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ }
+
+ /**
+ *
+ * @param node
+ */
+ private void setReadOnlyElement(Element node) {
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", "read-only");
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+
+ /**
+ *
+ */
+ void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
+ Element selectedElement = browser.getSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), mouseEvent.getMousePoint())) {
+ dnd.setMoveCursor();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param dragArea
+ * @param mousePoint
+ * @return
+ */
+ private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
+ return dragArea.contains(mousePoint) &&
+ mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH) &&
+ mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ }
+
+ /**
+ *
+ */
+ Element getDragElement(nsIDOMMouseEvent mouseEvent) {
+ Element selectedElement = browser.getSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), mouseEvent.getMousePoint())) {
+ return selectedElement;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(VpeVisualInnerDragInfo visualDragInfo) {
+ Node visualNode = visualDragInfo.getNode();
+ int offset = visualDragInfo.getOffset();
+ int length = visualDragInfo.getLength();
+
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
+ Node sourceNode = nodeMapping.getSourceNode();
+
+ if (sourceNode != null) {
+ switch (sourceNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ int end = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset);
+ length = end - offset;
+ break;
+ case Node.ELEMENT_NODE:
+ if (visualNode.getNodeType() == Node.TEXT_NODE) {
+ // it's attribute
+ sourceNode = null;
+ if (isTextEditable(visualNode)) {
+ String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element)nodeMapping.getSourceNode();
+ sourceNode = sourceElement.getAttributeNode(atributeNames[0]);
+ end = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset);
+ length = end - offset;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
+
+ /**
+ *
+ */
+ public void SetCursor(String aCursorName, int aLock) {
+ dnd.SetCursor(aCursorName, aLock);
+ }
+
+ /**
+ *
+ */
+ public Node getOutputTextNode(Attr attr) {
+ Element sourceElement = ((Attr)attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ Element getLastSelectedElement() {
+ return browser.getSelectedElement();
+ }
+
+ /**
+ *
+ */
+ public void pushIncludeStack(VpeIncludeInfo includeInfo) {
+ includeStack.add(includeInfo);
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo popIncludeStack() {
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo)includeStack.remove(includeStack.size() - 1);
+ }
+ return includeInfo;
+ }
+
+ /**
+ *
+ */
+ public boolean isFileInIncludeStack(IFile file) {
+ if (file == null) return false;
+ for (int i = 0; i < includeStack.size(); i++) {
+ if (file.equals(((VpeIncludeInfo)includeStack.get(i)).getFile())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private boolean isCurrentMainDocument() {
+ return includeStack.size() <= 1;
+ }
+
+ /**
+ *
+ *
+ */
+ public int getCurrentMainIncludeOffset() {
+ if (includeStack.size() <= 1) return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo)includeStack.get(1);
+ return ((IndexedRegion)info.getElement()).getStartOffset();
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo getCurrentIncludeInfo() {
+ if (includeStack.size() <= 0) return null;
+ return (VpeIncludeInfo)includeStack.get(includeStack.size() - 1);
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo getRootIncludeInfo() {
+ if (includeStack.size() <= 1) return null;
+ return (VpeIncludeInfo)includeStack.get(1);
+ }
+
+ /**
+ *
+ */
+ void dispose() {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.dispose();
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private Map createXmlns(Element sourceNode) {
+ NamedNodeMap attrs = ((Element)sourceNode).getAttributes();
+ if (attrs != null) {
+ Map xmlnsMap = new HashMap();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(), true);
+ }
+ if (xmlnsMap.size() > 0) {
+ return xmlnsMap;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param elementMapping
+ * @param name
+ * @param value
+ */
+ private void setXmlnsAttribute(VpeElementMapping elementMapping, String name, String value) {
+ Element sourceElement = (Element)elementMapping.getSourceNode();
+ if (sourceElement != null) {
+ Map xmlnsMap = elementMapping.getXmlnsMap();
+ if (xmlnsMap == null) xmlnsMap = new HashMap();
+ addTaglib(sourceElement, xmlnsMap, name, true);
+ elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
+ }
+ }
+
+ /**
+ *
+ * @param elementMapping
+ * @param name
+ */
+ private void removeXmlnsAttribute(VpeElementMapping elementMapping, String name) {
+ Element sourceElement = (Element)elementMapping.getSourceNode();
+ if (sourceElement != null) {
+ Map xmlnsMap = elementMapping.getXmlnsMap();
+ if (xmlnsMap != null) {
+ Object id = xmlnsMap.remove(name);
+ if (id != null) {
+ pageContext.setTaglib(((Integer)id).intValue(), null, null, true);
+ elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param xmlnsMap
+ * @param attrName
+ * @param ns
+ */
+ private void addTaglib(Element sourceElement, Map xmlnsMap, String attrName, boolean ns) {
+ Attr attr = sourceElement.getAttributeNode(attrName);
+ if (ATTR_XMLNS.equals(attr.getPrefix())) {
+ xmlnsMap.put(attr.getNodeName(), new Integer(attr.hashCode()));
+ pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr.getLocalName(), ns);
+ }
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-07-17 08:02:36 UTC (rev 2453)
@@ -0,0 +1,466 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.VpePreviewDomBuilder;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.MozillaSupports;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.VpeDnD;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMElement;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMEventTarget;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsISelectionController;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsISupports;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * a class implementation of mozilla previre
+ * @author A. Yukhovich
+ */
+public class MozillaPreview extends MozillaEditor {
+ private static final String INIT_URL = "chrome://vpe/content/init.html"; //$NON-NLS-1$
+ private static final String CONTENT_AREA_ID = "__content__area__"; //$NON-NLS-1$
+
+ static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
+ private MozillaBrowser editor;
+ private Document domDocument;
+ private nsIDOMEventTarget documentEventTarget;
+ private Element contentArea;
+ private Node headNode;
+ private nsIDOMEventTarget contentAreaEventTarget;
+ private MozillaDomEventListener contentAreaEventListener;
+ private MozillaBaseEventListener baseEventListener;
+ private EditorLoadWindowListener editorLoadWindowListener;
+ private EditorDomEventListener editorDomEventListener;
+ private VpeController controller;
+ private Link link = null;
+ private VpeTemplateManager templateManager;
+ private VpePageContext pageContext;
+ private BundleMap bundle;
+ private StructuredTextEditor sourceEditor;
+ private VpeEditorPart editPart;
+ private VpeDomMapping domMapping;
+ private IDOMDocument sourceDocument;
+
+ public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
+ templateManager = VpeTemplateManager.getInstance();
+
+ this.sourceEditor = sourceEditor;
+ this.editPart = editPart;
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ }
+
+ public void doSaveAs() {
+ }
+
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.setInput(input);
+ }
+
+ public void setInput(IEditorInput input) {
+ boolean isVisualRefreshRequired = (getEditorInput() != null && getEditorInput() != input && controller != null);
+ super.setInput(input);
+ if(isVisualRefreshRequired) controller.visualRefresh();
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(final Composite parent) {
+ try {
+ editor = new MozillaBrowser(parent, SWT.NONE) {
+ public void onLoadWindow() {
+ super.onLoadWindow();
+ MozillaPreview.this.onLoadWindow();
+ }
+
+ public void onElementResize(nsIDOMElement element, int resizerConstrains, int top, int left, int width, int height) {
+ }
+
+ public void onShowTooltip(int x, int y, String text) {
+ if (editorDomEventListener != null) {
+ editorDomEventListener.onShowTooltip(x, y, text);
+ }
+ }
+ public void onHideTooltip() {
+ if (editorDomEventListener != null) {
+ editorDomEventListener.onHideTooltip();
+ }
+ }
+ };
+ editor.setUrl(INIT_URL);
+ editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ } catch (Exception e) {
+ Label title = new Label(parent, SWT.WRAP);
+ title.setText(VpeUIMessages.MOZILLA_LOADING_ERROR);
+ title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ link = new Link(parent, SWT.WRAP);
+ link.setText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK_TEXT);
+ link.setToolTipText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
+ link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ link.addMouseListener(new MouseListener() {
+ public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
+ BusyIndicator.showWhile(link.getDisplay(), new Runnable() {
+ public void run() {
+ URL theURL=null;;
+ try {
+ theURL = new URL(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
+ } catch (MalformedURLException e) {
+ VpePlugin.reportProblem(e);
+ }
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
+ try {
+ support.getExternalBrowser().openURL(theURL);
+ } catch (PartInitException e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
+ });
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+ link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label fill = new Label(parent, SWT.WRAP);
+ fill.setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+ }
+
+ private ToolItem createToolItem(ToolBar parent, int type, String image, String toolTipText) {
+ ToolItem item = new ToolItem(parent, type);
+ item.setImage(ImageDescriptor.createFromFile(MozillaPreview.class, image).createImage());
+ item.setToolTipText(toolTipText);
+ return item;
+ }
+
+ public void setFocus() {
+ if(editor!=null) {
+ editor.setFocus();
+ } else {
+ //link.setFocus();
+ }
+ }
+
+ public void dispose() {
+ removeDomEventListeners();
+// removeClipboardDragDropHooks();
+ super.dispose();
+
+ if (contentArea != null) {
+ MozillaSupports.release(contentArea);
+ contentArea = null;
+ }
+ if (domDocument != null) {
+ MozillaSupports.release(domDocument);
+ domDocument = null;
+ }
+ if (editor != null) {
+ editor.dispose();
+ editor = null;
+ }
+ }
+
+ public void setEditorLoadWindowListener(EditorLoadWindowListener listener) {
+ editorLoadWindowListener = listener;
+ }
+
+ public void setEditorDomEventListener(EditorDomEventListener listener) {
+ editorDomEventListener = listener;
+ if (contentAreaEventListener != null) {
+ contentAreaEventListener.setEditorDomEventListener(listener);
+ }
+ if (editor != null) {
+ editor.setContextMenuListener(listener);
+ }
+ }
+
+ public Document getDomDocument() {
+ if (domDocument == null) {
+ domDocument = editor.getDOMDocument();
+ }
+ return domDocument;
+ }
+
+ public Element getContentArea() {
+ return contentArea;
+ }
+
+ public Node getHeadNode() {
+ return headNode;
+ }
+
+ public Menu getMenu() {
+ return editor.getMenu();
+ }
+
+ public Control getControl() {
+ return editor;
+ }
+
+ public VpeDnD getLocalDnD() {
+ if (contentAreaEventListener != null) {
+ return contentAreaEventListener.getLocalDnD();
+ }
+ return null;
+ }
+
+ private Element findContentArea() {
+ Node root = editor.getDOMDocumentElement();
+ Node area = findContentArea(root);
+ if (area == null) {
+ return null;
+ }
+ headNode = findHeadNode(root);
+ MozillaSupports.release(root);
+ return (Element)area;
+ }
+
+ private Node findHeadNode(Node root){
+ Node headNode = findChildNode(root, "HEAD"); //$NON-NLS-1$
+ return headNode;
+ }
+
+ private Node findChildNode(Node parent, String name) {
+ NodeList list = parent.getChildNodes();
+ Node node;
+ for (int i=0;i<list.getLength();i++) {
+ node = list.item(i);
+ if (node.getNodeName().equalsIgnoreCase(name)) {
+ MozillaSupports.release(list);
+ return node;
+ }
+ else {
+ MozillaSupports.release(node);
+ }
+ }
+ MozillaSupports.release(list);
+ return null;
+ }
+
+ private Node findContentArea(Node node) {
+ Node area = null;
+ if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ int length = children.getLength();
+ for (int i = 0; i < length; i++) {
+ Node child = children.item(i);
+ if (isContentArea(child)) {
+ area = child;
+ break;
+ }
+ area = findContentArea(child);
+ MozillaSupports.release(child);
+ if (area != null) {
+ break;
+ }
+ }
+ MozillaSupports.release(children);
+ }
+ }
+ return area;
+ }
+
+ private boolean isContentArea(Node node) {
+ boolean ret = false;
+ if ("BODY".equalsIgnoreCase(node.getNodeName())) { //$NON-NLS-1$
+ NamedNodeMap map = node.getAttributes();
+ if (map != null) {
+ int length = map.getLength();
+ for (int i = 0; i < length; i++) {
+ Node attr = map.item(i);
+ ret = attr.getNodeType() == Node.ATTRIBUTE_NODE &&
+ "ID".equalsIgnoreCase(attr.getNodeName()) && //$NON-NLS-1$
+ CONTENT_AREA_ID.equalsIgnoreCase(attr.getNodeValue());
+ MozillaSupports.release(attr);
+ if (ret) {
+ break;
+ }
+ }
+ MozillaSupports.release(map);
+ }
+ }
+ return ret;
+ }
+
+ /**
+ *
+ */
+ private void onLoadWindow() {
+ contentArea = findContentArea();
+ addDomEventListeners();
+ addSelectionListener();
+ if (editorLoadWindowListener != null) {
+ editorLoadWindowListener.load();
+ }
+ }
+
+ private void addDomEventListeners() {
+ if (contentArea != null) {
+ try {
+ contentAreaEventListener = (MozillaDomEventListener)Class.forName("org.jboss.tools.vpe.editor.mozilla.MozillaDomEventListener").newInstance(); //$NON-NLS-1$
+ } catch (Exception e) {
+ }
+
+ if (contentAreaEventListener != null) {
+ contentAreaEventListener.setMozillaBrowser(editor);
+ int aEventTarget = nsISupports.queryInterface(MozillaSupports.getAddress(contentArea), nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ contentAreaEventTarget = new nsIDOMEventTarget(aEventTarget);
+ contentAreaEventListener.getLocalDnD().Init(editor.getDOMDocument(),editor.getPresShell(), contentAreaEventListener.getDropListener());
+ //contentAreaEventTarget.addEventListener("DOMSubtreeModified", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeInserted", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeRemoved", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeRemovedFromDocument", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeInsertedIntoDocument", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMAttrModified", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMCharacterDataModified", contentAreaEventListener.getDomEventListener());
+ contentAreaEventTarget.addEventListener("click", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mousedown", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mouseup", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mousemove", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+
+ Document document = getDomDocument();
+ aEventTarget = nsISupports.queryInterface(MozillaSupports.getAddress(document), nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ documentEventTarget = new nsIDOMEventTarget(aEventTarget);
+ documentEventTarget.addEventListener("keypress", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ } else {
+ baseEventListener = new MozillaBaseEventListener();
+ baseEventListener.getLocalDnD().Init(editor.getDOMDocument(),editor.getPresShell(), baseEventListener.getDropListener());
+ }
+ }
+ }
+
+ private void removeDomEventListeners() {
+ if (contentAreaEventTarget != null && contentAreaEventListener != null) {
+ contentAreaEventTarget.removeEventListener("click", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mousedown", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mouseup", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mousemove", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ }
+ if (domDocument != null && documentEventTarget != null) {
+ documentEventTarget.removeEventListener("keypress", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ }
+ }
+
+ private void addSelectionListener() {
+ if (contentAreaEventListener != null) {
+ nsISelectionController selectionController = editor.getSelectionController();
+ selectionController.addSelectionListener(contentAreaEventListener.getSelectionListener());
+ selectionController.Release();
+ }
+ }
+
+ private void removeSelectionListener() {
+ nsISelectionController selectionController = editor.getSelectionController();
+ selectionController.removeSelectionListener(contentAreaEventListener.getSelectionListener());
+ selectionController.Release();
+ }
+
+ public void setSelectionRectangle(Element element, int resizerConstrains, boolean scroll) {
+ if (contentAreaEventListener != null) {
+ editor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains, scroll);
+ }
+ }
+
+ public void showResizer() {
+ if (contentAreaEventListener != null) {
+ editor.showResizer();
+ }
+ }
+
+ public void hideResizer() {
+ if (contentAreaEventListener != null) {
+ editor.hideResizer();
+ }
+ }
+
+ /**
+ *
+ */
+ public void rebuildDom() {
+ pageContext.getVisualBuilder().rebuildDom(sourceDocument);
+ }
+
+ /**
+ */
+ public void buildDom() {
+ bundle = new BundleMap();
+ bundle.init(sourceEditor);
+
+ pageContext = new VpePageContext(templateManager, bundle, editPart);
+
+ domMapping = new VpeDomMapping(pageContext);
+ VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null, templateManager, sourceEditor, pageContext);
+ VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null, templateManager, this, pageContext);
+ pageContext.setSourceDomBuilder(sourceBuilder);
+ pageContext.setVisualDomBuilder(visualBuilder);
+
+ IDOMModel sourceModel = (IDOMModel)sourceEditor.getModel();
+ sourceDocument = sourceModel.getDocument();
+
+ visualBuilder.buildDom(sourceDocument);
+ }
+}
\ No newline at end of file
17 years, 5 months