JBoss Tools SVN: r12932 - trunk/as/docs/reference/en.
by jbosstools-commits@lists.jboss.org
Author: abogachuk
Date: 2009-01-08 11:10:49 -0500 (Thu, 08 Jan 2009)
New Revision: 12932
Modified:
trunk/as/docs/reference/en/master.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-400
Modified: trunk/as/docs/reference/en/master.xml
===================================================================
--- trunk/as/docs/reference/en/master.xml 2009-01-08 16:10:31 UTC (rev 12931)
+++ trunk/as/docs/reference/en/master.xml 2009-01-08 16:10:49 UTC (rev 12932)
@@ -21,7 +21,7 @@
<!ENTITY strutsreflink "../../struts_tools_ref_guide/html_single/index.html">
<!ENTITY strutstutoriallink "../../struts_tools_tutorial/html_single/index.html">
-
+
]>
<book>
15 years, 3 months
JBoss Tools SVN: r12931 - trunk/as/docs/reference/en/modules.
by jbosstools-commits@lists.jboss.org
Author: abogachuk
Date: 2009-01-08 11:10:31 -0500 (Thu, 08 Jan 2009)
New Revision: 12931
Modified:
trunk/as/docs/reference/en/modules/perspective.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-400
Modified: trunk/as/docs/reference/en/modules/perspective.xml
===================================================================
--- trunk/as/docs/reference/en/modules/perspective.xml 2009-01-08 14:36:16 UTC (rev 12930)
+++ trunk/as/docs/reference/en/modules/perspective.xml 2009-01-08 16:10:31 UTC (rev 12931)
@@ -598,8 +598,13 @@
<section id="Project_archivesView" role="updated">
<title>Project Archives View</title>
<para>Every application, whether Plain Old Java, J2EE, or some other language altogether,
- needs to be packaged in some way. In Java-related projects, many people use ANT.
- <property>JBoss Tools</property> comes with our own Archives tool with a bit easier
+ needs to be packaged in some way. In Java-related projects, many people use ANT. </para>
+ <note>
+ <title>Note:</title>
+ <para>Those who use ANT will appreciate how the Project Archives Ant task is now improved: it supports variables and gives more informative error/logging messages when something goes wrong.</para>
+ </note>
+
+ <para>But <property>JBoss Tools</property> comes with our own Archives tool with a bit easier
and less-verbose XML and a handy user interface. The Project Archives plugin consists
primarily of a view, that is <property>Project Archives view</property>, to set up each
packaging configuration.</para>
15 years, 3 months
JBoss Tools SVN: r12930 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473 and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-01-08 09:36:16 -0500 (Thu, 08 Jan 2009)
New Revision: 12930
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473/JBIDE-3473.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
Log:
RESOLVED - issue JBIDE-3473: Something wrong with text processing inside table.
https://jira.jboss.org/jira/browse/JBIDE-3473
JUnit test has been written.
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473/JBIDE-3473.html
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473/JBIDE-3473.html (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473/JBIDE-3473.html 2009-01-08 14:36:16 UTC (rev 12930)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<style type="text/css">
+table {
+ background-color: black;
+}
+td {
+ background-color: yellow;
+}
+</style>
+</head>
+<body>
+<table id="table-id">
+ <tr>
+ <td>
+ 1JSF Testssssssssssssssssssssssssssssss
+ </td>
+ <td>
+ 2JSF Testsssssssssssssssss
+ </td>
+ </tr>
+ <tr>
+ <td>
+ 3JSF Testssssssssssss
+ </td>
+ <td>
+ 4JSF Testssssssss
+ </td>
+ </tr>
+</table>
+</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-01-08 14:08:28 UTC (rev 12929)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-01-08 14:36:16 UTC (rev 12930)
@@ -47,6 +47,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3376Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3396Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3441Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3473Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3482Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
@@ -78,6 +79,7 @@
// $JUnit-BEGIN$
suite.addTestSuite(JsfComponentTest.class);
suite.addTestSuite(Jsf20ComponentContentTest.class);
+ suite.addTestSuite(JBIDE3473Test.class);
suite.addTestSuite(JBIDE3441Test.class);
suite.addTestSuite(JsfJbide1467Test.class);
suite.addTestSuite(JsfJbide1501Test.class);
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-01-08 14:36:16 UTC (rev 12930)
@@ -0,0 +1,109 @@
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+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.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VisualDomUtil;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * @author yradtsevich
+ *
+ */
+public class JBIDE3473Test extends VpeTest {
+ private static final int INSERTING_POSITION = 179;
+ private static final String TABLE_ID = "table-id"; //$NON-NLS-1$
+ private static final String TEST_PAGE_NAME = "JBIDE/3473/JBIDE-3473.html"; //$NON-NLS-1$
+ private static final String INSERTING_TEXT = " id=\"td-id\""; //$NON-NLS-1$
+
+ public JBIDE3473Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Adds 'id' attribute to TD tag inside a table and checks if
+ * there are not changes in the VPE view.
+ *
+ * @throws Throwable
+ */
+ public void testNodeUpdate() 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$
+
+ // open and get editor
+ JSPMultiPageEditor jspEditor = openEditor(input);
+
+ StyledText styledText = jspEditor.getSourceEditor().getTextViewer()
+ .getTextWidget();
+
+ styledText.setCaretOffset(INSERTING_POSITION);
+ IndexedRegion indexedRegion = ContentAssistUtils.getNodeAt(jspEditor
+ .getSourceEditor().getTextViewer(), INSERTING_POSITION);
+ Node tdTextEditorNode = (Node) indexedRegion;
+ assertNotNull(tdTextEditorNode);
+ assertTrue("Text under cursor is not TD node", HTML.TAG_TD.equalsIgnoreCase(tdTextEditorNode.getNodeName())); //$NON-NLS-1$
+
+ VpeController vpeController = TestUtil.getVpeController(jspEditor);
+
+ Rectangle boundsBeforeInsert = getBoundsOfElementById(vpeController.getXulRunnerEditor().getDOMDocument(), TABLE_ID);
+ assertNotNull("boundsBeforeInsert should be not null.", boundsBeforeInsert); //$NON-NLS-1$
+
+ styledText.insert(INSERTING_TEXT); //$NON-NLS-1$
+ TestUtil.delay(450);
+ TestUtil.waitForJobs();
+
+ Rectangle boundsAfterInsert = getBoundsOfElementById(vpeController.getXulRunnerEditor().getDOMDocument(), TABLE_ID);
+ assertNotNull("boundsAfterInsert should be not null.", boundsAfterInsert); //$NON-NLS-1$
+
+ assertEquals("Width of the table has been changed.", boundsBeforeInsert.width, boundsAfterInsert.width); //$NON-NLS-1$
+ assertEquals("Height of the table has been changed.", boundsBeforeInsert.height, boundsAfterInsert.height); //$NON-NLS-1$
+
+ if(getException()!=null) {
+ throw getException();
+ }
+ }
+
+ /**
+ * Returns bounds of the element with given {@code id}
+ * from the {@code document}
+ *
+ * @param document the document
+ * @param id ID of the DOM element which bounds is needed
+ * @return bounds of the element with given {@code id}
+ * or {@code null} if the element is not found or not accessible
+ *
+ * @see VisualDomUtil#getBounds(nsIDOMNode)
+ */
+ private Rectangle getBoundsOfElementById(nsIDOMDocument document, String id) {
+ Rectangle bounds = null;
+
+ nsIDOMElement element = document.getElementById(id);
+ if (element != null) {
+ bounds = VisualDomUtil.getBounds(element);
+ }
+
+ return bounds;
+ }
+}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-01-08 14:08:28 UTC (rev 12929)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-01-08 14:36:16 UTC (rev 12930)
@@ -10,9 +10,14 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
import java.util.List;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.mozilla.interfaces.nsIAccessibilityService;
+import org.mozilla.interfaces.nsIAccessible;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
import org.mozilla.interfaces.nsIDOMMouseEvent;
@@ -22,6 +27,7 @@
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMRange;
import org.mozilla.interfaces.nsISelection;
+import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -29,6 +35,8 @@
public class VisualDomUtil {
+ private static final String ACCESSIBILITY_SERVICE_CONTRACT_ID = "@mozilla.org/accessibilityService;1";
+ private static Reference<nsIAccessibilityService> accessibilityServiceCache = null;
static public nsIDOMNode getAncestorNode(nsIDOMNode visualNode, String tagName){
if (tagName == null) return null;
@@ -207,4 +215,52 @@
}
}
+
+ /**
+ * Returns instance of {@link nsIAccessibilityService}.
+ *
+ * @author yradtsevich
+ */
+ public static nsIAccessibilityService getAccessibilityService() {
+ nsIAccessibilityService accessibilityService = null;
+ if (accessibilityServiceCache != null) {
+ // get accessibilityService from cache
+ accessibilityService = accessibilityServiceCache.get();
+ }
+ if (accessibilityService == null) {
+ accessibilityService = (nsIAccessibilityService) Mozilla.getInstance()
+ .getServiceManager()
+ .getServiceByContractID(ACCESSIBILITY_SERVICE_CONTRACT_ID,
+ nsIAccessibilityService.NS_IACCESSIBILITYSERVICE_IID);
+
+ // cache accessibilityService
+ accessibilityServiceCache = new SoftReference<nsIAccessibilityService>(accessibilityService);
+ }
+ return accessibilityService;
+ }
+
+ /**
+ * Returns on screen bounds of the {@code node}
+ *
+ * @param node cannot be {@code null}
+ * @return bounds of the {@code node} or {@code null} if it is not accessible
+ *
+ * @author yradtsevich
+ */
+ public static Rectangle getBounds(nsIDOMNode node) {
+ Rectangle bounds = null;
+
+ nsIAccessible accessible = getAccessibilityService().getAccessibleFor(node);
+ if (accessible != null) {
+ int[] xArray = new int[1]; // Left hand corner of the node
+ int[] yArray = new int[1]; // Top corner of the node
+ int[] widthArray = new int[1]; // Width of the node
+ int[] heightArray = new int[1]; // Height of the node
+
+ accessible.getBounds(xArray, yArray, widthArray, heightArray);
+ bounds = new Rectangle(xArray[0], yArray[0], widthArray[0], heightArray[0]);
+ }
+
+ return bounds;
+ }
}
15 years, 3 months
JBoss Tools SVN: r12929 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core: src/org/jboss/tools/hibernate/jpt/core/internal and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-01-08 09:08:28 -0500 (Thu, 08 Jan 2009)
New Revision: 12929
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3454
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2009-01-08 13:42:00 UTC (rev 12928)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2009-01-08 14:08:28 UTC (rev 12929)
@@ -8,12 +8,12 @@
org.eclipse.jpt.core,
org.eclipse.wst.validation,
org.eclipse.jpt.utility;bundle-version="1.2.0",
- org.eclipse.core.resources;bundle-version="3.4.0",
org.hibernate.eclipse.console;bundle-version="3.2.0",
org.hibernate.eclipse;bundle-version="3.2.0",
org.eclipse.jdt.launching;bundle-version="3.4.0",
org.eclipse.debug.core;bundle-version="3.4.0",
- org.eclipse.emf.ecore;bundle-version="2.4.0"
+ org.eclipse.emf.ecore;bundle-version="2.4.0",
+ org.eclipse.jdt.core;bundle-version="3.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss, a division of Red Hat
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJpaAnnotationProvider extends GenericJpaAnnotationProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider#addAttributeAnnotationDefinitionsTo(java.util.Collection)
+ */
+ @Override
+ protected void addAttributeAnnotationDefinitionsTo(Collection<AnnotationDefinition> definitions) {
+ super.addAttributeAnnotationDefinitionsTo(definitions);
+ definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2009-01-08 13:42:00 UTC (rev 12928)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal;
+import org.eclipse.jpt.core.JpaAnnotationProvider;
import org.eclipse.jpt.core.JpaFactory;
import org.eclipse.jpt.core.internal.platform.GenericJpaPlatform;
@@ -31,4 +32,10 @@
protected JpaFactory buildJpaFactory() {
return new HibernateFactory();
}
+
+ @Override
+ protected JpaAnnotationProvider buildAnnotationProvider() {
+ return new HibernateJpaAnnotationProvider();
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-01-08 13:42:00 UTC (rev 12928)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -15,6 +15,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -23,24 +24,32 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.Property;
import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlProperties;
import org.eclipse.jpt.core.resource.persistence.XmlProperty;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
/**
* @author Dmitry Geraskov
*
*/
public class HibernatePersistenceUnit extends GenericPersistenceUnit
- implements Messages {
+ implements Messages, Hibernate {
private HibernateProperties hibernateProperties;
@@ -55,6 +64,7 @@
protected void initialize(XmlPersistenceUnit xmlPersistenceUnit) {
super.initialize(xmlPersistenceUnit);
+ updateGenericGenerators();
this.hibernateProperties = new HibernateJpaProperties(this);
}
@@ -146,8 +156,33 @@
}
}
}
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit#update(org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit)
+ */
+ @Override
+ public void update(XmlPersistenceUnit persistenceUnit) {
+ super.update(persistenceUnit);
+ updateGenericGenerators();
+ }
+
+ protected void updateGenericGenerators(){
+ for (String annotClass : CollectionTools.iterable(getJpaProject().annotatedClassNames())) {
+ ClassRef classRef = buildClassRef(annotClass);
+ JavaPersistentType type = classRef.getJavaPersistentType();
+ ListIterator<JavaPersistentAttribute> typeAttrs = type.attributes();
+ for (JavaPersistentAttribute persAttr : CollectionTools.iterable(typeAttrs)) {
+ JavaResourcePersistentAttribute jrpa = persAttr.getResourcePersistentAttribute();
+ GenericGeneratorAnnotation annotation = (GenericGeneratorAnnotation) jrpa.getAnnotation(GENERIC_GENERATOR);
+ if (annotation != null){
+ JavaGenericGenerator generator = annotation.buildJavaGenericGenerator(persAttr.getSpecifiedMapping());
+ addGenerator(generator);
+ }
+ }
+ }
+ }
-
/**
* Hack class needed to make JPA/Validation API pick up our classloader instead of its own.
*
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.basic;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Hibernate {
+
+ // Hibernate package
+ String PACKAGE = "org.hibernate.annotations";
+ String PACKAGE_ = PACKAGE + ".";
+
+ // ********** API **********
+
+ // Hibernate annotations
+ String GENERIC_GENERATOR = PACKAGE_ + "GenericGenerator";
+ String GENERIC_GENERATOR__NAME = "name";
+ String GENERIC_GENERATOR__STRATEGY = "strategy";
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorAnnotation extends GeneratorAnnotation {
+
+ String ANNOTATION_NAME = Hibernate.GENERIC_GENERATOR;
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Returns null if the strategy element does not exist in java.
+ */
+ String getStrategy();
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Set to null to remove the strategy element.
+ */
+ void setStrategy(String strategy);
+ String STRATEGY_PROPERTY = "strategyProperty";
+
+ /**
+ * Return the {@link TextRange} for the strategy element. If the strategy element
+ * does not exist return the {@link TextRange} for the GenericGenerator annotation.
+ */
+ TextRange getStrategyTextRange(CompilationUnit astRoot);
+
+ JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent);
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorAnnotationImpl extends AbstractResourceAnnotation<Member>
+ implements GenericGeneratorAnnotation {
+
+ private final AnnotationElementAdapter<String> nameAdapter;
+
+ private final AnnotationElementAdapter<String> strategyAdapter;
+
+ private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter();
+
+ private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter();
+
+ private String name;
+
+ private String strategy;
+
+ private Integer initialValue = 1;
+
+ private Integer allocationSize = 1;
+
+ /**
+ * @param parent
+ * @param member
+ */
+ public GenericGeneratorAnnotationImpl(JavaResourcePersistentMember parent, Member member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, NAME_ADAPTER);
+ this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, STRATEGY_ADAPTER);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.name(astRoot);
+ this.strategy = this.strategy(astRoot);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public String getStrategy() {
+ return this.strategy;
+ }
+
+ public void setStrategy(String newStrategy) {
+ if (attributeValueHasNotChanged(this.strategy, newStrategy)) {
+ return;
+ }
+ String oldStrategy = this.strategy;
+ this.strategy = newStrategy;
+ this.strategyAdapter.setValue(newStrategy);
+ firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ if (attributeValueHasNotChanged(this.name, newName)) {
+ return;
+ }
+ String oldName = this.name;
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ firePropertyChanged(NAME_PROPERTY, oldName, newName);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(NAME_ADAPTER, astRoot);
+ }
+
+ public TextRange getStrategyTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(STRATEGY_ADAPTER, astRoot);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSize()
+ */
+ public Integer getAllocationSize() {
+ return allocationSize;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSizeTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValue()
+ */
+ public Integer getInitialValue() {
+ return initialValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValueTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public TextRange getInitialValueTextRange(CompilationUnit astRoot) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setAllocationSize(java.lang.Integer)
+ */
+ public void setAllocationSize(Integer allocationSize) {
+ this.allocationSize = allocationSize;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setInitialValue(java.lang.Integer)
+ */
+ public void setInitialValue(Integer initialValue) {
+ this.initialValue = initialValue;
+
+ }
+
+ // ********** java annotations -> persistence model **********
+ public void updateFromJava(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ }
+
+ protected String strategy(CompilationUnit astRoot) {
+ //TODO: get Generator instead of String
+ //use buildJavaGenericGenerator method before thi will be done
+ return this.strategyAdapter.getValue(astRoot);
+ }
+
+ protected String name(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotation#buildJavaGenericGenerator(org.eclipse.jpt.core.context.java.JavaJpaContextNode)
+ */
+ public JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent) {
+ JavaGenericGenerator generator = new JavaGenericGeneratorImpl(parent);
+ generator.initializeFromResource(this);
+ return generator;
+ }
+
+ // ********** static methods **********
+ private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, Hibernate.GENERIC_GENERATOR__NAME, false);
+ }
+
+ private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, Hibernate.GENERIC_GENERATOR__STRATEGY, false);
+ }
+
+
+ public static class GenericGeneratorAnnotationDefinition implements AnnotationDefinition
+ {
+ // singleton
+ private static final GenericGeneratorAnnotationDefinition INSTANCE = new GenericGeneratorAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private GenericGeneratorAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new GenericGeneratorAnnotationImpl(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return null;
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.java.JavaGenerator;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaGenericGenerator extends JavaGenerator, GenericGenerator {
+
+ void initializeFromResource(GenericGeneratorAnnotation generator);
+
+ void update(GenericGeneratorAnnotation generator);
+
+}
+
+interface GenericGenerator extends Generator {
+
+ Integer DEFAULT_INITIAL_VALUE = Integer.valueOf(1);
+
+ String getStrategy();
+
+ void setSpecifiedStrategy(String value);
+ String GENERIC_STRATEGY_PROPERTY = "genericStrategyProperty";
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-01-08 14:08:28 UTC (rev 12929)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaGenerator;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class JavaGenericGeneratorImpl extends AbstractJavaGenerator
+ implements JavaGenericGenerator {
+
+ private String strategy;
+
+ /**
+ * @param parent
+ */
+ public JavaGenericGeneratorImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ @Override
+ protected GenericGeneratorAnnotation getGeneratorResource() {
+ return (GenericGeneratorAnnotation) super.getGeneratorResource();
+ }
+
+ public Integer getDefaultInitialValue() {
+ return GenericGenerator.DEFAULT_INITIAL_VALUE;
+ }
+
+ public void initializeFromResource(GenericGeneratorAnnotation generator) {
+ super.initializeFromResource(generator);
+ this.strategy = generator.getStrategy();
+ }
+
+ public void update(GenericGeneratorAnnotation generator) {
+ super.update(generator);
+ setSpecifiedStrategy_(generator.getStrategy());
+ }
+
+ public String getStrategy() {
+ return strategy;
+ }
+
+ public void setSpecifiedStrategy(String strategy) {
+ String oldStrategy = this.strategy;
+ this.strategy = strategy;
+ getGeneratorResource().setStrategy(strategy);
+ firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
+ }
+
+ protected void setSpecifiedStrategy_(String strategy) {
+ String oldStrategy = this.strategy;
+ this.strategy = strategy;
+ firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Tools SVN: r12928 - in trunk/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-01-08 08:42:00 -0500 (Thu, 08 Jan 2009)
New Revision: 12928
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3464
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-01-08 13:00:11 UTC (rev 12927)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-01-08 13:42:00 UTC (rev 12928)
@@ -589,7 +589,7 @@
if (styleValue != null) {
styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext.getEditPart().getEditorInput());
+ pageContext);
element.setAttribute(HTML.TAG_STYLE, styleValue);
}
if (backgroundValue != null) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2009-01-08 13:00:11 UTC (rev 12927)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2009-01-08 13:42:00 UTC (rev 12928)
@@ -35,7 +35,7 @@
String text = null;
if (textNode != null) {
text = textNode.getNodeValue();
- text = VpeStyleUtil.addFullPathIntoURLValue(text, pageContext.getEditPart().getEditorInput());
+ text = VpeStyleUtil.addFullPathIntoURLValue(text, pageContext);
}
nsIDOMNode newStyle = pageContext.getVisualBuilder()
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-08 13:00:11 UTC (rev 12927)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-08 13:42:00 UTC (rev 12928)
@@ -12,6 +12,8 @@
import java.io.File;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
@@ -337,7 +339,7 @@
* @return format style string
*/
public static String addFullPathIntoURLValue(String value,
- IEditorInput input) {
+ VpePageContext pageContext) {
String urls[] = value.split(ATTR_URL);
@@ -363,23 +365,25 @@
String filePath = urls[i].substring(startPathIndex + 1,
endPathIndex);
- if (filePath.indexOf(FILE_PROTOCOL) != -1) {
- continue;
- }
+// if (filePath.indexOf(FILE_PROTOCOL) != -1) {
+// continue;
+// }
+//
+// if (!new File(filePath).isAbsolute()) {
+// filePath = getFilePath(input, filePath);
+// }
+//
+// filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\', '/');
+// URL url = null;
+// try {
+// url = new URL(filePath);
+// } catch (MalformedURLException e) {
+// continue;
+// }
+// filePath = url.toString();
+
+ filePath = getAbsoluteWorkspacePath(filePath, pageContext);
- if (!new File(filePath).isAbsolute()) {
- filePath = getFilePath(input, filePath);
- }
-
- filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\', '/');
- URL url = null;
- try {
- url = new URL(filePath);
- } catch (MalformedURLException e) {
- continue;
- }
- filePath = url.toString();
-
String firstPartValue = urls[i].substring(0, startPathIndex + 1);
String secondPartValue = urls[i].substring(endPathIndex, urls[i]
.length());
@@ -743,4 +747,43 @@
return size;
}
+
+ /**
+ * Gets the absolute workspace path.
+ *
+ * @param resourcePathInWorkspace the relative path in workspace
+ *
+ * @return the absolute workspace path
+ */
+ public static String getAbsoluteWorkspacePath(
+ String resourcePathInWorkspace, VpePageContext pageContext) {
+
+ String resolvedValue = resourcePathInWorkspace
+ .replaceFirst(
+ "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", Constants.EMPTY); //$NON-NLS-1$
+
+ IFile file = null;
+ if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
+ file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getFile();
+
+ if (file == null)
+ return resolvedValue;
+
+ resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+
+ URI uri = null;
+ try {
+ uri = new URI(resolvedValue);
+ } catch (URISyntaxException e) {
+ }
+
+ if ((uri != null)
+ && (uri.isAbsolute() || (new File(resolvedValue)).exists()))
+ return resolvedValue;
+
+ return Constants.FILE_PREFIX
+ + FileUtil.getFile(resolvedValue, file).getLocation()
+ .toOSString();
+ }
}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2009-01-08 13:00:11 UTC (rev 12927)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2009-01-08 13:42:00 UTC (rev 12928)
@@ -57,8 +57,8 @@
} else {
// all full path for 'url'
if (VpeStyleUtil.ATTRIBUTE_STYLE.equalsIgnoreCase(name))
- value = VpeStyleUtil.addFullPathIntoURLValue(value, pageContext
- .getEditPart().getEditorInput());
+ value = VpeStyleUtil.addFullPathIntoURLValue(value,
+ pageContext);
if (VpeStyleUtil.PARAMETR_BACKGROND.equalsIgnoreCase(name))
value = VpeStyleUtil.addFullPathIntoBackgroundValue(value,
pageContext.getEditPart().getEditorInput());
15 years, 3 months
JBoss Tools SVN: r12927 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/menu and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-01-08 08:00:11 -0500 (Thu, 08 Jan 2009)
New Revision: 12927
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-2017
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2009-01-08 09:10:41 UTC (rev 12926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2009-01-08 13:00:11 UTC (rev 12927)
@@ -78,4 +78,39 @@
point="org.jboss.tools.jst.jsp.visulaEditorImplementations" id="org.jboss.tools.vpe.editor.VpeEditorPartFactory">
<visualEditorImplementation name="XulRunner Visual Editor" class="org.jboss.tools.vpe.editor.VpeEditorPartFactory"/>
</extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor.source.EditorContext?after=paste">
+ <separator
+ name="org.jboss.tools.insertGroup" visible="true" >
+ </separator>
+ <dynamic
+ class="org.jboss.tools.vpe.editor.menu.InsertContributionItem"
+ id="org.jboss.tools.vpe.editor.menu.InsertContributionItem">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor.source.EditorContext?after=paste">
+ <separator
+ name="org.jboss.tools.insertGroup" visible="true" >
+ </separator>
+ <dynamic
+ class="org.jboss.tools.vpe.editor.menu.InsertContributionItem"
+ id="org.jboss.tools.vpe.editor.menu.InsertContributionItem">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.jboss.tools.vpe.insert"
+ name="org.jboss.tools.vpe.insert"
+ defaultHandler="org.jboss.tools.vpe.editor.menu.InsertAction"
+ >
+ </command>
+ </extension>
</plugin>
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-01-08 13:00:11 UTC (rev 12927)
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.vpe.editor.menu;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.util.ModelUtilities;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.menu.action.InsertAction;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.w3c.dom.Node;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class InsertContributionItem extends ContributionItem {
+
+ private StructuredTextEditor sourceEditor;
+
+ private VpePageContext pageContext;
+
+ private final static String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ private final static String HIDDEN_PROPERTY = "hidden"; //$NON-NLS-1$
+
+ private final static String ELEMENT_TYPE_PROPERTY = "element type"; //$NON-NLS-1$
+
+ private final static String END_TEXT_PROPERTY = "end text";//$NON-NLS-1$
+
+ private final static String TAG_ELEMENT_TYPE = "macro"; //$NON-NLS-1$
+
+ private static List<String> INSERT_ITEMS;
+ static {
+ INSERT_ITEMS = new ArrayList<String>();
+ INSERT_ITEMS.add(VpeUIMessages.INSERT_AROUND); // id = 0
+ INSERT_ITEMS.add(VpeUIMessages.INSERT_BEFORE); // id = 1
+ INSERT_ITEMS.add(VpeUIMessages.INSERT_AFTER); // id = 2
+ INSERT_ITEMS.add(VpeUIMessages.REPLACE_WITH); // id = 3
+ }
+
+ // ids correspond to order of items in INSERT_ITEMS
+ private int INSERT_AROUND = 0;
+ private int INSERT_BEFORE = 1;
+ private int INSERT_AFTER = 2;
+ private int REPLACE_WITH = 3;
+
+ public InsertContributionItem() {
+ JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .getActiveEditor();
+ this.sourceEditor = editor.getSourceEditor();
+ this.pageContext = ((VpeEditorPart) editor.getVisualEditor())
+ .getController().getPageContext();
+ }
+
+ public InsertContributionItem(StructuredTextEditor sourceEditor,
+ VpePageContext pageContext) {
+ this.sourceEditor = sourceEditor;
+ this.pageContext = pageContext;
+ }
+
+ @Override
+ public void fill(Menu menu, int index) {
+
+ for (int i = 0; i < INSERT_ITEMS.size(); i++) {
+
+ String itemName = INSERT_ITEMS.get(i);
+
+ MenuItem item = new MenuItem(menu, SWT.CASCADE, index + i);
+ item.setText(itemName);
+
+ Menu paletteManu = new Menu(menu);
+
+ item.setMenu(paletteManu);
+
+ MenuManager paletteManuManager = new MenuManager(
+ VpeUIMessages.FROM_PALETTE);
+
+ XModelObject model = ModelUtilities.getPreferenceModel().getByPath(
+ "%Palette%"); //$NON-NLS-1$
+
+ paletteManuManager
+ .addMenuListener(new InsertMenuListener(model, i));
+
+ paletteManuManager.fill(paletteManu, -1);
+
+ }
+
+ }
+
+ /**
+ *
+ * @param sourceEditor
+ * @return
+ */
+ private Point getSelectionRange(StructuredTextEditor sourceEditor) {
+
+ // IStructuredSelection selection = (IStructuredSelection) sourceEditor
+ // .getSelectionProvider().getSelection();
+
+ // Object[] selectedObjects = selection.toArray();
+
+ // Node firstElement = (Node) selectedObjects[0];
+ // Node endElement = (Node) selectedObjects[selectedObjects.length - 1];
+
+ Point selectionRange = SelectionUtil
+ .getSourceSelectionRange(sourceEditor);
+
+ Node firstElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
+ selectionRange.x);
+ Node endElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
+ selectionRange.x + selectionRange.y);
+
+ int start;
+ int length;
+
+ if (firstElement.getNodeType() == Node.TEXT_NODE)
+ start = selectionRange.x;
+ else
+ start = NodesManagingUtil.getStartOffsetNode(firstElement);
+
+ if (endElement.getNodeType() == Node.TEXT_NODE)
+ length = selectionRange.x + selectionRange.y - start;
+ else
+ length = NodesManagingUtil.getEndOffsetNode(endElement) - start;
+
+ return new Point(start, length);
+
+ }
+
+ /**
+ * @author Sergey Dzmitrovich
+ *
+ * fill contextMenu run-time
+ *
+ */
+ public class InsertMenuListener implements IMenuListener {
+
+ private XModelObject modelObject;
+ private int typeAction;
+
+ public InsertMenuListener(XModelObject modelObject, int typeAction) {
+ this.modelObject = modelObject;
+ this.typeAction = typeAction;
+ }
+
+ public void menuAboutToShow(IMenuManager manager) {
+
+ XModelObject[] modelObjects = modelObject.getChildren();
+ for (int i = 0; i < modelObjects.length; i++) {
+ if (Constants.YES_STRING.equals(modelObjects[i]
+ .getAttributeValue(HIDDEN_PROPERTY))) {
+ continue;
+ }
+
+ if (TAG_ELEMENT_TYPE.equals(modelObjects[i]
+ .getAttributeValue(ELEMENT_TYPE_PROPERTY))) {
+
+ String endText = modelObjects[i]
+ .getAttributeValue(END_TEXT_PROPERTY);
+
+ if (!((typeAction == INSERT_AROUND) && ((endText == null) || (endText
+ .length() == 0)))) {
+
+ Point selectionRange = getSelectionRange(sourceEditor);
+
+ if (typeAction == INSERT_BEFORE) {
+ selectionRange.y = 0;
+ } else if (typeAction == INSERT_AFTER) {
+ selectionRange.x += selectionRange.y;
+ selectionRange.y = 0;
+ }
+
+ manager.add(new InsertAction(modelObjects[i]
+ .getAttributeValue(NAME_PROPERTY),
+ selectionRange, modelObjects[i], pageContext,
+ sourceEditor, REPLACE_WITH == this.typeAction));
+ }
+ }
+
+ else {
+ MenuManager subMenu = new InsertSubMenuManager(
+ modelObjects[i].getAttributeValue(NAME_PROPERTY));
+
+ subMenu.addMenuListener(new InsertMenuListener(
+ modelObjects[i], typeAction));
+
+ manager.add(subMenu);
+
+ subMenu.fill(((MenuManager) manager).getMenu(), -1);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ /**
+ * @author Sergey Dzmitrovich
+ *
+ * class was created to override method isVisible ( because of it
+ * there is possibility to fill context menu run-time )
+ */
+ public class InsertSubMenuManager extends MenuManager {
+
+ @Override
+ public boolean isVisible() {
+ return true;
+ }
+
+ public InsertSubMenuManager(String text) {
+ super(text);
+ }
+
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java 2009-01-08 09:10:41 UTC (rev 12926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java 2009-01-08 13:00:11 UTC (rev 12927)
@@ -36,6 +36,7 @@
private VpePageContext pageContext = null;
private StructuredTextEditor sourceEditor = null;
+ private boolean replace= false;
/**
* Constructor.
@@ -54,6 +55,25 @@
this.pageContext = pageContext;
this.sourceEditor = sourceEditor;
}
+
+ /**
+ * Constructor.
+ *
+ * @param title the name of the action
+ * @param region the Point object
+ * @param item XModelObject object
+ * @param pageContext the VpePageContext element
+ * @param sourceEditor the StructuredTextEditor element
+ */
+ public InsertAction(String title, Point region, XModelObject item, VpePageContext pageContext,
+ StructuredTextEditor sourceEditor, boolean replace) {
+ super(title);
+ this.item = item;
+ this.region = region;
+ this.pageContext = pageContext;
+ this.sourceEditor = sourceEditor;
+ this.replace = replace;
+ }
/**
* @see org.eclipse.jface.action.Action#run()
@@ -76,8 +96,15 @@
*/
String startText = Constants.EMPTY + item.getAttributeValue("start text"); //$NON-NLS-1$
String endText = Constants.EMPTY + item.getAttributeValue("end text"); //$NON-NLS-1$
+
+ if (this.replace) {
+ getSourceEditor().getTextViewer().getTextWidget().replaceTextRange(
+ region.x, region.y, ""); //$NON-NLS-1$
+ region.y = 0;
+ }
+
if (region != null) {
- //set source selection
+ // set source selection
SelectionUtil.setSourceSelection(pageContext, region.x, region.y);
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2009-01-08 09:10:41 UTC (rev 12926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2009-01-08 13:00:11 UTC (rev 12927)
@@ -30,14 +30,14 @@
/**
* Utility class for selection manipulating.
- *
+ *
* @author S.Dzmitrovich
*/
public class SelectionUtil {
/**
* get selected visual node from nsISelection
- *
+ *
* @param selection
* @return
*/
@@ -72,8 +72,10 @@
int start = NodesManagingUtil.getStartOffsetNode(node);
int length = NodesManagingUtil.getNodeLength(node);
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(start, length);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(start, length);
+ pageContext.getSourceBuilder().getStructuredTextViewer()
+ .setSelectedRange(start, length);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
+ start, length);
}
/**
@@ -95,9 +97,11 @@
* @param node
* @param offset
*/
- public static void setSourceSelection(VpePageContext pageContext, Node node, int offset) {
+ public static void setSourceSelection(VpePageContext pageContext,
+ Node node, int offset) {
int start = NodesManagingUtil.getStartOffsetNode(node);
- pageContext.getSourceBuilder().getStructuredTextViewer().getTextWidget().setSelection(start + offset);
+ pageContext.getSourceBuilder().getStructuredTextViewer()
+ .getTextWidget().setSelection(start + offset);
}
/**
@@ -106,13 +110,17 @@
* @param offset
* @param length
*/
- public static void setSourceSelection(VpePageContext pageContext, int offset, int length) {
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(offset, length);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(offset, length);
+ public static void setSourceSelection(VpePageContext pageContext,
+ int offset, int length) {
+ pageContext.getSourceBuilder().getStructuredTextViewer()
+ .setSelectedRange(offset, length);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
+ offset, length);
}
public static VpeNodeMapping getNodeMappingBySourceSelection(
- IStructuredModel model, VpeDomMapping domMapping, int focus, int anchor) {
+ IStructuredModel model, VpeDomMapping domMapping, int focus,
+ int anchor) {
/*
* implementation of IDOMModel's method getIndexedRegion(...) has one
* feature : if cursor is situated at the border of elements then this
@@ -131,43 +139,48 @@
Node focusNode = getSourceNodeByPosition(model, focus);
// if focus node also contain anchor point (selected only 1 element)
- if (focusNode != null && NodesManagingUtil.isNodeContainsPosition(focusNode, anchor)) {
+ if (focusNode != null
+ && NodesManagingUtil.isNodeContainsPosition(focusNode, anchor)) {
return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
}
return null;
}
- public static Node getSourceNodeByPosition(IStructuredModel model, int position) {
- //if we state at the end of text node, model will return
- //for us next node or null if on page exists only text node,
- //but we still in the end of text node, so we should check
- //this situation
+ private static Node getSourceNodeByPosition(IStructuredModel model,
+ int position) {
+ // if we state at the end of text node, model will return
+ // for us next node or null if on page exists only text node,
+ // but we still in the end of text node, so we should check
+ // this situation
// get source node by position
- //see jbide-3163
+ // see jbide-3163
IndexedRegion node = model.getIndexedRegion(position);
- IndexedRegion possibleNode = position >= 1 ? model.getIndexedRegion(position - 1) : null;
+ IndexedRegion possibleNode = position >= 1 ? model
+ .getIndexedRegion(position - 1) : null;
if (node == null && position >= 1) {
node = possibleNode;
- } else if ((node!=null) && (((Node)node).getNodeType() != Node.TEXT_NODE)
- && (node.getStartOffset() == position)
- && (position >= 1)) {
- //check for such situation #text<h1></h1>
+ } else if ((node != null)
+ && (((Node) node).getNodeType() != Node.TEXT_NODE)
+ && (node.getStartOffset() == position) && (position >= 1)) {
+ // check for such situation #text<h1></h1>
node = possibleNode;
- } else if((node != null) && (((Node)node).getNodeType() != Node.TEXT_NODE)
+ } else if ((node != null)
+ && (((Node) node).getNodeType() != Node.TEXT_NODE)
&& (possibleNode != null)
- && ((Node)possibleNode).getNodeType() == Node.TEXT_NODE) {
+ && ((Node) possibleNode).getNodeType() == Node.TEXT_NODE) {
node = possibleNode;
}
- return (Node)node;
+ return (Node) node;
}
/**
* Returns selection range for visual part of editor Focus offset and anchor
* offset can be not equals to source focus offset and anchor offset
*
- * @param selection the selection in visual part of editor
+ * @param selection
+ * the selection in visual part of editor
* @return selection range for visual part of editor
*/
public static Point getVisualSelectionRange(nsISelection selection) {
@@ -183,11 +196,13 @@
/**
* Return source editor part selection range, range returns relatively to
* start of text in source, not for start of document
- *
- * @param selection the selection in visual part of editor
+ *
+ * @param selection
+ * the selection in visual part of editor
* @return source editor selection range
*/
- public static Point getSourceSelectionRange(nsISelection selection, Node sourceNode) {
+ public static Point getSourceSelectionRange(nsISelection selection,
+ Node sourceNode) {
nsIDOMNode focusedNode = getSelectedNode(selection);
// gets visual selection range
Point sourceRange = new Point(0, 0);
@@ -210,7 +225,8 @@
IStructuredModel model = null;
try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
int anchor = range.x;
int focus = range.x + range.y;
@@ -238,15 +254,17 @@
// fixed JBIDE-3388: Incorrect selection after Copy/Cut actions
IndexedRegion node = model.getIndexedRegion(focus);
if (node != null) {
- focusNode = (Node)node;
+ focusNode = (Node) node;
}
}
- // if focus node also contains anchor point (selected only 1 element)
+ // if focus node also contains anchor point (selected only 1
+ // element)
if (focusNode != null) {
-// if (NodesManagingUtil.isNodeContainsPosition(focusNode, anchor)) {
- return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
-// }
+ // if (NodesManagingUtil.isNodeContainsPosition(focusNode,
+ // anchor)) {
+ return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
+ // }
}
} finally {
if (model != null) {
@@ -257,23 +275,51 @@
return null;
}
+ public static Node getNodeBySourcePosition(
+ StructuredTextEditor sourceEditor, int position) {
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+
+ IDocument document = sourceEditor.getTextViewer().getDocument();
+
+ IStructuredModel model = null;
+
+ Node node = null;
+ try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
+
+ node = (Node) model.getIndexedRegion(position);
+
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ return node;
+ }
+
/**
* Method is used to select the last selected node.
- *
- * @param pageContext VpePageContext object
+ *
+ * @param pageContext
+ * VpePageContext object
* @return nsIDOMNode the last selected node
*/
public static nsIDOMNode getLastSelectedNode(VpePageContext pageContext) {
- return pageContext.getVisualBuilder().getXulRunnerEditor().getLastSelectedNode();
+ return pageContext.getVisualBuilder().getXulRunnerEditor()
+ .getLastSelectedNode();
}
/**
* Returns sourceSelectionRange
- *
- * @param sourceEditor StructuredTextEditor object
+ *
+ * @param sourceEditor
+ * StructuredTextEditor object
* @return sourceSelectionRange
*/
- public static Point getSourceSelectionRange(StructuredTextEditor sourceEditor) {
+ public static Point getSourceSelectionRange(
+ StructuredTextEditor sourceEditor) {
ITextViewer textViewer = sourceEditor.getTextViewer();
if (textViewer != null) {
return textViewer.getSelectedRange();
@@ -283,9 +329,11 @@
/**
*
- * @param selectionController VpeSelectionController object
+ * @param selectionController
+ * VpeSelectionController object
*/
public static void clearSelection(VpeSelectionController selectionController) {
- selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).removeAllRanges();
+ selectionController.getSelection(
+ nsISelectionController.SELECTION_NORMAL).removeAllRanges();
}
}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-01-08 09:10:41 UTC (rev 12926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-01-08 13:00:11 UTC (rev 12927)
@@ -87,4 +87,10 @@
public static String RESTORE_PREVIOUS_LOCATION;
public static String BACKGROUND_COLOR_TIP;
public static String SETUP_TEMPLATE_FOR_MENU;
+ public static String INSERT_AROUND;
+ public static String INSERT_BEFORE;
+ public static String INSERT_AFTER;
+ public static String REPLACE_WITH;
+ public static String FROM_PALETTE;
+
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-01-08 09:10:41 UTC (rev 12926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-01-08 13:00:11 UTC (rev 12927)
@@ -65,3 +65,8 @@
RESTORE_PREVIOUS_LOCATION=Restore Previous Location
BACKGROUND_COLOR_TIP=Choose background color
SETUP_TEMPLATE_FOR_MENU=Setup Template for {0}
+INSERT_AROUND=Insert Around
+INSERT_BEFORE=Insert Before
+INSERT_AFTER=Insert After
+REPLACE_WITH=Replace With
+FROM_PALETTE=From Palette
\ No newline at end of file
15 years, 3 months
JBoss Tools SVN: r12926 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui: editors and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-01-08 04:10:41 -0500 (Thu, 08 Jan 2009)
New Revision: 12926
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
Log:
JBIDE-3429
change the graphical model and source page text when the page was changed
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08 08:58:58 UTC (rev 12925)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08 09:10:41 UTC (rev 12926)
@@ -10,6 +10,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -36,6 +38,18 @@
private String errorMessage;
+ private boolean dirty = false;
+
+ public boolean isDirty() {
+ if (!dirty)
+ return false;
+ return super.isDirty();
+ }
+
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ }
+
public String getErrorMessage() {
return errorMessage;
}
@@ -89,6 +103,7 @@
|| messageLabel == null || messageLabel.isDisposed()) {
return;
}
+ errorMessage = message;
if (message == null) {
GridData gd = new GridData();
if (flag) {
@@ -112,7 +127,6 @@
parent.layout();
}
} else {
- errorMessage = message;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
errorComposite.setVisible(true);
messageLabel.setText(message);
@@ -194,6 +208,13 @@
textComposite.setLayoutData(gd);
textComposite.setLayout(new FillLayout());
super.createPartControl(textComposite);
+
+ getTextViewer().getTextWidget().addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setDirty(true);
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
}
public void endAnalyze(AnalyzeResult result) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08 08:58:58 UTC (rev 12925)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08 09:10:41 UTC (rev 12926)
@@ -19,7 +19,6 @@
import java.util.List;
import org.dom4j.Document;
-import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
@@ -80,7 +79,7 @@
// private SmooksTextEdtor textEdtior = null;
private boolean forceDirty = false;
-// private boolean onlyShowTextEditor = false;
+ // private boolean onlyShowTextEditor = false;
private Throwable showTextEditorReason = null;
private boolean allowdActiveErrorSourcePage = true;
@@ -254,22 +253,24 @@
@Override
public void doSave(IProgressMonitor monitor) {
- int index = this.getCurrentPage();
- if (index == 2) {
- this.xmlTextEditor.doSave(monitor);
+ IEditorPart editor = this.getActiveEditor();
+ if (editor == null) {
+ this.graphicalPage.doSave(monitor);
fireEditorDirty(false);
} else {
-
- this.graphicalPage.doSave(monitor);
+ this.xmlTextEditor.doSave(monitor);
fireEditorDirty(false);
}
}
public void fireEditorDirty(boolean dirty) {
this.forceDirty = dirty;
- if (graphicalPage != null) {
+ if (graphicalPage != null && !dirty) {
graphicalPage.setDirty(false);
}
+ if (xmlTextEditor != null && !dirty) {
+ xmlTextEditor.setDirty(false);
+ }
this.firePropertyChange(PROP_DIRTY);
}
@@ -333,7 +334,7 @@
}
public void endAnalyze(AnalyzeResult result) {
- if (result.getError() != null && allowdActiveErrorSourcePage ) {
+ if (result.getError() != null && allowdActiveErrorSourcePage) {
this.setActivePage(2);
}
}
@@ -356,7 +357,7 @@
ByteArrayOutputStream tempStream = null;
XMLWriter writer = null;
try {
- if ((oldPageIndex == 0 || oldPageIndex == 1)&& newPageIndex == 2) {
+ if ((oldPageIndex == 0 || oldPageIndex == 1) && newPageIndex == 2) {
if (xmlTextEditor.getErrorMessage() == null) {
InputStream stream = graphicalPage
.generateSmooksContents(null);
15 years, 3 months
JBoss Tools SVN: r12925 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-01-08 03:58:58 -0500 (Thu, 08 Jan 2009)
New Revision: 12925
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java
Log:
forgot to commit these when changing wizard fragment
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java 2009-01-08 08:58:58 UTC (rev 12925)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.ide.eclipse.as.core.util;
+
+import java.io.File;
+
+public class JBossServerType {
+
+ private static final String SYSTEM_JAR_NAME = "twiddle.jar";
+ private String type;
+ private String jbossSystemJarPath;
+ private String[] versions = new String[0];
+
+ private JBossServerType(String type, String jbossSystemJarPath, String[] versions) {
+ this.type = type;
+ this.jbossSystemJarPath = jbossSystemJarPath;
+ this.versions = versions;
+ }
+
+ public static final JBossServerType AS = new JBossServerType(
+ "AS",
+ "bin"+File.separatorChar + SYSTEM_JAR_NAME,
+ new String[]{"5.0", "4.2", "4.0", "3.2"});
+
+ public static final JBossServerType EAP = new JBossServerType(
+ "EAP",
+ "jboss-as" + File.separatorChar + "bin"+ File.separatorChar + SYSTEM_JAR_NAME,
+ new String[]{"4.2","4.3"});
+
+ public static final JBossServerType SOAP = new JBossServerType(
+ "SOA-P",
+ "jboss-as" + File.separatorChar + "bin"+ File.separatorChar + SYSTEM_JAR_NAME,
+ new String[]{"4.3"});
+
+ public static final JBossServerType UNKNOWN = new JBossServerType(
+ "UNKNOWN",
+ "",
+ new String[]{"5.0", "4.3", "4.2", "4.0", "3.2"});
+
+ public String toString() {
+ return type;
+ }
+
+ public static JBossServerType getType(String name) {
+ if(AS.type.equals(name)) {
+ return AS;
+ } else if(EAP.type.equals(name)) {
+ return EAP;
+ } else if(SOAP.type.equals(name)) {
+ return SOAP;
+ }
+ throw new IllegalArgumentException("Name '" + name + "' cannot be converted to ServerType");
+ }
+
+ public String[] getVersions() {
+ return versions;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getSystemJarPath() {
+ return jbossSystemJarPath;
+ }
+
+ public static final JBossServerType[] KNOWN_TYPES = {AS, EAP, SOAP};
+
+}
\ No newline at end of file
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java 2009-01-08 08:58:58 UTC (rev 12925)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.ide.eclipse.as.core.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ServerBeanLoader {
+
+ public static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl";
+
+ public JBossServerType getServerType(File location) {
+ File asSystemJar = new File(location, JBossServerType.AS.getSystemJarPath());
+ if(asSystemJar.exists() && asSystemJar.isFile()) {
+ return JBossServerType.AS;
+ } else {
+ File eapSystemJar = new File(location, JBossServerType.EAP.getSystemJarPath());
+ File jbpmJpdlFolder = new File(location, this.SOAP_JBPM_JPDL_PATH);
+ if(eapSystemJar.exists() && eapSystemJar.isFile()) {
+ if(jbpmJpdlFolder.exists() && jbpmJpdlFolder.isDirectory()) {
+ return JBossServerType.SOAP;
+ } else {
+ return JBossServerType.EAP;
+ }
+ }
+ }
+ return JBossServerType.UNKNOWN;
+ }
+
+ public String getName(File location) {
+ return location.getName();
+ }
+
+ public String getFullServerVersion(File systemJarFile) {
+ String version = null;
+ if(systemJarFile.canRead()) {
+ try {
+ ZipFile jar = new ZipFile(systemJarFile);
+ ZipEntry manifest = jar.getEntry("META-INF/MANIFEST.MF");
+ Properties props = new Properties();
+ props.load(jar.getInputStream(manifest));
+ version = (String)props.get("Specification-Version");
+ } catch (IOException e) {
+ // version = ""
+ }
+ }
+ return version;
+ }
+
+ public String getServerVersion(String version) {
+ if(version==null) return "";
+ String[] versions = JBossServerType.UNKNOWN.getVersions();
+ String adapterVersion = "";
+ // trying to match adapter version by X.X version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.replace(".", "\\.") + ".*";
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+
+ if("".equals(adapterVersion)) {
+ // trying to match by major version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.substring(0, 2).replace(".", "\\.") + ".*";
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+ }
+ return adapterVersion;
+ }
+
+ public String getAdapterVersion(String version) {
+ String[] versions = JBossServerType.UNKNOWN.getVersions();
+ String adapterVersion = "";
+ // trying to match adapter version by X.X version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.replace(".", "\\.") + ".*";
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+
+ if("".equals(adapterVersion)) {
+ // trying to match by major version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.substring(0, 2).replace(".", "\\.") + ".*";
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+ }
+ return adapterVersion;
+ }
+}
15 years, 3 months
JBoss Tools SVN: r12924 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui: editors and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-01-07 21:52:27 -0500 (Wed, 07 Jan 2009)
New Revision: 12924
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
Log:
JBIDE-3429
Do somethings to synchronize the source and model:
1.when pages are changed from graph page to source page , generate new xml contents replace the old source text.
2.when pages are changed from source page to graph page, parse the source again to create new graph model for the graph page.
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08 01:32:48 UTC (rev 12923)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08 02:52:27 UTC (rev 12924)
@@ -34,6 +34,12 @@
private Composite errorComposite;
private Label messageLabel;
+ private String errorMessage;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
public SmooksTextEdtor(Throwable error) {
super();
this.setErrorThrowable(error);
@@ -106,6 +112,7 @@
parent.layout();
}
} else {
+ errorMessage = message;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
errorComposite.setVisible(true);
messageLabel.setText(message);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08 01:32:48 UTC (rev 12923)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08 02:52:27 UTC (rev 12924)
@@ -80,9 +80,11 @@
// private SmooksTextEdtor textEdtior = null;
private boolean forceDirty = false;
- private boolean onlyShowTextEditor = false;
+// private boolean onlyShowTextEditor = false;
private Throwable showTextEditorReason = null;
+ private boolean allowdActiveErrorSourcePage = true;
+
public SmooksFormEditor() {
super();
adapterFactory = new ComposedAdapterFactory(
@@ -157,7 +159,6 @@
}
public void setParseException(boolean onlyShowTextEditor, Throwable reason) {
- this.onlyShowTextEditor = onlyShowTextEditor;
this.showTextEditorReason = reason;
}
@@ -190,7 +191,6 @@
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
- onlyShowTextEditor = false;
Throwable parsingException = null;
IFile file = ((IFileEditorInput) input).getFile();
String path = file.getLocation().toOSString();
@@ -206,7 +206,6 @@
}
if (parsingException != null) {
- onlyShowTextEditor = true;
showTextEditorReason = parsingException;
return;
}
@@ -268,6 +267,9 @@
public void fireEditorDirty(boolean dirty) {
this.forceDirty = dirty;
+ if (graphicalPage != null) {
+ graphicalPage.setDirty(false);
+ }
this.firePropertyChange(PROP_DIRTY);
}
@@ -331,7 +333,7 @@
}
public void endAnalyze(AnalyzeResult result) {
- if (result.getError() != null) {
+ if (result.getError() != null && allowdActiveErrorSourcePage ) {
this.setActivePage(2);
}
}
@@ -345,45 +347,54 @@
super.pageChange(newPageIndex);
return;
}
-
- if(!isDirty()){
+
+ if (!isDirty()) {
super.pageChange(newPageIndex);
return;
}
-
+
ByteArrayOutputStream tempStream = null;
XMLWriter writer = null;
try {
- if (oldPageIndex == 0 && newPageIndex == 2) {
- InputStream stream = graphicalPage.generateSmooksContents(null);
- SAXReader reader = new SAXReader();
- Document rootElement = reader.read(stream);
- if (prettyXMLOutput) {
- tempStream = new ByteArrayOutputStream();
- OutputFormat format = OutputFormat.createPrettyPrint();
- writer = new XMLWriter(tempStream, format);
- writer.write(rootElement);
+ if ((oldPageIndex == 0 || oldPageIndex == 1)&& newPageIndex == 2) {
+ if (xmlTextEditor.getErrorMessage() == null) {
+ InputStream stream = graphicalPage
+ .generateSmooksContents(null);
+ SAXReader reader = new SAXReader();
+ Document rootElement = reader.read(stream);
+ if (prettyXMLOutput) {
+ tempStream = new ByteArrayOutputStream();
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ writer = new XMLWriter(tempStream, format);
+ writer.write(rootElement);
+ }
+ String text = null;
+ if (prettyXMLOutput) {
+ text = new String(tempStream.toByteArray());
+ } else {
+ text = rootElement.asXML();
+ }
+ xmlTextEditor.getTextViewer().getDocument().set(text);
}
- String text = null;
- if (prettyXMLOutput) {
- text = new String(tempStream.toByteArray());
- } else {
- text = rootElement.asXML();
- }
- xmlTextEditor.getTextViewer().getDocument().set(text);
}
- if (newPageIndex == 0 && oldPageIndex == 2) {
- String contents = xmlTextEditor.getTextViewer().getDocument().get();
- graphicalPage.refreshAllGUI(new ByteArrayInputStream(contents.getBytes()));
+ if ((newPageIndex == 0 || newPageIndex == 1) && oldPageIndex == 2) {
+ String contents = xmlTextEditor.getTextViewer().getDocument()
+ .get();
+ allowdActiveErrorSourcePage = false;
+ graphicalPage.refreshAllGUI(new ByteArrayInputStream(contents
+ .getBytes()));
+ allowdActiveErrorSourcePage = true;
}
} catch (Exception e) {
- }finally{
- try{
- if(writer != null) writer.close();
- if(tempStream != null) tempStream.close();
- }catch(Exception e){
-
+ } finally {
+ try {
+ if (writer != null)
+ writer.close();
+ if (tempStream != null)
+ tempStream.close();
+ } catch (Exception e) {
+
}
}
super.pageChange(newPageIndex);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-08 01:32:48 UTC (rev 12923)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-08 02:52:27 UTC (rev 12924)
@@ -892,6 +892,10 @@
control.setBackground(ColorConstants.white);
return viewer;
}
+
+ public void setDirty(boolean dirty){
+ commandStackChanged = dirty;
+ }
/*
* (non-Javadoc)
15 years, 3 months
JBoss Tools SVN: r12923 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-01-07 20:32:48 -0500 (Wed, 07 Jan 2009)
New Revision: 12923
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
Log:
JBIDE-3389 java.lang.NullPointerException when change deploy directory using radiobuttons On Server Overview after renaming Server runtime Environments
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-01-07 21:27:18 UTC (rev 12922)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-01-08 01:32:48 UTC (rev 12923)
@@ -438,6 +438,9 @@
}
private String makeRelative(String path) {
+ if (getRuntime() == null) {
+ return "";
+ }
return DeployableServer.makeRelative(getRuntime(), new Path(path)).toString();
}
15 years, 3 months