JBoss Tools SVN: r18698 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-11-16 10:27:27 -0500 (Mon, 16 Nov 2009)
New Revision: 18698
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditingSPecialSymbolsVPE_JBIDE3810.java
Log:
Fix test failure under Linux JBIDE-3810
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditingSPecialSymbolsVPE_JBIDE3810.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditingSPecialSymbolsVPE_JBIDE3810.java 2009-11-16 15:20:42 UTC (rev 18697)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditingSPecialSymbolsVPE_JBIDE3810.java 2009-11-16 15:27:27 UTC (rev 18698)
@@ -31,7 +31,7 @@
@SuppressWarnings("restriction")
public class EditingSPecialSymbolsVPE_JBIDE3810 extends VpeTest {
- private final static int clientX = 20;
+ private final static int clientX = 5;
private final static int clientY = 10;
private final static long delay = 500;
@@ -52,7 +52,9 @@
Mouse mouse = new Mouse(controller, delay);
mouse.click(clientX, clientY);
Keybord keybord = new Keybord(controller, delay);
- keybord.pressDel().pressBackSP().pressLeft().pressBackSP();
+ keybord.pressBackSP();
+ mouse.click(clientX*2, clientY);
+ keybord.pressDel().pressDel();
compareVisualAndSourceTargets(part);
}
15 years, 1 month
JBoss Tools SVN: r18697 - trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2009-11-16 10:20:42 -0500 (Mon, 16 Nov 2009)
New Revision: 18697
Removed:
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools_simple.css
Log:
https://jira.jboss.org/jira/browse/JBDS-348 - deleted as unused;
Deleted: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools_simple.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools_simple.css 2009-11-16 14:14:23 UTC (rev 18696)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools_simple.css 2009-11-16 15:20:42 UTC (rev 18697)
@@ -1,6 +0,0 @@
-@import url("jbossorg.css");
-
-
-/* -----Override jbossorg.css----- */
-
-
15 years, 1 month
JBoss Tools SVN: r18696 - in trunk: jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-11-16 09:14:23 -0500 (Mon, 16 Nov 2009)
New Revision: 18696
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
Log:
JBIDE-5149: Make OpenOn work for styleClass="|"
JBIDE-5119: Refactor PageContextFactory to improve performance of context creation.
The CSSStyleSheet gathering is re-developed.
New Hyperlink is added.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF 2009-11-16 14:14:23 UTC (rev 18696)
@@ -12,7 +12,10 @@
org.jboss.tools.common.text.ext,
org.jboss.tools.jst.text.ext,
org.jboss.tools.jsf.text.ext,
- org.jboss.tools.jst.web;bundle-version="2.0.0"
+ org.jboss.tools.jst.web;bundle-version="2.0.0",
+ org.jboss.tools.jst.web.kb;bundle-version="1.0.0",
+ org.eclipse.wst.css.core;bundle-version="1.1.300",
+ org.jboss.tools.common.el.core;bundle-version="2.0.0"
Export-Package: org.jboss.tools.jsf.text.ext.richfaces,
org.jboss.tools.jsf.text.ext.richfaces.hyperlink
Bundle-Version: 2.0.0
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-11-16 14:14:23 UTC (rev 18696)
@@ -314,6 +314,19 @@
</contentType>
</hyperlinkPartitioner>
+ <hyperlinkPartitioner
+ id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlinkPartitioner"
+ class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlinkPartitioner">
+ <contentType id="org.eclipse.jst.jsp.core.jspsource">
+ <partitionType id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ </partitionType>
+ </contentType>
+ <contentType id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ </partitionType>
+ </contentType>
+ </hyperlinkPartitioner>
+
</extension>
<extension
@@ -342,6 +355,17 @@
<partitiontype id="org.jboss.tools.common.text.ext.jsp.JSP_RICHFACES_BUNDLE" />
</contenttypeidentifier>
</hyperlink>
+
+ <hyperlink
+ class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlink"
+ id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlink">
+ <contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS" />
+ </contenttypeidentifier>
+ <contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS" />
+ </contenttypeidentifier>
+ </hyperlink>
</extension>
<extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
Added: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -0,0 +1,90 @@
+package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.jst.text.ext.hyperlink.CSSClassHyperlink;
+import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+
+public class RichfacesCSSClassHyperlink extends CSSClassHyperlink {
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ ICSSContainerSupport cssContainerSupport = null;
+ IPageContext context = PageContextFactory.createPageContext(getFile(), region.getOffset(), getContentType(getDocument()));
+ if (!(context instanceof ICSSContainerSupport)) {
+ openFileFailed();
+ return;
+ }
+ cssContainerSupport = (ICSSContainerSupport)context;
+ List<CSSStyleSheetDescriptor> descrs = cssContainerSupport.getCSSStyleSheetDescriptors();
+
+ for (int i = (descrs == null) ? -1 : descrs.size() - 1; descrs != null && i >= 0; i--) {
+ CSSStyleSheetDescriptor descr = descrs.get(i);
+ CSSRuleList rules = descr.sheet.getCssRules();
+ for (int r = 0; rules != null && r < rules.getLength(); r++) {
+ if (isRuleMatch(rules.item(r), getStyleName(region))) {
+ CSSRule rule = rules.item(r);
+ System.out.println();
+ showRegion(
+ PageContextFactory.getFileFromProject(descr.source, getFile()),
+ new Region(((IndexedRegion)rule).getStartOffset(), ((IndexedRegion)rule).getLength()));
+ return;
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String styleName = getStyleName(fLastRegion);
+ if (styleName == null)
+ return MessageFormat.format(Messages.OpenA, Messages.CSSStyle);
+
+ return MessageFormat.format(Messages.OpenCSSStyle, styleName);
+ }
+
+
+ /**
+ * Returns the content type of document
+ *
+ * @param document -
+ * assumes document is not null
+ * @return String content type of given document
+ */
+ @SuppressWarnings("restriction")
+ private String getContentType(IDocument document) {
+ String type = null;
+
+ IModelManager mgr = StructuredModelManager.getModelManager();
+ IStructuredModel model = null;
+ try {
+ model = mgr.getExistingModelForRead(document);
+ if (model != null) {
+ type = model.getContentTypeIdentifier();
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return type;
+ }
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -0,0 +1,24 @@
+package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
+
+import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.jst.text.ext.hyperlink.CSSClassHyperlinkPartitioner;
+
+public class RichfacesCSSClassHyperlinkPartitioner extends CSSClassHyperlinkPartitioner {
+ public static final String RICHFACES_CSS_CLASS_PARTITION = "org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS"; //$NON-NLS-1$
+ private static final String RICHFACES_CSS_CLASS_TOKEN = "/styleClass/"; //$NON-NLS-1$
+
+ @Override
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if (region.getAxis() != null
+ && region.getAxis().endsWith(RICHFACES_CSS_CLASS_TOKEN))
+ return true;
+ return false;
+ }
+
+ @Override
+ protected String getPartitionType(String axis) {
+ return RICHFACES_CSS_CLASS_PARTITION;
+ }
+
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -227,28 +227,31 @@
* @param styleName
* @return
*/
- private boolean isRuleMatch(CSSRule cssRule, String styleName) {
+ protected boolean isRuleMatch(CSSRule cssRule, String styleName) {
// get selector text
String selectorText = ((ICSSStyleRule) cssRule).getSelectorText();
if (selectorText != null) {
-
- // split selector text by whitespace
- String[] styles = selectorText.trim().split(" "); //$NON-NLS-1$
- int searchIndex = Arrays.binarySearch(styles, styleName,
- new Comparator<String>() {
-
- public int compare(String o1, String o2) {
- Matcher matcher = Pattern.compile(
- COMPARE_CLASS_REGEX_PREFIX + o2)
- .matcher(o1);
- return matcher.matches() ? 0 : 1;
- }
-
- });
- if (searchIndex >= 0)
- return true;
+ String styles[] = selectorText.trim().split(","); //$NON-NLS-1$
+ for (String styleText : styles) {
+ String[] styleWords = styleText.trim().split(" "); //$NON-NLS-1$
+ if (styleWords != null) {
+ int searchIndex = Arrays.binarySearch(styleWords, styleName,
+ new Comparator<String>() {
+
+ public int compare(String o1, String o2) {
+ Matcher matcher = Pattern.compile(
+ COMPARE_CLASS_REGEX_PREFIX + o2)
+ .matcher(o1);
+ return matcher.matches() ? 0 : 1;
+ }
+
+ });
+ if (searchIndex >= 0)
+ return true;
+ }
+ }
}
return false;
}
@@ -296,7 +299,7 @@
*
* @param styleRegion
*/
- private void showRegion(RegionHolder styleRegion) {
+ protected void showRegion(RegionHolder styleRegion) {
IWorkbenchPage workbenchPage = ExtensionsPlugin.getDefault()
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
@@ -318,10 +321,35 @@
/**
*
+ * @param styleRegion
+ */
+ protected void showRegion(IFile file, IRegion region) {
+
+ IWorkbenchPage workbenchPage = ExtensionsPlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart part = null;
+ if (file != null) {
+ try {
+ part = IDE.openEditor(workbenchPage, file, true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ if (part == null) {
+ openFileFailed();
+ return;
+ }
+ StructuredSelectionHelper.setSelectionAndReveal(part,
+ region);
+ }
+
+
+ /**
+ *
* @param region
* @return
*/
- private String getStyleName(IRegion region) {
+ protected String getStyleName(IRegion region) {
try {
return getDocument().get(region.getOffset(), region.getLength());
} catch (BadLocationException e) {
@@ -329,7 +357,7 @@
}
}
- IRegion fLastRegion = null;
+ protected IRegion fLastRegion = null;
/**
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
Modified: trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -31,7 +31,7 @@
public static final String CSS_CLASS_PARTITION = "org.jboss.tools.common.text.ext.CSS_CLASS"; //$NON-NLS-1$
- private static final String CSS_CLASS_TOKEN = "class/"; //$NON-NLS-1$
+ private static final String CSS_CLASS_TOKEN = "/class/"; //$NON-NLS-1$
private static final String EXCLUSION_TOKEN = "jsp:usebean/class/"; //$NON-NLS-1$
@@ -71,7 +71,7 @@
}
}
- private String getPartitionType(String axis) {
+ protected String getPartitionType(String axis) {
return CSS_CLASS_PARTITION;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -12,6 +12,8 @@
import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.w3c.dom.css.CSSStyleSheet;
/**
@@ -26,14 +28,17 @@
/**
* Adds the CSS StyleSheet object found within the page
*
- * @param includedContext
+ * @param cssStyleSheet
+ * @param source
*/
- void addCSSStyleSheet(CSSStyleSheet cssStyleSheet);
+ void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheet);
+ IFile getResource();
+
/**
* Returns the list of all the collected CSS StyleSheet objects
*
* @return
*/
- List<CSSStyleSheet> getCSSStyleSheets();
+ List<CSSStyleSheetDescriptor> getCSSStyleSheetDescriptors();
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -85,6 +85,8 @@
public static String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
public static String FACELETS_PAGE_CONTEXT_TYPE = "FACELETS_PAGE_CONTEXT_TYPE";
+
+
/**
* Creates a page context for the specified context type
* @
@@ -150,7 +152,7 @@
setFaceletsNameSpaces(context, offset);
context.setLibraries(getTagLibraries(context, offset));
context.setResourceBundles(getResourceBundles(context));
-
+
collectIncludedAdditionalInfo(context);
} finally {
releaseConnectedDocument(input);
@@ -235,25 +237,33 @@
private static void createCSSStyleSheetFromAttribute(IDOMElement node,
String attribute, ICSSContainerSupport context) {
- CSSStyleSheet sheet = getSheetForTagAttribute(node, attribute);
- if (sheet != null)
- context.addCSSStyleSheet(sheet);
+ CSSStyleSheetDescriptor descr = getSheetForTagAttribute(node, attribute);
+ if (descr != null)
+ context.addCSSStyleSheetDescriptor(descr);
}
private static void createCSSStyleSheetFromElement(IDOMElement node,
ICSSContainerSupport context) {
CSSStyleSheet sheet = getSheetForTag(node);
if (sheet != null)
- context.addCSSStyleSheet(sheet);
+ context.addCSSStyleSheetDescriptor(new CSSStyleSheetDescriptor(context.getResource().getFullPath().toString(), sheet));
}
-
+ public static class CSSStyleSheetDescriptor {
+ public CSSStyleSheet sheet;
+ public String source;
+
+ CSSStyleSheetDescriptor (String source, CSSStyleSheet sheet) {
+ this.source = source;
+ this.sheet = sheet;
+ }
+ }
/**
*
* @param stylesContainer
* @return
*/
- private static CSSStyleSheet getSheetForTagAttribute(final Node stylesContainer, String attribute) {
+ private static CSSStyleSheetDescriptor getSheetForTagAttribute(final Node stylesContainer, String attribute) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
@@ -270,13 +280,14 @@
}
CSSStyleSheet sheet = null;
+ String source = null;
if (adapter != null) {
sheet = (CSSStyleSheet) adapter.getSheet();
-
+ source = ((ExtendedLinkElementAdapter)adapter).getSource();
}
- return sheet;
+ return sheet == null || source == null ? null : new CSSStyleSheetDescriptor(source, sheet);
}
/**
@@ -913,6 +924,7 @@
private Element element;
private String hrefAttrName;
+ private String source = null;
public ExtendedLinkElementAdapter(Element element, String hrefAttrName) {
this.element = element;
@@ -924,8 +936,15 @@
return element;
}
+ public String getSource() {
+ return source;
+ }
+
@Override
protected boolean isValidAttribute() {
+ if (super.isValidAttribute())
+ return true;
+
String href = getElement().getAttribute(hrefAttrName);
if (href == null || href.length() == 0)
return false;
@@ -936,30 +955,34 @@
*/
public ICSSModel getModel() {
// Fix for JBIDE-5079 >>>
- ICSSModel model = null;
if (super.isValidAttribute()) {
- model = super.getModel();
+ source = getSourceFromAttribute("href");
+ } else if (isValidAttribute()) {
+ source = getSourceFromAttribute(hrefAttrName);
+ } else {
+ return null;
}
- // Fix for JBIDE-5079 <<<
- if (model == null) {
- model = retrieveModel();
- setModel(model);
- }
+
+ ICSSModel model = retrieveModel();
+ setModel(model);
return model;
}
+ private String getSourceFromAttribute(String hrefAttributeName) {
+ String hrefExtracted = findAndReplaceElVariable(element
+ .getAttribute(hrefAttrName));
+
+ return hrefExtracted;
+ }
+
/**
*/
private ICSSModel retrieveModel() {
- if (!isValidAttribute()) {
+ if (!isValidAttribute() || source == null) {
return null;
}
// null,attr check is done in isValidAttribute()
- Element element = getElement();
- String href = findAndReplaceElVariable(element
- .getAttribute(hrefAttrName));
-
IDOMModel baseModel = ((IDOMNode) element).getModel();
if (baseModel == null)
return null;
@@ -975,7 +998,7 @@
URLModelProvider provider = new URLModelProvider();
try {
IStructuredModel newModel = provider.getModelForRead(baseModel,
- href);
+ source);
if (newModel == null)
return null;
if (!(newModel instanceof ICSSModel)) {
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -16,6 +16,7 @@
import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.css.CSSStyleSheet;
@@ -26,9 +27,8 @@
*/
public class JspContextImpl extends XmlContextImpl implements ICSSContainerSupport {
protected List<IPageContext> fIncludedContexts = null;
- protected List<CSSStyleSheet> fCSSStyleSheets = null;
+ protected List<CSSStyleSheetDescriptor> fCSSStyleSheetDescriptors = null;
-
@Override
public void addIncludedContext(IPageContext includedContext) {
if (fIncludedContexts == null) {
@@ -56,19 +56,19 @@
return superNameSpaces;
}
- public void addCSSStyleSheet(CSSStyleSheet cssStyleSheet) {
- if (fCSSStyleSheets == null) {
- fCSSStyleSheets = new ArrayList<CSSStyleSheet>();
+ public void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheetDescriptor) {
+ if (fCSSStyleSheetDescriptors == null) {
+ fCSSStyleSheetDescriptors = new ArrayList<CSSStyleSheetDescriptor>();
}
- fCSSStyleSheets.add(cssStyleSheet);
+ fCSSStyleSheetDescriptors.add(cssStyleSheetDescriptor);
}
- public List<CSSStyleSheet> getCSSStyleSheets() {
- List<CSSStyleSheet> sheets = new ArrayList<CSSStyleSheet>();
+ public List<CSSStyleSheetDescriptor> getCSSStyleSheetDescriptors() {
+ List<CSSStyleSheetDescriptor> descrs = new ArrayList<CSSStyleSheetDescriptor>();
- if (fCSSStyleSheets != null) {
- for (CSSStyleSheet sheet : fCSSStyleSheets) {
- sheets.add(sheet);
+ if (fCSSStyleSheetDescriptors != null) {
+ for (CSSStyleSheetDescriptor descr : fCSSStyleSheetDescriptors) {
+ descrs.add(descr);
}
}
@@ -76,16 +76,14 @@
if (includedContexts != null) {
for (IPageContext includedContext : includedContexts) {
if (includedContext instanceof ICSSContainerSupport) {
- List<CSSStyleSheet> includedSheets = ((ICSSContainerSupport)includedContext).getCSSStyleSheets();
- if (includedSheets != null) {
- sheets.addAll(includedSheets);
+ List<CSSStyleSheetDescriptor> includedSheetDescriptors = ((ICSSContainerSupport)includedContext).getCSSStyleSheetDescriptors();
+ if (includedSheetDescriptors != null) {
+ descrs.addAll(includedSheetDescriptors);
}
}
}
}
- return sheets;
-
- }
-
+ return descrs;
+ }
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-16 14:04:39 UTC (rev 18695)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-16 14:14:23 UTC (rev 18696)
@@ -23,9 +23,9 @@
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
-import org.w3c.dom.css.CSSStyleSheet;
/**
* The CSS Class proposal type. Is used to collect and return the proposals on
@@ -49,17 +49,16 @@
if (context instanceof ICSSContainerSupport) {
ICSSContainerSupport cssSource = (ICSSContainerSupport)context;
- List<CSSStyleSheet> sheets = cssSource.getCSSStyleSheets();
- if (sheets != null) {
- for (CSSStyleSheet sheet : sheets) {
- CSSRuleList rules = sheet.getCssRules();
+ List<CSSStyleSheetDescriptor> descrs = cssSource.getCSSStyleSheetDescriptors();
+ if (descrs != null) {
+ for (CSSStyleSheetDescriptor descr : descrs) {
+ CSSRuleList rules = descr.sheet.getCssRules();
for (int i = 0; rules != null && i < rules.getLength(); i++) {
CSSRule rule = rules.item(i);
idList.addAll(getNamesFromCSSRule(rule));
}
}
}
-
}
}
@@ -70,7 +69,7 @@
* @param styleName
* @return
*/
- private Set<String> getNamesFromCSSRule(CSSRule cssRule) {
+ public static Set<String> getNamesFromCSSRule(CSSRule cssRule) {
Set<String> styleNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
// get selector text
15 years, 1 month
JBoss Tools SVN: r18695 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-11-16 09:04:39 -0500 (Mon, 16 Nov 2009)
New Revision: 18695
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4988
In performFinish method uninstall jpa-facet from <project> and install it to <project-ejb>
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-11-16 14:01:10 UTC (rev 18694)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-11-16 14:04:39 UTC (rev 18695)
@@ -18,20 +18,21 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
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.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -59,6 +60,7 @@
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
import org.eclipse.wst.common.project.facet.core.IPreset;
@@ -73,7 +75,6 @@
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.ui.ServerUIUtil;
-import org.eclipse.wst.validation.internal.operations.ValidationBuilder;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.tools.jst.web.server.RegistrationHelper;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -95,6 +96,7 @@
* @author eskimo
*
*/
+@SuppressWarnings("restriction")
public class SeamProjectWizard extends WebProjectWizard {
private SeamWebProjectFirstPage firstPage;
@@ -266,9 +268,27 @@
SeamInstallWizardPage page = (SeamInstallWizardPage)getPage(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_FACET);
page.finishPressed();
IDataModel model = page.getConfig();
- model.setProperty(ISeamFacetDataModelProperties.CREATE_EAR_PROJECTS, Boolean.TRUE);
+ model.setProperty(ISeamFacetDataModelProperties.CREATE_EAR_PROJECTS, Boolean.TRUE);
+ boolean isEAR = ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equalsIgnoreCase(model.getStringProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
+ IFacetedProjectWorkingCopy fpwc = getFacetedProjectWorkingCopy();
+ IProjectFacet jpaFacet = ProjectFacetsManager.getProjectFacet("jpt.jpa");
+ IProjectFacetVersion pfv = fpwc.getProjectFacetVersion(jpaFacet);
+
+ if (isEAR && pfv != null){
+ //remove jpa facet from <project>
+ // and add it to <project>-ejb with the same model
+ action = fpwc.getProjectFacetAction(jpaFacet);
+ IDataModel dataModel = (IDataModel) action.getConfig();
+ String connectionProfileName = dataModel.getStringProperty("JpaFacetDataModelProperties.CONNECTION");
+ if (connectionProfileName == null) throw new NullPointerException("Jpa connection profile is null");
+ page.setJpaConnectionProfile(connectionProfileName);
+ fpwc.removeProjectFacet(jpaFacet);
+ }
+
return super.performFinish();
}
+
+ Action action = null;
/*
* (non-Javadoc)
@@ -303,10 +323,24 @@
projects.add(ejbProject);
projects.add(earProject);
}
-
-
+
if(ejbProject != null) {
provideClassPath(projects, ejbProject);
+ if (action != null) {
+ IDataModel jpaModel = (IDataModel) action.getConfig();
+ boolean isHibernatePlatform = "hibernate".equals(
+ jpaModel.getStringProperty("JpaFacetDataModelProperties.PLATFORM_ID"));
+ if (isHibernatePlatform){
+ IFile hibernateLaunchFile = ejbProject.getFile(ejbProject.getName() + ".launch"); //$NON-NLS-1$
+ if (hibernateLaunchFile.exists()){//delete the launch configuration to prevent doubling
+ hibernateLaunchFile.delete(1, monitor);
+ }
+ }
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(ejbProject, true, null);
+ //add facet
+ facetedProject.installProjectFacet(action.getProjectFacetVersion(), action.getConfig(), null);
+ }
}
buildProjects(projects, monitor);
15 years, 1 month
JBoss Tools SVN: r18694 - in trunk: seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-11-16 09:01:10 -0500 (Mon, 16 Nov 2009)
New Revision: 18694
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4987
Use jpa-connection profile if the facet is installed.
Use the profile in launch configuration instead of hibernate.properties.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-16 13:45:01 UTC (rev 18693)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-16 14:01:10 UTC (rev 18694)
@@ -59,7 +59,7 @@
protected boolean checkPreConditions(IProject project){
try {
ILaunchConfiguration lc = getLaunchConfiguration(project);
- if (lc != null){
+ if (lc != null && lc.exists()){
ProjectUtils.toggleHibernateOnProject(project, true, lc.getName());
return false;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2009-11-16 13:45:01 UTC (rev 18693)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2009-11-16 14:01:10 UTC (rev 18694)
@@ -307,7 +307,7 @@
protected File webInfClassesMetaInf;
protected File persistenceFile;
protected File hibernateConsoleLaunchFile;
- protected File hibernateConsolePropsFile;
+ //protected File hibernateConsolePropsFile;
/**
*
@@ -491,15 +491,17 @@
new File(resources, project.getName() + "-ds.xml"), //$NON-NLS-1$
viewFilterSetCollection, false);
- AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(project.getLocation().toFile(), project.getName() + ".launch"), //$NON-NLS-1$
- viewFilterSetCollection, false);
+ if (hibernateConsoleLaunchFile != null) {
+ AntCopyUtils.copyFileToFile(
+ hibernateConsoleLaunchFile,
+ new File(project.getLocation().toFile(), project.getName() + ".launch"), //$NON-NLS-1$
+ viewFilterSetCollection, false);
+ }
- AntCopyUtils.copyFileToFolder(
+ /*AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
project.getLocation().toFile(),
- hibernateDialectFilterSet, false);
+ hibernateDialectFilterSet, false);*/
WtpUtils.setClasspathEntryAsExported(project, new Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
} else {
@@ -682,8 +684,8 @@
ejbProjectFolder, ejbProjectFolder.getName() + ".launch"), //$NON-NLS-1$
new FilterSetCollection(ejbFilterSet), false);
- AntCopyUtils.copyFileToFolder(hibernateConsolePropsFile,
- ejbProjectFolder, hibernateDialectFilterSet, false);
+ /*AntCopyUtils.copyFileToFolder(hibernateConsolePropsFile,
+ ejbProjectFolder, hibernateDialectFilterSet, false);*/
}
enum ProjectType {
@@ -716,6 +718,7 @@
IProjectFacetVersion ejbVersion = facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.EJB_FACET);
IProjectFacetVersion webVersion = facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
IProjectFacetVersion earVersion = facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET);
+ IProjectFacetVersion jpaVersion = facetedProject.getProjectFacetVersion(ProjectFacetsManager.getProjectFacet("jpt.jpa"));
initDefaultModelValues(model, webVersion!=null);
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
@@ -760,8 +763,32 @@
dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml"); //$NON-NLS-1$
componentsFile = new File(seamGenResFolder, "WEB-INF/components" + (isWarConfiguration(model) ? "-war" : "") + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
- hibernateConsolePropsFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
+ if (jpaVersion != null) {
+ IScopeContext context = new ProjectScope(project);
+ IEclipsePreferences prefs = context.getNode("org.eclipse.jpt.core");
+ String platformId = prefs.get("org.eclipse.jpt.core.platform", null);
+ if ("hibernate".equals(platformId)){
+ /*
+ * Hibernate automatically creates console configuration
+ */
+ hibernateConsoleLaunchFile = null;
+ } else {
+ try {
+ hibernateConsoleLaunchFile = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "hibernatetools/hibernate-console_jpa.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console_jpa.launch"); //$NON-NLS-1$
+ }
+ } else {
+ try {
+ hibernateConsoleLaunchFile = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "hibernatetools/hibernate-console.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
+ }
+ //hibernateConsolePropsFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
//final File hibernateConsolePref = new File(seamGenHomeFolder, "hibernatetools/.settings/org.hibernate.eclipse.console.prefs"); //$NON-NLS-1$
persistenceFile = new File(seamGenResFolder, "META-INF/persistence-" + (isWarConfiguration(model) ? DEV_WAR_PROFILE : DEV_EAR_PROFILE) + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2009-11-16 13:45:01 UTC (rev 18693)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2009-11-16 14:01:10 UTC (rev 18694)
@@ -44,6 +44,7 @@
PROJECT_TEMPLATE.addFilter("debug","true"); //$NON-NLS-1$ //$NON-NLS-2$
//todo: keep this local for seam2 ?
PROJECT_TEMPLATE.addFilter("skin","blueSky"); //$NON-NLS-1$ //$NON-NLS-2$
+ PROJECT_TEMPLATE.addFilter("connectionProfile","${seam.project.connection.profile}"); //$NON-NLS-1$ //$NON-NLS-2$
FILTERS_TEMPLATE = new FilterSet();
FILTERS_TEMPLATE.addFilter("interfaceName","${interface.name}"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-11-16 13:45:01 UTC (rev 18693)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-11-16 14:01:10 UTC (rev 18694)
@@ -90,7 +90,7 @@
protected File seamGenResFolder;
protected File persistenceFile;
protected File hibernateConsoleLaunchFile;
- protected File hibernateConsolePropsFile;
+ //protected File hibernateConsolePropsFile;
protected FilterSet jdbcFilterSet;
protected FilterSet encodedJdbcFilterSet;
@@ -134,8 +134,14 @@
filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
seamGenResFolder = new File(seamGenHomeFolder, "resources"); //$NON-NLS-1$
persistenceFile = new File(seamGenResFolder, "META-INF/persistence-" + (SeamFacetAbstractInstallDelegate.isWarConfiguration(model) ? DEV_WAR_PROFILE : DEV_EAR_PROFILE) + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
- hibernateConsolePropsFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
+
+ try {
+ hibernateConsoleLaunchFile = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "hibernatetools/hibernate-console.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
+ //hibernateConsolePropsFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml"); //$NON-NLS-1$
IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
@@ -422,16 +428,17 @@
FilterSet ejbFilterSet = new FilterSet();
ejbFilterSet.addFilter("projectName", ejbProjectFolder.getName()); //$NON-NLS-1$
+ ejbFilterSet.addFilter("connectionProfile", model.getStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE));//$NON-NLS-1$
AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(ejbProjectFolder, ejbProjectFolder.getName() + ".launch"), //$NON-NLS-1$
- new FilterSetCollection(ejbFilterSet), true);
+ hibernateConsoleLaunchFile,
+ new File(ejbProjectFolder, ejbProjectFolder.getName() + ".launch"), //$NON-NLS-1$
+ new FilterSetCollection(ejbFilterSet), true);
- AntCopyUtils.copyFileToFolder(
+ /*AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
ejbProjectFolder,
- hibernateDialectFilterSet, true);
+ hibernateDialectFilterSet, true);*/
}
protected void createEarProject() {
Added: trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch 2009-11-16 14:01:10 UTC (rev 18694)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Hibernate Console launch configuration -->
+<launchConfiguration type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="@projectName@"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY" value="JPA"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONNECTION_PROFILE_NAME" value="@connectionProfile@"/>
+</launchConfiguration>
Added: trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch 2009-11-16 14:01:10 UTC (rev 18694)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Hibernate Console launch configuration -->
+<launchConfiguration type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="@projectName@"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY" value="JPA"/>
+<stringAttribute key="org.hibernate.eclipse.launch.USE_JPA_PROJECT_PROFILE" value="true"/>
+</launchConfiguration>
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2009-11-16 13:45:01 UTC (rev 18693)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2009-11-16 14:01:10 UTC (rev 18694)
@@ -36,6 +36,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.PlatformUI;
@@ -48,13 +49,16 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard;
import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.hibernate.eclipse.console.utils.DriverClassHelpers;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -65,7 +69,6 @@
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
-import org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
@@ -109,45 +112,17 @@
getDeployAsDefaultValue());
// Database group
- private IFieldEditor connProfileSelEditor = SeamWizardFactory
- .createConnectionProfileSelectionFieldEditor(
- getConnectionProfileDefaultValue(), new IValidator() {
- public Map<String, IStatus> validate(Object value,
- Object context) {
- SeamInstallWizardPage.this.validate();
- return ValidatorFactory.NO_ERRORS;
- }
- });
+ private IFieldEditor connProfileSelEditor;
- private IFieldEditor jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
- .createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_TYPE,
- Arrays.asList(HIBERNATE_HELPER.getDialectNames()),
- getDefaultDbType(), false);
+ private IFieldEditor jBossHibernateDbTypeEditor ;
- private IFieldEditor dbSchemaName = IFieldEditorFactory.INSTANCE
- .createTextEditor(
- ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_SCHEMA_NAME,
- ""); //$NON-NLS-1$
+ private IFieldEditor dbSchemaName;
- private IFieldEditor dbCatalogName = IFieldEditorFactory.INSTANCE
- .createTextEditor(
- ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME,
- ""); //$NON-NLS-1$
+ private IFieldEditor dbCatalogName;
- private IFieldEditor dbTablesExists = IFieldEditorFactory.INSTANCE
- .createCheckboxEditor(
- ISeamFacetDataModelProperties.DB_ALREADY_EXISTS,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DB_TABLES_ALREADY_EXISTS,
- false);
+ private IFieldEditor dbTablesExists;
- private IFieldEditor recreateTablesOnDeploy = IFieldEditorFactory.INSTANCE
- .createCheckboxEditor(
- ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_RECREATE_DATABASE_TABLES_AND_DATA_ON_DEPLOY,
- false);
+ private IFieldEditor recreateTablesOnDeploy;
private IFieldEditor sessionBeanPkgNameditor = IFieldEditorFactory.INSTANCE
.createTextEditor(
@@ -166,6 +141,8 @@
ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_TEST_PACKAGE_NAME,
"com.mydomain.projectname.test"); //$NON-NLS-1$
+
+ private Group databaseGroup;
/**
*
@@ -266,8 +243,7 @@
public void setConfig(Object config) {
model = (IDataModel) config;
model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
- HIBERNATE_HELPER.getDialectClass(jBossHibernateDbTypeEditor
- .getValueAsString()));
+ HIBERNATE_HELPER.getDialectClass(getDefaultDbType()));
}
/**
@@ -289,20 +265,66 @@
if (seamRuntime != null) {
SeamRuntimeManager.getInstance().setDefaultRuntime(seamRuntime);
}
+
+ if (connProfileSelEditor != null) {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
+ connProfileSelEditor.getValueAsString());
+ } else {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
+ getJpaConnectionProfile());
+ model.setStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE, getJpaConnectionProfile());
+ }
+
+ if (jBossHibernateDbTypeEditor != null) {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE,
+ this.jBossHibernateDbTypeEditor.getValueAsString());
+ }
SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
- connProfileSelEditor.getValueAsString());
-
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS,
- this.jBossAsDeployAsEditor.getValueAsString());
-
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE,
- this.jBossHibernateDbTypeEditor.getValueAsString());
+ this.jBossAsDeployAsEditor.getValueAsString());
}
+
+ /*
+ * Don't want to add jpa as required plugin, so use String constant instead of JptCorePlugin.FACET_ID
+ */
+ private IProjectFacetVersion getJpaFacetVersion(){
+ IFacetedProjectWorkingCopy facetedProject = ( (ModifyFacetedProjectWizard) getWizard() ).getFacetedProjectWorkingCopy();
+ return facetedProject.getProjectFacetVersion(ProjectFacetsManager.getProjectFacet("jpt.jpa")); //$NON-NLS-1$
+ }
+
+ /**
+ * Used to save connection profile from jpa facet.
+ * If not null then used as seam connection profile.
+ */
+ private String jpaConnectioProfile;
+
+ public void setJpaConnectionProfile(String jpaConnectioProfile){
+ this.jpaConnectioProfile = jpaConnectioProfile;
+ }
+
+ private String getJpaConnectionProfile(){
+ if (jpaConnectioProfile != null) return jpaConnectioProfile;
+ IProjectFacetVersion jpaVersion = getJpaFacetVersion();
+ if (jpaVersion == null) throw new NullPointerException("Jpa facet version is null");
+ try {
+ Object config = context.getConfig(jpaVersion, Action.Type.INSTALL, context.getProjectName());
+ if (config instanceof IDataModel) {
+ /*
+ * Don't want to add jpa as required plugin, so use String constant instead of JpaFacetDataModelProperties.CONNECTION
+ */
+ return ((IDataModel)config).getStringProperty("JpaFacetDataModelProperties.CONNECTION"); //$NON-NLS-1$
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+
/**
* Registers editor in data synchronizer and put SWT controls for it at
* wizard page.
@@ -365,19 +387,14 @@
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = false;
- Group databaseGroup = new Group(root, SWT.NONE);
+ databaseGroup = new Group(root, SWT.NONE);
databaseGroup.setLayoutData(gd);
databaseGroup.setText(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE);
gridLayout = new GridLayout(4, false);
databaseGroup.setLayout(gridLayout);
- registerEditor(jBossHibernateDbTypeEditor, databaseGroup, 4);
- registerEditor(connProfileSelEditor, databaseGroup, 4);
- registerEditor(dbSchemaName, databaseGroup, 4);
- registerEditor(dbCatalogName, databaseGroup, 4);
- registerEditor(dbTablesExists, databaseGroup, 4);
- registerEditor(recreateTablesOnDeploy, databaseGroup, 4);
- // registerEditor(pathToJdbcDriverJar,databaseGroup, 4);
+ createDatabaseGoupControl();
+
Group generationGroup = new Group(root, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 1;
@@ -422,16 +439,7 @@
getDeploymentTypeValidator(getWizard()));
}
- jBossHibernateDbTypeEditor
- .addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- SeamInstallWizardPage.this.model
- .setProperty(
- ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
- HIBERNATE_HELPER.getDialectClass(evt
- .getNewValue().toString()));
- }
- });
+
Dialog.applyDialogFont(parent);
initDefaultWizardProperties();
@@ -442,6 +450,85 @@
}
}
+ public void createDatabaseGoupControl() {
+ disposeControls(jBossHibernateDbTypeEditor);
+ disposeControls(connProfileSelEditor);
+ disposeControls(dbSchemaName);
+ disposeControls(dbCatalogName);
+ disposeControls(dbTablesExists);
+ disposeControls(recreateTablesOnDeploy);
+ if (!needToShowConnectionProfile){
+ jBossHibernateDbTypeEditor = null;
+ connProfileSelEditor = null;
+ dbSchemaName = null;
+ dbCatalogName = null;
+ } else {
+ jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
+ .createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_TYPE,
+ Arrays.asList(HIBERNATE_HELPER.getDialectNames()),
+ getDefaultDbType(), false);
+ connProfileSelEditor = SeamWizardFactory
+ .createConnectionProfileSelectionFieldEditor(
+ getConnectionProfileDefaultValue(), new IValidator() {
+ public Map<String, IStatus> validate(Object value,
+ Object context) {
+ SeamInstallWizardPage.this.validate();
+ return ValidatorFactory.NO_ERRORS;
+ }
+ });
+ dbSchemaName = IFieldEditorFactory.INSTANCE
+ .createTextEditor(
+ ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_SCHEMA_NAME,
+ ""); //$NON-NLS-1$
+ dbCatalogName = IFieldEditorFactory.INSTANCE
+ .createTextEditor(
+ ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME,
+ ""); //$NON-NLS-1$
+
+ jBossHibernateDbTypeEditor
+ .addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ SeamInstallWizardPage.this.model
+ .setProperty(
+ ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
+ HIBERNATE_HELPER.getDialectClass(evt
+ .getNewValue().toString()));
+ }
+ });
+ registerEditor(jBossHibernateDbTypeEditor, databaseGroup, 4);
+ registerEditor(connProfileSelEditor, databaseGroup, 4);
+ registerEditor(dbSchemaName, databaseGroup, 4);
+ registerEditor(dbCatalogName, databaseGroup, 4);
+ }
+ dbTablesExists = IFieldEditorFactory.INSTANCE
+ .createCheckboxEditor(
+ ISeamFacetDataModelProperties.DB_ALREADY_EXISTS,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DB_TABLES_ALREADY_EXISTS,
+ false);
+ recreateTablesOnDeploy = IFieldEditorFactory.INSTANCE
+ .createCheckboxEditor(
+ ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_RECREATE_DATABASE_TABLES_AND_DATA_ON_DEPLOY,
+ false);
+ registerEditor(dbTablesExists, databaseGroup, 4);
+ registerEditor(recreateTablesOnDeploy, databaseGroup, 4);
+ databaseGroup.getParent().layout(true);
+ }
+
+ private void disposeControls(IFieldEditor editor){
+ if (editor != null){
+ Object[] controls = editor.getEditorControls();
+ for (int i = 0; i < controls.length; i++) {
+ Control control = (Control) controls[i];
+ if (!control.isDisposed()) control.dispose();
+ }
+ editor.dispose();
+ }
+ }
+
private boolean isNewSeamProjectWizard() {
return getWizard() == null || getWizard() instanceof SeamProjectWizard;
}
@@ -478,6 +565,8 @@
getTestPkgName(p));
}
}
+
+ private boolean needToShowConnectionProfile = true;
/**
* It is overridden to fill Code Generation group with the default package
@@ -489,6 +578,16 @@
if (visible) {
setCodeGenerationProperties();
setDefaultSeamRuntime();
+ boolean jpaFacetAdded = getJpaFacetVersion() != null;
+ if (jpaFacetAdded == needToShowConnectionProfile){
+
+ needToShowConnectionProfile = !jpaFacetAdded;
+ createDatabaseGoupControl();
+ }
+ //update selected connection profile
+ if (!needToShowConnectionProfile){
+ model.setStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE, getJpaConnectionProfile());
+ }
validate();
}
super.setVisible(visible);
15 years, 1 month
JBoss Tools SVN: r18693 - trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2009-11-16 08:45:01 -0500 (Mon, 16 Nov 2009)
New Revision: 18693
Removed:
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml-single-simple.xsl
Log:
https://jira.jboss.org/jira/browse/JBDS-348 - deleted as unused;
Deleted: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml-single-simple.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml-single-simple.xsl 2009-11-16 11:29:44 UTC (rev 18692)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml-single-simple.xsl 2009-11-16 13:45:01 UTC (rev 18693)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:import href="classpath:/xslt/org/jboss/xhtml-single.xsl"/>
- <xsl:import href="common.xsl"/>
- <xsl:param name="html.stylesheet" select="'css/tools_simple.css'"/>
-
-</xsl:stylesheet>
15 years, 1 month
JBoss Tools SVN: r18692 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test: resources/jsfTest/WebContent/pages/JBIDE/5193 and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-11-16 06:29:44 -0500 (Mon, 16 Nov 2009)
New Revision: 18692
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5193/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5193/JBIDE5193.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/NullPointerWithStyleProperty_JBIDE5193.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5193 JUnit was added.
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5193/JBIDE5193.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5193/JBIDE5193.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5193/JBIDE5193.jsp 2009-11-16 11:29:44 UTC (rev 18692)
@@ -0,0 +1,13 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+ <ul>
+ <li style="">Text</li>
+ </ul>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-11-16 09:47:40 UTC (rev 18691)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-11-16 11:29:44 UTC (rev 18692)
@@ -71,6 +71,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE924Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.MozDirtyTest_JBIDE5105;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.NullPointerWithStyleProperty_JBIDE5193;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.VpeI18nTest_JBIDE4887;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1467Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1501Test;
@@ -176,6 +177,7 @@
suite.addTestSuite(VPERefreshTest.class);
suite.addTestSuite(OpenOnInsideJspRoot_JBIDE4852.class);
suite.addTestSuite(EditingSPecialSymbolsVPE_JBIDE3810.class);
+ suite.addTestSuite(NullPointerWithStyleProperty_JBIDE5193.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/NullPointerWithStyleProperty_JBIDE5193.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/NullPointerWithStyleProperty_JBIDE5193.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/NullPointerWithStyleProperty_JBIDE5193.java 2009-11-16 11:29:44 UTC (rev 18692)
@@ -0,0 +1,49 @@
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+public class NullPointerWithStyleProperty_JBIDE5193 extends VpeTest {
+
+ private static final String TEST_PAGE_NAME = "JBIDE/5193/JBIDE5193.jsp"; //$NON-NLS-1$
+
+ public NullPointerWithStyleProperty_JBIDE5193(String name) {
+ super(name);
+ }
+
+ public void testNullPointerWithStyleProperty_JBIDE5193() throws Throwable {
+ TestUtil.waitForJobs();
+ setException(null);
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+
+ assertNotNull("Could not open specified file " + TEST_PAGE_NAME, file); //$NON-NLS-1$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ final JSPMultiPageEditor parts = openEditor(input);
+ TestUtil.waitForIdle();
+ assertNotNull(parts);
+ StyledText styledText = parts.getSourceEditor().getTextViewer()
+ .getTextWidget();
+ String delimiter = styledText.getLineDelimiter();
+ int offset = styledText.getOffsetAtLine(10);
+ styledText.setCaretOffset(offset-delimiter.length()-"\">Text</li>".length());
+ styledText.insert(":");
+
+ VpeController controller = TestUtil.getVpeController(parts);
+ controller.selectionChanged(new SelectionChangedEvent(parts.getSelectionProvider(), parts.getSelectionProvider().getSelection()));
+ }
+
+}
15 years, 1 month
JBoss Tools SVN: r18691 - workspace/yradtsevich/DnD/trunk/DndJsPrototype/WebContent.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-11-16 04:47:40 -0500 (Mon, 16 Nov 2009)
New Revision: 18691
Modified:
workspace/yradtsevich/DnD/trunk/DndJsPrototype/WebContent/index.html
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
- Minor fix: JavaScript prototype - unnecessary rectangle has been deleted.
Modified: workspace/yradtsevich/DnD/trunk/DndJsPrototype/WebContent/index.html
===================================================================
--- workspace/yradtsevich/DnD/trunk/DndJsPrototype/WebContent/index.html 2009-11-16 08:01:09 UTC (rev 18690)
+++ workspace/yradtsevich/DnD/trunk/DndJsPrototype/WebContent/index.html 2009-11-16 09:47:40 UTC (rev 18691)
@@ -23,13 +23,7 @@
</head>
<body style="margin-left: 25px; margin-top: 25px;">
<img id="dragIcon" src="dragIcon.gif" style="display:none; position: absolute; cursor: move; z-index: 10000"/>
- <div id="orect" style="position: absolute;
- background-color:rgba(255, 174, 185, 0.5);
- left : 400px;
- top : 100px;
- width : 200px;
- height : 100px;">
- </div>
+
<button>Non-draggable</button>
<button id="draggableButton">DRAG ME!</button><p/>
<table class="colory">
15 years, 1 month
JBoss Tools SVN: r18690 - in trunk/smooks: plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration and 15 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-11-16 03:01:09 -0500 (Mon, 16 Nov 2009)
New Revision: 18690
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
Log:
JBIDE-5195
Done
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
===================================================================
(Binary files differ)
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
===================================================================
(Binary files differ)
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -65,12 +65,18 @@
protected void initializeImageRegistry(ImageRegistry reg) {
super.initializeImageRegistry(reg);
// regist palette image
- reg.put(GraphicsConstants.IMAGE_LINK16, imageDescriptorFromPlugin(PLUGIN_ID,
- GraphicsConstants.IMAGE_LINK16));
- reg.put(GraphicsConstants.IMAGE_LINK24, imageDescriptorFromPlugin(PLUGIN_ID,
- GraphicsConstants.IMAGE_LINK24));
+ reg.put(GraphicsConstants.IMAGE_DRAG_LINK, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_DRAG_LINK));
+
+ reg.put(GraphicsConstants.IMAGE_LINK16, imageDescriptorFromPlugin(PLUGIN_ID, GraphicsConstants.IMAGE_LINK16));
+ reg.put(GraphicsConstants.IMAGE_LINK24, imageDescriptorFromPlugin(PLUGIN_ID, GraphicsConstants.IMAGE_LINK24));
+
// registe task image
+
+ reg.put(GraphicsConstants.IMAGE_ADD_TASK_BUTTON, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_ADD_TASK_BUTTON));
+
reg.put(GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK));
reg.put(GraphicsConstants.IMAGE_JAVA_AMPPING_TASK, imageDescriptorFromPlugin(PLUGIN_ID,
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -22,6 +22,10 @@
}
public static final String IMAGE_JAVA_AMPPING_TASK = "icons/full/obj32/java_mapping_task.jpg";
+
+ public static final String IMAGE_DRAG_LINK = "icons/full/obj16/drag_link.gif";
+
+ public static final String IMAGE_ADD_TASK_BUTTON = "icons/full/obj16/add_task_button.png";
public static final String IMAGE_LINK16 = "icons/full/obj16/connection16.gif";
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -2949,7 +2949,50 @@
}
return false;
}
+
+ public static boolean isCollectionJavaGraphModel(EObject parent){
+ String classString = null;
+ if (parent instanceof BeanType) {
+ classString = ((BeanType) parent).getClass_();
+ }
+ if (parent instanceof BindingsType) {
+ classString = ((BindingsType) parent).getClass_();
+ }
+ if (classString != null)
+ classString = classString.trim();
+ IJavaProject project = SmooksUIUtils.getJavaProject(parent);
+ if (project != null) {
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ Class<?> clazz = loader.loadClass(classString);
+ if (Collection.class.isAssignableFrom(clazz)) {
+ return true;
+ }
+ } catch (Throwable t) {
+
+ }
+ }
+
+ return false;
+ }
+
+ public static boolean isArrayJavaGraphModel(EObject parent){
+ String classString = null;
+ if (parent instanceof BeanType) {
+ classString = ((BeanType) parent).getClass_();
+ }
+ if (parent instanceof BindingsType) {
+ classString = ((BindingsType) parent).getClass_();
+ }
+ if (classString != null)
+ classString = classString.trim();
+ if (classString.endsWith("]")) {
+ return true;
+ }
+ return false;
+ }
+
public static EStructuralFeature getFeature(Object model) {
if (model instanceof BindingsType) {
return JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -11,13 +11,18 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.ConnectionDragCreationTool;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.tree.editpolicy.FigureHighlightEditPolicy;
import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeGraphicalNodeEditPolicy;
+import org.jboss.tools.smooks.gef.tree.figures.DragLinkFigure;
import org.jboss.tools.smooks.gef.tree.figures.IMoveableModel;
import org.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure;
import org.jboss.tools.smooks.gef.tree.figures.TreeFigureExpansionEvent;
@@ -40,8 +45,8 @@
protected IFigure createFigure() {
return new TreeContainerFigure((TreeContainerModel) getModel());
}
-
- protected String getLabelText(){
+
+ protected String getLabelText() {
TreeContainerModel model = (TreeContainerModel) getModel();
String text = model.getText();
return text;
@@ -53,7 +58,7 @@
if (text != null && model.isHeaderVisable() && getFigure() instanceof TreeContainerFigure) {
TreeContainerFigure figure = (TreeContainerFigure) getFigure();
Image i = model.getImage();
- if(i != null){
+ if (i != null) {
figure.setIcon(i);
}
figure.setText(text);
@@ -62,7 +67,8 @@
if (!isSource) {
IFigure figure = getFigure();
if (figure instanceof TreeContainerFigure) {
-// ((TreeContainerFigure) figure).setHeaderColor(ColorConstants.orange);
+ // ((TreeContainerFigure)
+ // figure).setHeaderColor(ColorConstants.orange);
}
}
Point location = model.getLocation();
@@ -103,11 +109,11 @@
DefaultEditDomain domain = (DefaultEditDomain) getViewer().getEditDomain();
IEditorPart editor = domain.getEditorPart();
ISmooksModelProvider modelProvider = (ISmooksModelProvider) editor.getAdapter(ISmooksModelProvider.class);
-
- if(modelProvider != null && getModel() instanceof IMoveableModel){
+
+ if (modelProvider != null && getModel() instanceof IMoveableModel) {
SmooksGraphicsExtType graph = modelProvider.getSmooksGraphicsExt();
- Rectangle rect = ((IMoveableModel)getModel()).getBounds();
- recordBounds(graph,rect);
+ Rectangle rect = ((IMoveableModel) getModel()).getBounds();
+ recordBounds(graph, rect);
}
}
}
@@ -118,6 +124,27 @@
this.installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new FigureHighlightEditPolicy());
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editparts.AbstractGraphicalEditPart#getDragTracker(org
+ * .eclipse.gef.Request)
+ */
+ public DragTracker getDragTracker(Request request) {
+ Object model = getModel();
+ if (model instanceof TreeContainerModel && request instanceof SelectionRequest) {
+ Point location = ((SelectionRequest)request).getLocation();
+ IFigure figure = getFigure();
+ IFigure figure1 = figure.findFigureAt(location);
+ if (figure1 instanceof DragLinkFigure && ((TreeContainerModel) model).canDragLink()) {
+ getViewer().select(this);
+ return new ConnectionDragCreationTool();
+ }
+ }
+ return super.getDragTracker(request);
+ }
+
// @Override
// public ConnectionAnchor getSourceConnectionAnchor(
// ConnectionEditPart connection) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -100,9 +100,6 @@
* .eclipse.gef.Request)
*/
public DragTracker getDragTracker(Request request) {
- // if(true){
- // return super.getDragTracker(request);
- // }
if (isDragLink()) {
getViewer().select(this);
return new ConnectionDragCreationTool();
@@ -404,11 +401,21 @@
}
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
- return new LeftOrRightAnchor(getAnchorFigure());
+ try {
+ return new LeftOrRightAnchor(getAnchorFigure());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- return new LeftOrRightAnchor(getAnchorFigure());
+ try {
+ return new LeftOrRightAnchor(getAnchorFigure());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.gef.tree.figures;
+
+import org.eclipse.draw2d.Figure;
+
+/**
+ * @author Dart
+ *
+ */
+public class DragLinkFigure extends Figure {
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -7,13 +7,18 @@
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.GridData;
+import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.MouseMotionListener;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.gef.tree.editpolicy.IShowHighlighFigure;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
@@ -44,13 +49,88 @@
private boolean showHightlight = false;
+ private IFigure dragLinkFigure = null;
+
+ private boolean showDragLink = false;
+
public TreeContainerFigure(TreeContainerModel model) {
super();
this.model = model;
this.addChildrenFigures();
+ hookFigure();
}
+ protected void hookFigure() {
+ this.addMouseMotionListener(new MouseMotionListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseDragged(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseDragged(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent me) {
+ showDragLink = true;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseExited(MouseEvent me) {
+ showDragLink = false;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseHover(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseHover(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseMoved(MouseEvent me) {
+
+ }
+
+ });
+ }
+
protected void addChildrenFigures() {
+
+ IFigure headerContainerFigure = new Figure();
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ headerContainerFigure.setLayoutManager(gl);
+
headerFigure = new Figure() {
@Override
@@ -66,10 +146,108 @@
return new Dimension(width, 25);
}
};
+ headerFigure.add(headerContainerFigure);
+
label = new Label();
- headerFigure.add(label);
+ headerContainerFigure.add(label);
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gl.setConstraint(label, gd);
+
+ dragLinkFigure = new DragLinkFigure() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics
+ * )
+ */
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (showDragLink) {
+ if (model instanceof TreeContainerModel) {
+ if (!((TreeContainerModel) model).canDragLink()) {
+ return;
+ }
+ }
+ Image img = SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_DRAG_LINK);
+ if (img != null) {
+ graphics.drawImage(img, getLocation());
+ }
+ }
+ }
+ };
+ dragLinkFigure.addMouseMotionListener(new MouseMotionListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseDragged(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseDragged(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent me) {
+ showDragLink = true;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseExited(MouseEvent me) {
+ showDragLink = false;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseHover(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseHover(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseMoved(MouseEvent me) {
+
+ }
+
+ });
+ dragLinkFigure.setSize(16, 16);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ gl.setConstraint(dragLinkFigure, gd);
+
+ headerContainerFigure.add(dragLinkFigure);
+
headerFigure.setLayoutManager(layout);
headerFigure.setOpaque(true);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -14,6 +14,7 @@
private boolean headerVisable = false;
private Point location = new Point(0, 0);
+
public TreeContainerModel(Object data,
ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
@@ -27,6 +28,10 @@
public void setSourceLinkNode(boolean sourceLinkNode) {
this.sourceLinkNode = sourceLinkNode;
}
+
+ public boolean canDragLink(){
+ return false;
+ }
public Point getLocation() {
return location;
@@ -39,6 +44,7 @@
support.firePropertyChange(IMoveableModel.PRO_BOUNDS_CHANGED, oldLocation, this.location);
}
}
+
public Rectangle getBounds() {
return new Rectangle(getLocation(),new Dimension(0,0));
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -14,6 +14,7 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.CreateRequest;
@@ -21,15 +22,14 @@
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart;
/**
* @author Dart
- *
+ *
*/
public abstract class AddSmooksModelAction extends SelectionAction {
-
-
-
+
public AddSmooksModelAction(IWorkbenchPart part, int style) {
super(part, style);
// TODO Auto-generated constructor stub
@@ -53,30 +53,41 @@
return cmd.canExecute();
}
- protected Command createAddChildNodeCommand(List<?> objects){
+ protected Command createAddChildNodeCommand(List<?> objects) {
if (objects.isEmpty())
return null;
if (!(objects.get(0) instanceof EditPart))
return null;
- CreateRequest addReq = new CreateRequest();
- addReq.setLocation(new Point(0,0));
+ CreateRequest addReq = new CreateRequest();
+ Point location = new Point(0, 0);
+ if (this.getWorkbenchPart() != null) {
+ IWorkbenchPart part = this.getWorkbenchPart();
+ org.eclipse.swt.graphics.Point mouseLocation = part.getSite().getShell().getDisplay().getCursorLocation();
+ if (part instanceof SmooksGraphicalEditorPart) {
+ GraphicalViewer viewer = ((SmooksGraphicalEditorPart) part).getGraphicalViewer();
+ mouseLocation = viewer.getControl().toControl(mouseLocation);
+ }
+ location = new Point(mouseLocation.x, mouseLocation.y);
+ }
+ addReq.setLocation(location);
addReq.setFactory(getCreationFactory());
- CompoundCommand compoundCmd = new CompoundCommand("Add Child Node");
+ CompoundCommand compoundCmd = new CompoundCommand("Add " + getActionText());
for (int i = 0; i < objects.size(); i++) {
EditPart object = (EditPart) objects.get(i);
Command cmd = object.getCommand(addReq);
- if (cmd != null) compoundCmd.add(cmd);
+ if (cmd != null)
+ compoundCmd.add(cmd);
}
return compoundCmd;
}
-
+
public abstract String getActionText();
-
-// public abstract Imag
+ // public abstract Imag
+
/*
* (non-Javadoc)
*
@@ -84,9 +95,13 @@
*/
@Override
public void run() {
- execute(createAddChildNodeCommand(getSelectedObjects()));
+ try {
+ execute(createAddChildNodeCommand(getSelectedObjects()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
/*
* (non-Javadoc)
*
@@ -98,10 +113,10 @@
this.setText(getActionText());
this.setImageDescriptor(getActionImageDescriptor());
}
-
+
protected abstract CreationFactory getCreationFactory();
- public abstract ImageDescriptor getActionImageDescriptor() ;
+ public abstract ImageDescriptor getActionImageDescriptor();
/*
* (non-Javadoc)
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.actions;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.configuration.SmooksConstants;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+
+/**
+ * @author Dart
+ *
+ */
+public abstract class AddSmooksObjectAction extends AddSmooksModelAction {
+
+ private ISmooksModelProvider provider;
+
+ public AddSmooksObjectAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style);
+ this.provider = provider;
+ this.setText(getActionText());
+ this.setImageDescriptor(getActionImageDescriptor());
+ }
+
+ public AddSmooksObjectAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part);
+ this.provider = provider;
+ this.setText(getActionText());
+ this.setImageDescriptor(getActionImageDescriptor());
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#init()
+ */
+ @Override
+ protected void init() {
+
+ }
+
+ /**
+ * @return the provider
+ */
+ protected ISmooksModelProvider getProvider() {
+ return provider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#
+ * getActionImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getActionImageDescriptor() {
+ Object object = getNewObject();
+ if(object == null) return null;
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ AdapterFactoryEditingDomain editDomain = (AdapterFactoryEditingDomain) provider.getEditingDomain();
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) editDomain.getAdapterFactory().adapt(object,
+ IItemLabelProvider.class);
+ ImageDescriptor smallImage = null;
+ if (itemLabelProvider != null) {
+ Object imageObj = itemLabelProvider.getImage(object);
+ smallImage = ExtendedImageRegistry.getInstance().getImageDescriptor(imageObj);
+ }
+ return smallImage;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#getActionText
+ * ()
+ */
+ @Override
+ public String getActionText() {
+ Object object = getNewObject();
+ if(object == null) return "";
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ AdapterFactoryEditingDomain editDomain = (AdapterFactoryEditingDomain) provider.getEditingDomain();
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) editDomain.getAdapterFactory().adapt(object,
+ IItemLabelProvider.class);
+ if (itemLabelProvider != null) {
+ return itemLabelProvider.getText(object);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#
+ * getCreationFactory()
+ */
+ @Override
+ protected CreationFactory getCreationFactory() {
+ return new SmooksObjectCreationFactory(getNewObject(), getNewType());
+ }
+
+ protected abstract Object getSmooks11Object();
+
+ protected abstract Object getSmooks12Object();
+
+ protected abstract Object getSmooks11Type();
+
+ protected abstract Object getSmooks12Type();
+
+ protected Object getNewObject() {
+ SmooksGraphicsExtType ext = this.getProvider().getSmooksGraphicsExt();
+ if (ext == null)
+ return null;
+ String version = ext.getPlatformVersion();
+ if (SmooksConstants.VERSION_1_1.equals(version)) {
+ return getSmooks11Object();
+ }
+ if (SmooksConstants.VERSION_1_2.equals(version)) {
+ return getSmooks12Object();
+ }
+ return null;
+ }
+
+ protected Object getNewType() {
+ SmooksGraphicsExtType ext = this.getProvider().getSmooksGraphicsExt();
+ if (ext == null)
+ return null;
+ String version = ext.getPlatformVersion();
+ if (SmooksConstants.VERSION_1_1.equals(version)) {
+ return getSmooks11Type();
+ }
+ if (SmooksConstants.VERSION_1_2.equals(version)) {
+ return getSmooks12Type();
+ }
+ return null;
+ }
+
+ private class SmooksObjectCreationFactory implements CreationFactory {
+ private Object newObject;
+
+ private Object objectType;
+
+ public SmooksObjectCreationFactory(Object newObject, Object objectType) {
+ this.newObject = newObject;
+ this.objectType = objectType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.requests.CreationFactory#getNewObject()
+ */
+ public Object getNewObject() {
+ // TODO Auto-generated method stub
+ return newObject;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.requests.CreationFactory#getObjectType()
+ */
+ public Object getObjectType() {
+ // TODO Auto-generated method stub
+ return objectType;
+ }
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -50,6 +50,13 @@
@Override
public void update() {
List<TaskType> taskList = this.getCurrentSelectedTask();
+ if(!taskList.isEmpty() && taskList.size() == 1){
+ TaskType task = taskList.get(0);
+ if(TaskTypeManager.TASK_ID_INPUT.equals(task.getId())){
+ this.setEnabled(false);
+ return;
+ }
+ }
this.setEnabled((taskList != null && !taskList.isEmpty() && taskList.size() == 1));
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -91,7 +91,7 @@
protected void createActions() {
super.createActions();
FreemarkerActionCreator creator = new FreemarkerActionCreator();
- creator.registXSLActions(getActionRegistry(), getSelectionActions(), this);
+ creator.registXSLActions(getActionRegistry(), getSelectionActions(), this, this.smooksModelProvider);
}
/*
@@ -100,7 +100,6 @@
* @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
* getPaletteRoot()
*/
- @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain) this.smooksModelProvider.getEditingDomain(),
@@ -232,7 +231,8 @@
((TreeContainerModel) graphModel).setHeaderVisable(true);
}
if (model instanceof BindingsType || model instanceof BeanType) {
- graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider, provider);
+ graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider, provider,
+ SmooksFreemarkerTemplateGraphicalEditor.this);
((JavaBeanGraphModel) graphModel).setHeaderVisable(true);
}
if (graphModel != null) {
@@ -260,40 +260,14 @@
/*
* (non-Javadoc)
*
- * @see
- * org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#canDelete
- * (org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel)
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * createInputDataGraphModel()
*/
@Override
- public boolean canDelete(AbstractSmooksGraphicalModel graphModel) {
- return super.canDelete(graphModel);
- }
-
-
-
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#createInputDataGraphModel()
- */
- @Override
protected List<AbstractSmooksGraphicalModel> createInputDataGraphModel() {
return Collections.emptyList();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#canLink
- * (org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel)
- */
- @Override
- public boolean canLink(AbstractSmooksGraphicalModel graphModel) {
- if (graphModel instanceof JavaBeanGraphModel) {
- return true;
- }
- return super.canLink(graphModel);
- }
-
private class FreemarkerTemplateEditFactory extends SmooksEditFactory {
/*
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -41,15 +41,14 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.commands.CommandStackEvent;
import org.eclipse.gef.commands.CommandStackEventListener;
-import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
import org.eclipse.gef.dnd.TemplateTransferDropTargetListener;
import org.eclipse.gef.editparts.FreeformGraphicalRootEditPart;
-import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.util.TransferDropTargetListener;
@@ -110,7 +109,7 @@
* @author Dart
*
*/
-public class SmooksGraphicalEditorPart extends GraphicalEditorWithPalette implements ISelectionChangedListener,
+public class SmooksGraphicalEditorPart extends GraphicalEditor implements ISelectionChangedListener,
ISourceSynchronizeListener, ISmooksGraphChangeListener, IGraphicalEditorPart {
public static final int EXECUTE_COMMAND = 0;
@@ -172,6 +171,7 @@
this.smooksModelProvider = provider;
this.setEditDomain(editDomain);
}
+
@Override
public void createPartControl(Composite parent) {
@@ -192,6 +192,10 @@
super.createPartControl(parent);
}
+
+ public GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
private void handleCommandStack(org.eclipse.emf.common.command.CommandStack commandStack) {
commandStack.addCommandStackListener(new org.eclipse.emf.common.command.CommandStackListener() {
@@ -581,11 +585,11 @@
return editDomain;
}
- @Override
- protected void configurePaletteViewer() {
- super.configurePaletteViewer();
- getPaletteViewer().addDragSourceListener(new TemplateTransferDragSourceListener(getPaletteViewer()));
- }
+// @Override
+// protected void configurePaletteViewer() {
+// super.configurePaletteViewer();
+// getPaletteViewer().addDragSourceListener(new TemplateTransferDragSourceListener(getPaletteViewer()));
+// }
protected EditPartFactory createEdtiPartFactory() {
return new SmooksEditFactory();
@@ -1169,13 +1173,13 @@
initGraphicalModel();
}
- @Override
- protected PaletteRoot getPaletteRoot() {
- SmooksGraphicalEditorPaletteRootCreator creator = new SmooksGraphicalEditorPaletteRootCreator(
- this.smooksModelProvider, (AdapterFactoryEditingDomain) this.smooksModelProvider.getEditingDomain(),
- getSmooksResourceListType());
- return creator.createPaletteRoot();
- }
+// @Override
+// protected PaletteRoot getPaletteRoot() {
+// SmooksGraphicalEditorPaletteRootCreator creator = new SmooksGraphicalEditorPaletteRootCreator(
+// this.smooksModelProvider, (AdapterFactoryEditingDomain) this.smooksModelProvider.getEditingDomain(),
+// getSmooksResourceListType());
+// return creator.createPaletteRoot();
+// }
public SmooksResourceListType getSmooksResourceListType() {
if (smooksModelProvider != null) {
@@ -1235,12 +1239,4 @@
public String getID() {
return null;
}
-
- public boolean canDelete(AbstractSmooksGraphicalModel graphModel) {
- return true;
- }
-
- public boolean canLink(AbstractSmooksGraphicalModel graphModel) {
- return false;
- }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -24,6 +24,7 @@
import org.jboss.tools.smooks.graphical.editors.autolayout.IAutoLayout;
import org.jboss.tools.smooks.graphical.editors.autolayout.JavaMappingAutoLayout;
import org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaBeanGraphModel;
+import org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaMappingActionCreator;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.ExpressionType;
import org.jboss.tools.smooks.model.javabean.ValueType;
@@ -43,41 +44,48 @@
// TODO Auto-generated constructor stub
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getPaletteRoot()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * getPaletteRoot()
*/
- @Override
+ // @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain) this.smooksModelProvider.getEditingDomain(),
- getSmooksResourceListType()){
+ getSmooksResourceListType()) {
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPaletteRootCreator#fillActionGrouper(java.util.List)
- */
- @Override
- protected void fillActionGrouper(List<ISmooksActionGrouper> grouperList) {
- grouperList.add(new JavaBean11ActionGrouper());
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.
+ * SmooksGraphicalEditorPaletteRootCreator
+ * #fillActionGrouper(java.util.List)
+ */
+ @Override
+ protected void fillActionGrouper(List<ISmooksActionGrouper> grouperList) {
+ grouperList.add(new JavaBean11ActionGrouper());
+ }
+
};
return creator.createPaletteRoot();
}
-
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getAutoLayout()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * getAutoLayout()
*/
@Override
public IAutoLayout getAutoLayout() {
- if(javaMappingAutoLayout == null){
+ if (javaMappingAutoLayout == null) {
javaMappingAutoLayout = new JavaMappingAutoLayout();
}
return javaMappingAutoLayout;
}
-
-
/*
* (non-Javadoc)
*
@@ -100,6 +108,19 @@
return new JavaMappingGraphicalModelFactory();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * createActions()
+ */
+ @Override
+ protected void createActions() {
+ super.createActions();
+ JavaMappingActionCreator creator = new JavaMappingActionCreator();
+ creator.registXSLActions(getActionRegistry(), getSelectionActions(), this, this.getSmooksModelProvider());
+ }
+
private class JavaMappingConnectionModelFactory extends ConnectionModelFactoryImpl {
/*
@@ -199,7 +220,8 @@
ILabelProvider labelProvider = createLabelProvider(editingDomain.getAdapterFactory());
if (model instanceof BindingsType || model instanceof BeanType) {
- graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider, provider);
+ graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider, provider,
+ SmooksJavaMappingGraphicalEditor.this);
((JavaBeanGraphModel) graphModel).setHeaderVisable(true);
}
// if (model instanceof Xsl) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -33,22 +33,17 @@
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
@@ -74,8 +69,9 @@
import org.eclipse.ui.forms.widgets.ScrolledPageBook;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.zest.core.viewers.GraphViewer;
+import org.eclipse.zest.core.widgets.CGraphNode;
import org.eclipse.zest.core.widgets.Graph;
-import org.eclipse.zest.core.widgets.GraphNode;
+import org.eclipse.zest.core.widgets.GraphItem;
import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm;
@@ -84,14 +80,11 @@
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.editor.ISourceSynchronizeListener;
import org.jboss.tools.smooks.graphical.actions.AbstractProcessGraphAction;
-import org.jboss.tools.smooks.graphical.actions.AddInputTaskAction;
import org.jboss.tools.smooks.graphical.actions.AddNextTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.AddPreviousTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.AddTaskNodeAction;
import org.jboss.tools.smooks.graphical.actions.DeleteTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.TaskTypeRules;
import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
-import org.jboss.tools.smooks.model.graphics.ext.GraphFactory;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessGraphicalViewerLabelProvider;
+import org.jboss.tools.smooks.graphical.editors.process.TaskNodeFigure;
import org.jboss.tools.smooks.model.graphics.ext.ISmooksGraphChangeListener;
import org.jboss.tools.smooks.model.graphics.ext.ProcessType;
import org.jboss.tools.smooks.model.graphics.ext.ProcessesType;
@@ -124,6 +117,10 @@
private Map<String, Object> registedTaskPages = new HashMap<String, Object>();
+ private MenuManager manager;
+
+ protected boolean needupdatewhenshow = true;
+
public SmooksProcessGraphicalEditor(FormEditor editor, String id, String title, ISmooksModelProvider provider) {
super(editor, id, title);
this.smooksModelProvider = provider;
@@ -156,43 +153,9 @@
});
// GridData gd = new GridData(GridData.FILL_BOTH);
// processGraphViewer.getControl().setLayoutData(gd);
- processGraphViewer.setNodeStyle(ZestStyles.NODES_FISHEYE);
+ // processGraphViewer.setNodeStyle(ZestStyles.NODES_FISHEYE);
processGraphViewer.setContentProvider(new ProcessGraphContentProvider());
- processGraphViewer.setLabelProvider(new LabelProvider() {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof TaskType) {
- String id = ((TaskType) element).getId();
- List<TaskTypeDescriptor> des = TaskTypeManager.getAllTaskList();
- for (Iterator<?> iterator = des.iterator(); iterator.hasNext();) {
- TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
- if (taskTypeDescriptor.getId().equals(id)) {
- return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
- taskTypeDescriptor.getImagePath());
- }
- }
- }
- return super.getImage(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof TaskType) {
- String id = ((TaskType) element).getId();
- String name = ((TaskType) element).getName();
- if (name == null) {
- name = id;
- }
- if (name == null) {
- name = "null";
- }
- return name;
- }
- return "";
- }
-
- });
+ processGraphViewer.setLabelProvider(new ProcessGraphicalViewerLabelProvider(this));
processGraphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
HorizontalTreeLayoutAlgorithm layoutAlgorithm = new HorizontalTreeLayoutAlgorithm(
LayoutStyles.NO_LAYOUT_NODE_RESIZING);
@@ -230,112 +193,165 @@
}
protected void hookProcessGraphicalViewer() {
+ // final DropTarget dropTarge = new
+ // DropTarget(getProcessGraphViewer().getControl(), DND.DROP_MOVE |
+ // DND.DROP_COPY);
+ // dropTarge.setTransfer(new Transfer[] { TemplateTransfer.getInstance()
+ // });
+ // dropTarge.addDropListener(new DropTargetListener() {
+ // private TaskType taskType = null;
+ //
+ // private ProcessType process = null;
+ //
+ // public void dropAccept(DropTargetEvent event) {
+ //
+ // }
+ //
+ // public void drop(DropTargetEvent event) {
+ // if (event.detail == DND.DROP_COPY) {
+ // if (this.taskType != null) {
+ // TaskTypeDescriptor des = (TaskTypeDescriptor)
+ // TemplateTransfer.getInstance().getTemplate();
+ // AddNextTaskNodeAction action = new AddNextTaskNodeAction(des.getId(),
+ // des.getLabel(),
+ // smooksModelProvider);
+ // TaskType taskType = this.taskType;
+ // IStructuredSelection selection = new StructuredSelection(taskType);
+ // action.selectionChanged(new
+ // SelectionChangedEvent(getProcessGraphViewer(), selection));
+ // action.run();
+ // return;
+ // }
+ // if (this.process != null) {
+ // AddNextTaskNodeAction action = new
+ // AddInputTaskAction(smooksModelProvider);
+ // // IStructuredSelection selection = new
+ // // StructuredSelection(taskType);
+ // // action.selectionChanged(new
+ // // SelectionChangedEvent(getProcessGraphViewer(),
+ // // selection));
+ // action.run();
+ // return;
+ // }
+ // }
+ // }
+ //
+ // public void dragOver(DropTargetEvent event) {
+ // Control control = getProcessGraphViewer().getControl();
+ // if (control != null && control instanceof Graph) {
+ // Graph graph = (Graph) control;
+ // Point pp = graph.toControl(new Point(event.x, event.y));
+ // TaskTypeDescriptor des = (TaskTypeDescriptor)
+ // TemplateTransfer.getInstance().getTemplate();
+ // TaskType testType = GraphFactory.eINSTANCE.createTaskType();
+ // testType.setId(des.getId());
+ // IFigure figure = graph.getFigureAt(pp.x, pp.y);
+ // if (figure == null) {
+ // if (testType.getId().equals(TaskTypeManager.TASK_ID_INPUT)) {
+ // ProcessType process = (ProcessType)
+ // getProcessGraphViewer().getInput();
+ // if (process.getTask().isEmpty()) {
+ // event.detail = DND.DROP_COPY;
+ // this.process = process;
+ // return;
+ // }
+ // }
+ // event.detail = DND.DROP_NONE;
+ // this.taskType = null;
+ // process = null;
+ // return;
+ // }
+ // List<?> nodes = graph.getNodes();
+ // for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ // Object object = (Object) iterator.next();
+ // if (object instanceof GraphNode) {
+ // IFigure f = ((GraphNode) object).getNodeFigure();
+ // if (figure == f) {
+ // TaskTypeRules rules = new TaskTypeRules();
+ // if (rules.isNextTask((TaskType) ((GraphNode) object).getData(),
+ // testType)) {
+ // event.detail = DND.DROP_COPY;
+ // this.taskType = (TaskType) ((GraphNode) object).getData();
+ // return;
+ // }
+ // }
+ // }
+ // }
+ // event.detail = DND.DROP_NONE;
+ // this.taskType = null;
+ // this.process = null;
+ // }
+ // }
+ //
+ // public void dragOperationChanged(DropTargetEvent event) {
+ // }
+ //
+ // public void dragLeave(DropTargetEvent event) {
+ // }
+ //
+ // public void dragEnter(DropTargetEvent event) {
+ // event.detail = DND.DROP_MOVE;
+ // this.taskType = null;
+ // process = null;
+ // }
+ // });
+ getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- getProcessGraphViewer().getControl();
- final DropTarget dropTarge = new DropTarget(getProcessGraphViewer().getControl(), DND.DROP_MOVE | DND.DROP_COPY);
- dropTarge.setTransfer(new Transfer[] { TemplateTransfer.getInstance() });
- dropTarge.addDropListener(new DropTargetListener() {
- private TaskType taskType = null;
-
- private ProcessType process = null;
-
- public void dropAccept(DropTargetEvent event) {
-
- }
-
- public void drop(DropTargetEvent event) {
- if (event.detail == DND.DROP_COPY) {
- if (this.taskType != null) {
- TaskTypeDescriptor des = (TaskTypeDescriptor) TemplateTransfer.getInstance().getTemplate();
- AddNextTaskNodeAction action = new AddNextTaskNodeAction(des.getId(), des.getLabel(),
- smooksModelProvider);
- TaskType taskType = this.taskType;
- IStructuredSelection selection = new StructuredSelection(taskType);
- action.selectionChanged(new SelectionChangedEvent(getProcessGraphViewer(), selection));
- action.run();
- return;
- }
- if (this.process != null) {
- AddNextTaskNodeAction action = new AddInputTaskAction(smooksModelProvider);
- // IStructuredSelection selection = new
- // StructuredSelection(taskType);
- // action.selectionChanged(new
- // SelectionChangedEvent(getProcessGraphViewer(),
- // selection));
- action.run();
- return;
- }
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object firstElement = selection.getFirstElement();
+ if (firstElement == null) {
+ unhighlightGraphNodes();
}
- }
-
- public void dragOver(DropTargetEvent event) {
- Control control = getProcessGraphViewer().getControl();
- if (control != null && control instanceof Graph) {
- Graph graph = (Graph) control;
- Point pp = graph.toControl(new Point(event.x, event.y));
- TaskTypeDescriptor des = (TaskTypeDescriptor) TemplateTransfer.getInstance().getTemplate();
- TaskType testType = GraphFactory.eINSTANCE.createTaskType();
- testType.setId(des.getId());
- IFigure figure = graph.getFigureAt(pp.x, pp.y);
- if (figure == null) {
- if (testType.getId().equals(TaskTypeManager.TASK_ID_INPUT)) {
- ProcessType process = (ProcessType) getProcessGraphViewer().getInput();
- if (process.getTask().isEmpty()) {
- event.detail = DND.DROP_COPY;
- this.process = process;
- return;
- }
- }
- event.detail = DND.DROP_NONE;
- this.taskType = null;
- process = null;
- return;
+ Graph graph = getProcessGraphViewer().getGraphControl();
+ List<?> nodes = graph.getNodes();
+ GraphItem item = null;
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ GraphItem graphItem = (GraphItem) iterator.next();
+ if (graphItem.getData() == firstElement) {
+ item = graphItem;
+ break;
}
- List<?> nodes = graph.getNodes();
- for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
- Object object = (Object) iterator.next();
- if (object instanceof GraphNode) {
- IFigure f = ((GraphNode) object).getNodeFigure();
- if (figure == f) {
- TaskTypeRules rules = new TaskTypeRules();
- if (rules.isNextTask((TaskType) ((GraphNode) object).getData(), testType)) {
- event.detail = DND.DROP_COPY;
- this.taskType = (TaskType) ((GraphNode) object).getData();
- return;
- }
- }
- }
- }
- event.detail = DND.DROP_NONE;
- this.taskType = null;
- this.process = null;
}
+ if (item != null) {
+ unhighlightGraphNodes();
+ highlightGraphNode(item);
+ }
+ showTaskControl(firstElement);
}
+ });
+ }
- public void dragOperationChanged(DropTargetEvent event) {
- }
+ protected void unhighlightGraphNodes() {
- public void dragLeave(DropTargetEvent event) {
- }
+ Graph graph = this.getProcessGraphViewer().getGraphControl();
+ List<?> elements = graph.getNodes();
+ for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();) {
+ GraphItem graphItem = (GraphItem) iterator.next();
+ unhighlightGraphNode(graphItem);
+ }
+ }
- public void dragEnter(DropTargetEvent event) {
- event.detail = DND.DROP_MOVE;
- this.taskType = null;
- process = null;
+ protected void unhighlightGraphNode(GraphItem item) {
+ if (item instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) item).getFigure();
+ if (figure instanceof TaskNodeFigure) {
+ ((TaskNodeFigure) figure).unhighlightLabel();
}
- });
- getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ }
+ }
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object firstElement = selection.getFirstElement();
- showTaskControl(firstElement);
+ protected void highlightGraphNode(GraphItem item) {
+ if (item instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) item).getFigure();
+ if (figure instanceof TaskNodeFigure) {
+ ((TaskNodeFigure) figure).highlightLabel(org.eclipse.draw2d.ColorConstants.darkBlue);
}
- });
+ }
}
protected void configProcessGraphicalViewer() {
- MenuManager manager = new MenuManager();
+ manager = new MenuManager();
initProcessGraphicalPanelActions(manager);
@@ -344,34 +360,87 @@
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
- for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
- IAction a = (IAction) iterator.next();
- if (a instanceof AbstractProcessGraphAction) {
- ((AbstractProcessGraphAction) a).selectionChanged(new SelectionChangedEvent(processGraphViewer,
- processGraphViewer.getSelection()));
+ manager.removeAll();
+ if (needupdatewhenshow) {
+ updateProcessActions(processGraphViewer.getSelection());
+ fillProcessMenu(manager);
+ } else {
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ if (action.isEnabled() && !(action instanceof DeleteTaskNodeAction)) {
+ manager.add(action);
+ }
}
}
- manager.update();
+ needupdatewhenshow = true;
}
});
}
+ public void fillProcessMenu(IMenuManager manager) {
+ MenuManager addNextTaskMenuManager = new MenuManager("Add Task");
+ manager.add(addNextTaskMenuManager);
+
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ if (action instanceof DeleteTaskNodeAction) {
+ manager.add(action);
+ } else {
+ addNextTaskMenuManager.add(action);
+ }
+ }
+
+ // MenuManager addPreTaskMenuManager = new
+ // MenuManager("Add Previous Task");
+ // manager.add(addPreTaskMenuManager);
+ //
+ // fillPreTaskMenu(addPreTaskMenuManager);
+ }
+
+ /**
+ * @return the needupdatewhenshow
+ */
+ public boolean isNeedupdatewhenshow() {
+ return needupdatewhenshow;
+ }
+
+ /**
+ * @param needupdatewhenshow
+ * the needupdatewhenshow to set
+ */
+ public void setNeedupdatewhenshow(boolean needupdatewhenshow) {
+ this.needupdatewhenshow = needupdatewhenshow;
+ }
+
+ public void updateProcessActions(ISelection selection) {
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction a = (IAction) iterator.next();
+ if (a instanceof AbstractProcessGraphAction) {
+ ((AbstractProcessGraphAction) a).selectionChanged(new SelectionChangedEvent(processGraphViewer,
+ selection));
+ }
+ }
+ manager.update();
+ }
+
protected void initProcessGraphicalPanelActions(IMenuManager manager) {
- AddTaskNodeAction addInputTaskAction = new AddInputTaskAction(smooksModelProvider);
- manager.add(addInputTaskAction);
- processPanelActions.add(addInputTaskAction);
+ // AddTaskNodeAction addInputTaskAction = new
+ // AddInputTaskAction(smooksModelProvider);
+ // manager.add(addInputTaskAction);
+ // processPanelActions.add(addInputTaskAction);
- MenuManager addNextTaskMenuManager = new MenuManager("Add Next Task");
+ MenuManager addNextTaskMenuManager = new MenuManager("Add Task");
manager.add(addNextTaskMenuManager);
- fillNextTaskMenu(addNextTaskMenuManager);
+ generateNextTaskActions(addNextTaskMenuManager);
- MenuManager addPreTaskMenuManager = new MenuManager("Add Previous Task");
- manager.add(addPreTaskMenuManager);
+ // MenuManager addPreTaskMenuManager = new
+ // MenuManager("Add Previous Task");
+ // manager.add(addPreTaskMenuManager);
+ //
+ // fillPreTaskMenu(addPreTaskMenuManager);
- fillPreTaskMenu(addPreTaskMenuManager);
-
DeleteTaskNodeAction deleteAction = new DeleteTaskNodeAction(smooksModelProvider);
manager.add(deleteAction);
@@ -379,7 +448,7 @@
}
- private void fillNextTaskMenu(MenuManager addNextTaskMenuManager) {
+ private void generateNextTaskActions(MenuManager addNextTaskMenuManager) {
List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
@@ -390,16 +459,18 @@
}
}
- private void fillPreTaskMenu(MenuManager addPreTaskMenuManager) {
- List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
- for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
- TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
- AddPreviousTaskNodeAction addNextInputAction = new AddPreviousTaskNodeAction(taskTypeDescriptor.getId(),
- taskTypeDescriptor.getLabel(), smooksModelProvider);
- this.processPanelActions.add(addNextInputAction);
- addPreTaskMenuManager.add(addNextInputAction);
- }
- }
+ // private void fillPreTaskMenu(MenuManager addPreTaskMenuManager) {
+ // List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
+ // for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ // TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor)
+ // iterator.next();
+ // AddPreviousTaskNodeAction addNextInputAction = new
+ // AddPreviousTaskNodeAction(taskTypeDescriptor.getId(),
+ // taskTypeDescriptor.getLabel(), smooksModelProvider);
+ // this.processPanelActions.add(addNextInputAction);
+ // addPreTaskMenuManager.add(addNextInputAction);
+ // }
+ // }
public void registeTaskDetailsPage(IEditorPart editor, String taskID) {
editor.addPropertyListener(this);
@@ -437,17 +508,20 @@
processGraphSection.setClient(processGraphComposite);
- Composite toolBarComposite = toolkit.createComposite(processGraphComposite);
- FillLayout l = new FillLayout();
- l.marginHeight = 1;
- l.marginWidth = 1;
- toolBarComposite.setLayout(l);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- toolBarComposite.setLayoutData(gd);
- toolBarComposite.setBackground(toolkit.getColors().getBorderColor());
+ // Composite toolBarComposite =
+ // toolkit.createComposite(processGraphComposite);
+ // FillLayout l = new FillLayout();
+ // l.marginHeight = 1;
+ // l.marginWidth = 1;
+ // toolBarComposite.setLayout(l);
- createProcessToolBar(toolBarComposite, toolkit);
+ // toolBarComposite.setLayoutData(gd);
+ //
+ // toolBarComposite.setBackground(toolkit.getColors().getBorderColor());
+ //
+ // createProcessToolBar(toolBarComposite, toolkit);
Composite graphMainComposite = toolkit.createComposite(processGraphComposite);
FillLayout l1 = new FillLayout();
@@ -698,9 +772,11 @@
SmooksFreemarkerTemplateGraphicalEditor freemarkerPart = new SmooksFreemarkerTemplateGraphicalEditor(
smooksModelProvider);
this.registeTaskDetailsPage(freemarkerPart, TaskTypeManager.TASK_ID_FREEMARKER_TEMPLATE);
-
- SmooksXSLTemplateGraphicalEditor xsltemplatePart = new SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
- this.registeTaskDetailsPage(xsltemplatePart, TaskTypeManager.TASK_ID_XSL_TEMPLATE);
+
+ // SmooksXSLTemplateGraphicalEditor xsltemplatePart = new
+ // SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
+ // this.registeTaskDetailsPage(xsltemplatePart,
+ // TaskTypeManager.TASK_ID_XSL_TEMPLATE);
}
@Override
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -72,7 +72,7 @@
/* (non-Javadoc)
* @see org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getPaletteRoot()
*/
- @Override
+// @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain) this.smooksModelProvider.getEditingDomain(),
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -94,9 +94,12 @@
});
this.installEditPolicy(EditPolicy.CONTAINER_ROLE, new FlowLayoutEditPolicy() {
-
- /* (non-Javadoc)
- * @see org.eclipse.gef.editpolicies.FlowLayoutEditPolicy#isHorizontal()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.FlowLayoutEditPolicy#isHorizontal()
*/
@Override
protected boolean isHorizontal() {
@@ -174,6 +177,8 @@
}
org.eclipse.emf.common.command.Command emfCommand = createModelCreationEMFCommand(domain,
((AbstractResourceConfigGraphModel) graphModel).getData(), type, model);
+ if (emfCommand == null || !emfCommand.canExecute())
+ return null;
return createModelCreationCommand(domain, emfCommand);
}
return null;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -14,7 +14,6 @@
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -15,11 +15,17 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
+import org.jboss.tools.smooks.gef.tree.command.GEFAdapterCommand;
import org.jboss.tools.smooks.graphical.editors.IGraphicalEditorPart;
import org.jboss.tools.smooks.graphical.editors.SmooksFreemarkerTemplateGraphicalEditor;
import org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigChildNodeEditPart;
+import org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaBeanChildGraphModel;
import org.jboss.tools.smooks.model.javabean.ExpressionType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
import org.jboss.tools.smooks.model.javabean.ValueType;
@@ -28,70 +34,138 @@
/**
* @author Dart
- *
+ *
*/
public class JavaBeanChildNodeEditPart extends AbstractResourceConfigChildNodeEditPart {
private List<Object> supportTypes = new ArrayList<Object>();
-
-
-
+
public JavaBeanChildNodeEditPart() {
super();
supportTypes.add(ValueType.class);
supportTypes.add(ExpressionType.class);
supportTypes.add(WiringType.class);
-
+
supportTypes.add(org.jboss.tools.smooks.model.javabean12.ValueType.class);
supportTypes.add(org.jboss.tools.smooks.model.javabean12.ExpressionType.class);
supportTypes.add(org.jboss.tools.smooks.model.javabean12.WiringType.class);
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigChildNodeEditPart#isDragLink()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.editparts.
+ * AbstractResourceConfigChildNodeEditPart#isDragLink()
*/
@Override
protected boolean isDragLink() {
- IGraphicalEditorPart part = (IGraphicalEditorPart)getEditorPart();
- if(SmooksFreemarkerTemplateGraphicalEditor.ID.equals(part.getID())){
+ IGraphicalEditorPart part = (IGraphicalEditorPart) getEditorPart();
+ if (SmooksFreemarkerTemplateGraphicalEditor.ID.equals(part.getID())) {
AbstractSmooksGraphicalModel model = (AbstractSmooksGraphicalModel) this.getModel();
Object data = model.getData();
data = AdapterFactoryEditingDomain.unwrap(data);
- if(data instanceof ValueType || data instanceof org.jboss.tools.smooks.model.javabean12.ValueType){
+ if (data instanceof ValueType || data instanceof org.jboss.tools.smooks.model.javabean12.ValueType) {
return true;
}
}
return super.isDragLink();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart#canDirectEdit
+ * ()
+ */
+ @Override
+ protected boolean canDirectEdit() {
+ JavaBeanChildGraphModel graphModel = (JavaBeanChildGraphModel) getModel();
+ boolean isArray = graphModel.parentIsArray();
+ boolean isCollection = graphModel.parentIsCollection();
+ if (isArray || isCollection) {
+ return super.canDirectEdit();
+ }
+ return true;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart#
+ * createDirectEditCommand(org.eclipse.gef.requests.DirectEditRequest)
+ */
+ @Override
+ protected Command createDirectEditCommand(DirectEditRequest request) {
+ Object value = request.getCellEditor().getValue();
+ ISmooksModelProvider smooksModelProvider = (ISmooksModelProvider) this.getEditorPart().getAdapter(
+ ISmooksModelProvider.class);
+ AbstractSmooksGraphicalModel graphModel = (AbstractSmooksGraphicalModel) this.getModel();
+ Object data = graphModel.getData();
+ data = AdapterFactoryEditingDomain.unwrap(data);
+ EStructuralFeature feature = getFeature(data);
+
+ if (value != null && value instanceof String && smooksModelProvider != null && feature != null) {
+ org.eclipse.emf.common.command.Command setCommand = SetCommand.create(smooksModelProvider
+ .getEditingDomain(), data, feature, value);
+ if (setCommand.canExecute()) {
+ GEFAdapterCommand gefCommand = new GEFAdapterCommand(smooksModelProvider.getEditingDomain(), setCommand);
+ return gefCommand;
+ }
+ }
+ return null;
+ }
+
+ private EStructuralFeature getFeature(Object data) {
+ if (data instanceof ValueType) {
+ return JavabeanPackage.Literals.VALUE_TYPE__PROPERTY;
+ }
+ if (data instanceof WiringType) {
+ return JavabeanPackage.Literals.WIRING_TYPE__PROPERTY;
+ }
+ if (data instanceof ExpressionType) {
+ return JavabeanPackage.Literals.EXPRESSION_TYPE__PROPERTY;
+ }
+
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.ValueType) {
+ return Javabean12Package.Literals.VALUE_TYPE__PROPERTY;
+ }
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.WiringType) {
+ return Javabean12Package.Literals.WIRING_TYPE__PROPERTY;
+ }
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType) {
+ return Javabean12Package.Literals.EXPRESSION_TYPE__PROPERTY;
+ }
+ return null;
+ }
+
@Override
protected EStructuralFeature getFeature(EObject model) {
- if(model instanceof WiringType){
+ if (model instanceof WiringType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__WIRING;
}
-
- if(model instanceof ValueType){
+
+ if (model instanceof ValueType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__VALUE;
}
-
- if(model instanceof ExpressionType){
+
+ if (model instanceof ExpressionType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__EXPRESSION;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.WiringType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.WiringType) {
return Javabean12Package.Literals.BEAN_TYPE__WIRING;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.ValueType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.ValueType) {
return Javabean12Package.Literals.BEAN_TYPE__VALUE;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType) {
return Javabean12Package.Literals.BEAN_TYPE__EXPRESSION;
}
return null;
}
-
+
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -13,8 +13,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigEditPart;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
@@ -45,4 +51,36 @@
return null;
}
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart#createFigure()
+ */
+ @Override
+ protected IFigure createFigure() {
+ return super.createFigure();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.editparts.
+ * AbstractResourceConfigEditPart
+ * #createModelCreationEMFCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected Command createModelCreationEMFCommand(EditingDomain domain, Object owner, Object type, Object collections) {
+ Object model = ((AbstractSmooksGraphicalModel) getModel()).getData();
+ model = AdapterFactoryEditingDomain.unwrap(model);
+ if (model instanceof EObject) {
+ boolean isArray = SmooksUIUtils.isArrayJavaGraphModel((EObject) model);
+ boolean isCollection = SmooksUIUtils.isCollectionJavaGraphModel((EObject) model);
+ if(isArray || isCollection){
+ return null;
+ }
+ }
+ return super.createModelCreationEMFCommand(domain, owner, type, collections);
+ }
+
}
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.freemarker;
+
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.freemarker.FreemarkerFactory;
+import org.jboss.tools.smooks.model.freemarker.FreemarkerPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddFreemarkerAction extends AddSmooksObjectAction {
+
+ public AddFreemarkerAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddFreemarkerAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return FeatureMapUtil.createEntry(FreemarkerPackage.Literals.DOCUMENT_ROOT__FREEMARKER,
+ FreemarkerFactory.eINSTANCE.createFreemarker());
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return getSmooks11Object();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return getSmooks11Type();
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -15,18 +15,25 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
/**
* @author Dart
- *
+ *
*/
public class FreemarkerActionCreator {
- public void registXSLActions(ActionRegistry actionRegistry, List selectionActions, IEditorPart editorPart) {
+ public void registXSLActions(ActionRegistry actionRegistry, List selectionActions, IEditorPart editorPart,
+ ISmooksModelProvider provider) {
// add xsl actions
+
+ IAction addFreemarkerNodeAction = new AddFreemarkerAction(editorPart, provider);
+ actionRegistry.registerAction(addFreemarkerNodeAction);
+ selectionActions.add(addFreemarkerNodeAction.getId());
+
IAction addXSLNodeAction = new AddFreemarkerCSVRecordAction(editorPart);
actionRegistry.registerAction(addXSLNodeAction);
selectionActions.add(addXSLNodeAction.getId());
-
+
IAction addFieldNodeAction = new AddFreemarkerCSVFieldAction(editorPart);
actionRegistry.registerAction(addFieldNodeAction);
selectionActions.add(addFieldNodeAction.getId());
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddExpressionAction extends AddSmooksObjectAction {
+
+ public AddExpressionAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddExpressionAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createExpressionType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__EXPRESSION;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createExpressionType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__EXPRESSION;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.javamapping;
+
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddJavaBeanAction extends AddSmooksObjectAction {
+
+ public AddJavaBeanAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ }
+
+ public AddJavaBeanAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return FeatureMapUtil.createEntry(JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS, JavabeanFactory.eINSTANCE
+ .createBindingsType());
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return FeatureMapUtil.createEntry(Javabean12Package.Literals.JAVABEAN12_DOCUMENT_ROOT__BEAN,
+ Javabean12Factory.eINSTANCE.createBeanType());
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddValueAction extends AddSmooksObjectAction {
+
+
+
+ public AddValueAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddValueAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createValueType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__VALUE;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createValueType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__VALUE;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddWiringAction extends AddSmooksObjectAction {
+
+ public AddWiringAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddWiringAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createWiringType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__WIRING;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createWiringType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__WIRING;
+ }
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -10,29 +10,24 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.model.javamapping;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
-import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVLinkConnection;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVNodeModel;
-import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.ValueType;
-import org.jboss.tools.smooks.model.javabean12.BeanType;
/**
* @author Dart
@@ -78,8 +73,12 @@
return false;
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel#canLinkWithSource(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.model.
+ * AbstractResourceConfigChildNodeGraphModel
+ * #canLinkWithSource(java.lang.Object)
*/
@Override
public boolean canLinkWithSource(Object model) {
@@ -87,16 +86,20 @@
return super.canLinkWithSource(model);
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel#canLinkWithTarget(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.model.
+ * AbstractResourceConfigChildNodeGraphModel
+ * #canLinkWithTarget(java.lang.Object)
*/
@Override
public boolean canLinkWithTarget(Object model) {
- AbstractSmooksGraphicalModel gm = (AbstractSmooksGraphicalModel)model;
+ AbstractSmooksGraphicalModel gm = (AbstractSmooksGraphicalModel) model;
Object m = gm.getData();
if (data instanceof ValueType || data instanceof org.jboss.tools.smooks.model.javabean12.ValueType
|| m instanceof CSVNodeModel) {
- return !((CSVNodeModel)m).isRecord();
+ return !((CSVNodeModel) m).isRecord();
}
return super.canLinkWithTarget(model);
}
@@ -118,54 +121,22 @@
return super.getImage();
}
- private boolean parentIsCollection() {
+ public boolean parentIsCollection() {
Object model = getData();
model = AdapterFactoryEditingDomain.unwrap(model);
if (model instanceof EObject) {
EObject parent = ((EObject) model).eContainer();
- String classString = null;
- if (parent instanceof BeanType) {
- classString = ((BeanType) parent).getClass_();
- }
- if (parent instanceof BindingsType) {
- classString = ((BindingsType) parent).getClass_();
- }
- if (classString != null)
- classString = classString.trim();
-
- IJavaProject project = SmooksUIUtils.getJavaProject(parent);
- if (project != null) {
- try {
- ProjectClassLoader loader = new ProjectClassLoader(project);
- Class<?> clazz = loader.loadClass(classString);
- if (Collection.class.isAssignableFrom(clazz)) {
- return true;
- }
- } catch (Throwable t) {
-
- }
- }
+ return SmooksUIUtils.isCollectionJavaGraphModel(parent);
}
return false;
}
- private boolean parentIsArray() {
+ public boolean parentIsArray() {
Object model = getData();
model = AdapterFactoryEditingDomain.unwrap(model);
if (model instanceof EObject) {
EObject parent = ((EObject) model).eContainer();
- String classString = null;
- if (parent instanceof BeanType) {
- classString = ((BeanType) parent).getClass_();
- }
- if (parent instanceof BindingsType) {
- classString = ((BindingsType) parent).getClass_();
- }
- if (classString != null)
- classString = classString.trim();
- if (classString.endsWith("]")) {
- return true;
- }
+ return SmooksUIUtils.isArrayJavaGraphModel(parent);
}
return false;
}
@@ -188,10 +159,11 @@
*/
@Override
public String getText() {
- if (parentIsArray()) {
+ int index = this.getParent().getChildrenWithoutDynamic().indexOf(this);
+ if (parentIsArray() && index == 0) {
return "Array Entry";
}
- if (parentIsCollection()) {
+ if (parentIsCollection() && index == 0) {
return "Collection Entry";
}
return super.getText();
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2009-11-16 07:09:51 UTC (rev 18689)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -15,38 +15,55 @@
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.graphical.editors.IGraphicalEditorPart;
+import org.jboss.tools.smooks.graphical.editors.SmooksFreemarkerTemplateGraphicalEditor;
import org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigGraphModel;
-import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVLinkConnection;
/**
* @author Dart
*
*/
public class JavaBeanGraphModel extends AbstractResourceConfigGraphModel {
+
+ private IGraphicalEditorPart editorPart;
-
public JavaBeanGraphModel(Object data, ITreeContentProvider contentProvider, ILabelProvider labelProvider,
- IEditingDomainProvider domainProvider) {
- super(data,contentProvider,labelProvider,domainProvider);
+ IEditingDomainProvider domainProvider , IGraphicalEditorPart editorPart) {
+ super(data, contentProvider, labelProvider, domainProvider);
+ this.editorPart = editorPart;
}
@Override
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider contentProvider,
ILabelProvider labelProvider) {
Object m = AdapterFactoryEditingDomain.unwrap(model);
- if(m instanceof String) return null;
+ if (m instanceof String)
+ return null;
return new JavaBeanChildGraphModel(model, contentProvider, labelProvider, this.domainProvider);
}
+
+
/* (non-Javadoc)
- * @see org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel#isLinkable(java.lang.Class)
+ * @see org.jboss.tools.smooks.gef.tree.model.TreeContainerModel#canDragLink()
*/
@Override
- public boolean isLinkable(Class<?> connectionType) {
- if(connectionType == CSVLinkConnection.class){
+ public boolean canDragLink() {
+ if(SmooksFreemarkerTemplateGraphicalEditor.ID.equals(editorPart.getID())){
return true;
}
return false;
-// return super.isLinkable(connectionType);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel#isLinkable
+ * (java.lang.Class)
+ */
+ @Override
+ public boolean isLinkable(Class<?> connectionType) {
+ return canDragLink();
+ }
}
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.model.javamapping;
+
+import java.util.List;
+
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+
+/**
+ * @author Dart
+ *
+ */
+public class JavaMappingActionCreator {
+ public void registXSLActions(ActionRegistry actionRegistry, List selectionActions, IEditorPart editorPart,
+ ISmooksModelProvider smooksModelProvider) {
+ IAction addBeanAction = new AddJavaBeanAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addBeanAction);
+ selectionActions.add(addBeanAction.getId());
+
+ IAction addValueAction = new AddValueAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addValueAction);
+ selectionActions.add(addValueAction.getId());
+
+ IAction addWiringAction = new AddWiringAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addWiringAction);
+ selectionActions.add(addWiringAction.getId());
+
+ IAction addExpression = new AddExpressionAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addExpression);
+ selectionActions.add(addExpression.getId());
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.process;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.zest.core.viewers.IFigureProvider;
+import org.eclipse.zest.core.viewers.ISelfStyleProvider;
+import org.eclipse.zest.core.widgets.CGraphNode;
+import org.eclipse.zest.core.widgets.GraphConnection;
+import org.eclipse.zest.core.widgets.GraphNode;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.graphical.editors.SmooksProcessGraphicalEditor;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
+import org.jboss.tools.smooks.model.graphics.ext.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessGraphicalViewerLabelProvider extends LabelProvider implements IFigureProvider, ISelfStyleProvider {
+
+ private SmooksProcessGraphicalEditor processEditor;
+
+ public ProcessGraphicalViewerLabelProvider(SmooksProcessGraphicalEditor graph) {
+ this.processEditor = graph;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof TaskType) {
+ String id = ((TaskType) element).getId();
+ List<TaskTypeDescriptor> des = TaskTypeManager.getAllTaskList();
+ for (Iterator<?> iterator = des.iterator(); iterator.hasNext();) {
+ TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
+ if (taskTypeDescriptor.getId().equals(id)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ taskTypeDescriptor.getImagePath());
+ }
+ }
+ }
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof TaskType) {
+ String id = ((TaskType) element).getId();
+ String name = ((TaskType) element).getName();
+ if (name == null) {
+ name = id;
+ }
+ if (name == null) {
+ name = "null";
+ }
+ return name;
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.zest.core.viewers.IFigureProvider#getFigure(java.lang.Object)
+ */
+ public IFigure getFigure(Object element) {
+ if (element instanceof TaskType) {
+ // if(TaskTypeManager.TASK_ID_INPUT.equals(((TaskType)element).getId())){
+ Image image = getImage(element);
+ String text = getText(element);
+ return new TaskNodeFigure(processEditor, image, text);
+ // }
+ }
+ return null;
+ }
+
+ public void selfStyleConnection(Object element, GraphConnection connection) {
+ connection.setLineColor(GraphicsConstants.BORDER_CORLOR);
+ }
+
+ public void selfStyleNode(Object element, GraphNode node) {
+ if (node instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) node).getFigure();
+ Dimension size = figure.getLayoutManager().getPreferredSize(figure, -1, -1);
+ figure.setSize(size);
+ }
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.graphical.editors.process;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.ActionEvent;
+import org.eclipse.draw2d.ActionListener;
+import org.eclipse.draw2d.Clickable;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.MouseMotionListener;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.zest.core.widgets.CGraphNode;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphItem;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.graphical.editors.SmooksProcessGraphicalEditor;
+
+/**
+ * @author Dart
+ *
+ */
+public class TaskNodeFigure extends Figure {
+
+ private IFigure mainFigure;
+
+ private IFigure addTaskFigure;
+
+ private Image image;
+
+ private String labelText;
+
+ private SmooksProcessGraphicalEditor processGraphicalViewerEditor;
+
+ private Label label;
+
+ private IFigure imageFigure;
+
+ private Color oldLabelColor = null;
+
+ private boolean showAddFigure = false;
+
+ private Rectangle imageSourceRectangle = null;
+
+ public TaskNodeFigure(SmooksProcessGraphicalEditor graph, Image image, String labelText) {
+ super();
+ this.image = image;
+ this.labelText = labelText;
+ this.processGraphicalViewerEditor = graph;
+ initFigure();
+ hookTaskNodeFigure();
+ }
+
+ private void hookTaskNodeFigure() {
+ addTaskFigure.addMouseMotionListener(new MouseMotionListener() {
+
+ public void mouseDragged(MouseEvent me) {
+ }
+
+ public void mouseEntered(MouseEvent me) {
+ showAddFigure = true;
+ imageSourceRectangle = null;
+ addTaskFigure.repaint();
+ }
+
+ public void mouseExited(MouseEvent me) {
+ showAddFigure = false;
+ addTaskFigure.repaint();
+ }
+
+ public void mouseHover(MouseEvent me) {
+ }
+
+ public void mouseMoved(MouseEvent me) {
+ }
+
+ });
+ }
+
+ protected void initFigure() {
+ initMainFigure();
+ initAddTaskFigure();
+ ToolbarLayout layout = new ToolbarLayout(true);
+ layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ this.add(mainFigure);
+ this.add(addTaskFigure);
+
+ this.setLayoutManager(layout);
+ }
+
+ private void initAddTaskFigure() {
+ addTaskFigure = new Clickable() {
+ @Override
+ protected void paintBorder(Graphics graphics) {
+ }
+
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (!showAddFigure) {
+ int feet = 4;
+ Rectangle rect = getBounds();
+ imageSourceRectangle = new Rectangle(rect.x + feet, rect.y + feet, rect.width - feet * 2,
+ rect.height - feet * 2);
+ }
+ Image image = SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_ADD_TASK_BUTTON);
+ if (image != null) {
+ Rectangle sourceRectangle = new Rectangle(0, 0, image.getBounds().width, image.getBounds().height);
+ if (imageSourceRectangle == null) {
+ graphics.drawImage(image, getLocation());
+ } else {
+ graphics.drawImage(image, sourceRectangle, imageSourceRectangle);
+ }
+ }
+ }
+
+ };
+ ((Clickable) addTaskFigure).addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent event) {
+ if (!showAddFigure)
+ return;
+ Graph g = processGraphicalViewerEditor.getProcessGraphViewer().getGraphControl();
+ processGraphicalViewerEditor.setNeedupdatewhenshow(false);
+ List<?> nodes = g.getNodes();
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ GraphItem item = (GraphItem) iterator.next();
+ if (item instanceof CGraphNode) {
+ if (TaskNodeFigure.this == ((CGraphNode) item).getFigure()) {
+ processGraphicalViewerEditor.updateProcessActions(new StructuredSelection(item.getData()));
+ break;
+ }
+ }
+ }
+ Menu menu = processGraphicalViewerEditor.getProcessGraphViewer().getGraphControl().getMenu();
+ menu.setVisible(true);
+ // processGraphicalViewerEditor.setNeedupdatewhenshow(true);
+ }
+ });
+ addTaskFigure.setSize(16, 16);
+ }
+
+ private void initMainFigure() {
+ mainFigure = new Figure();
+ imageFigure = new Figure() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics
+ * )
+ */
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (image != null) {
+ graphics.drawImage(image, getLocation());
+ } else {
+ graphics.drawRectangle(0, 0, 24, 24);
+ }
+ }
+
+ };
+ if (image != null) {
+ imageFigure.setSize(new Dimension(image.getBounds().width, image.getBounds().height));
+ } else {
+ imageFigure.setSize(24, 24);
+ }
+
+ mainFigure.add(imageFigure);
+
+ label = new Label();
+ label.setForegroundColor(GraphicsConstants.BORDER_CORLOR);
+ label.setText(labelText);
+
+ oldLabelColor = label.getForegroundColor();
+
+ mainFigure.add(label);
+
+ ToolbarLayout layout = new ToolbarLayout(false);
+ layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ mainFigure.setLayoutManager(layout);
+ }
+
+ /**
+ * @return the image
+ */
+ public Image getImage() {
+ return image;
+ }
+
+ /**
+ * @param image
+ * the image to set
+ */
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+ /**
+ * @return the labelText
+ */
+ public String getLabelText() {
+ return labelText;
+ }
+
+ /**
+ * @param labelText
+ * the labelText to set
+ */
+ public void setLabelText(String labelText) {
+ this.labelText = labelText;
+ }
+
+ public void highlightLabel(Color highlightColor) {
+ oldLabelColor = label.getForegroundColor();
+ label.setForegroundColor(highlightColor);
+ label.repaint();
+ }
+
+ public void unhighlightLabel() {
+ if (oldLabelColor != null) {
+ label.setForegroundColor(oldLabelColor);
+ label.repaint();
+ }
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java 2009-11-16 08:01:09 UTC (rev 18690)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.template.csv;
+
+import junit.framework.TestCase;
+
+import org.jboss.template.exception.TemplateBuilderException;
+import org.jboss.template.exception.UnmappedCollectionNodeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly(a)jboss.com</a>
+ */
+public class CSVToFreemarkerTemplateBuilderTest extends TestCase {
+
+ public static void main(String[] args) throws TemplateBuilderException{
+ new CSVToFreemarkerTemplateBuilderTest().test_all_fields_mapped();
+ }
+
+ public void test_all_fields_mapped() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder(new String[]{"firstname", "lastname", "country"});
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',', '\"');
+
+ builder.addCollectionMapping("people", getRecordElement(model),"person");
+ builder.addValueMapping("person.fname", getFieldElement(model, "firstname"));
+ builder.addValueMapping("person.lname", getFieldElement(model, "lastname"));
+ builder.addValueMapping("person.address.country", getFieldElement(model, "country"));
+
+ String template = builder.buildTemplate();
+ System.out.println(template);
+ assertEquals("<#list people as person>\n" +
+ "\"${person.fname}\",\"${person.lname}\",\"${person.address.country}\"\n" +
+ "</#list>",
+ template);
+ }
+
+ public void test_all_fields_not_mapped() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname", "lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',', '\"');
+
+ builder.addCollectionMapping("people", getRecordElement(model), "person");
+ builder.addValueMapping("person.fname", getFieldElement(model, "firstname"));
+ builder.addValueMapping("person.address.country", getFieldElement(model, "country"));
+
+ String template = builder.buildTemplate();
+ System.out.println(template);
+ assertEquals("<#list people as person>\n" +
+ "\"${person.fname}\",,\"${person.address.country}\"\n" +
+ "</#list>",
+ template);
+ }
+
+ public void test_collection_not_mapped_01() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname", "lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',', '\"');
+
+ try {
+ // Shouldn't be able to add a value binding where the model target is inside
+ // an unmapped collection...
+ builder.addValueMapping("person.fname", getFieldElement(model, "firstname"));
+ fail("Expected UnmappedCollectionNodeException");
+ } catch(UnmappedCollectionNodeException e) {
+ assertEquals("Unmapped collection node 'csv-record'.", e.getMessage());
+ }
+ }
+
+ public void test_collection_not_mapped_02() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname", "lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',', '\"');
+
+ try {
+ // For CSV, you need to have at least mapped the collection...
+ builder.buildTemplate();
+ fail("Expected UnmappedCollectionNodeException");
+ } catch(UnmappedCollectionNodeException e) {
+ assertEquals("Unmapped collection node 'csv-record'.", e.getMessage());
+ }
+ }
+
+ private Element getRecordElement(Document model) {
+ return model.getDocumentElement();
+ }
+
+ private Element getFieldElement(Document model, String fieldName) {
+ return (Element) model.getElementsByTagName(fieldName).item(0);
+ }
+}
\ No newline at end of file
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
JBoss Tools SVN: r18689 - in trunk/common/plugins/org.jboss.tools.common.el.ui: src/org/jboss/tools/common/el/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-11-16 02:09:51 -0500 (Mon, 16 Nov 2009)
New Revision: 18689
Added:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiPlugin.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java
Removed:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/Activator.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4990
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-11-14 14:59:31 UTC (rev 18688)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-11-16 07:09:51 UTC (rev 18689)
@@ -6,7 +6,7 @@
Bundle-SymbolicName: org.jboss.tools.common.el.ui;singleton:=true
Bundle-Version: 1.0.0
Export-Package: org.jboss.tools.common.el.ui
-Bundle-Activator: org.jboss.tools.common.el.ui.Activator
+Bundle-Activator: org.jboss.tools.common.el.ui.ElUiPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.jboss.tools.common.el.core;bundle-version="2.0.0",
@@ -15,7 +15,12 @@
org.jboss.tools.common.model.ui;bundle-version="2.0.0",
org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
org.eclipse.jdt.ui;bundle-version="3.5.0",
- org.eclipse.search;bundle-version="3.5.0"
+ org.eclipse.search;bundle-version="3.5.0",
+ org.eclipse.ui.ide;bundle-version="3.5.0",
+ org.jboss.tools.jst.web.ui;bundle-version="2.0.0",
+ org.eclipse.jface.text;bundle-version="3.5.0",
+ org.eclipse.core.expressions;bundle-version="3.4.100",
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100"
Bundle-Vendor: %Bundle-Vendor.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.jboss.tools.vpe.resref.core
Deleted: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/Activator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/Activator.java 2009-11-14 14:59:31 UTC (rev 18688)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/Activator.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.common.el.ui;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.common.el.ui"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
Copied: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java (from rev 18131, trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -0,0 +1,22 @@
+package org.jboss.tools.common.el.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ElUIMessages {
+ private static final String BUNDLE_NAME = "org.jboss.tools.common.el.ui.messages"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, ElUIMessages.class);
+ }
+
+ public static String RENAME_METHOD_PARTICIPANT_GETTER_WARNING;
+ public static String RENAME_METHOD_PARTICIPANT_SETTER_WARNING;
+ public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES;
+ public static String RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES;
+
+ public static String REFACTOR_CONTRIBUTOR_MAIN_MENU;
+ public static String REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE;
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java 2009-11-14 14:59:31 UTC (rev 18688)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -1,19 +0,0 @@
-package org.jboss.tools.common.el.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public class ElUiCoreMessages {
- private static final String BUNDLE_NAME = "org.jboss.tools.common.el.ui.messages"; //$NON-NLS-1$
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ElUiCoreMessages.class);
- }
-
- public static String RENAME_METHOD_PARTICIPANT_GETTER_WARNING;
- public static String RENAME_METHOD_PARTICIPANT_SETTER_WARNING;
- public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE;
- public static String RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE;
- public static String RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE;
- public static String RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES;
-
-}
\ No newline at end of file
Copied: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiPlugin.java (from rev 17542, trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/Activator.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiPlugin.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiPlugin.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.common.el.ui;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ElUiPlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.common.el.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ElUiPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ElUiPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ElUiPlugin getDefault() {
+ return plugin;
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-11-14 14:59:31 UTC (rev 18688)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-11-16 07:09:51 UTC (rev 18689)
@@ -4,4 +4,7 @@
RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is not in sync.
RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE=Cannot change phantom file: ''{0}''.
RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file: ''{0}''.
-RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
\ No newline at end of file
+RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
+RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES=Update bundle references in EL
+REFACTOR_CONTRIBUTOR_MAIN_MENU=EL Refactor
+REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE=Rename EL Variable
Added: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.common.el.ui.refactoring;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
+import org.eclipse.jdt.ui.text.IJavaPartitions;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.internal.services.IWorkbenchLocationService;
+import org.eclipse.ui.menus.AbstractContributionFactory;
+import org.eclipse.ui.menus.IContributionRoot;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.services.IServiceLocator;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.ui.ElUiPlugin;
+import org.jboss.tools.common.el.ui.ElUIMessages;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.propertieseditor.PropertiesCompoundEditor;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.web.ui.editors.WebCompoundEditor;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Daniel Azarov
+ */
+public class ELRefactorContributionFactory extends AbstractContributionFactory {
+ private static final String ANNOTATION_NAME = "org.jboss.seam.annotations.Name"; //$NON-NLS-1$
+ private static final String JAVA_EXT = "java"; //$NON-NLS-1$
+ private static final String XML_EXT = "xml"; //$NON-NLS-1$
+ private static final String XHTML_EXT = "xhtml"; //$NON-NLS-1$
+ private static final String JSP_EXT = "jsp"; //$NON-NLS-1$
+ private static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
+ private static final String GET = "get"; //$NON-NLS-1$
+ private static final String SET = "set"; //$NON-NLS-1$
+ private static final String IS = "is"; //$NON-NLS-1$
+
+ static private String selectedText;
+ static private IFile editorFile;
+ private String fileContent;
+ private IEditorPart editor;
+ private Shell shell;
+
+ public ELRefactorContributionFactory(){
+ super("","");
+ }
+
+ public ELRefactorContributionFactory(String location, String namespace){
+ super(location, namespace);
+ }
+
+ @Override
+ public void createContributionItems(IServiceLocator serviceLocator,
+ IContributionRoot additions) {
+
+ if(serviceLocator.hasService(IWorkbenchLocationService.class)){
+ IWorkbenchLocationService service = (IWorkbenchLocationService)serviceLocator.getService(IWorkbenchLocationService.class);
+ editor = service.getWorkbenchWindow().getActivePage().getActiveEditor();
+ shell = service.getWorkbench().getActiveWorkbenchWindow().getShell();
+
+ if(!(editor.getEditorInput() instanceof FileEditorInput))
+ return;
+
+ FileEditorInput input = (FileEditorInput)editor.getEditorInput();
+
+ editorFile = input.getFile();
+ String ext = editorFile.getFileExtension();
+
+ if (!JAVA_EXT.equalsIgnoreCase(ext)
+ && !XML_EXT.equalsIgnoreCase(ext)
+ && !XHTML_EXT.equalsIgnoreCase(ext)
+ && !JSP_EXT.equalsIgnoreCase(ext)
+ && !PROPERTIES_EXT.equalsIgnoreCase(ext))
+ return;
+
+ MenuManager mm = new MenuManager(ElUIMessages.REFACTOR_CONTRIBUTOR_MAIN_MENU);
+ mm.setVisible(true);
+
+ boolean separatorIsAdded = false;
+
+ ISelection sel = editor.getEditorSite().getSelectionProvider().getSelection();
+
+ if(sel == null || sel.isEmpty())
+ return;
+
+ if(sel instanceof StructuredSelection){
+ if(editor instanceof PropertiesCompoundEditor){
+ sel = ((PropertiesCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }else if(editor instanceof EditorPartWrapper){
+ EditorPartWrapper wrapperEditor = (EditorPartWrapper)editor;
+ if(wrapperEditor.getEditor() instanceof WebCompoundEditor){
+ WebCompoundEditor xmlEditor = (WebCompoundEditor)wrapperEditor.getEditor();
+ sel = xmlEditor.getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+ }else if(editor instanceof WebCompoundEditor)
+ sel = ((WebCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+
+ if(sel instanceof TextSelection){
+ TextSelection selection = (TextSelection)sel;
+
+ selectedText = selection.getText();
+
+ try {
+ fileContent = FileUtil.readStream(editorFile);
+ } catch (CoreException e) {
+ ElUiPlugin.getDefault().logError(e);
+ }
+
+ boolean status = false;
+
+ if(JAVA_EXT.equalsIgnoreCase(ext)){
+ status = checkContextVariableInJava(editorFile, fileContent, selection);
+ } else if(XML_EXT.equalsIgnoreCase(ext) || XHTML_EXT.equalsIgnoreCase(ext) || JSP_EXT.equalsIgnoreCase(ext))
+ status = checkContextVariableInDOM(editorFile, fileContent, selection);
+ else if(PROPERTIES_EXT.equalsIgnoreCase(ext))
+ status = checkContextVariableInProperties(editorFile, fileContent, selection);
+
+ if(status){
+ mm.add(new RenameSeamContextVariableAction());
+
+ if(!separatorIsAdded)
+ additions.addContributionItem(new Separator(), null);
+ additions.addContributionItem(mm, null);
+ }
+ }
+ }
+ }
+
+ private boolean checkContextVariableInJava(IFile file, String content, TextSelection selection){
+ try {
+ FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
+ Document document = new Document(content);
+ scaner.setRange(document, 0, document.getLength());
+ IToken token = scaner.nextToken();
+ while(token!=null && token!=Token.EOF) {
+ if(IJavaPartitions.JAVA_STRING.equals(token.getData())) {
+ int length = scaner.getTokenLength();
+ int offset = scaner.getTokenOffset();
+ if(offset <= selection.getOffset() && (offset+length) >= (selection.getOffset()+selection.getLength())){
+ String value = document.get(offset, length);
+ if(value.indexOf('{')>-1) {
+ return scanString(file, value, offset, selection);
+ }
+ }
+ }
+ token = scaner.nextToken();
+ }
+ } catch (BadLocationException e) {
+ ElUiPlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
+ private boolean scanString(IFile file, String string, int offset, TextSelection selection) {
+ int startEl = string.indexOf("#{"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(string);
+ for (ELInstance instance : model.getInstances()) {
+ for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
+ ELPropertyInvocation pi = findSeamContextVariable(ie);
+ if(pi != null){
+ if(offset+pi.getStartPosition() == selection.getOffset() && pi.getLength() == selection.getLength())
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private ELPropertyInvocation findSeamContextVariable(ELInvocationExpression invocationExpression){
+ ELInvocationExpression invExp = invocationExpression;
+ while(invExp != null){
+ if(invExp instanceof ELPropertyInvocation){
+ if(((ELPropertyInvocation)invExp).getQualifiedName() != null && ((ELPropertyInvocation)invExp).getQualifiedName().equals(selectedText))
+ return (ELPropertyInvocation)invExp;
+ else
+ invExp = invExp.getLeft();
+
+ }else{
+ invExp = invExp.getLeft();
+ }
+ }
+ return null;
+ }
+
+ private boolean checkContextVariableInDOM(IFile file, String content, TextSelection selection){
+ IModelManager manager = StructuredModelManager.getModelManager();
+ if(manager == null) {
+ return false;
+ }
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ IDOMDocument document = domModel.getDocument();
+ return scanChildNodes(file, document, selection);
+ }
+ } catch (CoreException e) {
+ ElUiPlugin.getDefault().logError(e);
+ } catch (IOException e) {
+ ElUiPlugin.getDefault().logError(e);
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return false;
+ }
+
+ private boolean scanChildNodes(IFile file, Node parent, TextSelection selection) {
+ boolean status = false;
+ NodeList children = parent.getChildNodes();
+ for(int i=0; i<children.getLength(); i++) {
+ Node curentValidatedNode = children.item(i);
+ if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
+ status = scanNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, selection);
+ if(status)
+ return status;
+ } else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
+ status = scanNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_CONTENT, selection);
+ if(status)
+ return status;
+ }
+ status = scanChildNodes(file, curentValidatedNode, selection);
+ if(status)
+ return status;
+ }
+ return false;
+ }
+
+ private boolean scanNodeContent(IFile file, IStructuredDocumentRegion node, String regionType, TextSelection selection) {
+ boolean status = false;
+ ITextRegionList regions = node.getRegions();
+ for(int i=0; i<regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ if(region.getType() == regionType) {
+ String text = node.getFullText(region);
+ if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ int offset = node.getStartOffset() + region.getStart();
+ status = scanString(file, text, offset, selection);
+ if(status)
+ return status;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean checkContextVariableInProperties(IFile file, String content, TextSelection selection){
+ return scanString(file, content, 0, selection);
+ }
+
+ private IAnnotation getNameAnnotation(IFile file){
+ try{
+ ICompilationUnit unit = getCompilationUnit(file);
+ for(IType type : unit.getAllTypes()){
+ for(IAnnotation annotation : type.getAnnotations()){
+ if(EclipseJavaUtil.resolveType(type, annotation.getElementName()).equals(ANNOTATION_NAME))
+ return annotation;
+ }
+ }
+ }catch(CoreException ex){
+ ElUiPlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+
+ private ICompilationUnit getCompilationUnit(IFile file) throws CoreException {
+ IProject project = file.getProject();
+ IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
+ for (IResource resource : EclipseResourceUtil.getJavaSourceRoots(project)) {
+ if(resource.getFullPath().isPrefixOf(file.getFullPath())) {
+ IPath path = file.getFullPath().removeFirstSegments(resource.getFullPath().segmentCount());
+ IJavaElement element = javaProject.findElement(path);
+ if(element instanceof ICompilationUnit) {
+ return (ICompilationUnit)element;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getPropertyName(IMethod method){
+ String name = method.getElementName();
+
+ if(name.startsWith(GET) || name.startsWith(SET))
+ return name.substring(3).toLowerCase();
+
+ if(name.startsWith(IS))
+ return name.substring(2).toLowerCase();
+
+ return name.toLowerCase();
+ }
+
+ private static void saveAndBuild(){
+ if(!ElUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors(true))
+ return;
+
+ try {
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+
+ public static void invokeRenameSeamContextVariableWizard(String oldName, Shell activeShell) {
+// saveAndBuild();
+//
+// RenameSeamContextVariableProcessor processor = new RenameSeamContextVariableProcessor(editorFile, selectedText);
+// RenameComponentRefactoring refactoring = new RenameComponentRefactoring(processor);
+// RenameSeamContextVariableWizard wizard = new RenameSeamContextVariableWizard(refactoring, editorFile);
+// RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+// try {
+// String titleForFailedChecks = ElUIMessages.SEAM_COMPONENT_RENAME_HANDLER_ERROR;
+// op.run(activeShell, titleForFailedChecks);
+// } catch (final InterruptedException irex) {
+// // operation was canceled
+// }
+ }
+
+ class RenameSeamContextVariableAction extends Action{
+ public RenameSeamContextVariableAction(){
+ super(ElUIMessages.REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE);
+ }
+ public void run(){
+ saveAndBuild();
+
+ invokeRenameSeamContextVariableWizard(selectedText, shell);
+ }
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-11-14 14:59:31 UTC (rev 18688)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-11-16 07:09:51 UTC (rev 18689)
@@ -34,7 +34,7 @@
import org.jboss.tools.common.el.core.refactoring.ELProjectSetExtension;
import org.jboss.tools.common.el.core.refactoring.ProjectsSet;
import org.jboss.tools.common.el.core.refactoring.RefactorSearcher;
-import org.jboss.tools.common.el.ui.ElUiCoreMessages;
+import org.jboss.tools.common.el.ui.ElUIMessages;
import org.jboss.tools.common.model.project.ProjectHome;
public class RenameMethodParticipant extends RenameParticipant{
@@ -58,9 +58,9 @@
if(method != null && !added){
if(searcher.isGetter(method))
- status.addWarning(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_GETTER_WARNING);
+ status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_GETTER_WARNING);
else if(searcher.isSetter(method))
- status.addWarning(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
+ status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
added = true;
}
@@ -85,7 +85,7 @@
if(element instanceof IMethod){
status = new RefactoringStatus();
- rootChange = new CompositeChange(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+ rootChange = new CompositeChange(ElUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
method = (IMethod)element;
oldName = method.getElementName();
@@ -142,13 +142,13 @@
@Override
protected boolean isFileCorrect(IFile file) {
if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE, file.getFullPath().toString()));
+ status.addFatalError(Messages.format(ElUIMessages.RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE, file.getFullPath().toString()));
return false;
}else if(file.isPhantom()){
- status.addFatalError(Messages.format(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE, file.getFullPath().toString()));
+ status.addFatalError(Messages.format(ElUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE, file.getFullPath().toString()));
return false;
}else if(file.isReadOnly()){
- status.addFatalError(Messages.format(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE, file.getFullPath().toString()));
+ status.addFatalError(Messages.format(ElUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE, file.getFullPath().toString()));
return false;
}
return true;
15 years, 1 month