JBoss Tools SVN: r3415 - in branches/jbosstools_xulrunner/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-08-31 11:24:21 -0400 (Fri, 31 Aug 2007)
New Revision: 3415
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-744
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-31 15:24:14 UTC (rev 3414)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-31 15:24:21 UTC (rev 3415)
@@ -2435,9 +2435,22 @@
* Calls when editor content should be refreshed
*/
public void onRefresh() {
+ //when we using separate thread to display selection rectangle
+ //it's working more better than without
+ /*
+ * HACK
+ * We need wait some time while standart event will be handled
+ * and in process event handles some components are repainted(like buttons)
+ * and flasher are not repainted, so we should paint flasher
+ */
+ Display.getCurrent().asyncExec(new Thread(){
+ public void run(){
+
+ getXulRunnerEditor().showSelectionRectangle();
+ }
+ });
+// getXulRunnerEditor().showSelectionRectangle();
- getXulRunnerEditor().showSelectionRectangle();
-
}
/**
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-08-31 15:24:14 UTC (rev 3414)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-08-31 15:24:21 UTC (rev 3415)
@@ -391,7 +391,7 @@
offset = visualNode.getNodeValue().length();
}
selection.collapse(visualNode, offset);
- nsIDOMElement visualParentElement = (nsIDOMElement) visualNode.getParentNode();
+ nsIDOMElement visualParentElement = (nsIDOMElement) visualNode.getParentNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
visualBuilder.setSelectionRectangle(visualParentElement);
break;
case nsIDOMNode.ELEMENT_NODE:
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-31 15:24:14 UTC (rev 3414)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-31 15:24:21 UTC (rev 3415)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.mozilla;
-import org.eclipse.swt.widgets.Display;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIClipboardDragDropHooks;
@@ -393,25 +392,7 @@
//just ignore this event
} else if(DRAGOVEREVENT.equals(domEvent.getType())) {
getEditorDomEventListener().dragOver(domEvent);
- }
-
- /*
- * HACK
- * We need wait some time while standart event will be handled
- * and in process event handles some components are repainted(like buttons)
- * and flasher are not repainted, so we should paint flasher
- */
- Display.getCurrent().asyncExec(new Thread(){
- public void run() {
- try {
- sleep(50);
- getEditorDomEventListener().onRefresh();
- } catch (InterruptedException e) {
- //JUST IGNORE exception
- e.printStackTrace();
- }
- }
- });
+ }
getEditorDomEventListener().onRefresh();
17 years, 4 months
JBoss Tools SVN: r3414 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner: editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-08-31 11:24:14 -0400 (Fri, 31 Aug 2007)
New Revision: 3414
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-744
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-08-31 14:47:19 UTC (rev 3413)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-08-31 15:24:14 UTC (rev 3414)
@@ -67,7 +67,6 @@
super(parent, SWT.NONE);
mozilla = Mozilla.getInstance();
-
String xulRunnerPath = getXulRunnerPath();
Boolean isXulRunnerInitialized = "true".equals(System.getProperty(XULRUNNER_INITIALIZED));
@@ -289,6 +288,7 @@
}
public nsIWebBrowser getWebBrowser() {
+ System.out.println("getWebBrouser");
return webBrowser;
}
@@ -298,6 +298,7 @@
}
public void setChromeFlags(long arg0) {
+ System.out.println("setChromeFlags");
chrome_flags = arg0;
}
@@ -325,6 +326,7 @@
*/
public void onLocationChange(nsIWebProgress arg0, nsIRequest arg1,
nsIURI arg2) {
+ System.out.println("On location change");
}
/* (non-Javadoc)
@@ -354,6 +356,7 @@
* @see org.mozilla.interfaces.nsIWebProgressListener#onStatusChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, long, java.lang.String)
*/
public void onStatusChange(nsIWebProgress arg0, nsIRequest arg1, long aStatus, String message) {
+ System.out.println("on status change");
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2007-08-31 14:47:19 UTC (rev 3413)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2007-08-31 15:24:14 UTC (rev 3414)
@@ -11,11 +11,16 @@
package org.jboss.tools.vpe.xulrunner.editor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.XulRunnerException;
import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
import org.mozilla.interfaces.inIFlasher;
+import org.mozilla.interfaces.nsIBaseWindow;
import org.mozilla.interfaces.nsIClipboardDragDropHookList;
import org.mozilla.interfaces.nsIComponentManager;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -33,6 +38,7 @@
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsITransferable;
+import org.mozilla.interfaces.nsIWebBrowser;
import org.mozilla.xpcom.Mozilla;
import java.util.regex.Pattern;
@@ -98,6 +104,24 @@
public XulRunnerEditor(Composite parent) throws XulRunnerException {
super(parent);
+ Listener l = new Listener() {
+
+ public void handleEvent(Event event) {
+ System.out.println("Activate");
+ Display.getCurrent().asyncExec(new Thread(){
+ public void run(){
+ showSelectionRectangle();
+ }
+ });
+ }};
+ addListener(SWT.Activate, l);
+ addListener(SWT.Paint, l);
+ addListener(SWT.Resize, l);
+ addListener(SWT.Show, l);
+ addListener(SWT.FocusIn, l);
+ addListener(SWT.FocusOut, l);
+ addListener(SWT.Selection, l);
+ addListener(SWT.Paint, l);
resizeListener = new IVpeResizeListener() {
public void onEndResizing(int usedResizeMarkerHandle, int top,
@@ -375,6 +399,7 @@
*/
private nsIDOMElement findVisbleParentElement(nsIDOMElement element) {
+ //TODO Max Areshkau optimize code(do not calculate it each time)
if(!(element.getParentNode() instanceof nsIDOMElement)) {
return null;
@@ -425,6 +450,8 @@
}
public void showSelectionRectangle() {
+
+// ((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(false);
if (getIFlasher() != null && getLastSelectedElement() != null) {
// if (scrollRegtangleFlag) {
// scrollRegtangleFlag = false;
17 years, 4 months
JBoss Tools SVN: r3413 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: ayukhovich
Date: 2007-08-31 10:47:19 -0400 (Fri, 31 Aug 2007)
New Revision: 3413
Modified:
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/VpeVisualDomBuilder.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-623
add initial functionality for resolve this issue
Modified: 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 2007-08-31 14:30:10 UTC (rev 3412)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-08-31 14:47:19 UTC (rev 3413)
@@ -10,115 +10,39 @@
******************************************************************************/
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";
/**
*
@@ -130,82 +54,12 @@
*/
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
*/
@@ -247,18 +101,8 @@
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.TEXT_NODE:
+ return createTextNode(sourceNode, registerFlag);
case Node.COMMENT_NODE:
if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
return null;
@@ -272,1522 +116,4 @@
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);
- }
- }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-08-31 14:30:10 UTC (rev 3412)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-08-31 14:47:19 UTC (rev 3413)
@@ -78,11 +78,11 @@
private static final int DRAG_AREA_HEIGHT = 10;
private static final String ATTR_XMLNS = "xmlns";
- private MozillaEditor visualEditor;
+ protected MozillaEditor visualEditor;
private MozillaBrowser browser;
- private Document visualDocument;
+ protected Document visualDocument;
private Element visualContentArea;
- private VpePageContext pageContext;
+ protected VpePageContext pageContext;
private VpeDnD dnd;
private Node headNode;
private List<VpeIncludeInfo> includeStack;
@@ -346,18 +346,8 @@
pageContext.setCurrentVisualNode(null);
if(border != null) return border;
else 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.TEXT_NODE:
+ return createTextNode(sourceNode, registerFlag);
case Node.COMMENT_NODE:
if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
return null;
@@ -371,7 +361,24 @@
return null;
}
- private Element createComment(Node sourceNode) {
+ protected Element createTextNode(Node sourceNode, boolean registerFlag ) {
+ 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));
+ }
+
+ Element visualNewTextElement = (Element) visualNewTextNode;
+
+ return visualNewTextElement;
+ }
+
+ protected 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;
@@ -380,7 +387,7 @@
return div;
}
- private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
+ protected void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
NodeList sourceNodes = sourceContainer.getChildNodes();
int len = sourceNodes.getLength();
int childrenCount = 0;
@@ -395,7 +402,7 @@
}
}
- private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualOldContainer, List<VpeChildrenInfo> childrenInfoList) {
+ protected void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualOldContainer, List<VpeChildrenInfo> childrenInfoList) {
for (int i = 0; i < childrenInfoList.size(); i++) {
VpeChildrenInfo info = childrenInfoList.get(i);
Node visualParent = info.getVisualParent();
@@ -1305,7 +1312,7 @@
return new VpeVisualInnerDropInfo(visualDropContainer, visualDropOffset, 0, 0);
}
- private void setTooltip(Element sourceElement, Element visualElement) {
+ protected void setTooltip(Element sourceElement, Element visualElement) {
if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
if ("HTML".equalsIgnoreCase(sourceElement.getNodeName())) return;
String titleValue = getTooltip(sourceElement);
@@ -1464,7 +1471,7 @@
visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
}
- private void setReadOnlyElement(Element node) {
+ protected 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);
@@ -1573,7 +1580,7 @@
return false;
}
- private boolean isCurrentMainDocument() {
+ protected boolean isCurrentMainDocument() {
return includeStack.size() <= 1;
}
@@ -1599,7 +1606,7 @@
pageContext.dispose();
}
- private Map<String, Integer> createXmlns(Element sourceNode) {
+ protected Map<String, Integer> createXmlns(Element sourceNode) {
NamedNodeMap attrs = ((Element)sourceNode).getAttributes();
if (attrs != null) {
Map<String, Integer> xmlnsMap = new HashMap<String, Integer>();
17 years, 4 months
JBoss Tools SVN: r3412 - in trunk/seam/plugins/org.jboss.tools.seam.ui: src/org/jboss/tools/seam/ui/wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-08-31 10:30:10 -0400 (Fri, 31 Aug 2007)
New Revision: 3412
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
Log:
JBIDE-769
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-08-31 01:25:33 UTC (rev 3411)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-08-31 14:30:10 UTC (rev 3412)
@@ -41,6 +41,7 @@
org.eclipse.jst.j2ee.ui,
org.eclipse.jst.j2ee.web,
org.eclipse.wst.xml.ui,
+ org.eclipse.debug.core,
org.apache.ant,
org.jboss.ide.eclipse.jdt.core,
org.eclipse.datatools.connectivity,
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-08-31 01:25:33 UTC (rev 3411)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-08-31 14:30:10 UTC (rev 3412)
@@ -10,31 +10,122 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
+import org.hibernate.eclipse.console.ExtensionManager;
+import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamFacetPreference;
import org.jboss.tools.seam.ui.SeamUIMessages;
/**
* Seam Generate Entities Wizard.
* @author Alexey Kazakov
*/
-public class SeamGenerateEnitiesWizard extends Wizard implements INewWizard {
+public class SeamGenerateEnitiesWizard extends SeamBaseWizard implements INewWizard {
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
+ public SeamGenerateEnitiesWizard() {
+ super(GENERATE_SEAM_ENTITIES);
setWindowTitle(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_TITLE);
addPage(new SeamGenerateEnitiesWizardPage());
}
-}
\ No newline at end of file
+
+ public static final IUndoableOperation GENERATE_SEAM_ENTITIES = new SeamBaseOperation("Action creating operation") {
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Map<String, String> params = (Map)info.getAdapter(Map.class);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ params.get(IParameter.SEAM_PROJECT_NAME));
+
+ try {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType("org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType");
+ ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null, "GenerateEntities");
+
+ //Main
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, params.get(IParameter.HIBERNATE_CONFIGURATION_NAME));
+
+ IPath src = getSourceFolder(project);
+ if(src == null) {
+ throw new CoreException(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, "Source folder not found in project " + project.getName()));
+ }
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, src.toString());
+
+ boolean isReverseEngineer = "true".equals(params.get(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER));
+ wc.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineer);
+
+ if(isReverseEngineer) {
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, "seamtest");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+ }
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, true);
+ String template = "" + SeamFacetPreference.getStringPreference(SeamFacetPreference.SEAM_HOME_FOLDER) + "/seam-gen/view";
+// wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_TEMPLATE_DIR, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, template);
+
+ //Exporters
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
+
+ ExporterDefinition[] ds = ExtensionManager.findExporterDefinitions();
+ if(ds != null) for (int i = 0; i < ds.length; i++) {
+ wc.setAttribute(ds[i].getId(), true);
+ }
+
+ wc.launch("run", new NullProgressMonitor());
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public List<String[]> getFileMappings(Map<String, Object> vars) {
+ throw new UnsupportedOperationException("This method is not relevant in generating seam entities.");
+ }
+
+ };
+
+ static IPath getSourceFolder(IProject project) throws CoreException {
+ if(!project.hasNature(JavaCore.NATURE_ID)) return null;
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] es = javaProject.getRawClasspath();
+ for (int i = 0; i < es.length; i++) {
+ if(es[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) continue;
+ IPath p = es[i].getPath();
+ if(p == null) continue;
+ IFolder f = ResourcesPlugin.getWorkspace().getRoot().getFolder(p);
+ if(f != null && f.exists()) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-31 01:25:33 UTC (rev 3411)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-31 14:30:10 UTC (rev 3412)
@@ -13,14 +13,17 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
@@ -30,7 +33,7 @@
/**
* @author Alexey Kazakov
*/
-public class SeamGenerateEnitiesWizardPage extends WizardPage implements PropertyChangeListener {
+public class SeamGenerateEnitiesWizardPage extends WizardPage implements PropertyChangeListener, IAdaptable {
private IFieldEditor projectEditor;
private IFieldEditor configEditor;
@@ -130,4 +133,17 @@
setMessage(null);
setPageComplete(true);
}
-}
\ No newline at end of file
+
+ public Object getAdapter(Class adapter) {
+ if(adapter == Map.class) {
+ Map<String,String> values = new HashMap<String, String>();
+ values.put(projectEditor.getName(), projectEditor.getValueAsString());
+ values.put(configEditor.getName(), configEditor.getValueAsString());
+ String mode = radios.getValue().toString();
+ values.put(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, ("reverse".equals(mode) ? "true" : "false"));
+ return values;
+ }
+ return null;
+ }
+
+}
17 years, 4 months
JBoss Tools SVN: r3411 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-08-30 21:25:33 -0400 (Thu, 30 Aug 2007)
New Revision: 3411
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/CreateSeamWebProjectAction.java
Log:
http://jira.jboss.org/jira/browse/RHDS-110
Action to open seam new wizard.
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/CreateSeamWebProjectAction.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/CreateSeamWebProjectAction.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/CreateSeamWebProjectAction.java 2007-08-31 01:25:33 UTC (rev 3411)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.wizard;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.util.ExtensionPointUtils;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
+
+public class CreateSeamWebProjectAction extends Action implements IWorkbenchWindowActionDelegate {
+ public CreateSeamWebProjectAction() {
+ super("Create Seam Project");
+ setToolTipText("Create Seam Project");
+ ModelUIImages.setImageDescriptors(this, ModelUIImages.ACT_CREATE_PROJECT);
+ }
+
+ public void run() {
+ INewWizard wizard = ExtensionPointUtils.findNewWizardsItem(
+ SeamGuiPlugin.PLUGIN_ID,
+ "org.jboss.tools.seam.ui.wizards.SeamProjectWizard" //$NON-NLS-1$
+ );
+ if (wizard != null) {
+ wizard.init(ModelUIPlugin.getDefault().getWorkbench(), null);
+ WizardDialog dialog = new WizardDialog(ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+ } else {
+ SeamGuiPlugin.getPluginLog().logInfo("Unable to create wizard 'org.jboss.tools.seam.ui.wizards.SeamProjectWizard'."); //$NON-NLS-1$
+ }
+ }
+
+ public void dispose() {}
+
+ public void init(IWorkbenchWindow window) {}
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {}
+
+}
\ No newline at end of file
17 years, 4 months
JBoss Tools SVN: r3410 - in branches/jbosstools_xulrunner/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-08-30 13:36:26 -0400 (Thu, 30 Aug 2007)
New Revision: 3410
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-744
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-08-30 14:45:19 UTC (rev 3409)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-08-30 17:36:26 UTC (rev 3410)
@@ -90,7 +90,7 @@
if (sourceNode != null) {
switch (visualSelectedNode.getNodeType()) {
case nsIDOMNode.TEXT_NODE:
- nsIDOMElement visualParentElement = (nsIDOMElement)visualSelectedNode.getParentNode();
+ nsIDOMElement visualParentElement = (nsIDOMElement)visualSelectedNode.getParentNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
visualBuilder.setSelectionRectangle(visualParentElement, false);
// int pos = DataHelper.textPos(visualSelectedNode.getNodeValue(), selection.getFocusOffset());
int pos = selection.getFocusOffset();
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-30 14:45:19 UTC (rev 3409)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-30 17:36:26 UTC (rev 3410)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.mozilla;
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIClipboardDragDropHooks;
@@ -344,11 +345,15 @@
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseDown(mouseEvent);
+// domEvent.stopPropagation();
+// domEvent.preventDefault();
} else if(MOUSEUPEVENTTYPE.equals(domEvent.getType())) {
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseUp(mouseEvent);
+// domEvent.stopPropagation();
+// domEvent.preventDefault();
} else if(CLICKEVENTTYPE.equals(domEvent.getType())) {
nsIDOMMouseEvent mouseEvent;
@@ -389,8 +394,27 @@
} else if(DRAGOVEREVENT.equals(domEvent.getType())) {
getEditorDomEventListener().dragOver(domEvent);
}
+
+ /*
+ * HACK
+ * We need wait some time while standart event will be handled
+ * and in process event handles some components are repainted(like buttons)
+ * and flasher are not repainted, so we should paint flasher
+ */
+ Display.getCurrent().asyncExec(new Thread(){
+ public void run() {
+ try {
+ sleep(50);
+ getEditorDomEventListener().onRefresh();
+ } catch (InterruptedException e) {
+ //JUST IGNORE exception
+ e.printStackTrace();
+ }
+ }
+ });
getEditorDomEventListener().onRefresh();
+
//not using default mozilla event handlers
}catch(Throwable th) {
//TODO Max Areshkau remove when all will be adjusted
17 years, 4 months
JBoss Tools SVN: r3409 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views: actions and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-08-30 10:45:19 -0400 (Thu, 30 Aug 2007)
New Revision: 3409
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/ViewConstants.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamJarFilter.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/ScopePresentationActionProvider.java
Log:
JBIDE-667
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java 2007-08-30 09:39:59 UTC (rev 3408)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -24,10 +24,16 @@
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+import org.eclipse.ui.navigator.IExtensionStateModel;
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
@@ -55,27 +61,71 @@
*
* @author Viacheslav Kabanovich
*/
-public abstract class AbstractSeamContentProvider implements ITreeContentProvider, ISeamProjectChangeListener {
+public abstract class AbstractSeamContentProvider implements ITreeContentProvider, ISeamProjectChangeListener, ICommonContentProvider {
protected Viewer viewer;
IResourceChangeListener listener = new ResourceChangeListener();
Set<ISeamProject> processed = new HashSet<ISeamProject>();
-
+ private IExtensionStateModel fStateModel;
+ IPropertyChangeListener scopePropertyListener;
+ IPropertyChangeListener layoutPropertyListener;
+ boolean isFlatLayout = true;
+ boolean isScopeLable = false;
+
public AbstractSeamContentProvider() {}
+
+ public void init(ICommonContentExtensionSite commonContentExtensionSite) {
+ fStateModel = commonContentExtensionSite.getExtensionStateModel();
+ IMemento memento = commonContentExtensionSite.getMemento();
+ restoreState(memento);
+ scopePropertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (ViewConstants.SCOPE_PRESENTATION.equals(event.getProperty())) {
+ if (event.getNewValue() != null) {
+ boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
+ setIsScopeLable(newValue);
+ }
+ }
+ }
+ };
+ fStateModel.addPropertyChangeListener(scopePropertyListener);
+
+ layoutPropertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (ViewConstants.PACKAGE_STRUCTURE.equals(event.getProperty())) {
+ if (event.getNewValue() != null) {
+ boolean newValue = ((Boolean)event.getNewValue()).booleanValue();
+ setIsFlatLayout(newValue);
+ }
+ }
+ }
+ };
+ fStateModel.addPropertyChangeListener(layoutPropertyListener);
+
+ }
+
+ void setIsFlatLayout(boolean b) {
+ isFlatLayout = b;
+ }
+
+ void setIsScopeLable(boolean b) {
+ isScopeLable = b;
+ }
+
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
boolean isNotShowingScopeNodes() {
- return ScopePresentationActionProvider.isScopePresentedAsLabel();
+ return isScopeLable; // ScopePresentationActionProvider.isScopePresentedAsLabel();
// if(viewer == null) return false;
// Boolean b = (Boolean)viewer.getData("scopeAsNode");
// return b != null && b.booleanValue();
}
boolean isPackageStructureFlat() {
- return ScopePresentationActionProvider.isPackageStructureFlat();
+ return isFlatLayout; //ScopePresentationActionProvider.isPackageStructureFlat();
}
public boolean hasChildren(Object element) {
@@ -183,17 +233,6 @@
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
}
- public void dispose() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
- viewer = null;
- if(processed != null) {
- for (ISeamProject p : processed) {
- p.removeSeamProjectListener(this);
- }
- processed.clear();
- }
- }
-
class ResourceChangeListener implements IResourceChangeListener {
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
@@ -232,4 +271,25 @@
}
+ public void restoreState(IMemento memento) {
+ }
+
+ public void saveState(IMemento memento) {
+ }
+
+ public void dispose() {
+ fStateModel.removePropertyChangeListener(layoutPropertyListener);
+ fStateModel.removePropertyChangeListener(scopePropertyListener);
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
+ viewer = null;
+ if(processed != null) {
+ for (ISeamProject p : processed) {
+ p.removeSeamProjectListener(this);
+ }
+ processed.clear();
+ }
+ fStateModel.removePropertyChangeListener(layoutPropertyListener);
+ fStateModel.removePropertyChangeListener(scopePropertyListener);
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamJarFilter.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamJarFilter.java 2007-08-30 09:39:59 UTC (rev 3408)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamJarFilter.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -52,6 +52,9 @@
for (ISeamComponent c : p.getComponents()) {
if(isUserDefinedComponent(c)) return true;
}
+ for (ISeamPackage c : p.getPackages().values()) {
+ if(isUserDefinedPackage(c)) return true;
+ }
return false;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java 2007-08-30 09:39:59 UTC (rev 3408)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -15,11 +15,19 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.navigator.IExtensionStateConstants.Values;
+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMemento;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+import org.eclipse.ui.navigator.IExtensionStateModel;
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
@@ -35,9 +43,55 @@
/**
* @author Viacheslav Kabanovich
*/
-public class SeamLabelProvider extends LabelProvider {
+public class SeamLabelProvider extends LabelProvider implements ICommonLabelProvider {
+ private IExtensionStateModel fStateModel;
+ private AbstractSeamContentProvider contentProvider;
+
+ boolean isFlatLayout = true;
+ boolean isScopeLable = false;
+
+ IPropertyChangeListener scopePropertyListener;
+ IPropertyChangeListener layoutPropertyListener;
+
JavaElementImageProvider jip = new JavaElementImageProvider();
+ public void init(ICommonContentExtensionSite commonContentExtensionSite) {
+ fStateModel = commonContentExtensionSite.getExtensionStateModel();
+ contentProvider = (AbstractSeamContentProvider) commonContentExtensionSite.getExtension().getContentProvider();
+
+ scopePropertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (ViewConstants.SCOPE_PRESENTATION.equals(event.getProperty())) {
+ if (event.getNewValue() != null) {
+ boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
+ setIsScopeLable(newValue);
+ }
+ }
+ }
+ };
+ fStateModel.addPropertyChangeListener(scopePropertyListener);
+
+ layoutPropertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (ViewConstants.PACKAGE_STRUCTURE.equals(event.getProperty())) {
+ if (event.getNewValue() != null) {
+ boolean newValue = ((Boolean)event.getNewValue()).booleanValue();
+ setIsFlatLayout(newValue);
+ }
+ }
+ }
+ };
+ fStateModel.addPropertyChangeListener(layoutPropertyListener);
+ }
+
+ void setIsFlatLayout(boolean b) {
+ isFlatLayout = b;
+ }
+
+ void setIsScopeLable(boolean b) {
+ isScopeLable = b;
+ }
+
public String getText(Object element) {
if(element instanceof IWorkspaceRoot) {
return "";
@@ -46,7 +100,7 @@
} else if(element instanceof ISeamScope) {
return ((ISeamScope)element).getType().getLabel();
} else if(element instanceof ISeamPackage) {
- if(ScopePresentationActionProvider.isPackageStructureFlat()) {
+ if(isFlatLayout/* ScopePresentationActionProvider.isPackageStructureFlat()*/) {
return ((ISeamPackage)element).getQualifiedName();
} else {
return ((ISeamPackage)element).getName();
@@ -60,7 +114,7 @@
name = name.substring(lastIndexOf+1); // temp fix for JBIDE-644; shouldn't need to do this here. shold be a method to getShortName or similar but ISeamComponent extends ISeamContextVariable so ended up being weird to do clean.
}
- if(ScopePresentationActionProvider.isScopePresentedAsLabel()) {
+ if(isScopeLable /* ScopePresentationActionProvider.isScopePresentedAsLabel()*/) {
name += " (" + ((ISeamScope)c.getParent()).getType().getLabel() + ")";
}
return name;
@@ -115,4 +169,20 @@
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
+ public void restoreState(IMemento memento) {
+ }
+
+ public void saveState(IMemento memento) {
+ }
+
+ public String getDescription(Object anElement) {
+ return "";
+ }
+
+ public void dispose() {
+ super.dispose();
+ fStateModel.removePropertyChangeListener(layoutPropertyListener);
+ fStateModel.removePropertyChangeListener(scopePropertyListener);
+ }
+
}
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/ViewConstants.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/ViewConstants.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/ViewConstants.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.views;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ */
+public interface ViewConstants {
+ public String SCOPE_PRESENTATION = "seam.scopePresentation";
+ public String PACKAGE_STRUCTURE = "seam.packageStructure";
+
+ public String SCOPE_AS_LABEL = "label";
+ public String SCOPE_AS_NODE = "node";
+ public String PACKAGES_FLAT = "flat";
+ public String PACKAGES_HIERARCHICAL = "hierarchical";
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/ScopePresentationActionProvider.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/ScopePresentationActionProvider.java 2007-08-30 09:39:59 UTC (rev 3408)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/ScopePresentationActionProvider.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -10,37 +10,89 @@
******************************************************************************/
package org.jboss.tools.seam.ui.views.actions;
+import java.util.Arrays;
+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IMemento;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.IExtensionActivationListener;
+import org.eclipse.ui.navigator.IExtensionStateModel;
+import org.eclipse.ui.navigator.INavigatorActivationService;
import org.jboss.tools.seam.core.SeamPreferences;
+import org.jboss.tools.seam.ui.views.ViewConstants;
/**
* Action provider for Seam Components view.
* @author Viacheslav Kabanovich
*/
-public class ScopePresentationActionProvider extends CommonActionProvider {
- public static String SCOPE_PRESENTATION = "seam.scopePresentation";
- public static String PACKAGE_STRUCTURE = "seam.packageStructure";
-
- public static boolean isScopePresentedAsLabel() {
- String s = SeamPreferences.getInstancePreference(SCOPE_PRESENTATION);
- return "label".equals(s);
+public class ScopePresentationActionProvider extends CommonActionProvider implements ViewConstants {
+
+ private ICommonActionExtensionSite fExtensionSite;
+ IExtensionStateModel stateModel;
+ private String fExtensionId;
+ private IActionBars fActionBars;
+ private boolean fEnabled = false;
+ SeamViewLayoutActionGroup actionGroup;
+
+ private IExtensionActivationListener fMenuUpdater= new IExtensionActivationListener() {
+
+ public void onExtensionActivation(String viewerId, String[] theNavigatorExtensionIds, boolean isCurrentlyActive) {
+
+ if (fExtensionSite != null && fActionBars != null) {
+
+ int search= Arrays.binarySearch(theNavigatorExtensionIds, fExtensionId);
+ if (search > -1) {
+ if (isMyViewer(viewerId)) {
+ if (wasEnabled(isCurrentlyActive))
+ actionGroup.fillActionBars(fActionBars);
+
+ else
+ if (wasDisabled(isCurrentlyActive)) {
+ actionGroup.unfillActionBars(fActionBars);
+ }
+ // else no change
+ }
+ fEnabled = isCurrentlyActive;
+ }
+ }
+
+ }
+
+ private boolean isMyViewer(String viewerId) {
+ String myViewerId= fExtensionSite.getViewSite().getId();
+ return myViewerId != null && myViewerId.equals(viewerId);
+ }
+
+ private boolean wasDisabled(boolean isActive) {
+ return fEnabled && !isActive;
+ }
+
+ private boolean wasEnabled(boolean isActive) {
+ return !fEnabled && isActive;
+ }
+ };
+
+
+ public ScopePresentationActionProvider() {}
+
+ public void init(ICommonActionExtensionSite site) {
+ super.init(site);
+ fExtensionSite = site;
+ stateModel = site.getExtensionStateModel();
+ actionGroup = new SeamViewLayoutActionGroup(fExtensionSite.getStructuredViewer(), stateModel);
+ INavigatorActivationService activationService= fExtensionSite.getContentService().getActivationService();
+ activationService.addExtensionActivationListener(fMenuUpdater);
+ fExtensionId = fExtensionSite.getExtensionId();
+ fEnabled = true;
}
-
- public static boolean isPackageStructureFlat() {
- return true;
+
+ public void setPackageStructureFlat(boolean s) {
+ IEclipsePreferences p = SeamPreferences.getInstancePreferences();
+ p.put(PACKAGE_STRUCTURE, s ? "flat" : "hierarchical");
}
public void setScopePresentedAsLabel(boolean s) {
@@ -48,78 +100,20 @@
p.put(SCOPE_PRESENTATION, s ? "label" : "node");
}
- public ScopePresentationActionProvider() {}
-
- public void fillContextMenu(IMenuManager menu) {
- }
-
public void fillActionBars(IActionBars actionBars) {
- if(scopePresentation == null) {
- scopePresentation = new ScopePresentationContribution();
- IMenuManager menuManager = actionBars.getMenuManager();
- String SEP_NAME = "aaa";
- if(menuManager.find(IWorkbenchActionConstants.MB_ADDITIONS) != null)
- menuManager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(SEP_NAME));
- else
- menuManager.add(new Separator(SEP_NAME));
- menuManager.appendToGroup(SEP_NAME, scopePresentation);
- actionBars.updateActionBars();
- }
+ fActionBars = actionBars;
+ actionGroup.fillActionBars(actionBars);
}
- ScopePresentationContribution scopePresentation = null;
- boolean scopeAsNode = !isScopePresentedAsLabel();
+ boolean isFlatLayout = true;
+ boolean isScopeLable = false;
- class ScopePresentationContribution extends ContributionItem {
- boolean filled = false;
- public void fill(Menu menu, int index) {
- if(filled) return;
- filled = true;
- MenuItem item = new MenuItem(menu, SWT.CASCADE);
- item.setText("Scope Presentation");
- Menu smenu = new Menu(item);
- item.setMenu(smenu);
- final MenuItem item1 = new MenuItem(smenu, SWT.RADIO);
- item1.setText("As node");
- item1.setSelection(scopeAsNode);
- item1.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- if(item1.getSelection() && !scopeAsNode) {
- scopeAsNode = true;
- setUpViewer();
- }
- }
-
- });
- final MenuItem item2 = new MenuItem(smenu, SWT.RADIO);
- item2.setText("As label");
- item2.setSelection(!scopeAsNode);
- item2.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- if(item2.getSelection() && scopeAsNode) {
- scopeAsNode = false;
- setUpViewer();
- }
- }
-
- });
- }
-
- }
-
public void dispose() {
- scopePresentation = null;
super.dispose();
+ fExtensionSite.getContentService().getActivationService().removeExtensionActivationListener(fMenuUpdater);
}
- void setUpViewer() {
- setScopePresentedAsLabel(!scopeAsNode);
+ void updateViewer() {
BusyIndicator.showWhile(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell().getDisplay(),
new Runnable() {
@@ -127,6 +121,7 @@
try {
getActionSite().getStructuredViewer().refresh();
} catch (Exception e2) {
+ e2.printStackTrace();
//ignore
}
}
@@ -134,4 +129,53 @@
);
}
+ public void restoreState(IMemento memento) {
+ boolean isCurrentLayoutFlat = true;
+ String state = null;
+ if (memento != null)
+ state = memento.getString("seam-isFlatLayout");
+
+ if (state == null) {
+ state = SeamPreferences.getInstancePreference(PACKAGE_STRUCTURE);
+ }
+
+ isCurrentLayoutFlat = !(PACKAGES_HIERARCHICAL.equals(state));
+
+ setFlatLayout(isCurrentLayoutFlat);
+
+ boolean isCurrentScopeLabel = false;
+ state = null;
+ if (memento != null)
+ state = memento.getString("seam-isScopeLabel");
+
+ if (state == null) {
+ state = SeamPreferences.getInstancePreference(SCOPE_PRESENTATION);
+ }
+
+ isCurrentScopeLabel = !SCOPE_AS_NODE.equals(state);
+
+ setScopeLable(isCurrentScopeLabel);
+
+ }
+
+ public void saveState(IMemento aMemento) {
+ super.saveState(aMemento);
+
+ setPackageStructureFlat(isFlatLayout);
+ setScopePresentedAsLabel(isScopeLable);
+
+ }
+
+ void setFlatLayout(boolean b) {
+ isFlatLayout = b;
+ stateModel.setBooleanProperty(PACKAGE_STRUCTURE, b);
+ actionGroup.setFlatLayout(b);
+ }
+
+ void setScopeLable(boolean b) {
+ isScopeLable = b;
+ stateModel.setBooleanProperty(SCOPE_PRESENTATION, b);
+ actionGroup.setScopeLable(b);
+ }
+
}
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java 2007-08-30 14:45:19 UTC (rev 3409)
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.views.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.navigator.IExtensionStateModel;
+import org.jboss.tools.seam.ui.views.ViewConstants;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamViewLayoutActionGroup extends ActionGroup implements ViewConstants {
+ public static final String LAYOUT_GROUP_NAME = "layout"; //$NON-NLS-1$
+ StructuredViewer structuredViewer;
+ IExtensionStateModel stateModel;
+ private boolean hasContributedToViewMenu = false;
+
+ private IAction hierarchicalLayoutAction = null;
+ private IAction flatLayoutAction = null;
+
+ private IAction labelScopeAction = null;
+ private IAction nodeScopeAction = null;
+
+ private IMenuManager layoutSubMenu;
+ private IMenuManager scopeSubMenu;
+
+ private MenuItem hierarchicalLayoutItem = null;
+ private MenuItem flatLayoutItem = null;
+ private MenuItem labelScopeItem = null;
+ private MenuItem nodeScopeItem = null;
+
+ public SeamViewLayoutActionGroup(StructuredViewer structuredViewer,
+ IExtensionStateModel stateModel) {
+ this.structuredViewer = structuredViewer;
+ this.stateModel = stateModel;
+ }
+
+ private class CommonLayoutAction extends Action implements IAction {
+
+ private String property;
+ private final boolean value;
+
+ public CommonLayoutAction(String property, boolean value) {
+ super("", AS_RADIO_BUTTON);
+ this.property = property;
+ this.value = value;
+ }
+
+ public void run() {
+ if (stateModel.getBooleanProperty(property) != value) {
+ stateModel.setBooleanProperty(property, value);
+ structuredViewer.getControl().setRedraw(false);
+ try {
+ structuredViewer.refresh();
+ } finally {
+ structuredViewer.getControl().setRedraw(true);
+ }
+ }
+ }
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ if (!hasContributedToViewMenu) {
+
+ IMenuManager viewMenu = actionBars.getMenuManager();
+ // Create layout sub menu
+ if (layoutSubMenu == null) {
+ layoutSubMenu = new MenuManager("Seam Packages");
+ addLayoutActions(layoutSubMenu);
+ viewMenu.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(LAYOUT_GROUP_NAME));
+ }
+
+ if(scopeSubMenu == null) {
+ scopeSubMenu = new MenuManager("Scope Presentation");
+ addScopeActions(scopeSubMenu);
+ }
+
+ viewMenu.appendToGroup(LAYOUT_GROUP_NAME, layoutSubMenu);
+ viewMenu.appendToGroup(LAYOUT_GROUP_NAME, scopeSubMenu);
+
+ hasContributedToViewMenu = true;
+ }
+ }
+
+ public void unfillActionBars(IActionBars actionBars) {
+ if (hasContributedToViewMenu) {
+ // Create layout sub menu
+ if (layoutSubMenu != null) {
+ actionBars.getMenuManager().remove(layoutSubMenu);
+ layoutSubMenu.dispose();
+ layoutSubMenu = null;
+ }
+
+ if (scopeSubMenu != null) {
+ actionBars.getMenuManager().remove(scopeSubMenu);
+ scopeSubMenu.dispose();
+ scopeSubMenu = null;
+ }
+
+ hasContributedToViewMenu = false;
+ }
+ }
+
+ boolean isFlatLayout = true;
+ boolean isScopeLable = false;
+
+ void setFlatLayout(boolean b) {
+ isFlatLayout = b;
+ if(flatLayoutAction == null) {
+ createActions();
+ flatLayoutAction.setChecked(b);
+ hierarchicalLayoutAction.setChecked(!b);
+ }
+ }
+
+ void setScopeLable(boolean b) {
+ isScopeLable = b;
+ if(labelScopeAction == null) {
+ createActions();
+ labelScopeAction.setChecked(b);
+ nodeScopeAction.setChecked(!b);
+ }
+ }
+
+ private void createActions() {
+ flatLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE, true);
+ hierarchicalLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE, false);
+ labelScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION, true);
+ nodeScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION, false);
+ }
+
+ protected void addLayoutActions(IMenuManager viewMenu) {
+ viewMenu.add(new ContributionItem() {
+ public void fill(Menu menu, int index) {
+ int style = SWT.RADIO;
+ MenuItem mi = new MenuItem(menu, style, index);
+ flatLayoutItem = mi;
+ mi.setText("Flat");
+ mi.setSelection(isFlatLayout);
+ mi.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (isFlatLayout) {
+ flatLayoutItem.setSelection(true);
+ return;
+ }
+ flatLayoutAction.run();
+
+ hierarchicalLayoutItem.setSelection(false);
+ flatLayoutItem.setSelection(true);
+ isFlatLayout = true;
+ e.doit = false;
+ }
+ });
+ }
+ public boolean isDynamic() {
+ return false;
+ }
+ });
+
+ viewMenu.add(new ContributionItem() {
+ public void fill(Menu menu, int index) {
+ int style = SWT.RADIO;
+ MenuItem mi = new MenuItem(menu, style, index);
+ hierarchicalLayoutItem = mi;
+ mi.setText("Hierarchical");
+ mi.setSelection(!isFlatLayout);
+ mi.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!isFlatLayout) {
+ hierarchicalLayoutItem.setSelection(true);
+ return;
+ }
+ hierarchicalLayoutAction.run();
+
+ flatLayoutItem.setSelection(false);
+ hierarchicalLayoutItem.setSelection(true);
+ isFlatLayout = false;
+ e.doit = false;
+ }
+ });
+ }
+ public boolean isDynamic() {
+ return false;
+ }
+ });
+
+ }
+
+ protected void addScopeActions(IMenuManager viewMenu) {
+ viewMenu.add(new ContributionItem() {
+ public void fill(Menu menu, int index) {
+ int style = SWT.RADIO;
+ MenuItem mi = new MenuItem(menu, style, index);
+ labelScopeItem = mi;
+ mi.setText("Label");
+ mi.setSelection(isScopeLable);
+ mi.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (isScopeLable) {
+ labelScopeItem.setSelection(true);
+ return;
+ }
+ labelScopeAction.run();
+
+ nodeScopeItem.setSelection(false);
+ labelScopeItem.setSelection(true);
+ isScopeLable = true;
+ e.doit = false;
+ }
+ });
+ }
+ public boolean isDynamic() {
+ return false;
+ }
+ });
+
+ viewMenu.add(new ContributionItem() {
+ public void fill(Menu menu, int index) {
+ int style = SWT.RADIO;
+ MenuItem mi = new MenuItem(menu, style, index);
+ nodeScopeItem = mi;
+ mi.setText("Node");
+ mi.setSelection(!isScopeLable);
+ mi.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!isScopeLable) {
+ nodeScopeItem.setSelection(true);
+ return;
+ }
+ nodeScopeAction.run();
+
+ labelScopeItem.setSelection(false);
+ nodeScopeItem.setSelection(true);
+ isScopeLable = false;
+ e.doit = false;
+ }
+ });
+ }
+ public boolean isDynamic() {
+ return false;
+ }
+ });
+
+ }
+
+}
17 years, 4 months
JBoss Tools SVN: r3408 - branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-08-30 05:39:59 -0400 (Thu, 30 Aug 2007)
New Revision: 3408
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
Log:
code adjustment, @Overdrive annotation not allowed in java 5,
when we implements from interface
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java 2007-08-29 17:51:49 UTC (rev 3407)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java 2007-08-30 09:39:59 UTC (rev 3408)
@@ -43,7 +43,7 @@
private static String INFO_MESSAGE = "Info message";
private static String WARNING_MESSAGE = "Warning message";
- @Override
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java 2007-08-29 17:51:49 UTC (rev 3407)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java 2007-08-30 09:39:59 UTC (rev 3408)
@@ -38,7 +38,6 @@
private static String STYLE_CLASS_ATTR_NAME = "styleClass";
- @Override
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
17 years, 4 months
JBoss Tools SVN: r3407 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-08-29 13:51:49 -0400 (Wed, 29 Aug 2007)
New Revision: 3407
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
Log:
http://jira.jboss.com/jira/browse/JBIDE-769
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-08-29 17:50:24 UTC (rev 3406)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-08-29 17:51:49 UTC (rev 3407)
@@ -5,5 +5,5 @@
GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE = Select Hibernate Console Configuration
GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR = Hibernate console configuration name is empty
GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL = Generation Mode
-GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL = Reverse Engineer from data base
+GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL = Reverse Engineer from database
GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL = Use existing entities
\ No newline at end of file
17 years, 4 months
JBoss Tools SVN: r3406 - in trunk/seam/plugins/org.jboss.tools.seam.ui: src/org/jboss/tools/seam/ui and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-08-29 13:50:24 -0400 (Wed, 29 Aug 2007)
New Revision: 3406
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.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/SeamGenerateEnitiesWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-769 Added Generate Seam Entities Wizard
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-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-08-29 17:50:24 UTC (rev 3406)
@@ -47,7 +47,8 @@
org.eclipse.datatools.connectivity.ui.dse,
org.eclipse.datatools.connectivity.db.generic.ui,
org.eclipse.datatools.connectivity.db.generic,
- org.jboss.tools.common.model.ui
+ org.jboss.tools.common.model.ui,
+ org.hibernate.eclipse
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.seam.ui,
org.jboss.tools.seam.ui.actions,
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -13,7 +13,13 @@
public static String CREATE_NEW_SEAM_PROJECT;
public static String GENERATE_SEAM_ENTITIES_WIZARD_TITLE;
- public static String GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL;
static {
// load message values from bundle file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-08-29 17:50:24 UTC (rev 3406)
@@ -1,3 +1,9 @@
CREATE_NEW_SEAM_PROJECT = Create New Seam Project
GENERATE_SEAM_ENTITIES_WIZARD_TITLE = Generate Seam Entities
-GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE = Select seam project
\ No newline at end of file
+GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE = Select Seam project
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL = Hibernate Console Configuration:
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE = Select Hibernate Console Configuration
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR = Hibernate console configuration name is empty
+GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL = Generation Mode
+GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL = Reverse Engineer from data base
+GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL = Use existing entities
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -16,8 +16,6 @@
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.seam.ui.widget.field.ComboBoxField;
@@ -92,5 +90,14 @@
// TODO Auto-generated method stub
return 1;
}
-
-}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ super.setEditable(ediatble);
+ comboField.setEditable(ediatble);
+ }
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -14,9 +14,7 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
public class TaggedComboFieldEditor extends CompositeEditor implements ITaggedFieldEditor, PropertyChangeListener{
@@ -25,7 +23,7 @@
boolean floatStyle = true;
ComboFieldEditor combo = null;
- public TaggedComboFieldEditor(String name, String label, List values,Object defaultValue, boolean floatStyle) {
+ public TaggedComboFieldEditor(String name, String label, List values, Object defaultValue, boolean floatStyle) {
super(name, label, defaultValue);
this.values = Collections.unmodifiableList(values);
this.floatStyle = floatStyle;
@@ -48,4 +46,21 @@
combo.setTags(tags);
}
-}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ combo.setEditable(ediatble);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return combo.isEditable();
+ }
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -23,13 +23,14 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
/**
* @author eskimo
@@ -43,13 +44,14 @@
public ComboBoxField(Composite parent,List values, ILabelProvider labelProvider,
Object value, boolean floatStyle) {
this(parent, values, value, floatStyle);
-
comboControl.setLabelProvider(labelProvider);
}
+
public ComboBoxField(Composite parent,List values, Object value, boolean floatStyle) {
this.values = values;
- comboControl = new ComboViewer(parent,floatStyle?SWT.FLAT:SWT.READ_ONLY);
-
+ CCombo ccombo = new CCombo(parent, SWT.BORDER);
+ ccombo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ comboControl = new ComboViewer(ccombo);
comboControl.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
@@ -62,18 +64,14 @@
public Object[] getElements(Object inputElement) {
return ComboBoxField.this.values.toArray();
}
-
-
});
comboControl.addSelectionChangedListener(this);
- comboControl.getCombo().addModifyListener(new ModifyListener() {
-
+ comboControl.getCCombo().addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- firePropertyChange(new Object(), comboControl.getCombo().getText());
+ firePropertyChange(new Object(), comboControl.getCCombo().getText());
}});
comboControl.setLabelProvider(new ILabelProvider() {
-
public void addListener(ILabelProviderListener listener) {
}
@@ -94,34 +92,32 @@
public String getText(Object element) {
return element.toString();
}
-
});
comboControl.setInput(values);
comboControl.setSelection(new StructuredSelection(value), true);
-
-
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
public void selectionChanged(SelectionChangedEvent event) {
firePropertyChange("", ((StructuredSelection)event.getSelection()).getFirstElement());
}
-
- public Combo getComboControl() {
- return comboControl.getCombo();
+
+ public CCombo getComboControl() {
+ return comboControl.getCCombo();
}
@Override
public Control getControl() {
return getComboControl();
}
-
+
public void setValue(Object newValue) {
comboControl.setSelection(new StructuredSelection(newValue));
- comboControl.getCombo().setText(newValue.toString());
+ comboControl.getCCombo().setText(newValue.toString());
}
-
+
public void setTags(String[] tags,String value) {
values = Arrays.asList(tags);
comboControl.removeSelectionChangedListener(this);
@@ -129,4 +125,8 @@
comboControl.addPostSelectionChangedListener(this);
comboControl.setSelection(new StructuredSelection(value));
}
-}
+
+ public void setEditable(boolean ediatble) {
+ comboControl.getCCombo().setEditable(ediatble);
+ }
+}
\ No newline at end of file
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -0,0 +1,84 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.widget.field;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * A group of labels and radio buttons.
+ * @author Alexey Kazakov
+ */
+public class RadioField extends BaseField implements SelectionListener {
+
+ private Composite topComposite;
+ private Button[] radios;
+ private Object value;
+
+ public RadioField(Composite parent, List<String> labels, List<Object> values, Object defaultValue) {
+ topComposite = new Composite(parent, SWT.NONE);
+ topComposite.setLayout(new GridLayout(1, false));
+ topComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ radios = new Button[values.size()];
+ if(defaultValue==null && values.size()>0) {
+ defaultValue = values.get(0);
+ }
+ for (int i = 0; i < radios.length; i++) {
+ radios[i] = new Button(topComposite, SWT.RADIO);
+ radios[i].setText(labels.get(i));
+ radios[i].addSelectionListener(this);
+ Object value = values.get(i);
+ radios[i].setData(value);
+ if(value==defaultValue) {
+ radios[i].setSelection(true);
+ this.value = value;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.field.BaseField#getControl()
+ */
+ @Override
+ public Control getControl() {
+ return topComposite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent event) {
+ value = event.widget.getData();
+ firePropertyChange("", value);
+ }
+
+ /**
+ * @return Value of selected button
+ */
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
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-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -27,6 +27,7 @@
public static String SEAM_ENTITY_CLASS_NAME = "entity.name";
public static String SEAM_PROJECT_LOCATION_PATH = "seam.project.location";
public static String SEAM_PROJECT_WEBCONTENT_PATH = "seam.project.webcontent";
+ public static String HIBERNATE_CONFIGURATION_NAME = "hibernate.configuratrion.name";
public static String SEAM_EAR_PROJECT_LOCATION_PATH = "seam.ear.project.location";
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -10,36 +10,124 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Map;
+
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.swt.widgets.Group;
import org.jboss.tools.seam.ui.SeamUIMessages;
-import org.jboss.tools.seam.ui.widget.editor.LabelFieldEditor;
+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;
+import org.jboss.tools.seam.ui.widget.field.RadioField;
/**
* @author Alexey Kazakov
*/
-public class SeamGenerateEnitiesWizardPage extends WizardPage {
+public class SeamGenerateEnitiesWizardPage extends WizardPage implements PropertyChangeListener {
+ private IFieldEditor projectEditor;
+ private IFieldEditor configEditor;
+ private RadioField radios;
+
public SeamGenerateEnitiesWizardPage() {
super("seam.generate.entities.page", SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_TITLE, null);
- setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE);
+ setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE);
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayout(new GridLayout());
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
+ setPageComplete(true);
+ String projectName = SeamWizardUtils.getSelectedProjectName();
+ projectEditor = SeamWizardFactory.createSeamProjectSelectionFieldEditor(projectName);
+ projectEditor.addPropertyChangeListener(this);
+ if(projectName!=null && projectName.length()>0) {
+ Map<String, String> errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ } else {
+ setMessage(null);
+ }
+ }
- LabelFieldEditor label = new LabelFieldEditor("test", "test");
- label.createLabelControl(top);
- setPageComplete(false);
+ Composite top = new GridLayoutComposite(parent);
+ Composite projectComposite = new GridLayoutComposite(top, SWT.NONE, 3);
+
+ projectEditor.doFillIntoGrid(projectComposite);
+
+ configEditor = SeamWizardFactory.createHibernateConsoleConfigurationSelectionFieldEditor(null);
+ configEditor.addPropertyChangeListener(this);
+ configEditor.doFillIntoGrid(projectComposite);
+ configEditor.setEditable(false);
+
+ String config = (String)configEditor.getValue();
+ if(config==null && config.length()==0) {
+ setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE);
+ setPageComplete(false);
+ }
+
+ Composite groupComposite = new GridLayoutComposite(top);
+ Group group = new Group(groupComposite, SWT.NONE);
+ group.setText(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL);
+ group.setLayout(new GridLayout(1, false));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite radioComposite = new GridLayoutComposite(group, SWT.NONE, 2);
+ ArrayList<Object> values = new ArrayList<Object>();
+ values.add("reverse");
+ values.add("existing");
+ ArrayList<String> labels = new ArrayList<String>();
+ labels.add(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL);
+ labels.add(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL);
+ radios = new RadioField(radioComposite, labels, values, null);
+ radios.addPropertyChangeListener(this);
+
setControl(top);
}
+
+ public static class GridLayoutComposite extends Composite {
+
+ public GridLayoutComposite(Composite parent, int style, int columnNumber) {
+ super(parent, style);
+ GridLayout gl = new GridLayout(columnNumber, false);
+ setLayout(gl);
+ setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ public GridLayoutComposite(Composite parent) {
+ this(parent, SWT.NONE, 1);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ Map<String, String> errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+ String config = (String)configEditor.getValue();
+ if(config==null && config.length()==0) {
+ setErrorMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setMessage(null);
+ setPageComplete(true);
+ }
}
\ No newline at end of file
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-08-29 16:14:41 UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-08-29 17:50:24 UTC (rev 3406)
@@ -11,6 +11,12 @@
package org.jboss.tools.seam.ui.wizard;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.SwtFieldEditorFactory;
@@ -97,4 +103,25 @@
return SwtFieldEditorFactory.INSTANCE.createTextEditor(
IParameter.SEAM_ENTITY_CLASS_NAME, "Seam entity class name:", "");
}
-}
+
+ /**
+ * @param defaultSelection if "null" sets first configuration as default
+ * @return
+ */
+ public static IFieldEditor createHibernateConsoleConfigurationSelectionFieldEditor(String defaultSelection) {
+ ConsoleConfiguration[] configs = KnownConfigurations.getInstance().getConfigurations();
+ List<String> configurationNames = new ArrayList<String>();
+ for (int i = 0; i < configs.length; i++) {
+ configurationNames.add(configs[i].getName());
+ }
+ if(defaultSelection==null) {
+ if(configurationNames.size()>0) {
+ defaultSelection = configurationNames.get(0);
+ } else {
+ defaultSelection = "";
+ }
+ }
+ IFieldEditor editor = SwtFieldEditorFactory.INSTANCE.createComboEditor(IParameter.HIBERNATE_CONFIGURATION_NAME, SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL, configurationNames, defaultSelection);
+ return editor;
+ }
+}
\ No newline at end of file
17 years, 4 months