JBoss Tools SVN: r17019 - trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-08-07 12:45:32 -0400 (Fri, 07 Aug 2009)
New Revision: 17019
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
Log:
JBIDE-4660: Update and correct the CA-related JUnit tests after the new-style CA is applied.
Test project data for JsfJspJbide11641Test JUnit Test suite is updated to suite the new-style CA requirements
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2009-08-07 16:17:40 UTC (rev 17018)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2009-08-07 16:45:32 UTC (rev 17019)
@@ -56,6 +56,8 @@
jspTextEditor.setText(documentContentModified);
+ JobUtils.waitForIdle();
+
ICompletionProposal[] result= null;
String errorMessage = null;
16 years, 4 months
JBoss Tools SVN: r17018 - trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-08-07 12:17:40 -0400 (Fri, 07 Aug 2009)
New Revision: 17018
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/.project
Log:
JBIDE-4660: Update and correct the CA-related JUnit tests after the new-style CA is applied.
Test project data for SeamUiAllTests JUnit Test suite is updated to suite the new-style CA requirements:
Project settings are changed due to include new CA nature and builder to the project
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/.project 2009-08-07 15:29:14 UTC (rev 17017)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/.project 2009-08-07 16:17:40 UTC (rev 17018)
@@ -25,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
@@ -34,5 +39,6 @@
<nature>org.jboss.tools.jsf.jsfnature</nature>
<nature>org.jboss.tools.seam.core.seamnature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures>
</projectDescription>
16 years, 4 months
JBoss Tools SVN: r17017 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-08-07 11:29:14 -0400 (Fri, 07 Aug 2009)
New Revision: 17017
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4603 commit again, after previous commit overrode the change.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-08-07 15:18:09 UTC (rev 17016)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-08-07 15:29:14 UTC (rev 17017)
@@ -681,7 +681,7 @@
// Get Fixed Structured Document Region
IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(getOffset());
if (sdFixedRegion == null)
- return null;
+ return EMPTY_TAGS;
n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
}
16 years, 4 months
JBoss Tools SVN: r17016 - in trunk/jst/tests/org.jboss.tools.jst.jsp.test: projects/CAForIDTest and 11 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-08-07 11:18:09 -0400 (Fri, 07 Aug 2009)
New Revision: 17016
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.classpath
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.project
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/.jsdtscope
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.jdt.core.prefs
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.component
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/Messages.properties
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/User.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/MANIFEST.MF
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/faces-config.xml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/common-annotations.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-beanutils.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-collections.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-digester.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-logging.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-api.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-impl.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jstl.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-api-3.3.0.GA.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-impl-3.3.0.GA.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/standard.jar
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/web.xml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/index.jsp
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/hello.jsp
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/inputUserName.jsp
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.properties
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.xml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForIDTest.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3571
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.classpath
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.classpath (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.classpath 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="JavaSource"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 4.2 Runtime">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.6.0_04">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
+</classpath>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.project
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.project (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.project 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CAForIDTest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.jboss.tools.jsf.jsfnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/.jsdtscope
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/.jsdtscope (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/.jsdtscope 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.jdt.core.prefs 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,7 @@
+#Fri Aug 07 19:13:22 MSD 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.component (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.component 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="CAForID">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/JavaSource"/>
+<property name="context-root" value="CAForID"/>
+<property name="java-output-path"/>
+</wb-module>
+</project-modules>
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.project.facet.core.xml 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="JBoss 4.2 Runtime"/>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.java" version="6.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.common.project.facet.core.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.container (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.container 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.name (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/.settings/org.eclipse.wst.jsdt.ui.superType.name 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/Messages.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/Messages.properties (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/Messages.properties 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,3 @@
+header=Hello Demo Application
+prompt_message=Name:
+hello_message=Hello
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/Messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/User.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/User.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/User.java 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package demo;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+public class User {
+
+ private String name;
+
+ /**
+ * @return User Name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param User Name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/JavaSource/demo/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/MANIFEST.MF (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/MANIFEST.MF 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/faces-config.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/faces-config.xml (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/faces-config.xml 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <managed-bean>
+ <description>User Name Bean</description>
+ <managed-bean-name>user</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>name</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
+ <navigation-rule>
+ <from-view-id>/pages/inputUserName.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>hello</from-outcome>
+ <to-view-id>/pages/hello.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/common-annotations.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/common-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-beanutils.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-beanutils.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-collections.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-collections.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-digester.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-digester.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-api.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-api.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-impl.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jsf-impl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jstl.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/jstl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-api-3.3.0.GA.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-api-3.3.0.GA.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-impl-3.3.0.GA.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-impl-3.3.0.GA.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/standard.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/lib/standard.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/web.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/web.xml (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/web.xml 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>CAForID</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.SKIN</param-name>
+ <param-value>classic</param-value>
+ </context-param>
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/index.jsp
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/index.jsp (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/index.jsp 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+ <body>
+ <jsp:forward page="/pages/inputUserName.jsf" />
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/index.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/hello.jsp
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/hello.jsp (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/hello.jsp 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,20 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title>Hello!</title>
+ </head>
+
+ <body>
+ <f:view>
+ <h3>
+ <h:outputText value="#{Message.hello_message}" />,
+ <h:outputText value="#{user.name}" />!
+ </h3>
+ </f:view>
+ </body>
+
+</html>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/hello.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/inputUserName.jsp
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/inputUserName.jsp (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/inputUserName.jsp 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,29 @@
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+
+ <f:view>
+ <h1><h:outputText value="#{Message.header}"/></h1>
+ <a4j:commandButton focus=""/>
+ <h:messages style="color: red"/>
+
+ <h:form id="greetingForm">
+ <h:outputText value="#{Message.prompt_message}"/>
+ <h:inputText value="#{user.name}" required="true">
+ <f:validateLength maximum="30" minimum="3"/>
+ </h:inputText>
+
+ <h:commandButton action="hello" value="Say Hello!" />
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/WebContent/pages/inputUserName.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.properties (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.properties 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,3 @@
+#
+#Fri Aug 07 19:13:21 MSD 2009
+classpath.external=
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.xml (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.xml 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,74 @@
+<project name="KickStart" default="deploy" basedir="../">
+
+ <!-- Project settings -->
+ <property file="${basedir}/ant/build.properties" />
+
+ <property name="project.name" value="KickStart" />
+ <property name="web.content.dir" value="${basedir}/WebContent" />
+ <property name="web-inf.dir" value="${web.content.dir}/WEB-INF" />
+ <property name="build.dir" value="build" />
+ <property name="war.name" value="${build.dir}/${project.name}.war" />
+
+ <!-- Define a folder for deployment -->
+ <property name="deploy.dir" value="deploy" />
+
+ <!-- Compile classpath -->
+ <path id="compile.classpath">
+ <fileset dir="${webinf.dir}/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${classpath}" />
+ <pathelement path="${classpath.external}" />
+ <pathelement path="${webinf.dir}/classes" />
+ </path>
+
+ <!-- Copy any resource or configuration files -->
+ <target name="copyResources">
+ <copy todir="${web-inf.dir}/classes" includeEmptyDirs="no">
+ <fileset dir="JavaSource">
+ <patternset>
+ <include name="**/*.*" />
+ <exclude name="**/*.java" />
+ </patternset>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Check timestamp on files -->
+ <target name="prepare">
+ <tstamp />
+ </target>
+
+ <!-- Remove classes directory for clean build -->
+ <target name="clean" description="Prepare for clean build">
+ <delete dir="${web-inf.dir}/classes" failonerror="false"/>
+ <mkdir dir="${web-inf.dir}/classes" />
+ </target>
+
+ <!-- Normal build of application -->
+ <target name="compile" depends="prepare, copyResources">
+ <javac srcdir="JavaSource" destdir="${web-inf.dir}/classes">
+ <classpath refid="compile.classpath" />
+ </javac>
+ </target>
+
+ <!-- Build Project -->
+ <target name="build" depends="prepare, compile" />
+
+ <!-- Rebuild Project -->
+ <target name="rebuild" depends="clean, prepare, compile" />
+
+ <!-- Build WAR -->
+ <target name="war" depends="build">
+ <mkdir dir="${build.dir}" />
+ <war warfile="${war.name}" basedir="${web.content.dir}" webxml="${web-inf.dir}/web.xml">
+ <exclude name="WEB-INF/web.xml" />
+ </war>
+ </target>
+
+ <target name="deploy" depends="war">
+ <delete dir="${deploy.dir}/${project.name}" failonerror="false"/>
+ <copy file="${war.name}" todir="${deploy.dir}" />
+ </target>
+
+</project>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForIDTest/ant/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2009-08-07 13:58:13 UTC (rev 17015)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2009-08-07 15:18:09 UTC (rev 17016)
@@ -4,6 +4,7 @@
import junit.framework.TestSuite;
import org.jboss.tools.jst.jsp.test.ca.CAForELinStyleTest;
+import org.jboss.tools.jst.jsp.test.ca.CAForIDTest;
import org.jboss.tools.jst.jsp.test.ca.Jbide1791Test;
import org.jboss.tools.jst.jsp.test.ca.JsfJspJbide1704Test;
import org.jboss.tools.jst.jsp.test.ca.JsfJspJbide1717Test;
@@ -21,8 +22,9 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test");
+ suite.addTestSuite(JsfJspJbide1807Test.class);
+ suite.addTestSuite(CAForIDTest.class);
suite.addTestSuite(JsfJspJbide1813Test.class);
- suite.addTestSuite(JsfJspJbide1807Test.class);
suite.addTestSuite(JstJspJbide1585Test.class);
suite.addTestSuite(StrutsJspJbide1648Test.class);
suite.addTestSuite(JstJspJbide1641Test.class);
Added: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForIDTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForIDTest.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForIDTest.java 2009-08-07 15:18:09 UTC (rev 17016)
@@ -0,0 +1,29 @@
+package org.jboss.tools.jst.jsp.test.ca;
+
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+public class CAForIDTest extends ContentAssistantTestCase{
+ TestProjectProvider provider = null;
+ boolean makeCopy = false;
+ private static final String PROJECT_NAME = "CAForIDTest";
+ private static final String PAGE_NAME = "/WebContent/pages/inputUserName.jsp";
+
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null, PROJECT_NAME, makeCopy);
+ project = provider.getProject();
+ }
+
+ protected void tearDown() throws Exception {
+ if(provider != null) {
+ provider.dispose();
+ }
+ }
+
+ public void testCAForIDTest(){
+ String[] proposals = {
+ "greetingForm",
+ };
+
+ checkProposals(PAGE_NAME, "<a4j:commandButton focus=\"\"/>", 26, proposals, false);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForIDTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 4 months
JBoss Tools SVN: r17015 - in trunk/hibernatetools: plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-08-07 09:58:13 -0400 (Fri, 07 Aug 2009)
New Revision: 17015
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/autolayout.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleconnections.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapevisiblestate.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/BaseElement.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Utils.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeTreeEditPart.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/AutoLayout.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandeableShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ModelElement.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/ILinkInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/LayoutConstants.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/ComponentFigure.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleFigure.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleLabel.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ComponentShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ConnectionEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/GEFRootEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPartFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/TreePartFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/HibernateUtils.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java
Log:
JBIDE-4620, JBIDE-4668, JBIDE-4669, JBIDE-4715 - workaround for
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -39,6 +39,9 @@
public static String OpenSourceAction_canot_find_source_file;
public static String OpenSourceAction_canot_open_source_file;
public static String OpenSourceAction_open_source_file;
+ public static String ToggleShapeExpandStateAction_toggle_expand_state;
+ public static String ToggleShapeVisibleStateAction_toggle_visible_state;
+ public static String ToggleConnectionsAction_toggle_connections;
public static String ShapeSetConstraintCommand_move;
public static String PartFactory_canot_create_part_for_model_element;
public static String PartFactory_null;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-08-07 13:58:13 UTC (rev 17015)
@@ -15,6 +15,9 @@
OpenSourceAction_canot_find_source_file=Can't find source file.
OpenSourceAction_canot_open_source_file=Can't open source file.
OpenSourceAction_open_source_file=Open Source File
+ToggleShapeExpandStateAction_toggle_expand_state=Toggle expand state
+ToggleShapeVisibleStateAction_toggle_visible_state=Toggle visible state
+ToggleConnectionsAction_toggle_connections=Toggle connections
ShapeSetConstraintCommand_move=move
PartFactory_canot_create_part_for_model_element=Can't create part for model element:
PartFactory_null=null
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -30,6 +30,10 @@
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.view.ImageBundle;
@SuppressWarnings("restriction")
@@ -43,6 +47,13 @@
workbenchAction.setImageDescriptor(UiPlugin.getImageDescriptor2(ImageBundle.getString("Explorer.refreshOrmGef"))); //$NON-NLS-1$
workbenchAction.setToolTipText(DiagramViewerMessages.EditorActionContributor_refresh_visual_mapping);
addAction(workbenchAction);
+ //
+ addAction(new AutoLayoutAction(null));
+ //
+ addAction(new ToggleConnectionsAction(null));
+ addAction(new ToggleShapeExpandStateAction(null));
+ addAction(new ToggleShapeVisibleStateAction(null));
+ //
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addRetargetAction(new ZoomInRetargetAction());
@@ -65,6 +76,7 @@
*/
public void contributeToToolBar(IToolBarManager tbm) {
tbm.add(getAction(ActionFactory.REFRESH.getId()));
+ tbm.add(new Separator());
tbm.add(getAction(ActionFactory.UNDO.getId()));
tbm.add(getAction(ActionFactory.REDO.getId()));
tbm.add(new Separator());
@@ -76,6 +88,12 @@
ZoomManager.FIT_WIDTH
};
tbm.add(new ZoomComboContributionItem(getPage(), zoomStrings));
+ tbm.add(new Separator());
+ tbm.add(getAction(AutoLayoutAction.ACTION_ID));
+ tbm.add(new Separator());
+ tbm.add(getAction(ToggleConnectionsAction.ACTION_ID));
+ tbm.add(getAction(ToggleShapeExpandStateAction.ACTION_ID));
+ tbm.add(getAction(ToggleShapeVisibleStateAction.ACTION_ID));
}
/**
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.ui.diagram.editors;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -57,6 +58,9 @@
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenSourceAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.GEFRootEditPart;
@@ -68,7 +72,7 @@
import org.jboss.tools.hibernate.ui.view.ObjectEditorInput;
/**
- *
+ * @author some modifications from Vitali
*/
public class DiagramViewer extends GraphicalEditor {
@@ -82,7 +86,7 @@
public void doSave(IProgressMonitor monitor) {
saveProperties();
- ormDiagram.save();
+ ormDiagram.saveInFile();
ormDiagram.setDirty(false);
}
@@ -169,7 +173,16 @@
action = new AutoLayoutAction(this);
registry.registerAction(action);
+
+ action = new ToggleConnectionsAction(this);
+ registry.registerAction(action);
+
+ action = new ToggleShapeExpandStateAction(this);
+ registry.registerAction(action);
+ action = new ToggleShapeVisibleStateAction(this);
+ registry.registerAction(action);
+
action = new CollapseAllAction(this);
registry.registerAction(action);
@@ -207,6 +220,18 @@
public boolean isDirty() {
return ormDiagram.isDirty();
}
+
+ protected String getItemName(RootClass rootClass) {
+ String res = rootClass.getEntityName();
+ if (res == null) {
+ res = rootClass.getClassName();
+ }
+ if (res == null) {
+ res = rootClass.getNodeName();
+ }
+ res = res.substring(res.lastIndexOf(".") + 1); //$NON-NLS-1$
+ return res;
+ }
protected void setInput(IEditorInput input) {
ObjectEditorInput objectEditorInput = (ObjectEditorInput)input;
@@ -214,15 +239,21 @@
Object obj = objectEditorInput.getObject();
if (obj instanceof RootClass) {
RootClass rootClass = (RootClass)obj;
- setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + rootClass.getEntityName());
+ setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + " " + getItemName(rootClass)); //$NON-NLS-1$
ormDiagram = new OrmDiagram(configuration, rootClass);
} else if (obj instanceof RootClass[]) {
RootClass[] rootClasses = (RootClass[])obj;
- String name = rootClasses.length > 0 ? rootClasses[0].getEntityName() : ""; //$NON-NLS-1$
+ ArrayList<String> names = new ArrayList<String>();
+ for (int i = 0; i < rootClasses.length; i++) {
+ names.add(getItemName(rootClasses[i]));
+ }
+ // sort to get same name for same combinations of entities
+ Collections.sort(names);
+ String name = names.size() > 0 ? names.get(0) : ""; //$NON-NLS-1$
for (int i = 1; i < rootClasses.length; i++) {
- name += " & " + rootClasses[i].getEntityName(); //$NON-NLS-1$
+ name += " & " + names.get(i); //$NON-NLS-1$
}
- setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + name);
+ setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + " " + name); //$NON-NLS-1$
ormDiagram = new OrmDiagram(configuration, rootClasses);
}
super.setInput(input);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,25 +10,27 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
-import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
-public class AutoLayoutAction extends Action {
+/**
+ * @author some modifications from Vitali
+ */
+public class AutoLayoutAction extends DiagramBaseAction {
public static final String ACTION_ID = "auto_layout_id"; //$NON-NLS-1$
- private DiagramViewer editor;
-
public AutoLayoutAction(DiagramViewer editor) {
- this.editor = editor;
+ super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.AutoLayoutAction_auto_layout);
- //setImageDescriptor(ImageDescriptor.createFromFile(
- // DiagramViewer.class, "icons/export.png"));
+ setToolTipText(DiagramViewerMessages.AutoLayoutAction_auto_layout);
+ setImageDescriptor(ImageDescriptor.createFromFile(
+ DiagramViewer.class, "icons/autolayout.png")); //$NON-NLS-1$
}
public void run() {
- editor.getViewerContents().update();
+ getDiagramViewer().getViewerContents().autolayout();
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -10,21 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
-import org.eclipse.jface.action.Action;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
/**
- *
+ * @author Vitali Yemialyanchyk
*/
-public class CollapseAllAction extends Action {
+public class CollapseAllAction extends DiagramBaseAction {
public static final String ACTION_ID = "collapse_all_id"; //$NON-NLS-1$
- private DiagramViewer editor;
-
public CollapseAllAction(DiagramViewer editor) {
- this.editor = editor;
+ super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.CollapseAllAction_collapse_all);
//setImageDescriptor(ImageDescriptor.createFromFile(
@@ -32,6 +29,6 @@
}
public void run() {
- editor.getViewerContents().collapseAll();
+ getDiagramViewer().getViewerContents().collapseAll();
}
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class DiagramBaseAction extends Action {
+
+ protected DiagramViewer editor;
+
+ public DiagramBaseAction(DiagramViewer editor) {
+ this.editor = editor;
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ DiagramViewer res = editor;
+ if (res == null && PlatformUI.getWorkbench() != null &&
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null &&
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null &&
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() != null) {
+ IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+ if (part instanceof DiagramViewer) {
+ res = (DiagramViewer)part;
+ }
+ }
+ return res;
+ }
+
+ public boolean isEnabled() {
+ return (getDiagramViewer() != null);
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -10,21 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
-import org.eclipse.jface.action.Action;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
/**
- *
+ * @author Vitali Yemialyanchyk
*/
-public class ExpandAllAction extends Action {
+public class ExpandAllAction extends DiagramBaseAction {
public static final String ACTION_ID = "expand_all_id"; //$NON-NLS-1$
- private DiagramViewer editor;
-
public ExpandAllAction(DiagramViewer editor) {
- this.editor = editor;
+ super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ExpandAllAction_expand_all);
//setImageDescriptor(ImageDescriptor.createFromFile(
@@ -32,6 +29,6 @@
}
public void run() {
- editor.getViewerContents().expandAll();
+ getDiagramViewer().getViewerContents().expandAll();
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -20,7 +20,6 @@
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
@@ -33,18 +32,17 @@
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
-public class ExportImageAction extends Action {
+public class ExportImageAction extends DiagramBaseAction {
public static final String ACTION_ID = "export_as_image_id"; //$NON-NLS-1$
public static final String[] dialogFilterExtensions = new String[] { "*.png", "*.jpg", "*.bmp" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static final String[] dialogFilterNames = new String[] { DiagramViewerMessages.ExportImageAction_png_format,
DiagramViewerMessages.ExportImageAction_jpg_format, DiagramViewerMessages.ExportImageAction_bmp_format };
- private DiagramViewer editor;
private FileDialog saveDialog = null;
public ExportImageAction(DiagramViewer editor) {
- this.editor = editor;
+ super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ExportImageAction_export_as_image);
setImageDescriptor(ImageDescriptor.createFromFile(
@@ -65,7 +63,7 @@
if (saveDialog == null) {
saveDialog = new FileDialog(
- this.editor.getSite().getShell(), SWT.SAVE);
+ getDiagramViewer().getSite().getShell(), SWT.SAVE);
}
saveDialog.setFilterExtensions(dialogFilterExtensions);
saveDialog.setFilterNames(dialogFilterNames);
@@ -76,7 +74,7 @@
return;
}
- IFigure fig = ((ScalableFreeformRootEditPart) this.editor
+ IFigure fig = ((ScalableFreeformRootEditPart) getDiagramViewer()
.getEditPartViewer().getRootEditPart())
.getLayer(LayerConstants.PRINTABLE_LAYERS);
int imageType = SWT.IMAGE_BMP;
@@ -92,7 +90,7 @@
outStream.write(imageData);
outStream.flush();
} catch (Exception e) {
- MessageDialog.openInformation(this.editor.getSite().getShell(),
+ MessageDialog.openInformation(getDiagramViewer().getSite().getShell(),
DiagramViewerMessages.ExportImageAction_error, DiagramViewerMessages.ExportImageAction_failed_to_export_image + e.getMessage());
return;
}
@@ -118,7 +116,7 @@
*/
private byte[] createImage(IFigure figure, int format) throws Exception {
- Device device = this.editor.getEditPartViewer().getControl()
+ Device device = getDiagramViewer().getEditPartViewer().getControl()
.getDisplay();
Rectangle r = figure.getBounds();
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleConnectionsAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleConnectionsId"; //$NON-NLS-1$
+
+ public ToggleConnectionsAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleConnectionsAction_toggle_connections);
+ setToolTipText(DiagramViewerMessages.ToggleConnectionsAction_toggle_connections);
+ setImageDescriptor(ImageDescriptor.createFromFile(
+ DiagramViewer.class, "icons/toggleconnections.png")); //$NON-NLS-1$
+ }
+
+ public void run() {
+ getDiagramViewer().getViewerContents().toggleConnections();
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.gef.editparts.AbstractTreeEditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
+
+/**
+ * Toggle expand state of selected shapes.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleShapeExpandStateAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleShapeExpandStateId"; //$NON-NLS-1$
+
+ public ToggleShapeExpandStateAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state);
+ setToolTipText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state);
+ setImageDescriptor(ImageDescriptor.createFromFile(
+ DiagramViewer.class, "icons/toggleshapeexpandstate.png")); //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("unchecked")
+ public void run() {
+ ISelection selection = getDiagramViewer().getEditPartViewer().getSelection();
+ if (!(selection instanceof StructuredSelection)) {
+ return;
+ }
+ List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
+ IStructuredSelection structedSelection = (IStructuredSelection)selection;
+ if (structedSelection != null) {
+ Iterator it = structedSelection.iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ Object obj = null;
+ if (firstElement instanceof OrmEditPart) {
+ obj = ((OrmEditPart)firstElement).getModel();
+ } else if (firstElement instanceof AbstractTreeEditPart) {
+ obj = ((AbstractTreeEditPart)firstElement).getModel();
+ }
+ if (null != obj && obj instanceof ExpandableShape) {
+ selectedShape.add((ExpandableShape)obj);
+ }
+ }
+ }
+ for (ExpandableShape shape : selectedShape) {
+ shape.setExpanded(!shape.isExpanded());
+ }
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.gef.editparts.AbstractTreeEditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Table;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
+
+/**
+ * Toggle visible state of selected shapes.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleShapeVisibleStateAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleShapeVisibleStateId"; //$NON-NLS-1$
+
+ public ToggleShapeVisibleStateAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state);
+ setToolTipText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state);
+ setImageDescriptor(ImageDescriptor.createFromFile(
+ DiagramViewer.class, "icons/toggleshapevisiblestate.png")); //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("unchecked")
+ public void run() {
+ ISelection selection = getDiagramViewer().getEditPartViewer().getSelection();
+ if (!(selection instanceof StructuredSelection)) {
+ return;
+ }
+ List<OrmShape> selectedShape = new ArrayList<OrmShape>();
+ IStructuredSelection structedSelection = (IStructuredSelection)selection;
+ if (structedSelection != null) {
+ Iterator it = structedSelection.iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ Object obj = null;
+ if (firstElement instanceof OrmEditPart) {
+ obj = ((OrmEditPart)firstElement).getModel();
+ } else if (firstElement instanceof AbstractTreeEditPart) {
+ obj = ((AbstractTreeEditPart)firstElement).getModel();
+ }
+ if (null != obj && obj instanceof OrmShape) {
+ selectedShape.add((OrmShape)obj);
+ }
+ }
+ }
+ for (OrmShape shape : selectedShape) {
+ Object ormElement = shape.getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ shape.setVisible(!shape.isVisible());
+ }
+ }
+ }
+}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/AutoLayout.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/AutoLayout.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/AutoLayout.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.ui.diagram.editors.autolayout;
-
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl.AutoLayoutImpl;
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl.Items;
-
-
-public class AutoLayout {
- AutoLayoutImpl engine = new AutoLayoutImpl();
-
- public AutoLayout() {
- this(new Items());
- }
-
- public AutoLayout(Items items) {
- setItems(items);
- }
-
- public void setGridStep(String gridStep) {
- engine.setGridStep(gridStep);
- }
-
- public void setItems(Items items) {
- engine.setItems(items);
- }
-
- public void setOverride(boolean b) {
- engine.setOverride(b);
- }
-
- public void setProcess(IDiagramInfo process) {
- engine.setProcess(process);
- }
-
-}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -11,7 +11,7 @@
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout;
/**
- * interface to provide information about whole diagram
+ * interface to provide whole diagram information to autolayout
*/
public interface IDiagramInfo {
IItemInfo[] getItems();
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,10 +10,24 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout;
+/**
+ * Information about item which is essential for our autolayout implementation.
+ */
public interface IItemInfo {
+ /**
+ * @return unique item id
+ */
public String getID();
public boolean isComment();
+ /**
+ * gets shape vertices
+ */
public int[] getShape();
+ /**
+ * setup OrmShape up-left point location, using s[0] and s[1]
+ * -> this is really thing behind this function, change the comment if you change the behavior
+ */
+ public void setShape(int[] s);
+
ILinkInfo[] getLinks();
- public void setShape(int[] s);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/ILinkInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/ILinkInfo.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/ILinkInfo.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout;
+/**
+ * Information about item links which is essential for our autolayout implementation.
+ */
public interface ILinkInfo {
public String getTargetID();
- public void setLinkShape(int[] vs);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -11,17 +11,21 @@
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IDiagramInfo;
-
+/**
+ *
+ * @author some modifications from Vitali
+ */
public class AutoLayoutImpl {
LayoutConstants constants = new LayoutConstants();
- protected Items items;
+ protected Items items = new Items();
- public AutoLayoutImpl() {}
+ public AutoLayoutImpl() {
+ items.setConstants(constants);
+ }
- public void setGridStep(String gridStep) {
+ public void setGridStep(int gridStep) {
constants.update(gridStep);
}
@@ -46,8 +50,6 @@
}
private void apply() {
- resetTransitions(); // temporal
-
Item[] is = items.items;
int[] yDeltas = items.groups.yDeltas;
for (int i = 0; i < is.length; i++) {
@@ -65,23 +67,4 @@
o.setShape(new int[]{x, y, 0, 0});
}
}
-
- private void resetTransitions() {
- if (!items.override) {
- return;
- }
- Item[] is = items.items;
- for (int i = 0; i < is.length; i++) {
- IItemInfo o = is[i].itemInfo;
- if (o instanceof ILinkInfo) {
- ((ILinkInfo)o).setLinkShape(new int[0]);
- }
- ILinkInfo[] os = items.getOutput(o);
- for (int j = 0; j < os.length; j++) {
- os[j].setLinkShape(new int[0]);
- }
- }
-
- }
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/LayoutConstants.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/LayoutConstants.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/LayoutConstants.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl;
+/**
+ *
+ * @author some modifications from Vitali
+ */
public class LayoutConstants {
static int DELTA_X = 200;
static int DELTA_Y = 104;
@@ -32,7 +36,11 @@
deltaY = DELTA_Y;
incX = X_INC;
incY = Y_INC;
- }
+ }
+ update(step);
+ }
+
+ public void update(int step) {
indentX = (step < 24) ? 24 : step;
indentY = (step < 16) ? 16 : step;
if (step == 16) {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -10,11 +10,10 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl;
-import java.util.List;
-
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
-
-
+/**
+ *
+ * @author some modifications from Vitali
+ */
public class TransitionArranger {
Item[] items;
@@ -35,7 +34,11 @@
}
private void clean(int[][] occ) {
- for (int i = 0; i < occ.length; i++) for (int j = 0; j < occ[0].length; j++) occ[i][j] = 0;
+ for (int i = 0; i < occ.length; i++) {
+ for (int j = 0; j < occ[0].length; j++) {
+ occ[i][j] = 0;
+ }
+ }
}
private void fill(Item[] v, int ix) {
@@ -83,7 +86,6 @@
int iy2 = items[is[k]].iy;
occ[tg][iy2]++;
}
- apply(v[iy], tg);
}
}
@@ -122,13 +124,4 @@
}
return p;
}
-
- private void apply(Item item, int tg) {
- List<ILinkInfo> links = item.inputLinks;
- for (int k = 0; k < links.size(); k++) {
- ILinkInfo io = links.get(k);
- io.setLinkShape(new int[]{-1, 8 * (tg + 2)});
- }
- }
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/ComponentFigure.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/ComponentFigure.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/ComponentFigure.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -14,15 +14,56 @@
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
/**
- *
+ * @author some modifications from Vitali
*/
@SuppressWarnings("unchecked")
public class ComponentFigure extends Figure {
- private boolean childsHiden = false;
+ /**
+ * to represent expanded/collapsed state
+ */
+ protected boolean expanded = true;
+
+ protected TitleLabel titleLabel = null;
+
+ public ComponentFigure() {
+ super();
+ setLayoutManager(new ToolbarLayout());
+ }
+
+ public void createTitle(String text, Image icon, Color bg) {
+ removeTitle();
+ TitleLabel label = new TitleLabel();
+ label.setText(text);
+ label.setBackgroundColor(bg);
+ label.setOpaque(true);
+ label.setIcon(icon);
+ label.setLabelAlignment(PositionConstants.LEFT);
+ label.setBorder(new MarginBorder(1, 2, 1, 2));
+ add(label, -2);
+ titleLabel = label;
+ }
+ public void removeTitle() {
+ if (titleLabel != null) {
+ remove(titleLabel);
+ titleLabel = null;
+ }
+ }
+
+ /**
+ * Override
+ * @see IFigure#add(IFigure, Object, int)
+ * so index == -2 means add to the 0 place, in other case index incremented
+ */
+ @Override
public void add(IFigure figure, Object constraint, int index) {
if (index != -1) {
if (index == -2) {
@@ -34,21 +75,34 @@
super.add(figure, constraint, index);
}
+ /**
+ * @see IFigure#getChildren()
+ * in expanded state return all children,
+ * in collapsed state return only the first child
+ */
+ @Override
public List getChildren() {
List res = super.getChildren();
- if (childsHiden) {
- res = res.subList(0, 1);
- }
+ // in collapsed state - show only first title item
+ res = expanded ? res : res.subList(0, 1);
return res;
}
- public void setChildsHiden(boolean childsHiden) {
- this.childsHiden = childsHiden;
- List children = getChildren();
- for (int i = 0; i < children.size(); i++) {
- if (children.get(i) instanceof TitleLabel) {
- ((TitleLabel)children.get(i)).setHidden(childsHiden);
- }
+ public void setExpanded(boolean expanded) {
+ this.expanded = expanded;
+ if (titleLabel != null) {
+ titleLabel.setExpanded(expanded);
}
+ int width = expanded ? -1 : getPreferredSize().width;
+ setSize(width, -1);
+ repaint();
}
+
+ public boolean getExpanded() {
+ return expanded;
+ }
+
+ public void refresh() {
+ setExpanded(getExpanded());
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleFigure.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleFigure.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleFigure.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -14,15 +14,77 @@
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.hibernate.ui.diagram.editors.parts.ResourceManager;
/**
+ * Main draw figure to OrmShape. It has a border and children.
+ * One specific child is TitleLabel.
+ * Could be in 2 states: expanded and collapsed.
*
+ * @author some modifications from Vitali
*/
@SuppressWarnings("unchecked")
public class TitleFigure extends Figure {
- private boolean hiden = false;
+ /**
+ * to represent expanded/collapsed state
+ */
+ protected boolean expanded = true;
+
+ protected TitleLabel titleLabel = null;
+
+ public TitleFigure() {
+ super();
+ RoundLineBorder border = new RoundLineBorder();
+ border.setColor(ResourceManager.getInstance().getColor(new RGB(160, 160, 160)));
+ setBorder(border);
+ setSize(-1, -1);
+ }
+
+ /**
+ * Creates title child figure.
+ * @param text
+ * @param icon
+ * @param bg
+ */
+ public void createTitle(String text, Image icon, Color bg) {
+ removeTitle();
+ TitleLabel label = new TitleLabel();
+ label.setText(text);
+ FontData fontData[] = Display.getCurrent().getSystemFont().getFontData();
+ fontData[0].setStyle(SWT.BOLD);
+ //fontData[0].height++;
+ label.setFont(ResourceManager.getInstance().getFont(fontData[0]));
+ label.setBackgroundColor(bg);
+ label.setIcon(icon);
+ label.setLabelAlignment(PositionConstants.LEFT);
+ label.setBorder(new MarginBorder(1, 2, 1, 2));
+ label.setOpaque(true);
+ add(label, -2);
+ titleLabel = label;
+ }
+ public void removeTitle() {
+ if (titleLabel != null) {
+ remove(titleLabel);
+ titleLabel = null;
+ }
+ }
+
+ /**
+ * Override
+ * @see IFigure#add(IFigure, Object, int)
+ * so index == -2 means add to the 0 place, in other case index incremented
+ */
+ @Override
public void add(IFigure figure, Object constraint, int index) {
if (index != -1) {
if (index == -2) {
@@ -34,13 +96,34 @@
super.add(figure, constraint, index);
}
+ /**
+ * @see IFigure#getChildren()
+ * in expanded state return all children,
+ * in collapsed state return only the first child
+ */
+ @Override
public List getChildren() {
List res = super.getChildren();
- res = hiden ? res.subList(0, 1) : res;
+ // in collapsed state - show only first title item
+ res = expanded ? res : res.subList(0, 1);
return res;
}
- public void setHidden(boolean hiden) {
- this.hiden = hiden;
+ public void setExpanded(boolean expanded) {
+ this.expanded = expanded;
+ if (titleLabel != null) {
+ titleLabel.setExpanded(expanded);
+ }
+ int width = expanded ? -1 : getPreferredSize().width;
+ setSize(width, -1);
+ repaint();
}
+
+ public boolean getExpanded() {
+ return expanded;
+ }
+
+ public void refresh() {
+ setExpanded(getExpanded());
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleLabel.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleLabel.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/figures/TitleLabel.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.figures;
+import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
@@ -17,32 +18,49 @@
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
import org.jboss.tools.hibernate.ui.view.ImageBundle;
-
+/**
+ * Specific label with 2 additional states: expanded and collapsed
+ *
+ * @author some modifications from Vitali
+ */
public class TitleLabel extends Label {
static Image shevronUp = UiPlugin.getImageDescriptor2(ImageBundle.getString("VisualMapping.shevronUp")).createImage(); //$NON-NLS-1$
static Image shevronDown = UiPlugin.getImageDescriptor2(ImageBundle.getString("VisualMapping.shevronDown")).createImage(); //$NON-NLS-1$
- protected boolean hiden = false;
-
+ /**
+ * to represent expanded/collapsed state
+ */
+ protected boolean expanded = true;
+ /**
+ * @see Label#calculateLabelSize(Dimension)
+ */
+ @Override
protected Dimension calculateLabelSize(Dimension txtSize) {
Dimension p = super.calculateLabelSize(txtSize).getCopy();
p.width += 40;
return p;
}
+ /**
+ * @see Figure#paintFigure(Graphics)
+ * plus draws expanded or collapsed state
+ */
+ @Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
- if (hiden) {
- graphics.drawImage(shevronDown, getBounds().x+getBounds().width-20, getBounds().y);
+ if (expanded) {
+ graphics.drawImage(shevronUp, getBounds().x + getBounds().width - 20, getBounds().y);
} else {
- graphics.drawImage(shevronUp, getBounds().x+getBounds().width-20, getBounds().y);
+ graphics.drawImage(shevronDown, getBounds().x + getBounds().width - 20, getBounds().y);
}
}
- public void setHidden(boolean hiden) {
- this.hiden = hiden;
+ public void setExpanded(boolean expanded) {
+ if (this.expanded != expanded) {
+ this.expanded = expanded;
+ }
repaint();
}
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/autolayout.png
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/autolayout.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleconnections.png
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleconnections.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate.png
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapevisiblestate.png
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapevisiblestate.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/BaseElement.java (from rev 16821, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ModelElement.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/BaseElement.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/BaseElement.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * This is basis model class for diagram items.
+ * Any BaseElement could be a parent, but only Shape could be a child.
+ *
+ * @author Vitali
+ */
+public abstract class BaseElement implements IPropertySource, Comparable<BaseElement> {
+
+ public static final String SELECTED = "selected"; //$NON-NLS-1$
+ public static final String VISIBLE = "visible"; //$NON-NLS-1$
+ public static final String VISIBLE_CHILDREN = "visibileChildren"; //$NON-NLS-1$
+ public static final String REFRESH = "refresh"; //$NON-NLS-1$
+
+ /** An empty property descriptor. */
+ private static final IPropertyDescriptor[] EMPTY_ARRAY = new IPropertyDescriptor[0];
+
+ private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport(this);
+
+ protected boolean selected = false;
+ protected boolean visible = true;
+ protected boolean visibleChildren = true;
+
+ public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
+ if (l == null) {
+ throw new IllegalArgumentException();
+ }
+ pcsDelegate.addPropertyChangeListener(l);
+ }
+
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ if (pcsDelegate.hasListeners(property)) {
+ pcsDelegate.firePropertyChange(property, oldValue, newValue);
+ }
+ }
+
+ public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
+ if (l != null) {
+ pcsDelegate.removePropertyChangeListener(l);
+ }
+ }
+
+ /**
+ * The result is parent or null if the object has no parent
+ * @return BaseElement
+ */
+ abstract public BaseElement getParent();
+
+ /**
+ * The children are items which type is Shape!
+ * In general BaseElement is not a child.
+ */
+ private ArrayList<Shape> children = new ArrayList<Shape>();
+
+ public Iterator<Shape> getChildrenIterator() {
+ return children.iterator();
+ }
+
+ /**
+ * Return copy of children list (to prevent modification of internal array)
+ * @return
+ */
+ public List<Shape> getChildrenList() {
+ ArrayList<Shape> copy = new ArrayList<Shape>();
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ copy.add(it.next());
+ }
+ return copy;
+ }
+
+ /**
+ * Number of children
+ * @return
+ */
+ public int getChildrenNumber() {
+ return children.size();
+ }
+
+ /**
+ * Standard way to add child
+ * @param item
+ * @return
+ */
+ public boolean addChild(Shape item) {
+ if (item == null || (this == item.getParent() && children.contains(item))) {
+ return false;
+ }
+ item.setParent(this);
+ return children.add(item);
+ }
+
+ /**
+ * Standard way to remove child
+ * @param item
+ * @return
+ */
+ public boolean removeChild(Shape item) {
+ if (item == null) {
+ return false;
+ }
+ item.setParent(null);
+ return children.remove(item);
+ }
+
+ /**
+ * Clear all children
+ */
+ public void deleteChildren() {
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ Shape me = it.next();
+ me.setParent(null);
+ }
+ children.clear();
+ }
+
+ public void sortChildren(boolean deepInto) {
+ Collections.sort(children);
+ if (deepInto) {
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ Shape me = it.next();
+ me.sortChildren(deepInto);
+ }
+ }
+ }
+
+ public int compareTo(BaseElement be) {
+ return toString().compareToIgnoreCase(be.toString());
+ }
+
+ public Object getEditableValue() {
+ return this;
+ }
+
+ /**
+ * Children should override this. The default implementation returns an empty array.
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * Children should override this. The default implementation returns null.
+ */
+ public Object getPropertyValue(Object id) {
+ return null;
+ }
+
+ /**
+ * Children should override this. The default implementation returns false.
+ */
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ /**
+ * Children should override this. The default implementation does nothing.
+ */
+ public void resetPropertyValue(Object id) {
+ // do nothing
+ }
+
+ /**
+ * Children should override this. The default implementation does nothing.
+ */
+ public void setPropertyValue(Object id, Object value) {
+ // do nothing
+ }
+
+ public boolean isSelected() {
+ return selected;
+ }
+
+ public void setSelected(boolean selected) {
+ boolean selectedOld = this.selected;
+ //if (!visible && selected) {
+ // // invisible item can't be selected
+ // selected = false;
+ //}
+ this.selected = selected;
+ firePropertyChange(SELECTED, Boolean.valueOf(selectedOld), Boolean.valueOf(selected));
+ }
+
+ public boolean isVisible() {
+ //boolean visible = this.visible;
+ //if (visible && getParent() != null) {
+ // visible = getParent().isVisible();
+ //}
+ return visible;
+ }
+
+ public void setVisible(boolean visible) {
+ boolean visibleOld = this.visible;
+ this.visible = visible;
+ setVisibleChildren(visible);
+ firePropertyChange(VISIBLE, Boolean.valueOf(visibleOld), Boolean.valueOf(visible));
+ updateVisibleValue(this.visible);
+ }
+
+ /**
+ * updates visible value for model elements which are dependent
+ * of visible state of the current model element and update
+ * other properties which are dependent of visible state
+ */
+ public void updateVisibleValue(boolean initState) {
+ if (!visible) {
+ setSelected(false);
+ }
+ }
+
+ public boolean isVisibleChildren() {
+ return visibleChildren;
+ }
+
+ public void setVisibleChildren(boolean visibleChildren) {
+ boolean visibleChildrenOld = this.visibleChildren;
+ this.visibleChildren = visibleChildren;
+ if (visibleChildren && !visible) {
+ setVisible(true);
+ }
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ it.next().setVisible(visibleChildren);
+ }
+ firePropertyChange(VISIBLE_CHILDREN, Boolean.valueOf(visibleChildrenOld), Boolean.valueOf(visibleChildren));
+ }
+
+ public void refreshBasic() {
+ firePropertyChange(REFRESH, null, null);
+ }
+
+ public void refresh() {
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ Shape shape = it.next();
+ shape.refresh();
+ }
+ refreshBasic();
+ }
+
+ /**
+ * @return key value for object of this class
+ */
+ public abstract String getKey();
+
+ protected void setPropertyValue(Properties properties, String key, boolean value) {
+ if (properties.containsKey(key)) {
+ properties.remove(key);
+ }
+ properties.put(key, Boolean.valueOf(value).toString());
+ }
+
+ protected boolean getPropertyValue(Properties properties, String key) {
+ String str = properties.getProperty(key, "true"); //$NON-NLS-1$
+ return Boolean.valueOf(str).booleanValue();
+ }
+
+ public void setPrValue(Properties properties, boolean value, String propertyName) {
+ setPropertyValue(properties, getKey() + "." + propertyName, value); //$NON-NLS-1$
+ }
+
+ public boolean getPrValue(Properties properties, String propertyName) {
+ return getPropertyValue(properties, getKey() + "." + propertyName); //$NON-NLS-1$
+ }
+
+ protected void loadFromProperties(Properties properties) {
+ boolean visibleChildren = getPrValue(properties, VISIBLE_CHILDREN);
+ setVisibleChildren(visibleChildren);
+ boolean visible = getPrValue(properties, VISIBLE);
+ setVisible(visible);
+ boolean selected = getPrValue(properties, SELECTED);
+ setSelected(selected);
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ it.next().loadFromProperties(properties);
+ }
+ }
+
+ protected void saveInProperties(Properties properties) {
+ boolean visibleChildren = isVisibleChildren();
+ setPrValue(properties, visibleChildren, VISIBLE_CHILDREN);
+ boolean visible = isVisible();
+ setPrValue(properties, visible, VISIBLE);
+ boolean selected = isSelected();
+ setPrValue(properties, selected, SELECTED);
+ Iterator<Shape> it = getChildrenIterator();
+ while (it.hasNext()) {
+ it.next().saveInProperties(properties);
+ }
+ }
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,21 +10,27 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.model;
-import java.util.Iterator;
-
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Property;
-public class ComponentShape extends ExpandeableShape {
+/**
+ * @author some modifications from Vitali
+ */
+public class ComponentShape extends ExpandableShape {
- public static final String SET_CHILDS_HIDEN = "set childs hiden"; //$NON-NLS-1$
-
public ComponentShape(Object ioe) {
super(ioe);
- Shape bodyOrmShape;
- if (ioe instanceof Property) {
- Collection collection = (Collection)((Property)ioe).getValue();
- bodyOrmShape = new Shape(collection.getKey());
+ initModel();
+ }
+
+ /**
+ * creates children of the shape,
+ */
+ protected void initModel() {
+ Object ormElement = getOrmElement();
+ if (ormElement instanceof Property) {
+ Collection collection = (Collection)((Property)ormElement).getValue();
+ Shape bodyOrmShape = new Shape(collection.getKey());
bodyOrmShape.setIndent(20);
addChild(bodyOrmShape);
bodyOrmShape = new Shape(collection.getElement());
@@ -32,23 +38,4 @@
addChild(bodyOrmShape);
}
}
-
- protected void setChildsHidden(boolean hidden) {
- Iterator<Shape> it = getChildrenIterator();
- while (it.hasNext()) {
- it.next().setHidden(hidden);
- }
- }
-
- public void refreshChildsHiden(OrmDiagram ormDiagram) {
- refHide = !refHide;
- setChildsHidden(!refHide);
- if (refHide) {
- if (first) {
- ormDiagram.refreshComponentReferences(this);
- first = false;
- }
- }
- firePropertyChange(SET_CHILDS_HIDEN, null, Boolean.valueOf(!refHide));
- }
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -10,22 +10,25 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.model;
-public class Connection extends ModelElement {
+/**
+ * Directed connection between 2 shapes, from source to target.
+ *
+ * @author some modifications from Vitali
+ */
+public class Connection extends BaseElement {
- public static final String HIDE_SELECTION = "hide selection"; //$NON-NLS-1$
- public static final String SHOW_SELECTION = "show selection"; //$NON-NLS-1$
- public static final String SET_HIDEN = "set hiden"; //$NON-NLS-1$
-
- private Shape source;
- private Shape target;
-
- private int needHide;
+ protected Shape source;
+ protected Shape target;
+
+ /**
+ * flag to prevent cycle call of updateVisibleValue()
+ */
+ protected boolean inUpdateVisibleValue = false;
public Connection(Shape s, Shape newTarget) {
if (s == null || newTarget == null || s == newTarget) {
throw new IllegalArgumentException();
}
- needHide = 2;
this.source = s;
this.target = newTarget;
source.addConnection(this);
@@ -39,43 +42,51 @@
public Shape getTarget() {
return target;
}
-
- public void hideSelection() {
- firePropertyChange(HIDE_SELECTION, null, null);
- source.firePropertyChange(Shape.HIDE_SELECTION, null, null);
- target.firePropertyChange(Shape.HIDE_SELECTION, null, null);
- }
- public void showSelection() {
- firePropertyChange(SHOW_SELECTION, null, null);
- source.firePropertyChange(Shape.SHOW_SELECTION, null, null);
- target.firePropertyChange(Shape.SHOW_SELECTION, null, null);
+ /**
+ * It has no children, so not possible to add.
+ */
+ public boolean addChild(Shape item) {
+ return false;
}
- public void setHidden(boolean hiden) {
- if (hiden) {
- needHide--;
- if (needHide == 0) {
- return;
- }
- } else {
- needHide++;
- if (needHide == 1) {
- return;
- }
+ @Override
+ public void setSelected(boolean selected) {
+ source.setSelected(selected);
+ target.setSelected(selected);
+ super.setSelected(selected);
+ }
+
+ @Override
+ public void updateVisibleValue(boolean initState) {
+ if (inUpdateVisibleValue) {
+ return;
}
- firePropertyChange(SET_HIDEN, null, Boolean.valueOf(hiden));
+ inUpdateVisibleValue = true;
+ boolean visible = initState;
+ visible = visible && source.isVisible();
+ visible = visible && target.isVisible();
+ setVisible(visible);
+ super.updateVisibleValue(this.visible);
+ inUpdateVisibleValue = false;
}
- public boolean isHiden() {
- return needHide != 2;
- }
-
/**
* It has no parent
*/
@Override
- public ModelElement getParent() {
+ public BaseElement getParent() {
return null;
}
+
+ @Override
+ public void refresh() {
+ updateVisibleValue(isVisible());
+ super.refresh();
+ }
+
+ @Override
+ public String getKey() {
+ return null;
+ }
}
\ No newline at end of file
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,437 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.DependantValue;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Subclass;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.EntityType;
+import org.hibernate.type.Type;
+
+/**
+ *
+ * @author Vitali
+ */
+public class ElementsFactory {
+
+ private final Configuration config;
+ private final HashMap<String, OrmShape> elements;
+ private final ArrayList<Connection> connections;
+
+ public ElementsFactory(Configuration config, HashMap<String, OrmShape> elements,
+ ArrayList<Connection> connections) {
+ this.config = config;
+ this.elements = elements;
+ this.connections = connections;
+ }
+
+ public void createChildren(BaseElement element) {
+ if (element.getClass().equals(ExpandableShape.class)) {
+ processExpand((ExpandableShape)element);
+ } else if (element.getClass().equals(ComponentShape.class)) {
+ refreshComponentReferences((ComponentShape)element);
+ }
+ Iterator<Shape> it = element.getChildrenList().iterator();
+ while (it.hasNext()) {
+ createChildren(it.next());
+ }
+ }
+
+ protected void processExpand(ExpandableShape shape) {
+ Object element = shape.getOrmElement();
+ if (!(element instanceof Property)) {
+ return;
+ }
+ OrmShape s = null;
+ Property property = (Property)element;
+ if (!property.isComposite()) {
+ Type type = ((Property)element).getType();
+ if (type.isEntityType()) {
+ EntityType et = (EntityType) type;
+ Object clazz = config.getClassMapping(et.getAssociatedEntityName());
+ if (clazz instanceof RootClass) {
+ RootClass rootClass = (RootClass)clazz;
+ s = getOrCreatePersistentClass(rootClass, null);
+ if (!isConnectionExist(shape, s)) {
+ connections.add(new Connection(shape, s));
+ }
+ } else if (clazz instanceof Subclass) {
+ s = getOrCreatePersistentClass(((Subclass)clazz).getRootClass(), null);
+ }
+ }
+ } else {
+ s = getOrCreatePersistentClass(new SpecialRootClass(property), null);
+ if (!isConnectionExist(shape, s)) {
+ connections.add(new Connection(shape, s));
+ }
+ createConnections(s, getOrCreateDatabaseTable(property.getValue().getTable()));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void refreshComponentReferences(ComponentShape componentShape) {
+ Property property = (Property)componentShape.getOrmElement();
+ if (!(property.getValue() instanceof Collection)) {
+ return;
+ }
+ Collection collection = (Collection)property.getValue();
+ Value component = collection.getElement();
+ Shape csChild0 = null, csChild1 = null;
+ Iterator<Shape> tmp = componentShape.getChildrenIterator();
+ if (tmp.hasNext()) {
+ csChild0 = tmp.next();
+ }
+ if (tmp.hasNext()) {
+ csChild1 = tmp.next();
+ }
+ OrmShape childShape = null;
+ if (component instanceof Component) {
+ childShape = elements.get(((Component)component).getComponentClassName());
+ if (childShape == null) {
+ childShape = getOrCreateComponentClass(property);
+ }
+ SimpleValue value = (SimpleValue)csChild0.getOrmElement();
+ OrmShape tableShape = getOrCreateDatabaseTable(value.getTable());
+ Iterator it = value.getColumnIterator();
+ while (it.hasNext()) {
+ Object el = it.next();
+ if (el instanceof Column) {
+ Column col = (Column)el;
+ Shape shape = tableShape.getChild(col);
+ if (shape != null && !isConnectionExist(csChild0, shape)) {
+ connections.add(new Connection(csChild0, shape));
+ }
+ }
+ }
+ if (!isConnectionExist(csChild1, childShape)) {
+ connections.add(new Connection(csChild1, childShape));
+ }
+
+ } else if (collection.isOneToMany()) {
+ childShape = getOrCreateAssociationClass(property);
+ if (childShape == null) {
+ return;
+ }
+ if (!isConnectionExist(csChild1, childShape)) {
+ connections.add(new Connection(csChild1, childShape));
+ }
+ OrmShape keyTableShape = getOrCreateDatabaseTable(collection.getKey().getTable());
+ Iterator it = collection.getKey().getColumnIterator();
+ while (it.hasNext()) {
+ Object el = it.next();
+ if (el instanceof Column) {
+ Column col = (Column)el;
+ Shape shape = keyTableShape.getChild(col);
+ if (shape != null && !isConnectionExist(csChild0, shape)) {
+ connections.add(new Connection(csChild0, shape));
+ }
+ }
+ }
+
+ } else /* if (collection.isMap() || collection.isSet()) */ {
+ childShape = getOrCreateDatabaseTable(collection.getCollectionTable());
+ Iterator it = ((DependantValue)csChild0.getOrmElement()).getColumnIterator();
+ while (it.hasNext()) {
+ Object el = it.next();
+ if (el instanceof Column) {
+ Column col = (Column)el;
+ Shape shape = childShape.getChild(col);
+ if (shape != null && !isConnectionExist(csChild0, shape)) {
+ connections.add(new Connection(csChild0, shape));
+ }
+ }
+ }
+ it = ((SimpleValue)csChild1.getOrmElement()).getColumnIterator();
+ while (it.hasNext()) {
+ Object el = it.next();
+ if (el instanceof Column) {
+ Column col = (Column)el;
+ Shape shape = childShape.getChild(col);
+ if (shape != null && !isConnectionExist(csChild1, shape)) {
+ connections.add(new Connection(csChild1, shape));
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected OrmShape getOrCreateDatabaseTable(Table databaseTable) {
+ OrmShape tableShape = null;
+ if (databaseTable != null) {
+ tableShape = getShape(databaseTable);
+ if (tableShape == null) {
+ tableShape = createShape(databaseTable);
+ Iterator iterator = config.getClassMappings();
+ while (iterator.hasNext()) {
+ Object clazz = iterator.next();
+ if (clazz instanceof RootClass) {
+ RootClass cls = (RootClass)clazz;
+ getOrCreatePersistentClass(cls, null);
+ }
+ }
+ }
+ }
+ return tableShape;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected OrmShape getOrCreatePersistentClass(PersistentClass persistentClass, Table componentClassDatabaseTable) {
+ OrmShape classShape = null;
+ if (persistentClass == null) {
+ return classShape;
+ }
+ OrmShape shape = null;
+ classShape = getShape(persistentClass.getEntityName());
+ if (classShape == null) {
+ classShape = createShape(persistentClass);
+ }
+ if (componentClassDatabaseTable == null && persistentClass.getTable() != null) {
+ componentClassDatabaseTable = persistentClass.getTable();
+ }
+ if (componentClassDatabaseTable != null) {
+ shape = getShape(componentClassDatabaseTable);
+ if (shape == null) {
+ shape = getOrCreateDatabaseTable(componentClassDatabaseTable);
+ }
+ createConnections(classShape, shape);
+ if (!isConnectionExist(classShape, shape)) {
+ connections.add(new Connection(classShape, shape));
+ }
+ }
+ RootClass rc = (RootClass)persistentClass;
+ Iterator iter = rc.getSubclassIterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (element instanceof Subclass) {
+ Subclass subclass = (Subclass)element;
+ OrmShape subclassShape = getShape(subclass);
+ if (subclassShape == null) {
+ subclassShape = createShape(subclass);
+ }
+ if (((Subclass)element).isJoinedSubclass()) {
+ Table jcTable = ((Subclass)element).getTable();
+ OrmShape jcTableShape = getOrCreateDatabaseTable(jcTable);
+ createConnections(subclassShape, jcTableShape);
+ if (!isConnectionExist(subclassShape, jcTableShape)) {
+ connections.add(new Connection(subclassShape, jcTableShape));
+ }
+ } else {
+ createConnections(subclassShape, shape);
+ if (!isConnectionExist(subclassShape, shape)) {
+ connections.add(new Connection(subclassShape, shape));
+ }
+ }
+ OrmShape ownerTableShape = getOrCreateDatabaseTable(((Subclass)element).getRootTable());
+ createConnections(subclassShape, ownerTableShape);
+
+ Iterator<Join> joinIterator = subclass.getJoinIterator();
+ while (joinIterator.hasNext()) {
+ Join join = joinIterator.next();
+ Iterator<Property> iterator = join.getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = iterator.next();
+ OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
+ createConnections(subclassShape, tableShape);
+ }
+ }
+ }
+ }
+
+ if (persistentClass.getIdentifier() instanceof Component) {
+ Component identifier = (Component)persistentClass.getIdentifier();
+ if (identifier.getComponentClassName() != null && !identifier.getComponentClassName().equals(identifier.getOwner().getEntityName())) {
+ OrmShape componentClassShape = elements.get(identifier.getComponentClassName());
+ if (componentClassShape == null && persistentClass instanceof RootClass) {
+ componentClassShape = getOrCreateComponentClass(((RootClass)persistentClass).getIdentifierProperty());
+
+ Shape idPropertyShape = classShape.getChild(persistentClass.getIdentifierProperty());
+ if (idPropertyShape != null && !isConnectionExist(idPropertyShape, componentClassShape)) {
+ connections.add(new Connection(idPropertyShape, componentClassShape));
+ }
+
+ OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
+ if (componentClassShape != null) {
+ createConnections(componentClassShape, tableShape);
+ }
+ }
+ }
+ }
+
+ Iterator joinIterator = persistentClass.getJoinIterator();
+ while (joinIterator.hasNext()) {
+ Join join = (Join)joinIterator.next();
+ Iterator<Property> iterator = join.getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = iterator.next();
+ OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
+ createConnections(classShape, tableShape);
+ }
+ }
+ return classShape;
+ }
+
+ protected OrmShape getOrCreateComponentClass(Property property) {
+ OrmShape classShape = null;
+ if (property == null) {
+ return classShape;
+ }
+ if (property.getValue() instanceof Collection) {
+ Component component = (Component)((Collection)property.getValue()).getElement();
+ if (component != null) {
+ classShape = createShape(property);
+ OrmShape tableShape = elements.get(Utils.getTableName(component.getTable()));
+ if (tableShape == null) {
+ tableShape = getOrCreateDatabaseTable(component.getTable());
+ }
+ createConnections(classShape, tableShape);
+ if (!isConnectionExist(classShape, tableShape)) {
+ connections.add(new Connection(classShape, tableShape));
+ }
+ Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
+ if (parentShape != null) {
+ OrmShape parentClassShape = elements.get(Utils.getName(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName()));
+ if (!isConnectionExist(parentShape, parentClassShape)) {
+ connections.add(new Connection(parentShape, parentClassShape));
+ }
+ }
+ }
+ } else if (property.getValue() instanceof Component) {
+ classShape = elements.get(((Component)property.getValue()).getComponentClassName());
+ if (classShape == null) {
+ classShape = createShape(property);
+ }
+ }
+ return classShape;
+ }
+
+ protected OrmShape getOrCreateAssociationClass(Property property) {
+ OrmShape classShape = null;
+ OneToMany component = (OneToMany)((Collection)property.getValue()).getElement();
+ if (component == null) {
+ return classShape;
+ }
+ if (component.getAssociatedClass() instanceof RootClass) {
+ classShape = getOrCreatePersistentClass(component.getAssociatedClass(), null);
+ if (classShape == null) {
+ classShape = createShape(component.getAssociatedClass());
+ }
+ OrmShape tableShape = elements.get(Utils.getTableName(component.getAssociatedClass().getTable()));
+ if (tableShape == null) {
+ tableShape = getOrCreateDatabaseTable(component.getAssociatedClass().getTable());
+ }
+ createConnections(classShape, tableShape);
+ if (!isConnectionExist(classShape, tableShape)) {
+ connections.add(new Connection(classShape, tableShape));
+ }
+ }
+ return classShape;
+ }
+
+
+
+ protected OrmShape createShape(Object ormElement) {
+ OrmShape ormShape = null;
+ if (ormElement instanceof Property) {
+ SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
+ String key = Utils.getName(specialRootClass.getEntityName());
+ ormShape = elements.get(key);
+ if (null == ormShape) {
+ ormShape = new SpecialOrmShape(specialRootClass);
+ elements.put(key, ormShape);
+ }
+ } else {
+ String key = Utils.getName(ormElement);
+ ormShape = elements.get(key);
+ if (null == ormShape) {
+ ormShape = new OrmShape(ormElement);
+ elements.put(key, ormShape);
+ }
+ }
+ return ormShape;
+ }
+
+
+
+
+ @SuppressWarnings("unchecked")
+ private void createConnections(ExpandableShape persistentClass, ExpandableShape dbTable) {
+ Property parentProperty = null;
+ if (persistentClass.getOrmElement() instanceof SpecialRootClass) {
+ parentProperty = ((SpecialRootClass)persistentClass.getOrmElement()).getParentProperty();
+ }
+ Iterator<Shape> itFields = persistentClass.getChildrenIterator();
+ Set<Shape> processed = new HashSet<Shape>();
+ while (itFields.hasNext()) {
+ final Shape shape = itFields.next();
+ Object element = shape.getOrmElement();
+ if (!(element instanceof Property && parentProperty != element)) {
+ continue;
+ }
+ Value value = ((Property)element).getValue();
+ Iterator iterator = value.getColumnIterator();
+ while (iterator.hasNext()) {
+ Object o = iterator.next();
+ if (!(o instanceof Column)) {
+ continue;
+ }
+ Column dbColumn = (Column)o;
+ Iterator<Shape> itColumns = dbTable.getChildrenIterator();
+ while (itColumns.hasNext()) {
+ final Shape shapeCol = itColumns.next();
+ if (processed.contains(shapeCol)) {
+ continue;
+ }
+ if (dbColumn.getName().equals(((Column)(shapeCol).getOrmElement()).getName())) {
+ if (!isConnectionExist(shape, shapeCol)) {
+ connections.add(new Connection(shape, shapeCol));
+ }
+ processed.add(shapeCol);
+ }
+ }
+ }
+ }
+ }
+
+
+ public OrmShape getShape(Object ormElement) {
+ OrmShape ormShape = null;
+ if (ormElement instanceof Property) {
+ SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
+ ormShape = elements.get(Utils.getName(specialRootClass.getEntityName()));
+ } else {
+ ormShape = elements.get(Utils.getName(ormElement));
+ }
+ return ormShape;
+ }
+
+
+ private boolean isConnectionExist(Shape source, Shape target) {
+ return Utils.isConnectionExist(source, target);
+ }
+}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java (from rev 16821, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandeableShape.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import java.util.Properties;
+
+/**
+ * Shape with two intrinsic states: expand and collapse.
+ *
+ * @author some modifications from Vitali
+ */
+public class ExpandableShape extends Shape {
+
+ public static final String EXPANDED = "expanded"; //$NON-NLS-1$
+
+ protected boolean expanded = true;
+
+ public ExpandableShape(Object ioe) {
+ super(ioe);
+ }
+
+ public boolean isExpanded() {
+ return expanded;
+ }
+
+ public void setExpanded(boolean expanded) {
+ if (expanded) {
+ expand();
+ } else {
+ collapse();
+ }
+ }
+
+ public boolean expand() {
+ if (!isVisible()) {
+ // prohibit expand and collapse in invisible mode
+ return false;
+ }
+ boolean expandedOld = this.expanded;
+ expanded = true;
+ setVisibleChildren(true);
+ firePropertyChange(EXPANDED, Boolean.valueOf(expandedOld), Boolean.valueOf(expanded));
+ return true;
+ }
+
+ public boolean collapse() {
+ if (!isVisible()) {
+ // prohibit expand and collapse in invisible mode
+ return false;
+ }
+ boolean expandedOld = this.expanded;
+ expanded = false;
+ setVisibleChildren(false);
+ firePropertyChange(EXPANDED, Boolean.valueOf(expandedOld), Boolean.valueOf(expanded));
+ return true;
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ boolean visibleOld = this.visible;
+ this.visible = visible;
+ if (expanded) {
+ // set children visible only if in expanded state
+ setVisibleChildren(visible);
+ }
+ firePropertyChange(VISIBLE, Boolean.valueOf(visibleOld), Boolean.valueOf(visible));
+ // update connections visibility state
+ updateVisibleValue(this.visible);
+ }
+
+ @Override
+ protected void loadFromProperties(Properties properties) {
+ super.loadFromProperties(properties);
+ boolean expanded = getPrValue(properties, EXPANDED);
+ setExpanded(expanded);
+ }
+
+ @Override
+ protected void saveInProperties(Properties properties) {
+ boolean expanded = isExpanded();
+ setPrValue(properties, expanded, EXPANDED);
+ super.saveInProperties(properties);
+ }
+}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandeableShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandeableShape.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandeableShape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.ui.diagram.editors.model;
-
-public class ExpandeableShape extends Shape {
-
- public static final String SHOW_REFERENCES = "show references"; //$NON-NLS-1$
-
- public boolean refHide = true;
- protected boolean first = false;
-
- private OrmShape reference = null;
-
- public ExpandeableShape(Object ioe) {
- super(ioe);
- }
-
- public void setReference(OrmShape reference) {
- this.reference = reference;
- }
-
- public OrmShape getReference() {
- return reference;
- }
-
- public boolean isReferenceVisible() {
- return refHide;
- }
-
- protected boolean getHide() {
- return refHide;
- }
-
- public void refreshReferences(Object model) {
- refHide = !refHide;
- if (model instanceof OrmDiagram) {
- if (refHide) {
- if (first) {
- ((OrmDiagram)model).processExpand(this);
- first = false;
- }
- }
- }
- firePropertyChange(SHOW_REFERENCES, null, Boolean.valueOf(refHide));
- }
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ModelElement.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ModelElement.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ModelElement.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.ui.diagram.editors.model;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * This is basis model class for diagram items.
- */
-public abstract class ModelElement implements IPropertySource {
-
- /** An empty property descriptor. */
- private static final IPropertyDescriptor[] EMPTY_ARRAY = new IPropertyDescriptor[0];
-
- private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport(this);
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
- if (l == null) {
- throw new IllegalArgumentException();
- }
- pcsDelegate.addPropertyChangeListener(l);
- }
-
- protected void firePropertyChange(String property, Object oldValue, Object newValue) {
- if (pcsDelegate.hasListeners(property)) {
- pcsDelegate.firePropertyChange(property, oldValue, newValue);
- }
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
- if (l != null) {
- pcsDelegate.removePropertyChangeListener(l);
- }
- }
-
- /**
- * The result is parent or null if the object has no parent
- * @return ModelElement
- */
- abstract public ModelElement getParent();
-
- /**
- * The children are items which type is Shape!
- * In general ModelElement is not a child.
- */
- private ArrayList<Shape> children = new ArrayList<Shape>();
-
- public Iterator<Shape> getChildrenIterator() {
- return children.iterator();
- }
-
- /**
- * Return copy of children list (to prevent modification of internal array)
- * @return
- */
- public List<Shape> getChildrenList() {
- ArrayList<Shape> copy = new ArrayList<Shape>();
- Iterator<Shape> it = getChildrenIterator();
- while (it.hasNext()) {
- copy.add(it.next());
- }
- return copy;
- }
-
- /**
- * Number of children
- * @return
- */
- public int getChildrenNumber() {
- return children.size();
- }
-
- /**
- * Standard way to add child
- * @param item
- * @return
- */
- public boolean addChild(Shape item) {
- item.setParent(this);
- return children.add(item);
- }
-
- /**
- * Standard way to remove child
- * @param item
- * @return
- */
- public boolean removeChild(Shape item) {
- item.setParent(null);
- return children.remove(item);
- }
-
- /**
- * Clear all children
- */
- public void deleteChildren() {
- Iterator<Shape> it = getChildrenIterator();
- while (it.hasNext()) {
- Shape me = it.next();
- me.setParent(null);
- }
- children.clear();
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- /**
- * Children should override this. The default implementation returns an empty array.
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return EMPTY_ARRAY;
- }
-
- /**
- * Children should override this. The default implementation returns null.
- */
- public Object getPropertyValue(Object id) {
- return null;
- }
-
- /**
- * Children should override this. The default implementation returns false.
- */
- public boolean isPropertySet(Object id) {
- return false;
- }
-
- /**
- * Children should override this. The default implementation does nothing.
- */
- public void resetPropertyValue(Object id) {
- // do nothing
- }
-
- /**
- * Children should override this. The default implementation does nothing.
- */
- public void setPropertyValue(Object id, Object value) {
- // do nothing
- }
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -17,13 +17,12 @@
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties;
-import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -31,48 +30,47 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.jdt.core.IJavaProject;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.ProjectUtils;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.Component;
-import org.hibernate.mapping.DependantValue;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.OneToMany;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.Subclass;
-import org.hibernate.mapping.Table;
-import org.hibernate.mapping.Value;
-import org.hibernate.type.EntityType;
-import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler;
-import org.jboss.tools.hibernate.ui.view.HibernateUtils;
-public class OrmDiagram extends ModelElement {
+/**
+ * The whole diagram, all information about diagram elements are here.
+ * @author some modifications from Vitali
+ * @see BaseElement
+*/
+public class OrmDiagram extends BaseElement {
- public static final String REFRESH = "refresh"; //$NON-NLS-1$
+ // special folder name to store OrmDiagram layout and settings
+ public static final String HIBERNATE_MAPPING_LAYOUT_FOLDER_NAME = "hibernateMapping"; //$NON-NLS-1$
public static final String DIRTY = "dirty"; //$NON-NLS-1$
+ public static final String AUTOLAYOUT = "autolayout"; //$NON-NLS-1$
+
+ // hibernate console configuration is the source of diagram elements
+ private ConsoleConfiguration consoleConfig;
+
private boolean dirty = false;
- private String childrenLocations[];
private HashMap<String, OrmShape> elements = new HashMap<String, OrmShape>();
private RootClass[] ormElements;
- private ConsoleConfiguration consoleConfig;
private String[] entityNames;
- public static final String HIBERNATE_MAPPING_LAYOUT_FOLDER_NAME = "hibernateMapping"; //$NON-NLS-1$
+ private boolean connectionsVisibility = true;
+ private ArrayList<Connection> connections = new ArrayList<Connection>();
+
+ // editor elements settings
protected DiagramRuler leftRuler, topRuler;
private boolean rulersVisibility = false;
private boolean snapToGeometry = false;
private boolean gridEnabled = false;
private double zoom = 1.0;
+ //
+ private boolean fileLoadSuccessfull = false;
+
public OrmDiagram(ConsoleConfiguration consoleConfig, RootClass ioe) {
createRulers();
this.consoleConfig = consoleConfig;
@@ -80,12 +78,10 @@
ormElements[0] = ioe;
entityNames = new String[1];
entityNames[0] = ioe.getEntityName();
-
- childrenLocations = new String[]{new String("")}; //$NON-NLS-1$
-
- getOrCreatePersistentClass(ormElements[0], null);
- expandModel(this);
- load();
+ recreateChildren();
+ sortChildren(false);
+ loadFromFile();
+ refreshDiagramElements();
setDirty(false);
}
@@ -101,15 +97,46 @@
for (int i = 0; i < ormElements.length; i++) {
entityNames[i] = ormElements[i].getEntityName();
}
- childrenLocations = new String[]{new String("")}; //$NON-NLS-1$
+ recreateChildren();
+ sortChildren(false);
+ loadFromFile();
+ refreshDiagramElements();
+ setDirty(false);
+ }
+
+ protected void recreateChildren() {
+ deleteChildren();
+ elements.clear();
+ connections.clear();
+ final ElementsFactory factory = new ElementsFactory(
+ consoleConfig.getConfiguration(), elements, connections);
for (int i = 0; i < ormElements.length; i++) {
- getOrCreatePersistentClass(ormElements[i], null);
+ factory.getOrCreatePersistentClass(ormElements[i], null);
}
- expandModel(this);
- load();
- setDirty(false);
+ updateChildrenList();
+ factory.createChildren(this);
+ updateChildrenList();
}
+ protected void updateChildrenList() {
+ Iterator<OrmShape> it = elements.values().iterator();
+ while (it.hasNext()) {
+ OrmShape ormShape = it.next();
+ addChild(ormShape);
+ }
+ }
+
+ protected void refreshDiagramElements() {
+ Iterator<OrmShape> it = elements.values().iterator();
+ while (it.hasNext()) {
+ OrmShape ormShape = it.next();
+ ormShape.refresh();
+ }
+ for (int i = 0; i < connections.size(); i++) {
+ connections.get(i).refresh();
+ }
+ }
+
protected void createRulers() {
leftRuler = new DiagramRuler(false);
topRuler = new DiagramRuler(true);
@@ -127,7 +154,7 @@
* It has no parent
*/
@Override
- public ModelElement getParent() {
+ public BaseElement getParent() {
return null;
}
@@ -195,8 +222,8 @@
}
@SuppressWarnings("unchecked")
- public HashMap<String,OrmShape> getCloneElements() {
- return (HashMap<String,OrmShape>)elements.clone();
+ public HashMap<String, OrmShape> getCloneElements() {
+ return (HashMap<String, OrmShape>)elements.clone();
}
public RootClass getOrmElement(int idx) {
@@ -210,8 +237,8 @@
return ormElements;
}
+ @Override
public void refresh() {
- boolean bRefresh = false;
final Configuration config = consoleConfig.getConfiguration();
for (int i = 0; i < ormElements.length; i++) {
RootClass newOrmElement = (RootClass)config.getClassMapping(entityNames[i]);
@@ -219,321 +246,44 @@
continue;
}
ormElements[i] = newOrmElement;
- bRefresh = true;
}
- if (!bRefresh) {
- return;
- }
- saveHelper();
- deleteChildren();
- elements.clear();
- for (int i = 0; i < ormElements.length; i++) {
- getOrCreatePersistentClass(ormElements[i], null);
- }
- expandModel(this);
- load();
- firePropertyChange(REFRESH, null, null);
+ // -> save just into properties
+ Properties properties = new Properties();
+ saveInProperties(properties);
+ recreateChildren();
+ sortChildren(false);
+ // -> load just from properties
+ loadFromProperties(properties);
+ refreshDiagramElements();
+ updateDirty(true);
+ super.refresh();
}
public void collapseAll() {
- toggleModelState(this, false);
+ toggleModelExpandState(this, false);
}
public void expandAll() {
- toggleModelState(this, true);
+ toggleModelExpandState(this, true);
}
- private void toggleModelState(ModelElement element, final boolean state) {
+ private void toggleModelExpandState(BaseElement element, final boolean expandState) {
if (element instanceof OrmShape) {
- OrmShape ormShape = ((OrmShape)element);
- boolean refresh = state ? ormShape.isHiden() : !ormShape.isHiden();
- if (refresh) {
- ormShape.refreshHiden();
+ OrmShape ormShape = (OrmShape)element;
+ if (expandState != ormShape.isExpanded()) {
+ if (expandState) {
+ ormShape.expand();
+ } else {
+ ormShape.collapse();
+ }
}
}
Iterator<Shape> it = element.getChildrenList().iterator();
while (it.hasNext()) {
- toggleModelState(it.next(), state);
+ toggleModelExpandState(it.next(), expandState);
}
}
-
- private void expandModel(ModelElement element) {
- if (element.getClass().equals(ExpandeableShape.class)) {
- processExpand((ExpandeableShape)element);
- } else if (element.getClass().equals(ComponentShape.class)) {
- refreshComponentReferences((ComponentShape)element);
- }
- Iterator<Shape> it = element.getChildrenList().iterator();
- while (it.hasNext()) {
- expandModel(it.next());
- }
- }
-
- private void saveHelper() {
- childrenLocations = new String[getChildrenNumber()];
- Iterator<Shape> it = getChildrenIterator();
- for (int i = 0; it.hasNext(); i++) {
- OrmShape shape = (OrmShape)it.next();
- Object ormElement = shape.getOrmElement();
- if (ormElement instanceof RootClass) {
- childrenLocations[i] = ((RootClass)ormElement).getEntityName() + "@"; //$NON-NLS-1$
- } else if (ormElement instanceof Table) {
- childrenLocations[i] = HibernateUtils.getTableName((Table)ormElement)+"@"; //$NON-NLS-1$
- }
- childrenLocations[i] += shape.getLocation().x + ";" + shape.getLocation().y+";" + shape.isHiden(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private OrmShape createShape(Object ormElement) {
- OrmShape ormShape = null;
- if (ormElement instanceof RootClass) {
- String key = HibernateUtils.getPersistentClassName(((RootClass)ormElement).getEntityName());
- ormShape = elements.get(key);
- if (null == ormShape) {
- ormShape = new OrmShape(ormElement);
- addChild(ormShape);
- elements.put(key, ormShape);
- }
- } else if (ormElement instanceof Table) {
- String key = HibernateUtils.getTableName((Table)ormElement);
- ormShape = elements.get(key);
- if (null == ormShape) {
- ormShape = new OrmShape(ormElement);
- addChild(ormShape);
- elements.put(key, ormShape);
- }
- } else if (ormElement instanceof Property) {
- SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
- String key = HibernateUtils.getPersistentClassName(specialRootClass.getEntityName());
- ormShape = elements.get(key);
- if (null == ormShape) {
- ormShape = new SpecialOrmShape(specialRootClass);
- addChild(ormShape);
- elements.put(key, ormShape);
- }
- } else if (ormElement instanceof Subclass) {
- String key = HibernateUtils.getPersistentClassName(((Subclass)ormElement).getEntityName());
- ormShape = elements.get(key);
- if (null == ormShape) {
- ormShape = new OrmShape(ormElement);
- addChild(ormShape);
- elements.put(key, ormShape);
- }
- }
- return ormShape;
- }
- public OrmShape getShape(Object ormElement) {
- OrmShape ormShape = null;
- if (ormElement instanceof RootClass) {
- ormShape = elements.get(HibernateUtils.getPersistentClassName(((RootClass)ormElement).getEntityName()));
- } else if (ormElement instanceof Table) {
- ormShape = elements.get(HibernateUtils.getTableName((Table)ormElement));
- } else if (ormElement instanceof Property) {
- SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
- ormShape = elements.get(HibernateUtils.getPersistentClassName(specialRootClass.getEntityName()));
- } else if (ormElement instanceof Subclass) {
- ormShape = elements.get(HibernateUtils.getPersistentClassName(((Subclass)ormElement).getEntityName()));
- }
- return ormShape;
- }
-
-
- @SuppressWarnings("unchecked")
- private OrmShape getOrCreatePersistentClass(PersistentClass persistentClass, Table componentClassDatabaseTable) {
- OrmShape classShape = null;
- if (persistentClass == null) {
- return classShape;
- }
- OrmShape shape = null;
- classShape = elements.get(HibernateUtils.getPersistentClassName(persistentClass.getEntityName()));
- if (classShape == null) {
- classShape = createShape(persistentClass);
- }
- if (componentClassDatabaseTable == null && persistentClass.getTable() != null) {
- componentClassDatabaseTable = persistentClass.getTable();
- }
- if (componentClassDatabaseTable != null) {
- shape = elements.get(HibernateUtils.getTableName(componentClassDatabaseTable));
- if (shape == null) {
- shape = getOrCreateDatabaseTable(componentClassDatabaseTable);
- }
- createConnections(classShape, shape);
- if (!isConnectionExist(classShape, shape)) {
- new Connection(classShape, shape);
- classShape.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- RootClass rc = (RootClass)persistentClass;
- Iterator iter = rc.getSubclassIterator();
- while (iter.hasNext()) {
- Object element = iter.next();
- if (element instanceof Subclass) {
- Subclass subclass = (Subclass)element;
- OrmShape subclassShape = elements.get(HibernateUtils.getPersistentClassName(subclass.getEntityName()));
- if (subclassShape == null) {
- subclassShape = createShape(subclass);
- }
- if (((Subclass)element).isJoinedSubclass()) {
- Table jcTable = ((Subclass)element).getTable();
- OrmShape jcTableShape = getOrCreateDatabaseTable(jcTable);
- createConnections(subclassShape, jcTableShape);
- if (!isConnectionExist(subclassShape, jcTableShape)) {
- new Connection(subclassShape, jcTableShape);
- subclassShape.firePropertyChange(REFRESH, null, null);
- jcTableShape.firePropertyChange(REFRESH, null, null);
- }
- } else {
- createConnections(subclassShape, shape);
- if (!isConnectionExist(subclassShape, shape)) {
- new Connection(subclassShape, shape);
- subclassShape.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- OrmShape ownerTableShape = getOrCreateDatabaseTable(((Subclass)element).getRootTable());
- createConnections(subclassShape, ownerTableShape);
-
- Iterator<Join> joinIterator = subclass.getJoinIterator();
- while (joinIterator.hasNext()) {
- Join join = joinIterator.next();
- Iterator<Property> iterator = join.getPropertyIterator();
- while (iterator.hasNext()) {
- Property property = iterator.next();
- OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
- createConnections(subclassShape, tableShape);
- subclassShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
- }
-
- if (persistentClass.getIdentifier() instanceof Component) {
- Component identifier = (Component)persistentClass.getIdentifier();
- if (identifier.getComponentClassName() != null && !identifier.getComponentClassName().equals(identifier.getOwner().getEntityName())) {
- OrmShape componentClassShape = elements.get(identifier.getComponentClassName());
- if (componentClassShape == null && persistentClass instanceof RootClass) {
- componentClassShape = getOrCreateComponentClass(((RootClass)persistentClass).getIdentifierProperty());
-
- Shape idPropertyShape = classShape.getChild(persistentClass.getIdentifierProperty());
- if (idPropertyShape != null && !isConnectionExist(idPropertyShape, componentClassShape)) {
- new Connection(idPropertyShape, componentClassShape);
- idPropertyShape.firePropertyChange(REFRESH, null, null);
- componentClassShape.firePropertyChange(REFRESH, null, null);
- }
-
- OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
- if (componentClassShape != null) {
- createConnections(componentClassShape, tableShape);
- componentClassShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
- }
-
- Iterator joinIterator = persistentClass.getJoinIterator();
- while (joinIterator.hasNext()) {
- Join join = (Join)joinIterator.next();
- Iterator<Property> iterator = join.getPropertyIterator();
- while (iterator.hasNext()) {
- Property property = iterator.next();
- OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
- createConnections(classShape, tableShape);
- classShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- }
- return classShape;
- }
-
- @SuppressWarnings("unchecked")
- private OrmShape getOrCreateDatabaseTable(Table databaseTable) {
- OrmShape tableShape = null;
- if (databaseTable != null) {
- String tableName = HibernateUtils.getTableName(databaseTable);
- tableShape = elements.get(tableName);
- if (tableShape == null) {
- tableShape = createShape(databaseTable);
- final Configuration config = consoleConfig.getConfiguration();
- Iterator iterator = config.getClassMappings();
- while (iterator.hasNext()) {
- Object clazz = iterator.next();
- if (clazz instanceof RootClass) {
- RootClass cls = (RootClass)clazz;
- Table table = cls.getTable();
- if (tableName.equals(table.getName() + "." + table.getName())) { //$NON-NLS-1$
- if (elements.get(HibernateUtils.getPersistentClassName(cls.getEntityName())) == null) {
- getOrCreatePersistentClass(cls, null);
- }
- }
- }
- }
- }
- }
- return tableShape;
- }
-
- @SuppressWarnings("unchecked")
- private void createConnections(ExpandeableShape persistentClass, ExpandeableShape dbTable) {
- Property parentProperty = null;
- if (persistentClass.getOrmElement() instanceof SpecialRootClass) {
- parentProperty = ((SpecialRootClass)persistentClass.getOrmElement()).getParentProperty();
- }
- Iterator<Shape> itFields = persistentClass.getChildrenIterator();
- Set<Shape> processed = new HashSet<Shape>();
- while (itFields.hasNext()) {
- final Shape shape = itFields.next();
- Object element = shape.getOrmElement();
- if (!(element instanceof Property && parentProperty != element)) {
- continue;
- }
- Value value = ((Property)element).getValue();
- Iterator iterator = value.getColumnIterator();
- while (iterator.hasNext()) {
- Object o = iterator.next();
- if (!(o instanceof Column)) {
- continue;
- }
- Column dbColumn = (Column)o;
- Iterator<Shape> itColumns = dbTable.getChildrenIterator();
- while (itColumns.hasNext()) {
- final Shape shapeCol = itColumns.next();
- if (processed.contains(shapeCol)) {
- continue;
- }
- if (dbColumn.getName().equals(((Column)(shapeCol).getOrmElement()).getName())) {
- if (!isConnectionExist(shape, shapeCol)) {
- new Connection(shape, shapeCol);
- shape.firePropertyChange(REFRESH, null, null);
- shapeCol.firePropertyChange(REFRESH, null, null);
- }
- processed.add(shapeCol);
- }
- }
- }
- }
- }
-
- private boolean isConnectionExist(Shape source, Shape target) {
- Connection conn;
- if (source != null && source.getSourceConnections() != null) {
- for (int i = 0; i < source.getSourceConnections().size(); i++) {
- conn = source.getSourceConnections().get(i);
- if (conn.getTarget().equals(target)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public String[] getChildrenLocations() {
- return childrenLocations;
- }
-
public boolean isDirty() {
return dirty;
}
@@ -544,279 +294,63 @@
firePropertyChange(DIRTY, null, null);
}
}
-
- public void processExpand(ExpandeableShape shape) {
- Object element = shape.getOrmElement();
- if (!(element instanceof Property)) {
- return;
+
+ public void updateDirty(boolean dirtyUpdate) {
+ if (dirtyUpdate) {
+ setDirty(true);
}
- OrmShape s = null;
- Property property = (Property)element;
- if (!property.isComposite()) {
- Type type = ((Property)element).getType();
- if (type.isEntityType()) {
- EntityType et = (EntityType) type;
- final Configuration config = consoleConfig.getConfiguration();
- Object clazz = config.getClassMapping(et.getAssociatedEntityName());
- if (clazz instanceof RootClass) {
- RootClass rootClass = (RootClass)clazz;
- s = getOrCreatePersistentClass(rootClass, null);
- if (!isConnectionExist(shape, s)) {
- new Connection(shape, s);
- shape.firePropertyChange(REFRESH, null, null);
- s.firePropertyChange(REFRESH, null, null);
- }
- } else if (clazz instanceof Subclass) {
- s = getOrCreatePersistentClass(((Subclass)clazz).getRootClass(), null);
- }
- }
- } else {
- s = getOrCreatePersistentClass(new SpecialRootClass(property), null);
- new Connection(shape, s);
- createConnections(s, getOrCreateDatabaseTable(property.getValue().getTable()));
- shape.firePropertyChange(REFRESH, null, null);
- s.firePropertyChange(REFRESH, null, null);
- }
- if (!shape.getParent().equals(s)) {
- shape.setReference(s);
- }
- firePropertyChange(REFRESH, null, null);
}
- public void update() {
- firePropertyChange(REFRESH, null, null);
+ public void autolayout() {
+ firePropertyChange(AUTOLAYOUT, null, null);
}
-
- @SuppressWarnings("unchecked")
- protected void refreshComponentReferences(ComponentShape componentShape) {
- Property property = (Property)componentShape.getOrmElement();
- if (!(property.getValue() instanceof Collection)) {
+
+ public boolean getConnectionsVisibility() {
+ return connectionsVisibility;
+ }
+
+ public void setConnectionsVisibility(boolean connectionsVisibility) {
+ if (this.connectionsVisibility == connectionsVisibility) {
return;
}
- Collection collection = (Collection)property.getValue();
- Value component = collection.getElement();
- Shape csChild0 = null, csChild1 = null;
- Iterator<Shape> tmp = componentShape.getChildrenIterator();
- if (tmp.hasNext()) {
- csChild0 = tmp.next();
- }
- if (tmp.hasNext()) {
- csChild1 = tmp.next();
- }
- OrmShape childShape = null;
- if (component instanceof Component) {
- childShape = elements.get(((Component)component).getComponentClassName());
- if (childShape == null) {
- childShape = getOrCreateComponentClass(property);
+ this.connectionsVisibility = connectionsVisibility;
+ for (Connection connection : connections) {
+ if (!(connection.getSource() instanceof OrmShape) ||
+ !(connection.getTarget() instanceof OrmShape)) {
+ connection.setVisible(connectionsVisibility);
}
- SimpleValue value = (SimpleValue)csChild0.getOrmElement();
- OrmShape tableShape = getOrCreateDatabaseTable(value.getTable());
- Iterator it = value.getColumnIterator();
- while (it.hasNext()) {
- Object el = it.next();
- if (el instanceof Column) {
- Column col = (Column)el;
- Shape shape = tableShape.getChild(col);
- if (shape != null && !isConnectionExist(csChild0, shape)) {
- new Connection(csChild0, shape);
- csChild0.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
- if (!isConnectionExist(csChild1, childShape)) {
- new Connection(csChild1, childShape);
- csChild1.firePropertyChange(REFRESH, null, null);
- childShape.firePropertyChange(REFRESH, null, null);
- }
-
- } else if (collection.isOneToMany()) {
- childShape = getOrCreateAssociationClass(property);
- if (childShape == null) {
- return;
- }
- if (!isConnectionExist(csChild1, childShape)) {
- new Connection(csChild1, childShape);
- csChild1.firePropertyChange(REFRESH, null, null);
- childShape.firePropertyChange(REFRESH, null, null);
- }
- OrmShape keyTableShape = getOrCreateDatabaseTable(collection.getKey().getTable());
- Iterator it = collection.getKey().getColumnIterator();
- while (it.hasNext()) {
- Object el = it.next();
- if (el instanceof Column) {
- Column col = (Column)el;
- Shape shape = keyTableShape.getChild(col);
- if (shape != null && !isConnectionExist(csChild0, shape)) {
- new Connection(csChild0, shape);
- csChild0.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
-
- } else /* if (collection.isMap() || collection.isSet()) */ {
- childShape = getOrCreateDatabaseTable(collection.getCollectionTable());
- Iterator it = ((DependantValue)csChild0.getOrmElement()).getColumnIterator();
- while (it.hasNext()) {
- Object el = it.next();
- if (el instanceof Column) {
- Column col = (Column)el;
- Shape shape = childShape.getChild(col);
- if (shape != null && !isConnectionExist(csChild0, shape)) {
- new Connection(csChild0, shape);
- csChild0.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
- it = ((SimpleValue)csChild1.getOrmElement()).getColumnIterator();
- while (it.hasNext()) {
- Object el = it.next();
- if (el instanceof Column) {
- Column col = (Column)el;
- Shape shape = childShape.getChild(col);
- if (shape != null && !isConnectionExist(csChild1, shape)) {
- new Connection(csChild1, shape);
- csChild1.firePropertyChange(REFRESH, null, null);
- shape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
}
- if (!componentShape.getParent().equals(childShape)) {
- componentShape.setReference(childShape);
- }
- setDirty(true);
- firePropertyChange(REFRESH, null, null);
}
-
- public OrmShape getOrCreateComponentClass(Property property) {
- OrmShape classShape = null;
- if (property == null) {
- return classShape;
- }
- if (property.getValue() instanceof Collection) {
- Component component = (Component)((Collection)property.getValue()).getElement();
- if (component != null) {
- classShape = createShape(property);
- OrmShape tableShape = elements.get(HibernateUtils.getTableName(component.getTable()));
- if (tableShape == null) {
- tableShape = getOrCreateDatabaseTable(component.getTable());
- }
- createConnections(classShape, tableShape);
- if (!isConnectionExist(classShape, tableShape)) {
- new Connection(classShape, tableShape);
- classShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
- if (parentShape != null) {
- OrmShape parentClassShape = elements.get(HibernateUtils.getPersistentClassName(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName()));
- if (!isConnectionExist(parentShape, parentClassShape)) {
- new Connection(parentShape, parentClassShape);
- parentShape.firePropertyChange(REFRESH, null, null);
- parentClassShape.firePropertyChange(REFRESH, null, null);
- }
- }
- }
- } else if (property.getValue() instanceof Component) {
- classShape = elements.get(((Component)property.getValue()).getComponentClassName());
- if (classShape == null) {
- classShape = createShape(property);
- }
- }
- return classShape;
+
+ public void toggleConnections() {
+ setConnectionsVisibility(!getConnectionsVisibility());
}
-
- private OrmShape getOrCreateAssociationClass(Property property) {
- OrmShape classShape = null;
- OneToMany component = (OneToMany)((Collection)property.getValue()).getElement();
- if (component == null) {
- return classShape;
- }
- if (component.getAssociatedClass() instanceof RootClass) {
- classShape = getOrCreatePersistentClass(component.getAssociatedClass(), null);
- if (classShape == null) {
- classShape = createShape(component.getAssociatedClass());
- }
- OrmShape tableShape = elements.get(HibernateUtils.getTableName(component.getAssociatedClass().getTable()));
- if (tableShape == null) {
- tableShape = getOrCreateDatabaseTable(component.getAssociatedClass().getTable());
- }
- createConnections(classShape, tableShape);
- if (!isConnectionExist(classShape, tableShape)) {
- new Connection(classShape, tableShape);
- classShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- }
- return classShape;
- }
-
- public String getKey(Shape shape) {
- Object element = shape.getOrmElement();
- String key = null;
- if (element instanceof RootClass) {
- key = HibernateUtils.getPersistentClassName(((RootClass)element).getEntityName());
- } else if (element instanceof Table) {
- key = HibernateUtils.getTableName((Table)element);
- } else if (element instanceof Property) {
- Property property = (Property)element;
- key = property.getPersistentClass().getEntityName() + "." + property.getName(); //$NON-NLS-1$
- } else if (element instanceof Subclass) {
- key = HibernateUtils.getPersistentClassName(((Subclass)element).getEntityName());
- }
- return key;
- }
- public void propertiesInit(Properties properties, ModelElement shape) {
- boolean state;
- if (shape instanceof OrmShape) {
- final OrmShape ormShape = (OrmShape)shape;
- state = getState(properties, ormShape);
- if (state) {
- ormShape.refreshHiden();
- }
- ormShape.setLocation(getPosition(properties, ormShape));
- } else if (shape instanceof ExpandeableShape) {
- final ExpandeableShape expandeableShape = (ExpandeableShape)shape;
- state = getState(properties, expandeableShape);
- if (!state) {
- expandeableShape.refHide = false;
- }
- }
- Iterator<Shape> it = shape.getChildrenIterator();
- while (it.hasNext()) {
- propertiesInit(properties, it.next());
- }
+ @Override
+ protected void loadFromProperties(Properties properties) {
+ super.loadFromProperties(properties);
+ String str = properties.getProperty("rulersVisibility", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ rulersVisibility = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("snapToGeometry", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ snapToGeometry = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("gridEnabled", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ gridEnabled = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("zoom", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+ zoom = Double.valueOf(str).doubleValue();
}
- private void storeProperties(Properties properties, ModelElement shape) {
- boolean state;
- if (shape instanceof OrmShape) {
- final OrmShape ormShape = (OrmShape)shape;
- state = ormShape.hiden;
- setState(properties, ormShape, state);
- setPosition(properties, (OrmShape)shape);
- } else if (shape instanceof ExpandeableShape) {
- final ExpandeableShape expandeableShape = (ExpandeableShape)shape;
- state = expandeableShape.refHide;
- setState(properties, expandeableShape, state);
- }
- Iterator<Shape> it = shape.getChildrenIterator();
- while (it.hasNext()) {
- storeProperties(properties, it.next());
- }
- }
-
- public void save() {
- Properties properties = new Properties();
+ @Override
+ protected void saveInProperties(Properties properties) {
properties.put("rulersVisibility", "" + rulersVisibility); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("snapToGeometry", "" + snapToGeometry); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("gridEnabled", "" + gridEnabled); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("zoom", "" + zoom); //$NON-NLS-1$ //$NON-NLS-2$
- storeProperties(properties, this);
+ super.saveInProperties(properties);
+ }
+
+ public void saveInFile() {
+ Properties properties = new Properties();
+ saveInProperties(properties);
FileOutputStream fos = null;
try {
File folder = new File(getStoreFolderPath().toOSString());
@@ -849,7 +383,6 @@
if (!folder.exists()) {
try {
folder.create(true, true, null);
-
file = folder.getFile(getStoreFileName());
if (!file.exists()) {
file.create(source, true, null);
@@ -861,26 +394,17 @@
return file;
}
- private boolean loadSuccessfull = false;
-
- public void load() {
- Properties properties = new Properties();
+ public void loadFromFile() {
+ fileLoadSuccessfull = false;
FileInputStream fis = null;
try {
File file = new File(getStoreFilePath().toOSString());
if (file.exists()) {
fis = new FileInputStream(file);
+ Properties properties = new Properties();
properties.load(fis);
- String str = properties.getProperty("rulersVisibility", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- rulersVisibility = Boolean.valueOf(str).booleanValue();
- str = properties.getProperty("snapToGeometry", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- snapToGeometry = Boolean.valueOf(str).booleanValue();
- str = properties.getProperty("gridEnabled", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- gridEnabled = Boolean.valueOf(str).booleanValue();
- str = properties.getProperty("zoom", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
- zoom = Double.valueOf(str).doubleValue();
- propertiesInit(properties, this);
- loadSuccessfull = true;
+ loadFromProperties(properties);
+ fileLoadSuccessfull = true;
}
} catch (IOException ex) {
HibernateConsolePlugin.getDefault().logErrorMessage("Can't load layout of mapping.", ex); //$NON-NLS-1$
@@ -895,68 +419,10 @@
}
}
- public boolean isLoadSuccessfull() {
- return loadSuccessfull;
+ public boolean isFileLoadSuccessfull() {
+ return fileLoadSuccessfull;
}
-
-
- private void setState(Properties properties, String key, boolean value) {
- if (properties.containsKey(key)) {
- properties.remove(key);
- properties.put(key, Boolean.valueOf(value).toString());
- } else {
- properties.put(key, Boolean.valueOf(value).toString());
- }
- }
-
- public void setState(Properties properties, Shape shape, boolean value) {
- setState(properties, getKey(shape) + ".state", value); //$NON-NLS-1$
- }
-
- private boolean getState(Properties properties, String key) {
- String str = properties.getProperty(key, "true"); //$NON-NLS-1$
- return Boolean.valueOf(str).booleanValue();
- }
-
- private Point getPoint(Properties properties, String key) {
- Point point = new Point(0, 0);
- String str = properties.getProperty(key + ".x", "0"); //$NON-NLS-1$ //$NON-NLS-2$
- point.x = Integer.parseInt(str);
- String str2 = properties.getProperty(key + ".y", "0"); //$NON-NLS-1$ //$NON-NLS-2$
- point.y = Integer.parseInt(str2);
- return point;
- }
-
- private void setPoint(Properties properties, String key, Point point) {
- String key1 = key + ".x"; //$NON-NLS-1$
- if (!properties.containsKey(key1)) {
- properties.remove(key1);
- properties.put(key1, "" + point.x); //$NON-NLS-1$
- } else {
- properties.put(key1, "" + point.x); //$NON-NLS-1$
- }
- String key2 = key + ".y"; //$NON-NLS-1$
- if (!properties.containsKey(key2)) {
- properties.remove(key2);
- properties.put(key2, "" + point.y); //$NON-NLS-1$
- } else {
- properties.put(key2, "" + point.y); //$NON-NLS-1$
- }
- }
-
- public void setPosition(Properties properties, OrmShape shape) {
- Point point = shape.getLocation();
- setPoint(properties, getKey(shape), point);
- }
- public Point getPosition(Properties properties, OrmShape shape) {
- return getPoint(properties, getKey(shape));
- }
-
- public boolean getState(Properties properties, Shape shape) {
- return getState(properties, getKey(shape) + ".state"); //$NON-NLS-1$
- }
-
public ConsoleConfiguration getConsoleConfig() {
return consoleConfig;
}
@@ -1005,4 +471,9 @@
public double getZoom() {
return zoom;
}
-}
\ No newline at end of file
+
+ @Override
+ public String getKey() {
+ return null;
+ }
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.ui.diagram.editors.model;
import java.util.Iterator;
+import java.util.Properties;
import org.eclipse.draw2d.geometry.Point;
import org.hibernate.mapping.Collection;
@@ -24,23 +25,34 @@
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramGuide;
-public class OrmShape extends ExpandeableShape {
- public static final String SET_HIDEN = "set hiden"; //$NON-NLS-1$
-
- public static final String LOCATION_PROP = "OrmShape.Location"; //$NON-NLS-1$
+/**
+ * Only OrmShape has it's own location on Diagram.
+ *
+ * @author some modifications from Vitali
+ */
+public class OrmShape extends ExpandableShape {
+
+ public static final String LOCATION_PROP = "location"; //$NON-NLS-1$
+ /**
+ * up-left point element location on diagram
+ */
private Point location = new Point(0, 0);
- protected boolean hiden = false;
-
+ /**
+ * vertical and horizontal guide attached to OrmShape,
+ * additional way to change shape location on diagram
+ */
private DiagramGuide verticalGuide, horizontalGuide;
public OrmShape(Object ioe) {
super(ioe);
- generate();
+ initModel();
}
+ /**
+ * creates children of the shape,
+ */
@SuppressWarnings("unchecked")
- protected void generate() {
- Shape bodyOrmShape;
+ protected void initModel() {
Object ormElement = getOrmElement();
if (ormElement instanceof RootClass) {
RootClass rootClass = (RootClass)ormElement;
@@ -74,18 +86,19 @@
typeIsAccessible = false;
}
}
+ Shape bodyOrmShape = null;
if (field.getValue().isSimpleValue() && !((SimpleValue)field.getValue()).isTypeSpecified()) {
bodyOrmShape = new Shape(field);
} else if (typeIsAccessible && field.getValue() instanceof Collection) {
bodyOrmShape = new ComponentShape(field);
} else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandeableShape(field);
+ bodyOrmShape = new ExpandableShape(field);
} else {
bodyOrmShape = new Shape(field);
}
addChild(bodyOrmShape);
} else {
- bodyOrmShape = new ExpandeableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field);
addChild(bodyOrmShape);
}
}
@@ -112,8 +125,7 @@
Property field = iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
-
-
+
boolean typeIsAccessible = true;
if (field.getValue().isSimpleValue() && ((SimpleValue)field.getValue()).isTypeSpecified()) {
try {
@@ -122,11 +134,11 @@
typeIsAccessible = false;
}
}
-
+ Shape bodyOrmShape = null;
if (typeIsAccessible && field.getValue().isSimpleValue()) {
bodyOrmShape = new Shape(field);
} else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandeableShape(field);
+ bodyOrmShape = new ExpandableShape(field);
} else if (typeIsAccessible && field.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(field);
} else {
@@ -134,7 +146,7 @@
}
addChild(bodyOrmShape);
} else {
- bodyOrmShape = new ExpandeableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field);
addChild(bodyOrmShape);
}
}
@@ -153,25 +165,26 @@
typeIsAccessible = false;
}
}
-
+ Shape bodyOrmShape = null;
if (typeIsAccessible && property.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandeableShape(property);
+ bodyOrmShape = new ExpandableShape(property);
} else if (typeIsAccessible && property.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(property);
} else {
bodyOrmShape = new Shape(property);
}
+ addChild(bodyOrmShape);
} else {
- bodyOrmShape = new ExpandeableShape(property);
+ Shape bodyOrmShape = new ExpandableShape(property);
+ addChild(bodyOrmShape);
}
- addChild(bodyOrmShape);
}
}
} else if (ormElement instanceof Table) {
Iterator iterator = ((Table)getOrmElement()).getColumnIterator();
while (iterator.hasNext()) {
Column column = (Column)iterator.next();
- bodyOrmShape = new Shape(column);
+ Shape bodyOrmShape = new Shape(column);
addChild(bodyOrmShape);
}
}
@@ -207,34 +220,6 @@
return null;
}
- protected void setHidden(boolean hiden) {
- super.setHidden(hiden);
- Iterator<Shape> it = getChildrenIterator();
- while (it.hasNext()) {
- final Shape child = it.next();
- child.setHidden(hiden);
- }
- }
-
- public void refreshHiden() {
- hiden = !hiden;
- setElementHidden(this, hiden);
- firePropertyChange(SET_HIDEN, null, Boolean.valueOf(hiden));
- }
-
- public void refreshReference() {
- firePropertyChange(SET_HIDEN, null, Boolean.valueOf(hiden));
- }
-
- private void setElementHidden(ModelElement element, boolean hidden) {
- Iterator<Shape> it = element.getChildrenIterator();
- while (it.hasNext()) {
- final Shape child = it.next();
- child.setHidden(hidden);
- setElementHidden(child, hidden);
- }
- }
-
public Point getLocation() {
return location.getCopy();
}
@@ -247,10 +232,6 @@
firePropertyChange(LOCATION_PROP, null, location);
}
- public boolean isHiden() {
- return hiden;
- }
-
public DiagramGuide getHorizontalGuide() {
return horizontalGuide;
}
@@ -266,4 +247,52 @@
public void setVerticalGuide(DiagramGuide vGuide) {
verticalGuide = vGuide;
}
+
+ protected Point getPoint(Properties properties, String key) {
+ Point point = new Point(0, 0);
+ String str = properties.getProperty(key + ".x", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ point.x = Integer.parseInt(str);
+ String str2 = properties.getProperty(key + ".y", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ point.y = Integer.parseInt(str2);
+ return point;
+ }
+
+ protected void setPoint(Properties properties, String key, Point point) {
+ String key1 = key + ".x"; //$NON-NLS-1$
+ if (!properties.containsKey(key1)) {
+ properties.remove(key1);
+ properties.put(key1, "" + point.x); //$NON-NLS-1$
+ } else {
+ properties.put(key1, "" + point.x); //$NON-NLS-1$
+ }
+ String key2 = key + ".y"; //$NON-NLS-1$
+ if (!properties.containsKey(key2)) {
+ properties.remove(key2);
+ properties.put(key2, "" + point.y); //$NON-NLS-1$
+ } else {
+ properties.put(key2, "" + point.y); //$NON-NLS-1$
+ }
+ }
+
+ public void setPosition(Properties properties) {
+ Point point = getLocation();
+ setPoint(properties, getKey(), point);
+ }
+
+ public Point getPosition(Properties properties) {
+ return getPoint(properties, getKey());
+ }
+
+ @Override
+ protected void loadFromProperties(Properties properties) {
+ super.loadFromProperties(properties);
+ Point pos = getPosition(properties);
+ setLocation(pos);
+ }
+
+ @Override
+ protected void saveInProperties(Properties properties) {
+ setPosition(properties);
+ super.saveInProperties(properties);
+ }
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
@@ -22,26 +23,39 @@
import org.jboss.tools.hibernate.ui.view.HibernateUtils;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
-public class Shape extends ModelElement {
+/**
+ * Shape which represents particular Hibernate element on the diagram.
+ *
+ * @author some modifications from Vitali
+ */
+public class Shape extends BaseElement {
+ public static final String SET_FOCUS = "setFocus"; //$NON-NLS-1$
+
+ /**
+ * left indent for property string on diagram
+ */
private int indent = 0;
-
+ /**
+ * source and target connections to connect shapes with directed edges.
+ */
private List<Connection> sourceConnections = new ArrayList<Connection>();
private List<Connection> targetConnections = new ArrayList<Connection>();
-
- public static final String HIDE_SELECTION = "hide selection"; //$NON-NLS-1$
- public static final String SHOW_SELECTION = "show selection"; //$NON-NLS-1$
- public static final String SET_FOCUS = "set focus"; //$NON-NLS-1$
-
+ /**
+ * orm element which is behind the shape
+ */
private Object ormElement;
+ /**
+ * only one BaseElement offspring has a parent - this is Shape
+ */
+ private BaseElement parent;
private static OrmLabelProvider labelProvider = new OrmLabelProvider();
-
private static IPropertyDescriptor[] descriptors_property;
private static IPropertyDescriptor[] descriptors_column;
/**
- * Property set
+ * Hibernate properties set
*/
private static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
private static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
@@ -91,20 +105,19 @@
protected Shape(Object ioe) {
ormElement = ioe;
}
-
- private ModelElement parent;
- public ModelElement getParent() {
+ @Override
+ public BaseElement getParent() {
return parent;
}
- public void setParent(ModelElement element) {
+ public void setParent(BaseElement element) {
parent = element;
}
public OrmDiagram getOrmDiagram() {
OrmDiagram res = null;
- ModelElement el = this;
+ BaseElement el = this;
while (el != null) {
if (el instanceof OrmDiagram) {
res = (OrmDiagram)el;
@@ -114,40 +127,14 @@
}
return res;
}
-
- public ExpandeableShape getExtendeableShape() {
- ExpandeableShape res = null;
- ModelElement el = this;
- while (el != null) {
- if (el instanceof ExpandeableShape) {
- res = (ExpandeableShape)el;
- break;
- }
- el = el.getParent();
- }
- return res;
- }
-
- public OrmShape getOrmShape() {
- OrmShape res = null;
- ModelElement el = this;
- while (el != null) {
- if (el instanceof OrmShape) {
- res = (OrmShape)el;
- break;
- }
- el = el.getParent();
- }
- return res;
- }
public void addConnection(Connection conn) {
if (conn == null || conn.getSource() == conn.getTarget()) {
throw new IllegalArgumentException();
}
- if (conn.getSource() == this) {
+ if (conn.getSource() == this && !sourceConnections.contains(conn)) {
sourceConnections.add(conn);
- } else if (conn.getTarget() == this) {
+ } else if (conn.getTarget() == this && !targetConnections.contains(conn)) {
targetConnections.add(conn);
}
}
@@ -163,13 +150,10 @@
public Object getOrmElement() {
return ormElement;
}
-
- public void hideSelection() {
- firePropertyChange(HIDE_SELECTION, null, null);
- }
- public void showSelection() {
- firePropertyChange(SHOW_SELECTION, null, null);
+ @Override
+ public String getKey() {
+ return Utils.getName(getOrmElement());
}
public void setFocus() {
@@ -184,15 +168,38 @@
this.indent = indent;
}
- protected void setHidden(boolean hiden) {
- for (int i = 0; i < sourceConnections.size(); i++) {
- sourceConnections.get(i).setHidden(hiden);
+ @Override
+ public void updateVisibleValue(boolean initState) {
+ super.updateVisibleValue(initState);
+ // update connections visibility state
+ for (Connection connection : sourceConnections) {
+ connection.updateVisibleValue(getOrmDiagram().getConnectionsVisibility());
}
- for (int i = 0; i < targetConnections.size(); i++) {
- targetConnections.get(i).setHidden(hiden);
+ for (Connection connection : targetConnections) {
+ connection.updateVisibleValue(getOrmDiagram().getConnectionsVisibility());
}
}
+
+ @Override
+ protected void loadFromProperties(Properties properties) {
+ super.loadFromProperties(properties);
+ String str = properties.getProperty("indent", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ indent = Integer.valueOf(str).intValue();
+ }
+ @Override
+ protected void saveInProperties(Properties properties) {
+ properties.put("indent", "" + indent); //$NON-NLS-1$ //$NON-NLS-2$
+ super.saveInProperties(properties);
+ }
+
+ public String toString() {
+ if (ormElement == null) {
+ return super.toString();
+ }
+ return ormElement.toString();
+ }
+
/**
* Returns an array of IPropertyDescriptors for this shape.
* <p>The returned array is used to fill the property view, when the edit-part corresponding
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -20,17 +20,23 @@
import org.hibernate.mapping.RootClass;
import org.hibernate.type.Type;
+/**
+ *
+ * @author some modifications from Vitali
+ */
public class SpecialOrmShape extends OrmShape {
private Shape parentShape;
public SpecialOrmShape(SpecialRootClass ioe) {
super(ioe);
-// generate();
}
+ /**
+ * creates children of the shape,
+ */
@SuppressWarnings("unchecked")
- protected void generate() {
- Shape bodyOrmShape;
+ @Override
+ protected void initModel() {
RootClass rootClass = (RootClass)getOrmElement();
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
@@ -39,7 +45,7 @@
SpecialRootClass src = (SpecialRootClass)getOrmElement();
if (src.getParentProperty() != null) {
- bodyOrmShape = new Shape(src.getParentProperty());
+ Shape bodyOrmShape = new Shape(src.getParentProperty());
addChild(bodyOrmShape);
parentShape = bodyOrmShape;
}
@@ -63,8 +69,9 @@
HibernateConsolePlugin.getDefault().logErrorMessage("MappingException: ", e); //$NON-NLS-1$
}
}
+ Shape bodyOrmShape = null;
if (type != null && type.isEntityType()) {
- bodyOrmShape = new ExpandeableShape(field);
+ bodyOrmShape = new ExpandableShape(field);
} else if (type != null && type.isCollectionType()) {
bodyOrmShape = new ComponentShape(field);
} else {
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Utils.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Utils.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Utils.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import java.util.List;
+
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Table;
+
+/**
+ * Some common model utils.
+ *
+ * @author vitali
+ */
+public class Utils {
+
+ public static boolean isConnectionExist(Shape source, Shape target) {
+ boolean res = false;
+ if (source != null && target != null) {
+ List<Connection> sourceConnections = source.getSourceConnections();
+ for (int i = 0; !res && i < sourceConnections.size(); i++) {
+ Connection conn = sourceConnections.get(i);
+ if (conn.getTarget().equals(target)) {
+ res = true;
+ }
+ }
+ }
+ return res;
+ }
+
+ public static String getName(Object obj) {
+ String res = ""; //$NON-NLS-1$
+ if (obj instanceof PersistentClass) {
+ PersistentClass rootClass = (PersistentClass)obj;
+ if (rootClass.getEntityName() != null) {
+ res = rootClass.getEntityName();
+ } else {
+ res = rootClass.getClassName();
+ }
+ } else if (obj instanceof Table) {
+ res = getTableName((Table)obj);
+ } else if (obj instanceof Property) {
+ Property property = (Property)obj;
+ res = property.getPersistentClass().getEntityName() + "." + property.getName(); //$NON-NLS-1$
+ } else if (obj instanceof String) {
+ res = (String)obj;
+ }
+ if (res.length() > 0 && res.indexOf(".") < 0) { //$NON-NLS-1$
+ return "default." + res; //$NON-NLS-1$
+ }
+ return res;
+ }
+
+ public static String getTableName(String catalog, String schema, String name) {
+ return (catalog != null ? catalog + "." : "") + (schema != null ? schema + "." : "") + name; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ public static String getTableName(Table table) {
+ return getTableName(table.getCatalog(), table.getSchema(), table.getName());
+ }
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ComponentShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ComponentShapeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ComponentShapeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -14,87 +14,104 @@
import org.eclipse.draw2d.FocusBorder;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.jboss.tools.hibernate.ui.diagram.editors.figures.ComponentFigure;
-import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleLabel;
import org.jboss.tools.hibernate.ui.diagram.editors.model.ComponentShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
+/**
+ *
+ * @author some modifications from Vitali
+ */
+public class ComponentShapeEditPart extends ExpandableShapeEditPart {
-public class ComponentShapeEditPart extends ExpandeableShapeEditPart {
-
- protected IFigure createFigure() {
- if (getModel() instanceof ComponentShape) {
- IFigure figure = new ComponentFigure();
- figure.setLayoutManager(new ToolbarLayout());
- Label label = new TitleLabel();
- label.setText(ormLabelProvider.getText(getCastedModel().getOrmElement()));
- label.setBackgroundColor(getColor());
- label.setOpaque(true);
- label.setIcon(ormLabelProvider.getImage(getCastedModel().getOrmElement()));
- label.setLabelAlignment(PositionConstants.LEFT);
- label.setBorder(new MarginBorder(1,2,1,2));
- figure.add(label,-2);
- figure.setBorder(new FocusBorder());
- figure.setSize(-1,-1);
- return figure;
- } else {
- throw new IllegalArgumentException();
+ public ComponentFigure getComponentFigure() {
+ if (getFigure() instanceof ComponentFigure) {
+ return (ComponentFigure)getFigure();
}
+ return null;
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
+ protected IFigure createFigure() {
+ ComponentFigure figure = new ComponentFigure();
+ figure.createTitle(ormLabelProvider.getText(getElement()),
+ ormLabelProvider.getImage(getElement()), getColor());
+ figure.setBorder(new FocusBorder());
+ figure.setSize(-1, -1);
+ return figure;
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+ */
+ @Override
public void activate() {
super.activate();
- if (this.getClass().equals(ComponentShapeEditPart.class) &&
- !((ExpandeableShape)getModel()).isReferenceVisible()) {
- ((ComponentShape)getModel()).refHide = true;
- ((ComponentShape)getModel()).refreshChildsHiden(((OrmDiagram)getViewer().getContents().getModel()));
- ((ExpandeableShape)getModel()).getOrmDiagram().setDirty(false);
- }
}
+ public ComponentShape getModelComponentShape() {
+ return (ComponentShape)getModel();
+ }
+
+ /**
+ * @see AbstractEditPart#performRequest(Request)
+ */
+ @Override
public void performRequest(Request req) {
- if (RequestConstants.REQ_OPEN.equals(req.getType()) &&
- getModel() instanceof ComponentShape) {
- ((ComponentShape)getModel()).refreshChildsHiden(((OrmDiagram)getViewer().getContents().getModel()));
+ if (RequestConstants.REQ_OPEN.equals(req.getType())) {
+ ExpandableShape es = getModelExpandableShape();
+ if (es.isExpanded()) {
+ es.collapse();
+ } else {
+ es.expand();
+ }
+ } else {
+ super.performRequest(req);
}
}
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
- if (ComponentShape.SET_CHILDS_HIDEN.equals(prop)) {
- int i = figure.getPreferredSize().width;
- ((ComponentFigure)figure).setChildsHiden(((Boolean)evt.getNewValue()).booleanValue());
-
- if (((Boolean)evt.getNewValue()).booleanValue()) {
- figure.setSize(i,-1);
- } else {
- figure.setSize(-1,-1);
+ if (ExpandableShape.EXPANDED.equals(prop)) {
+ boolean expanded = (Boolean)evt.getNewValue();
+ if (getComponentFigure() != null) {
+ getComponentFigure().setExpanded(expanded);
}
-
- referenceList.add((OrmShape)getCastedModel().getParent());
- refreshReferences((ExpandeableShape)getCastedModel(), ((ExpandeableShape)getCastedModel()).isReferenceVisible());
-
- ((OrmShape)getParent().getModel()).refreshReference();
+ BaseElement parent = getModelParent();
+ if (parent.getParent() != null) {
+ // refresh only parent which has a parent! so we exclude OrmDiagram here
+ // refresh only basic properties
+ parent.refreshBasic();
+ }
+ getOrmDiagram().updateDirty(evt.getNewValue() != evt.getOldValue());
+ } else if (BaseElement.REFRESH.equals(prop)) {
+ if (getComponentFigure() != null) {
+ getComponentFigure().setExpanded(getModelExpandableShape().isExpanded());
+ }
+ super.propertyChange(evt);
} else {
super.propertyChange(evt);
}
+ refresh();
}
protected void refreshVisuals() {
Rectangle bounds = null;
if (getModel() instanceof ComponentShape) {
- bounds = new Rectangle(new Point(0,0), getFigure().getSize());
+ bounds = new Rectangle(new Point(0, 0), getFigure().getSize());
}
if (bounds != null) {
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ConnectionEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ConnectionEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ConnectionEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -31,15 +31,18 @@
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.editors.figures.RoundPolylineConnection;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ModelElement;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
+/**
+ * @author some modifications from Vitali
+ */
class ConnectionEditPart extends AbstractConnectionEditPart
-implements PropertyChangeListener, EditPartListener {
+ implements PropertyChangeListener, EditPartListener {
public void activate() {
if (!isActive()) {
super.activate();
- ((ModelElement) getModel()).addPropertyChangeListener(this);
+ ((BaseElement) getModel()).addPropertyChangeListener(this);
addEditPartListener(this);
}
}
@@ -52,64 +55,73 @@
PolylineConnection connection = new RoundPolylineConnection();
connection.setForegroundColor(getColor());
connection.setTargetDecoration(new PolygonDecoration());
- connection.setVisible(!getCastedModel().isHiden());
+ connection.setVisible(getModelConnection().isVisible());
return connection;
}
public void deactivate() {
if (isActive()) {
super.deactivate();
- ((ModelElement) getModel()).removePropertyChangeListener(this);
+ ((BaseElement) getModel()).removePropertyChangeListener(this);
}
}
public void propertyChange(PropertyChangeEvent event) {
String property = event.getPropertyName();
- if (Connection.SHOW_SELECTION.equals(property)) {
- getFigure().setForegroundColor(getSelectionColor());
- } else if (Connection.HIDE_SELECTION.equals(property)) {
- getFigure().setForegroundColor(getColor());
- } else if (Connection.SET_HIDEN.equals(property)) {
- getFigure().setVisible(!((Boolean)event.getNewValue()).booleanValue());
+ if (BaseElement.SELECTED.equals(property)) {
+ updateSelected((Boolean)event.getNewValue());
+ } else if (BaseElement.VISIBLE.equals(property)) {
+ getFigure().setVisible(((Boolean)event.getNewValue()).booleanValue());
+ } else if (BaseElement.REFRESH.equals(property)) {
+ getFigure().setVisible(getModelConnection().isVisible());
+ updateSelected(getModelConnection().isSelected());
}
}
- private Connection getCastedModel() {
+ protected void updateSelected(boolean selected) {
+ //setSelected(selected ? EditPart.SELECTED : EditPart.SELECTED_NONE);
+ if (!selected) {
+ setSelected(EditPart.SELECTED_NONE);
+ }
+ getFigure().setForegroundColor(selected ? getSelectionColor() : getColor());
+ }
+
+ private Connection getModelConnection() {
return (Connection) getModel();
}
+ protected Object getTargetElement() {
+ return getModelConnection().getTarget().getOrmElement();
+ }
+
private Color getColor() {
- Object element = getCastedModel().getTarget().getOrmElement();
- if (element instanceof RootClass || element instanceof Subclass) {
- return ResourceManager.getInstance().getColor(new RGB(210,155,100));
- } else if (element instanceof Column || element instanceof Table || element instanceof Property) {
+ Object el = getTargetElement();
+ if (el instanceof RootClass || el instanceof Subclass) {
+ return ResourceManager.getInstance().getColor(new RGB(210, 155, 100));
+ } else if (el instanceof Column || el instanceof Table || el instanceof Property) {
return ResourceManager.getInstance().getColor(new RGB(160, 160, 160));
- } else {
- throw new IllegalArgumentException();
}
+ return ResourceManager.getInstance().getColor(new RGB(255, 0, 0));
}
private Color getSelectionColor() {
- if (getCastedModel().getTarget().getOrmElement() instanceof RootClass ||
- getCastedModel().getTarget().getOrmElement() instanceof Subclass) {
- return ResourceManager.getInstance().getColor(new RGB(112,161,99));
- } else if (getCastedModel().getTarget().getOrmElement() instanceof Column ||
- getCastedModel().getTarget().getOrmElement() instanceof Table ||
- getCastedModel().getTarget().getOrmElement() instanceof Component) {
- return ResourceManager.getInstance().getColor(new RGB(66,173,247));
- } else {
- throw new IllegalArgumentException();
+ Object el = getTargetElement();
+ if (el instanceof RootClass || el instanceof Subclass) {
+ return ResourceManager.getInstance().getColor(new RGB(112, 161, 99));
+ } else if (el instanceof Column || el instanceof Table || el instanceof Component) {
+ return ResourceManager.getInstance().getColor(new RGB(66, 173, 247));
}
+ return ResourceManager.getInstance().getColor(new RGB(255, 0, 0));
}
private class ShapesSelectionEditPolicy extends SelectionEditPolicy {
protected void hideSelection() {
- getCastedModel().hideSelection();
+ getModelConnection().setSelected(false);
}
protected void showSelection() {
- getCastedModel().showSelection();
+ getModelConnection().setSelected(true);
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -11,9 +11,7 @@
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -30,36 +28,27 @@
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.SnapToGeometry;
import org.eclipse.gef.SnapToGrid;
import org.eclipse.gef.SnapToGuides;
import org.eclipse.gef.SnapToHelper;
import org.eclipse.gef.rulers.RulerProvider;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Component;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.AutoLayout;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IDiagramInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl.AutoLayoutImpl;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ModelElement;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.SpecialOrmShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.SpecialRootClass;
-import org.jboss.tools.hibernate.ui.view.HibernateUtils;
/**
- *
+ * @author some modifications from Vitali
*/
-class DiagramEditPart extends OrmEditPart implements PropertyChangeListener {
+class DiagramEditPart extends OrmEditPart {
protected void createEditPolicies() {
installEditPolicy(EditPolicy.LAYOUT_ROLE,
@@ -77,139 +66,24 @@
return f;
}
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
- if (OrmDiagram.REFRESH.equals(prop)) {
+ if (OrmDiagram.AUTOLAYOUT.equals(prop)) {
refresh();
autolayout();
- // restore();
+ } else if (BaseElement.REFRESH.equals(prop)) {
+ refresh();
} else if (OrmDiagram.DIRTY.equals(prop)) {
((DiagramViewer) ((DefaultEditDomain) getViewer().getEditDomain())
.getEditorPart()).refreshDirty();
}
+ refresh();
}
- public void restore() {
- boolean dirty = getOrmDiagram().isDirty();
- HashMap<String, OrmShape> hashMap = getOrmDiagram().getCloneElements();
- String childrenLocations[] = getOrmDiagram().getChildrenLocations();
- int tempPoint = 1;
- OrmShape ormShape;
- int point = 1;
- int pointX = calculateTableLocation();
- String string, xy[];
- for (int i = 0; i < childrenLocations.length; i++) {
- if (childrenLocations[i].indexOf('@') != -1
- && childrenLocations[i].indexOf(';') != -1) {
- string = childrenLocations[i].substring(0, childrenLocations[i]
- .indexOf('@'));
- ormShape = hashMap.remove(string);
- if (ormShape != null) {
- string = childrenLocations[i]
- .substring(childrenLocations[i].indexOf('@') + 1);
- xy = string.split(";"); //$NON-NLS-1$
- if (xy.length > 1) {
- try {
- ormShape.setLocation(new Point(Integer
- .parseInt(xy[0]), Integer.parseInt(xy[1])));
- } catch (NumberFormatException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("NumberFormatException: ", e); //$NON-NLS-1$
- }
- }
- if (xy.length > 2) {
- if ((Boolean.valueOf(xy[2]))) {
- ormShape.refreshHiden();
- }
- }
- tempPoint = ormShape.getLocation().y
- + getChildrenFigurePreferredHeight(ormShape) + 20;
- if (tempPoint > point) {
- point = tempPoint;
- }
- }
- }
- }
- RootClass[] ormElements = getOrmDiagram().getOrmElements();
- for (int i = 0; i < childrenLocations.length; i++) {
- RootClass persistentClass = ormElements[i];
- ormShape = hashMap.remove(persistentClass.getEntityName());
- if (ormShape != null) {
- ormShape.setLocation(new Point(20, 20));
- tempPoint = 40 + getChildrenFigurePreferredHeight(ormShape);
- }
- Table table = persistentClass.getTable();
- ormShape = hashMap.remove(HibernateUtils.getTableName(table));
- if (ormShape != null) {
- ormShape.setLocation(new Point(pointX, 20));
- point = 40 + getChildrenFigurePreferredHeight(ormShape);
- }
- if (tempPoint > point) {
- point = tempPoint;
- }
- }
- Object objects[] = hashMap.keySet().toArray();
- for (int i = 0; i < objects.length; i++) {
- ormShape = hashMap.get(objects[i]);
- if (ormShape != null
- && (ormShape.getOrmElement() instanceof RootClass || ormShape
- .getOrmElement() instanceof SpecialOrmShape)) {
- ormShape.setLocation(new Point(20, point));
- tempPoint = point + getChildrenFigurePreferredHeight(ormShape)
- + 20;
- // if (ormShape.getOrmElement() instanceof SpecialRootClass) {
- Component component = (Component) ((Collection) ((SpecialRootClass) (ormShape
- .getOrmElement())).getProperty().getValue())
- .getElement();
- Table ownerTable = component.getOwner().getTable();
- ormShape = hashMap.remove(HibernateUtils.getTableName(ownerTable));
- // }
- // if (ormShape != null ) {
- // ormShape.setLocation(new Point(pointX,point));
- // point = point + getChildrenFigurePreferredHeight(ormShape) +
- // 20;
- // }
- if (tempPoint > point) {
- point = tempPoint;
- }
- }
- }
- for (OrmShape shape : hashMap.values()) {
- if (shape.getOrmElement() instanceof Table) {
- shape.setLocation(new Point(pointX, point));
- point = point + getChildrenFigurePreferredHeight(shape) + 20;
- }
- }
- getOrmDiagram().setDirty(dirty);
- }
-
- private OrmDiagram getOrmDiagram() {
- return (OrmDiagram) getModel();
- }
-
- private int getChildrenFigurePreferredHeight(OrmShape ormShape) {
- GraphicalEditPart part;
- for (int i = 0; i < getChildren().size(); i++) {
- part = (GraphicalEditPart) getChildren().get(i);
- if (ormShape.equals(part.getModel())) {
- return part.getFigure().getPreferredSize().height;
- }
- }
- return 0;
- }
-
- @SuppressWarnings("unchecked")
- private int calculateTableLocation() {
- int j = 0;
- List<IFigure> children = getFigure().getChildren();
- for (int i = 0; i < children.size(); i++) {
- IFigure figure = children.get(i);
- if (figure.getPreferredSize().width > j) {
- j = figure.getPreferredSize().width;
- }
- }
- return j + 120;
- }
-
/**
* Returns a <code>List</code> containing the children model objects.
* @return the List of children
@@ -227,19 +101,20 @@
public void activate() {
if (!isActive()) {
super.activate();
- ((ModelElement) getModel()).addPropertyChangeListener(this);
- if (!getOrmDiagram().isLoadSuccessfull()) {
+ ((BaseElement) getModel()).addPropertyChangeListener(this);
+ if (!getOrmDiagram().isFileLoadSuccessfull()) {
+ refresh();
autolayout();
+ refresh();
getOrmDiagram().setDirty(false);
}
- // restore();
}
}
public void autolayout() {
IDiagramInfo process = new DiagramInfo(getOrmDiagram());
- AutoLayout layout = new AutoLayout();
- layout.setGridStep("" + 5); //$NON-NLS-1$
+ AutoLayoutImpl layout = new AutoLayoutImpl();
+ layout.setGridStep(5);
layout.setOverride(true);
layout.setProcess(process);
}
@@ -257,7 +132,7 @@
public void deactivate() {
if (isActive()) {
super.deactivate();
- ((ModelElement) getModel()).removePropertyChangeListener(this);
+ ((BaseElement) getModel()).removePropertyChangeListener(this);
}
}
@@ -267,16 +142,12 @@
OrmDiagram diagram;
public DiagramInfo(OrmDiagram diagram) {
- IItemInfo item;
this.diagram = diagram;
- OrmShapeEditPart part;
-
Iterator<Shape> it = diagram.getChildrenIterator();
while (it.hasNext()) {
Shape child = it.next();
- part = (OrmShapeEditPart) getViewer().getEditPartRegistry().get(child);
- if (part != null && part.getFigure().isVisible()) {
- item = new DiagramElementInfo((OrmShape)child);
+ if (child.isVisible()) {
+ IItemInfo item = new DiagramElementInfo((OrmShape)child);
addItem(item);
}
}
@@ -311,19 +182,27 @@
ILinkInfo link;
this.element = element;
for (Connection connection : element.getSourceConnections()) {
- link = new LinkInfo(connection);
- addLink(link);
+ if (connection.isVisible()) {
+ link = new LinkInfo(connection);
+ addLink(link);
+ }
}
Iterator<Shape> it = element.getChildrenIterator();
while (it.hasNext()) {
Shape child = it.next();
- if (child.getSourceConnections().size() == 0) {
+ if (!child.isVisible()) {
+ continue;
+ }
+ final List<Connection> sourceConnections = child.getSourceConnections();
+ if (sourceConnections.size() == 0) {
link = new LinkInfo(getID());
addLink(link);
}
- for (int i = 0; i < child.getSourceConnections().size(); i++) {
- link = new LinkInfo(child.getSourceConnections().get(i));
- addLink(link);
+ for (Connection connection : sourceConnections) {
+ if (connection.isVisible()) {
+ link = new LinkInfo(connection);
+ addLink(link);
+ }
}
}
}
@@ -343,7 +222,7 @@
}
/**
- *
+ * gets shape vertices
*/
public int[] getShape() {
int[] shape = new int[4];
@@ -353,9 +232,13 @@
.getEditPartRegistry().get(element);
if (part != null) {
IFigure fig = part.getFigure();
- shape[2] = fig.getSize().width;//fig.getPreferredSize().width;
- shape[3] = fig.getSize().height;//fig.getPreferredSize().height;
+ //shape[2] = fig.getSize().width;
+ //shape[3] = fig.getSize().height;
+ // use preferred size for correct autolayout
+ shape[2] = fig.getPreferredSize().width;
+ shape[3] = fig.getPreferredSize().height;
} else {
+ // indicate refresh model error
shape[2] = 6000;
shape[3] = 1000;
}
@@ -363,6 +246,13 @@
}
/**
+ * setup OrmShape up-left point location, using s[0] and s[1]
+ */
+ public void setShape(int[] s) {
+ element.setLocation(new Point(s[0], s[1]));
+ }
+
+ /**
*
*/
public ILinkInfo[] getLinks() {
@@ -377,13 +267,6 @@
links.add(link);
}
- /**
- *
- */
- public void setShape(int[] s) {
- element.setLocation(new Point(s[0], s[1]));
- }
-
}
class LinkInfo implements ILinkInfo {
@@ -416,12 +299,6 @@
}
return ""; //$NON-NLS-1$
}
-
- /**
- *
- */
- public void setLinkShape(int[] vs) {
- }
}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeEditPart.java (from rev 16821, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeEditPart.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeEditPart.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleLabel;
+import org.jboss.tools.hibernate.ui.diagram.editors.figures.TopLineBorder;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
+
+/**
+ * @author some modifications from Vitali
+ */
+public class ExpandableShapeEditPart extends ShapeEditPart {
+
+ public TitleLabel getTitleLabel() {
+ if (getFigure() instanceof TitleLabel) {
+ return (TitleLabel)getFigure();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
+ protected IFigure createFigure() {
+ Label label = new TitleLabel();
+ label.setText(ormLabelProvider.getText(getElement()));
+ label.setBackgroundColor(getColor());
+ label.setIcon(ormLabelProvider.getImage(getElement()));
+ label.setLabelAlignment(PositionConstants.LEFT);
+ label.setOpaque(true);
+ TopLineBorder border =
+ new TopLineBorder(1, 2 + getModelShape().getIndent(), 1, 2);
+ border.setColor(getOrmShapeEditPart().getColor());
+ label.setBorder(border);
+ return label;
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ getModelExpandableShape().refresh();
+ }
+
+ protected ExpandableShape getModelExpandableShape() {
+ return (ExpandableShape) getModel();
+ }
+
+ /**
+ * @see AbstractEditPart#performRequest(Request)
+ */
+ @Override
+ public void performRequest(Request req) {
+ if (RequestConstants.REQ_OPEN.equals(req.getType())) {
+ ExpandableShape es = getModelExpandableShape();
+ if (es.isExpanded()) {
+ es.collapse();
+ } else {
+ es.expand();
+ }
+ } else {
+ super.performRequest(req);
+ }
+ }
+
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ String prop = evt.getPropertyName();
+ if (ExpandableShape.EXPANDED.equals(prop)) {
+ boolean expanded = (Boolean)evt.getNewValue();
+ if (getTitleLabel() != null) {
+ getTitleLabel().setExpanded(expanded);
+ }
+ BaseElement parent = getModelParent();
+ if (parent.getParent() != null) {
+ // refresh only parent which has a parent! so we exclude OrmDiagram here
+ // refresh only basic properties
+ parent.refreshBasic();
+ }
+ getOrmDiagram().updateDirty(evt.getNewValue() != evt.getOldValue());
+ } else if (BaseElement.REFRESH.equals(prop)) {
+ if (getTitleLabel() != null) {
+ getTitleLabel().setExpanded(getModelExpandableShape().isExpanded());
+ }
+ super.propertyChange(evt);
+ BaseElement parent = getModelParent();
+ if (parent.getParent() != null) {
+ // refresh only parent which has a parent! so we exclude OrmDiagram here
+ // refresh only basic properties
+ parent.refreshBasic();
+ }
+ } else {
+ super.propertyChange(evt);
+ }
+ refresh();
+ }
+
+ @Override
+ protected void updateSelected(boolean selected) {
+ //setSelected(selected ? EditPart.SELECTED : EditPart.SELECTED_NONE);
+ if (!selected) {
+ setSelected(EditPart.SELECTED_NONE);
+ }
+ IFigure updateFigure;
+ if (getFigure().getChildren().size() > 0) {
+ updateFigure = (IFigure)getFigure().getChildren().get(0);
+ } else {
+ updateFigure = getFigure();
+ }
+ Color background = selected ? getSelectionColor() : getColor();
+ Color foreground = ResourceManager.getInstance().getColor(
+ selected ? new RGB(255, 255, 255) : new RGB(0, 0, 0));
+ updateFigure.setBackgroundColor(background);
+ updateFigure.setForegroundColor(foreground);
+ }
+
+ /**
+ * Returns a <code>List</code> containing the children model objects.
+ * @return the List of children
+ */
+ @Override
+ protected List<Shape> getModelChildren() {
+ List<Shape> res = new ArrayList<Shape>();
+ Iterator<Shape> it = getModelExpandableShape().getChildrenIterator();
+ while (it.hasNext()) {
+ res.add(it.next());
+ }
+ return res;
+ }
+}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeTreeEditPart.java (from rev 16822, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeTreeEditPart.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandableShapeTreeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Tree;
+import org.hibernate.console.ConsoleConfiguration;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
+import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
+
+/**
+ * @author some modifications from Vitali
+ */
+public class ExpandableShapeTreeEditPart extends
+ org.eclipse.gef.editparts.AbstractTreeEditPart implements
+ PropertyChangeListener {
+
+ protected OrmLabelProvider ormLabelProvider;
+
+ /**
+ * Constructor initializes this with the given model.
+ *
+ * @param model
+ * Model for this.
+ */
+ public ExpandableShapeTreeEditPart(ExpandableShape model) {
+ super(model);
+ ConsoleConfiguration cfg = model.getOrmDiagram().getConsoleConfig();
+ ormLabelProvider = new OrmLabelProvider(cfg.getConfiguration());
+ }
+
+ /**
+ * Returns the model of this as a ExpandeableShape.
+ *
+ * @return Model of this.
+ */
+ protected ExpandableShape getExpandeableShape() {
+ return (ExpandableShape) getModel();
+ }
+
+ /**
+ * Returns <code>null</code> as a Tree EditPart holds no children under it.
+ * @return <code>null</code>
+ */
+ @Override
+ protected List<Shape> getModelChildren() {
+ List<Shape> res = new ArrayList<Shape>();
+ Iterator<Shape> it = getExpandeableShape().getChildrenIterator();
+ while (it.hasNext()) {
+ res.add(it.next());
+ }
+ return res;
+ }
+
+ public void propertyChange(PropertyChangeEvent change) {
+ refreshVisuals();
+ }
+
+ /**
+ * Refreshes the visual properties of the TreeItem for this part.
+ */
+ protected void refreshVisuals() {
+ if (getWidget() instanceof Tree) {
+ return;
+ }
+ Shape model = (Shape) getModel();
+ Object element = model.getOrmElement();
+ setWidgetImage(ormLabelProvider.getImage(element));
+ setWidgetText(ormLabelProvider.getText(element));
+ }
+
+}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,290 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.ui.diagram.editors.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.swt.graphics.RGB;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Table;
-import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleLabel;
-import org.jboss.tools.hibernate.ui.diagram.editors.figures.TopLineBorder;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
-
-/**
- *
- */
-public class ExpandeableShapeEditPart extends ShapeEditPart {
- protected IFigure createFigure() {
- if (getModel() instanceof Shape) {
- Label label = new TitleLabel();
- label.setText(ormLabelProvider.getText(getElement()));
- label.setBackgroundColor(getColor());
- label.setIcon(ormLabelProvider.getImage(getElement()));
- label.setLabelAlignment(PositionConstants.LEFT);
- label.setOpaque(true);
- TopLineBorder border = new TopLineBorder(1,2+getCastedModel().getIndent(),1,2);
- border.setColor(getOrmShapeEditPart().getColor());
- label.setBorder(border);
- return label;
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- public void activate() {
- super.activate();
- if (this.getClass().equals(ExpandeableShapeEditPart.class) &&
- !((ExpandeableShape)getModel()).isReferenceVisible()) {
- ((ExpandeableShape)getModel()).refHide = true;
- ((ExpandeableShape)getModel()).refreshReferences(getViewer().getContents().getModel());
- ((ExpandeableShape)getModel()).getOrmDiagram().setDirty(false);
- }
- }
-
- public void performRequest(Request req) {
- if (RequestConstants.REQ_OPEN.equals(req.getType())) {
- ((ExpandeableShape)getModel()).refreshReferences(getViewer().getContents().getModel());
- }
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- String prop = evt.getPropertyName();
- if (Shape.SHOW_SELECTION.equals(prop)) {
- IFigure updateFigure;
- if (getFigure().getChildren().size() > 0) {
- updateFigure = (IFigure)getFigure().getChildren().get(0);
- } else {
- updateFigure = getFigure();
- }
- updateFigure.setBackgroundColor(getSelectionColor());
- updateFigure.setForegroundColor(ResourceManager.getInstance().getColor(new RGB(255,255,255)));
- } else if (Shape.HIDE_SELECTION.equals(prop)) {
- IFigure updateFigure;
- if (getFigure().getChildren().size() > 0) {
- updateFigure = (IFigure)getFigure().getChildren().get(0);
- } else {
- updateFigure = getFigure();
- }
- updateFigure.setBackgroundColor(getColor());
- updateFigure.setForegroundColor(ResourceManager.getInstance().getColor(new RGB(0,0,0)));
- } else if (ExpandeableShape.SHOW_REFERENCES.equals(prop)) {
- refreshReferences(getCastedModel(), ((ExpandeableShape)getCastedModel()).isReferenceVisible());
- ((TitleLabel)getFigure()).setHidden(!((ExpandeableShape)getCastedModel()).isReferenceVisible());
- } else {
- super.propertyChange(evt);
- }
- }
-
- protected ArrayList<OrmShape> referenceList = new ArrayList<OrmShape>();
-
- protected void refreshReference(ExpandeableShape shape, boolean visible) {
- OrmShape refShape = shape.getReference();
- if (refShape == null) {
- return;
- }
- if (!isReferencesCorrect(refShape)) {
- return;
- }
-
- OrmEditPart refPart = (OrmEditPart)getViewer().getEditPartRegistry().get(refShape);
- if (refPart != null) {
- refPart.getFigure().setVisible(visible);
- setLinksVisible(refPart, visible);
- }
- Object element = refShape.getOrmElement();
- if (element instanceof RootClass) {
- RootClass rc = (RootClass)element;
- Table table = rc.getTable();
- OrmShape tableShape = refShape.getOrmDiagram().getShape(table);
- OrmEditPart tablePart = (OrmEditPart)getViewer().getEditPartRegistry().get(tableShape);
- if (tablePart != null) {
- if (isTableCanBeInvisible(tablePart, visible)) {
- tablePart.getFigure().setVisible(visible);
- setLinksVisible(tablePart, visible);
- }
- }
- }
- referenceList.add(refShape);
- Iterator<Shape> it = refShape.getChildrenIterator();
- while (it.hasNext()) {
- final Shape tmp = it.next();
- if (tmp instanceof ExpandeableShape) {
- refreshReference((ExpandeableShape)tmp, visible);
- }
- }
- referenceList.remove(refShape);
- shape.getOrmDiagram().update();
- }
-
- protected void refreshReferences(Shape shape, boolean visible) {
- Connection link;
- OrmShape refShape;
-
- OrmEditPart shapePart = (OrmEditPart)getViewer().getEditPartRegistry().get(shape);
-
- for (int i = 0; i < shape.getSourceConnections().size(); i++ ) {
- link = shape.getSourceConnections().get(i);
- refShape = link.getTarget().getOrmShape();
- if (refShape == null) {
- continue;
- }
- if (!isReferencesCorrect(refShape)) {
- continue;
- }
- OrmEditPart refPart = (OrmEditPart)getViewer().getEditPartRegistry().get(refShape);
- if (refPart != null) {
- if (isShapeCanBeInvisible(shapePart, refPart, visible)) {
- refPart.getFigure().setVisible(visible);
- setLinksVisible(refPart, visible);
- }
- }
- referenceList.add(shape.getOrmShape());
- refreshReferences(refShape, visible);
- referenceList.remove(shape.getOrmShape());
- }
-
- referenceList.add(shape.getOrmShape());
-
- Iterator<Shape> it = shape.getChildrenIterator();
- while (it.hasNext()) {
- refreshReferences(it.next(), visible);
- }
- referenceList.remove(shape.getOrmShape());
- shape.getOrmDiagram().update();
- }
-
- private boolean isTableCanBeInvisible(OrmEditPart tablePart, boolean visible) {
- if (visible) {
- return true;
- }
- ConnectionEditPart link;
- for (int i = 0; i < tablePart.getTargetConnections().size(); i++) {
- link = (ConnectionEditPart)tablePart.getTargetConnections().get(i);
- if (link.getFigure().isVisible()) {
- return false;
- }
- }
- return true;
- }
-
- private boolean isShapeCanBeInvisible(OrmEditPart source, OrmEditPart target, boolean visible) {
- if (visible) {
- return true;
- }
- ConnectionEditPart link;
- for (int i=0;i<target.getTargetConnections().size();i++) {
- link = (ConnectionEditPart)target.getTargetConnections().get(i);
- if (link.getFigure().isVisible() && link.getSource() != source) {
- return false;
- }
- }
- return true;
- }
-
- private boolean isReferencesCorrect(OrmShape shape) {
- if (shape == null) {
- return false;
- }
- for (int i = 0; i < referenceList.size(); i++) {
- if (shape.equals(referenceList.get(i))) {
- return false;
- }
- }
- return true;
- }
-
- private void setLinksVisible(OrmEditPart editPart, boolean flag) {
- ConnectionEditPart link;
- OrmEditPart child;
-
- for (int i = 0; i < editPart.getSourceConnections().size(); i++) {
- link = (ConnectionEditPart)editPart.getSourceConnections().get(i);
- if (isLinkCanBeVisible(link, flag)) {
- link.getFigure().setVisible(flag);
- }
- }
- for (int i = 0; i < editPart.getTargetConnections().size(); i++) {
- link = (ConnectionEditPart)editPart.getTargetConnections().get(i);
- if (isLinkCanBeVisible(link, flag)) {
- link.getFigure().setVisible(flag);
- }
- }
- for (int i = 0; i < editPart.getChildren().size();i++) {
- child = (OrmEditPart)editPart.getChildren().get(i);
- setLinksVisible(child, flag);
- }
- }
-
- private boolean isLinkCanBeVisible(ConnectionEditPart link, boolean visible) {
- if (!visible) {
- return true;
- }
- if (!((OrmEditPart)link.getSource()).getFigure().isVisible()) {
- return false;
- }
- if (!((OrmEditPart)link.getTarget()).getFigure().isVisible()) {
- return false;
- }
- if (!validateShape((Shape)((OrmEditPart)link.getSource()).getModel())) {
- return false;
- }
- if (!validateShape((Shape)((OrmEditPart)link.getTarget()).getModel())) {
- return false;
- }
- return true;
- }
-
- private boolean validateShape(Shape shape) {
- if (!shape.getClass().equals(OrmShape.class)) {
- OrmShape ormShape = shape.getOrmShape();
- if (ormShape != null) {
- if (ormShape.isHiden()) {
- return false;
- }
- }
- }
- ExpandeableShape expanableShape = shape.getExtendeableShape();
- if (expanableShape != null && !shape.equals(expanableShape) &&
- !expanableShape.getClass().equals(OrmShape.class)) {
- if (!expanableShape.isReferenceVisible()) {
- return false;
- }
- }
- return true;
- }
-
-
- /**
- * Returns a <code>List</code> containing the children model objects.
- * @return the List of children
- */
- @Override
- protected List<Shape> getModelChildren() {
- List<Shape> res = new ArrayList<Shape>();
- Iterator<Shape> it = ((ExpandeableShape)getModel()).getChildrenIterator();
- while (it.hasNext()) {
- res.add(it.next());
- }
- return res;
- }
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.ui.diagram.editors.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Tree;
-import org.hibernate.console.ConsoleConfiguration;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
-import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
-
-/**
- *
- */
-public class ExpandeableShapeTreeEditPart extends
- org.eclipse.gef.editparts.AbstractTreeEditPart implements
- PropertyChangeListener {
-
- protected OrmLabelProvider ormLabelProvider;
-
- /**
- * Constructor initializes this with the given model.
- *
- * @param model
- * Model for this.
- */
- public ExpandeableShapeTreeEditPart(ExpandeableShape model) {
- super(model);
- ConsoleConfiguration cfg = model.getOrmDiagram().getConsoleConfig();
- ormLabelProvider = new OrmLabelProvider(cfg.getConfiguration());
- }
-
- /**
- * Returns the model of this as a ExpandeableShape.
- *
- * @return Model of this.
- */
- protected ExpandeableShape getExpandeableShape() {
- return (ExpandeableShape) getModel();
- }
-
- /**
- * Returns <code>null</code> as a Tree EditPart holds no children under it.
- * @return <code>null</code>
- */
- @Override
- protected List<Shape> getModelChildren() {
- List<Shape> res = new ArrayList<Shape>();
- Iterator<Shape> it = getExpandeableShape().getChildrenIterator();
- while (it.hasNext()) {
- res.add(it.next());
- }
- return res;
- }
-
- public void propertyChange(PropertyChangeEvent change) {
- refreshVisuals();
- }
-
- /**
- * Refreshes the visual properties of the TreeItem for this part.
- */
- protected void refreshVisuals() {
- if (getWidget() instanceof Tree) {
- return;
- }
- Shape model = (Shape) getModel();
- Object element = model.getOrmElement();
- setWidgetImage(ormLabelProvider.getImage(element));
- setWidgetText(ormLabelProvider.getText(element));
- }
-
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/GEFRootEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/GEFRootEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/GEFRootEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -15,8 +15,10 @@
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
-//import org.eclipse.gef.LayerConstants;
+/**
+ * @author some modifications from Vitali
+ */
public class GEFRootEditPart extends ScalableFreeformRootEditPart {
public GEFRootEditPart() {
@@ -30,6 +32,4 @@
layer.getChildren().remove(fig);
layer.getChildren().add(fig);
}
-
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -20,8 +22,13 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartListener;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
-public class OrmEditPart extends AbstractGraphicalEditPart implements EditPartListener {
+/**
+ * @author some modifications from Vitali
+ */
+public class OrmEditPart extends AbstractGraphicalEditPart implements PropertyChangeListener, EditPartListener {
public void setModel(Object model) {
super.setModel(model);
@@ -46,6 +53,10 @@
}
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
protected IFigure createFigure() {
return null;
}
@@ -173,4 +184,24 @@
primRemoveTargetConnection(connection);
}
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ }
+
+ public OrmDiagram getOrmDiagram() {
+ BaseElement modelTmp = (BaseElement)getModel();
+ OrmDiagram res = modelTmp instanceof OrmDiagram ? (OrmDiagram)modelTmp : null;
+ while (modelTmp.getParent() != null) {
+ modelTmp = modelTmp.getParent();
+ res = modelTmp instanceof OrmDiagram ? (OrmDiagram)modelTmp : res;
+ }
+ return res;
+ }
+
+ public BaseElement getModelParent() {
+ BaseElement modelTmp = (BaseElement)getModel();
+ return modelTmp.getParent();
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPartFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPartFactory.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmEditPartFactory.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -15,43 +15,44 @@
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.model.ComponentShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
-
+/**
+ * @author some modifications from Vitali
+ * @see org.eclipse.gef.EditPartFactory
+ */
public class OrmEditPartFactory implements EditPartFactory {
-
- public EditPart createEditPart(EditPart context, Object modelElement) {
- EditPart part = getPartForElement(modelElement);
- part.setModel(modelElement);
+ public EditPart createEditPart(EditPart context, Object baseElement) {
+ EditPart part = getPartForElement(baseElement);
+ part.setModel(baseElement);
return part;
}
- private EditPart getPartForElement(Object modelElement) {
- if (modelElement instanceof OrmDiagram) {
- return new DiagramEditPart();
+ private EditPart getPartForElement(Object baseElement) {
+ EditPart res = null;
+ if (baseElement instanceof OrmDiagram) {
+ res = new DiagramEditPart();
+ } else if (baseElement instanceof OrmShape) {
+ res = new OrmShapeEditPart();
+ } else if (baseElement instanceof ComponentShape) {
+ res = new ComponentShapeEditPart();
+ } else if (baseElement instanceof ExpandableShape) {
+ res = new ExpandableShapeEditPart();
+ } else if (baseElement instanceof Shape) {
+ res = new ShapeEditPart();
+ } else if (baseElement instanceof Connection) {
+ res = new ConnectionEditPart();
}
- if (modelElement instanceof OrmShape) {
- return new OrmShapeEditPart();
+ if (res == null) {
+ throw new RuntimeException(
+ DiagramViewerMessages.PartFactory_canot_create_part_for_model_element
+ + ((baseElement != null) ? baseElement.getClass().getName() : DiagramViewerMessages.PartFactory_null));
}
- if (modelElement instanceof ComponentShape) {
- return new ComponentShapeEditPart();
- }
- if (modelElement instanceof ExpandeableShape) {
- return new ExpandeableShapeEditPart();
- }
- if (modelElement instanceof Shape) {
- return new ShapeEditPart();
- }
- if (modelElement instanceof Connection) {
- return new ConnectionEditPart();
- }
- throw new RuntimeException(
- DiagramViewerMessages.PartFactory_canot_create_part_for_model_element
- + ((modelElement != null) ? modelElement.getClass().getName() : DiagramViewerMessages.PartFactory_null));
+ return res;
}
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmShapeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/OrmShapeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-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,
@@ -13,124 +13,115 @@
import java.beans.PropertyChangeEvent;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
-import org.jboss.tools.hibernate.ui.diagram.editors.figures.RoundLineBorder;
import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleFigure;
-import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleLabel;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
/**
- *
+ * @author some modifications from Vitali
*/
-public class OrmShapeEditPart extends ExpandeableShapeEditPart{
+public class OrmShapeEditPart extends ExpandableShapeEditPart{
+ public OrmShape getModelOrmShape() {
+ return (OrmShape)getModel();
+ }
+
+ public TitleFigure getTitleFigure() {
+ if (getFigure() instanceof TitleFigure) {
+ return (TitleFigure)getFigure();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPart#addNotify()
+ */
+ @Override
public void addNotify() {
super.addNotify();
- if (((OrmShape)getModel()).isHiden()) {
- int i = figure.getPreferredSize().width;
- ((TitleFigure)figure).setHidden(true);
- ((TitleLabel)figure.getChildren().get(0)).setHidden(true);
- figure.setSize(i,-1);
- refresh();
- }
+ getTitleFigure().refresh();
+ refresh();
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
protected IFigure createFigure() {
- if (getModel() instanceof OrmShape) {
- TitleFigure figure = new TitleFigure();
- figure.setLayoutManager(new ToolbarLayout());
- TitleLabel label = new TitleLabel();
- String text = ""; //$NON-NLS-1$
- Object element = getCastedModel().getOrmElement();
- if (element instanceof RootClass) {
- text = ormLabelProvider.getText((PersistentClass)element);
- } else if (element instanceof Table) {
- text = ormLabelProvider.getText((Table)element);
- } else if (element instanceof Subclass) {
- text = ormLabelProvider.getText((Subclass)element);
- }
- label.setText(text);
- label.setIcon(ormLabelProvider.getImage(getCastedModel().getOrmElement()));
- FontData fontData[] = Display.getCurrent().getSystemFont().getFontData();
- fontData[0].setStyle(SWT.BOLD);
- //fontData[0].height++;
- label.setFont(ResourceManager.getInstance().getFont(fontData[0]));
- label.setBackgroundColor(getColor());
- label.setIcon(ormLabelProvider.getImage(getCastedModel().getOrmElement()));
- label.setLabelAlignment(PositionConstants.LEFT);
- label.setBorder(new MarginBorder(1,2,1,2));
- figure.add(label,-2);
- label.setOpaque(true);
- figure.setBackgroundColor(getBackgroundColor());
- RoundLineBorder border = new RoundLineBorder();
- border.setColor(ResourceManager.getInstance().getColor(new RGB(160, 160, 160)));
- figure.setBorder(border);
- figure.setSize(-1,-1);
- return figure;
- } else {
- throw new IllegalArgumentException();
- }
+ Object element = getElement();
+ TitleFigure figure = new TitleFigure();
+ figure.setLayoutManager(new ToolbarLayout());
+ String text = ormLabelProvider.getText(element);
+ figure.createTitle(text, ormLabelProvider.getImage(element), getColor());
+ figure.setBackgroundColor(getBackgroundColor());
+ return figure;
}
+ /**
+ * @see AbstractEditPart#performRequest(Request)
+ */
+ @Override
public void performRequest(Request req) {
- if (RequestConstants.REQ_OPEN.equals(req.getType()) && getModel() instanceof OrmShape) {
- ((OrmShape)getModel()).refreshHiden();
+ if (RequestConstants.REQ_OPEN.equals(req.getType())) {
+ // double click on "class" or "table" header will toggle it's expand state
+ OrmShape shape = getModelOrmShape();
+ if (shape.isExpanded()) {
+ shape.collapse();
+ } else {
+ shape.expand();
+ }
+ } else {
+ super.performRequest(req);
}
}
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if (OrmShape.LOCATION_PROP.equals(prop)) {
refreshVisuals();
- ((OrmDiagram)getParent().getModel()).setDirty(true);
- } else if (OrmShape.SET_HIDEN.equals(prop)) {
- int i = figure.getPreferredSize().width;
- ((TitleFigure)figure).setHidden(((Boolean)evt.getNewValue()).booleanValue());
- ((TitleLabel)figure.getChildren().get(0)).setHidden(((Boolean)evt.getNewValue()).booleanValue());
- if (((Boolean)evt.getNewValue()).booleanValue()) {
- figure.setSize(i,-1);
- } else {
- figure.setSize(-1,-1);
+ getOrmDiagram().setDirty(true);
+ } else if (ExpandableShape.EXPANDED.equals(prop)) {
+ boolean expanded = (Boolean)evt.getNewValue();
+ if (getTitleFigure() != null) {
+ getTitleFigure().setExpanded(expanded);
}
- refresh();
- ((OrmDiagram)getParent().getModel()).setDirty(true);
+ getOrmDiagram().updateDirty(evt.getNewValue() != evt.getOldValue());
+ } else if (BaseElement.REFRESH.equals(prop)) {
+ if (getTitleFigure() != null) {
+ getTitleFigure().setExpanded(getModelExpandableShape().isExpanded());
+ }
+ super.propertyChange(evt);
} else {
super.propertyChange(evt);
}
+ refresh();
}
protected void refreshVisuals() {
- Rectangle bounds = null;
- if (getModel() instanceof OrmShape) {
- bounds = new Rectangle(((OrmShape)getModel()).getLocation(), getFigure().getSize());
- }
- if (bounds != null) {
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
- }
+ Rectangle bounds = new Rectangle(getModelOrmShape().getLocation(), getFigure().getSize());
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
}
protected Color getBackgroundColor() {
- Object element = getCastedModel().getOrmElement();
+ Object element = getElement();
if (element instanceof PersistentClass || element instanceof Component) {
- return ResourceManager.getInstance().getColor(new RGB(0,0,0));
+ return ResourceManager.getInstance().getColor(new RGB(0, 0, 0));
} else if (element instanceof Table || element instanceof Property) {
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_DatabaseColumnR),
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -11,7 +11,6 @@
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.Iterator;
import java.util.List;
@@ -28,6 +27,7 @@
import org.eclipse.gef.NodeEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editparts.AbstractEditPart;
import org.eclipse.gef.editpolicies.SelectionEditPolicy;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
@@ -43,15 +43,14 @@
import org.jboss.tools.hibernate.ui.diagram.editors.figures.TitleFigure;
import org.jboss.tools.hibernate.ui.diagram.editors.figures.TopLineBorder;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ModelElement;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
/**
- *
+ * @author some modifications from Vitali
*/
-public class ShapeEditPart extends OrmEditPart implements PropertyChangeListener, NodeEditPart {
+public class ShapeEditPart extends OrmEditPart implements NodeEditPart {
protected OrmLabelProvider ormLabelProvider = new OrmLabelProvider();
protected ChopboxAnchorNearestSide sourceAnchor = null;
@@ -59,12 +58,8 @@
public void setModel(Object model) {
super.setModel(model);
- ModelElement modelTmp = (ModelElement)model;
- while (modelTmp.getParent() != null) {
- modelTmp = modelTmp.getParent();
- }
- if (modelTmp instanceof OrmDiagram) {
- ConsoleConfiguration consoleConfig = ((OrmDiagram)modelTmp).getConsoleConfig();
+ if (getOrmDiagram() != null) {
+ ConsoleConfiguration consoleConfig = getOrmDiagram().getConsoleConfig();
ormLabelProvider.setConfig(consoleConfig.getConfiguration());
}
}
@@ -73,76 +68,105 @@
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ShapesSelectionEditPolicy());
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
protected IFigure createFigure() {
- if (getModel() instanceof Shape) {
- Label label = new Label();
- label.setText(ormLabelProvider.getText(getElement()));
- label.setBackgroundColor(getColor());
- label.setIcon(ormLabelProvider.getImage(getElement()));
- label.setLabelAlignment(PositionConstants.LEFT);
- label.setOpaque(true);
- TopLineBorder border = new TopLineBorder(1, 2 + getCastedModel().getIndent(), 1, 2);
- border.setColor(getOrmShapeEditPart().getColor());
- label.setBorder(border);
- return label;
- } else {
- throw new IllegalArgumentException();
- }
+ Label label = new Label();
+ label.setText(ormLabelProvider.getText(getElement()));
+ label.setBackgroundColor(getColor());
+ label.setIcon(ormLabelProvider.getImage(getElement()));
+ label.setLabelAlignment(PositionConstants.LEFT);
+ label.setOpaque(true);
+ TopLineBorder border = new TopLineBorder(1, 2 + getModelShape().getIndent(), 1, 2);
+ border.setColor(getOrmShapeEditPart().getColor());
+ label.setBorder(border);
+ return label;
}
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
- if (Shape.SHOW_SELECTION.equals(prop)) {
- getFigure().setBackgroundColor(getSelectionColor());
- getFigure().setForegroundColor(ResourceManager.getInstance().getColor(new RGB(255,255,255)));
- } else if (Shape.HIDE_SELECTION.equals(prop)) {
- getFigure().setBackgroundColor(getColor());
- getFigure().setForegroundColor(ResourceManager.getInstance().getColor(new RGB(0,0,0)));
+ if (BaseElement.SELECTED.equals(prop)) {
+ updateSelected((Boolean)evt.getNewValue());
+ } else if (BaseElement.VISIBLE.equals(prop)) {
+ getFigure().setVisible(((Boolean)evt.getNewValue()).booleanValue());
+ } else if (BaseElement.REFRESH.equals(prop)) {
+ getFigure().setVisible(getModelShape().isVisible());
+ updateSelected(getModelShape().isSelected());
} else if (Shape.SET_FOCUS.equals(prop)) {
getViewer().select(this);
getViewer().reveal(this);
}
refresh();
}
+
+ protected void updateSelected(boolean selected) {
+ //setSelected(selected ? EditPart.SELECTED : EditPart.SELECTED_NONE);
+ if (!selected) {
+ setSelected(EditPart.SELECTED_NONE);
+ }
+ getFigure().setBackgroundColor(selected ? getSelectionColor() : getColor());
+ getFigure().setForegroundColor(ResourceManager.getInstance().getColor(
+ selected ? new RGB(255, 255, 255) : new RGB(0, 0, 0)));
+ }
+ /**
+ * @see AbstractEditPart#performRequest(Request)
+ */
+ @Override
public void performRequest(Request req) {
if (RequestConstants.REQ_OPEN.equals(req.getType())) {
- if (getCastedModel().getOrmElement() instanceof Column) {
- if (getCastedModel().getTargetConnections().size() > 0) {
- getCastedModel().getTargetConnections().get(0).getSource().setFocus();
+ if (getModelShape().getOrmElement() instanceof Column) {
+ if (getModelShape().getTargetConnections().size() > 0) {
+ getModelShape().getTargetConnections().get(0).getSource().setFocus();
}
} else {
- if (getCastedModel().getSourceConnections().size() > 0) {
- getCastedModel().getSourceConnections().get(0).getTarget().setFocus();
+ if (getModelShape().getSourceConnections().size() > 0) {
+ getModelShape().getSourceConnections().get(0).getTarget().setFocus();
}
}
+ } else {
+ super.performRequest(req);
}
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+ */
+ @Override
public void activate() {
if (!isActive()) {
super.activate();
- getCastedModel().addPropertyChangeListener(this);
+ getModelShape().addPropertyChangeListener(this);
}
}
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
+ */
+ @Override
public void deactivate() {
if (isActive()) {
super.deactivate();
- getCastedModel().removePropertyChangeListener(this);
+ getModelShape().removePropertyChangeListener(this);
}
}
- protected Shape getCastedModel() {
+ protected Shape getModelShape() {
return (Shape) getModel();
}
protected List<Connection> getModelSourceConnections() {
- return getCastedModel().getSourceConnections();
+ return getModelShape().getSourceConnections();
}
protected List<Connection> getModelTargetConnections() {
- return getCastedModel().getTargetConnections();
+ return getModelShape().getTargetConnections();
}
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
@@ -271,33 +295,33 @@
}
protected Color getColor() {
- Object element = getCastedModel().getOrmElement();
- if (element instanceof PersistentClass || element instanceof Component)
+ final Object el = getElement();
+ if (el instanceof PersistentClass || el instanceof Component)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_PersistentClassR),
Integer.parseInt(ColorConstants.Colors_PersistentClassG),
Integer.parseInt(ColorConstants.Colors_PersistentClassB)));
- else if (element instanceof Property || element instanceof SimpleValue)
+ else if (el instanceof Property || el instanceof SimpleValue)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_PersistentFieldR),
Integer.parseInt(ColorConstants.Colors_PersistentFieldG),
Integer.parseInt(ColorConstants.Colors_PersistentFieldB)));
- else if (element instanceof Column)
+ else if (el instanceof Column)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_DatabaseColumnR),
Integer.parseInt(ColorConstants.Colors_DatabaseColumnG),
Integer.parseInt(ColorConstants.Colors_DatabaseColumnB)));
- else if (element instanceof Table)
+ else if (el instanceof Table)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_DatabaseTableR),
Integer.parseInt(ColorConstants.Colors_DatabaseTableG),
Integer.parseInt(ColorConstants.Colors_DatabaseTableB)));
- else if (element instanceof DependantValue)
+ else if (el instanceof DependantValue)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_DatabaseTableR),
Integer.parseInt(ColorConstants.Colors_DatabaseTableG),
Integer.parseInt(ColorConstants.Colors_DatabaseTableB)));
- else if (element instanceof OneToMany)
+ else if (el instanceof OneToMany)
return ResourceManager.getInstance().getColor(new RGB(
Integer.parseInt(ColorConstants.Colors_PersistentFieldR),
Integer.parseInt(ColorConstants.Colors_PersistentFieldG),
@@ -307,50 +331,49 @@
}
protected Color getSelectionColor() {
- if (getCastedModel().getOrmElement() instanceof PersistentClass ||
- getCastedModel().getOrmElement() instanceof Property ||
- getCastedModel().getOrmElement() instanceof SimpleValue ||
- getCastedModel().getOrmElement() instanceof OneToMany)
- return ResourceManager.getInstance().getColor(new RGB(112,161,99));
- else if (getCastedModel().getOrmElement() instanceof Table || getCastedModel().getOrmElement() instanceof Column)
- return ResourceManager.getInstance().getColor(new RGB(66,173,247));
- return ResourceManager.getInstance().getColor(new RGB(255,0,0));
+ final Object el = getElement();
+ if (el instanceof PersistentClass || el instanceof Property ||
+ el instanceof SimpleValue || el instanceof OneToMany) {
+ return ResourceManager.getInstance().getColor(new RGB(112, 161, 99));
+ } else if (el instanceof Table || el instanceof Column) {
+ return ResourceManager.getInstance().getColor(new RGB(66, 173, 247));
+ }
+ return ResourceManager.getInstance().getColor(new RGB(255, 0, 0));
}
private class ShapesSelectionEditPolicy extends SelectionEditPolicy {
protected void hideSelection() {
- getCastedModel().hideSelection();
- Iterator<Connection> iter = getCastedModel().getSourceConnections().iterator();
+ getModelShape().setSelected(false);
+ Iterator<Connection> iter = getModelShape().getSourceConnections().iterator();
while (iter.hasNext()) {
Connection element = iter.next();
- element.hideSelection();
+ element.setSelected(false);
}
- iter = getCastedModel().getTargetConnections().iterator();
+ iter = getModelShape().getTargetConnections().iterator();
while (iter.hasNext()) {
Connection element = iter.next();
- element.hideSelection();
+ element.setSelected(false);
}
}
protected void showSelection() {
- getCastedModel().showSelection();
- Iterator<Connection> iter = getCastedModel().getSourceConnections().iterator();
+ getModelShape().setSelected(true);
+ Iterator<Connection> iter = getModelShape().getSourceConnections().iterator();
while (iter.hasNext()) {
Connection element = iter.next();
- element.showSelection();
+ element.setSelected(true);
}
- iter = getCastedModel().getTargetConnections().iterator();
+ iter = getModelShape().getTargetConnections().iterator();
while (iter.hasNext()) {
Connection element = iter.next();
- element.showSelection();
+ element.setSelected(true);
}
}
}
protected Object getElement() {
- Object element = getCastedModel().getOrmElement();
- return element;
+ return getModelShape().getOrmElement();
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -17,12 +17,12 @@
import org.eclipse.swt.widgets.Tree;
import org.hibernate.console.ConsoleConfiguration;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
/**
- *
+ * @author some modifications from Vitali
*/
public class ShapeTreeEditPart extends
org.eclipse.gef.editparts.AbstractTreeEditPart implements
@@ -47,8 +47,8 @@
*
* @return Model of this.
*/
- protected ExpandeableShape getExpandeableShape() {
- return (ExpandeableShape) getModel();
+ protected ExpandableShape getExpandeableShape() {
+ return (ExpandableShape) getModel();
}
/**
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/TreePartFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/TreePartFactory.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/TreePartFactory.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
import org.eclipse.gef.EditPart;
@@ -3,23 +13,29 @@
import org.eclipse.gef.EditPartFactory;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandeableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
+/**
+ * @author some modifications from Vitali
+ * @see org.eclipse.gef.EditPartFactory
+ */
public class TreePartFactory implements EditPartFactory {
- public EditPart createEditPart(EditPart context, Object modelElement) {
- if (modelElement instanceof OrmDiagram) {
- return new DiagramTreeEditPart((OrmDiagram)modelElement);
+ public EditPart createEditPart(EditPart context, Object baseElement) {
+ EditPart res = null;
+ if (baseElement instanceof OrmDiagram) {
+ res = new DiagramTreeEditPart((OrmDiagram)baseElement);
+ } else if (baseElement instanceof ExpandableShape) {
+ res = new ExpandableShapeTreeEditPart((ExpandableShape)baseElement);
+ } else if (baseElement instanceof Shape) {
+ res = new ShapeTreeEditPart((Shape)baseElement);
}
- if (modelElement instanceof ExpandeableShape) {
- return new ExpandeableShapeTreeEditPart((ExpandeableShape)modelElement);
+ if (res == null) {
+ throw new RuntimeException(DiagramViewerMessages.PartFactory_canot_create_part_for_model_element
+ + ((baseElement != null) ? baseElement.getClass().getName()
+ : DiagramViewerMessages.PartFactory_null));
}
- if (modelElement instanceof Shape) {
- return new ShapeTreeEditPart((Shape)modelElement);
- }
- throw new RuntimeException(DiagramViewerMessages.PartFactory_canot_create_part_for_model_element
- + ((modelElement != null) ? modelElement.getClass().getName()
- : DiagramViewerMessages.PartFactory_null));
+ return res;
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.popup;
+import java.util.Iterator;
+
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
@@ -36,11 +38,16 @@
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenSourceAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
/**
* Context menu provider for Diagram Viewer and Diagram Outline.
+ *
+ * @author some modifications from Vitali
*/
public class PopupMenuProvider extends ContextMenuProvider {
private ActionRegistry actionRegistry;
@@ -50,6 +57,7 @@
this.actionRegistry = actionRegistry;
}
+ @SuppressWarnings("unchecked")
public void buildContextMenu(IMenuManager menu) {
// Add standard action groups to the menu
GEFActionConstants.addStandardActionGroups(menu);
@@ -61,19 +69,17 @@
IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
if (selection != null) {
Object firstElement = selection.getFirstElement();
+ Object obj = null;
if (firstElement instanceof OrmEditPart) {
- Object obj = ((OrmEditPart)firstElement).getModel();
- if (null != obj && obj instanceof Shape) {
- selectedShape = (Shape)obj;
- }
+ obj = ((OrmEditPart)firstElement).getModel();
} else if (firstElement instanceof AbstractTreeEditPart) {
- Object obj = ((AbstractTreeEditPart)firstElement).getModel();
- if (null != obj && obj instanceof Shape) {
- selectedShape = (Shape)obj;
- }
+ obj = ((AbstractTreeEditPart)firstElement).getModel();
}
+ if (null != obj && obj instanceof Shape) {
+ selectedShape = (Shape)obj;
+ }
}
- if (selectedShape != null) {
+ if (selectedShape != null && selection.size() == 1) {
Object first = selectedShape.getOrmElement();
if (first instanceof PersistentClass
|| first.getClass() == Property.class
@@ -88,7 +94,38 @@
createMenuItem(getMenu(), action);
}
}
+ boolean addToggleMenu = false;
+ Iterator it = selection.iterator();
+ while (it.hasNext() && !addToggleMenu) {
+ Object element = it.next();
+ Object obj = null;
+ if (element instanceof OrmEditPart) {
+ obj = ((OrmEditPart)element).getModel();
+ } else if (element instanceof AbstractTreeEditPart) {
+ obj = ((AbstractTreeEditPart)element).getModel();
+ }
+ if (null != obj && obj instanceof Shape) {
+ selectedShape = (Shape)obj;
+ Object first = selectedShape.getOrmElement();
+ if (first instanceof PersistentClass || first instanceof Table) {
+ addToggleMenu = true;
+ }
+ }
+ }
+ if (addToggleMenu) {
+ action = getActionRegistry().getAction(ToggleShapeVisibleStateAction.ACTION_ID);
+ appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ createMenuItem(getMenu(), action);
+
+ action = getActionRegistry().getAction(ToggleShapeExpandStateAction.ACTION_ID);
+ appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ createMenuItem(getMenu(), action);
+ }
}
+
+ action = getActionRegistry().getAction(ToggleConnectionsAction.ACTION_ID);
+ appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ createMenuItem(getMenu(), action);
action = getActionRegistry().getAction(AutoLayoutAction.ACTION_ID);
appendToGroup(GEFActionConstants.GROUP_VIEW, action);
@@ -107,12 +144,15 @@
createMenuItem(getMenu(), action);
// Add actions to the menu
+ /** /
+ // is undo/redo operation so necessary for popup menu?
menu.appendToGroup(
GEFActionConstants.GROUP_UNDO, // target group id
getAction(ActionFactory.UNDO.getId())); // action to add
menu.appendToGroup(
GEFActionConstants.GROUP_UNDO,
getAction(ActionFactory.REDO.getId()));
+ /**/
menu.appendToGroup(
GEFActionConstants.GROUP_VIEW, // target group id
getAction(ActionFactory.SELECT_ALL.getId())); // action to add
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/HibernateUtils.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/HibernateUtils.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/HibernateUtils.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -14,38 +14,13 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
/**
- *
+ * @author some modifications from Vitali
*/
public class HibernateUtils {
- public static String getTableName(String catalog, String schema, String name) {
- return (catalog != null ? catalog + "." : "") + (schema != null ? schema + "." : "") + name; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public static String getTableName(Table table) {
- return getTableName(table.getCatalog(), table.getSchema(), table.getName());
- }
-
- public static String getPersistentClassName(PersistentClass rootClass) {
- if (rootClass == null) {
- return ""; //$NON-NLS-1$
- }
- return rootClass.getEntityName() != null ? rootClass.getEntityName() : rootClass.getClassName();
- }
-
- public static String getPersistentClassName(String className) {
- if (className == null) {
- return ""; //$NON-NLS-1$
- } else if (className.indexOf(".") < 0) { //$NON-NLS-1$
- return "default." + className; //$NON-NLS-1$
- }
- return className;
- }
-
public static boolean isPrimaryKey(Column column) {
Table table = getTable(column);
if (table != null) {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -21,9 +21,11 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Utils;
/**
* Map: ORM object -> label
+ * @author some modifications from Vitali
*/
public class OrmLabelMap {
@@ -58,7 +60,7 @@
}
public static String getParticularLabel(Table table) {
- return HibernateUtils.getTableName(table);
+ return Utils.getTableName(table);
}
public static String getParticularLabel(Column column) {
@@ -160,7 +162,7 @@
persistentClass.getEntityName() : persistentClass.getClassName());
Table table = persistentClass.getTable();
if (table != null) {
- final String tableName = HibernateUtils.getTableName(table);
+ final String tableName = Utils.getTableName(table);
if (tableName != null) {
name.append(POINTER);
name.append(tableName);
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java 2009-08-07 13:56:57 UTC (rev 17014)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java 2009-08-07 13:58:13 UTC (rev 17015)
@@ -15,6 +15,7 @@
import java.util.Iterator;
import java.util.List;
+import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.RootClass;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
@@ -40,6 +41,7 @@
public void testLoadAndSave() {
final ConsoleConfiguration consoleConfig = context.mock(ConsoleConfiguration.class);
+ final Configuration config = context.mock(Configuration.class);
final RootClass ioe = context.mock(RootClass.class);
final List<Object> emptyList = new ArrayList<Object>();
final Iterator<Object> emptyListIterator = emptyList.iterator();
@@ -48,6 +50,9 @@
{
oneOf(ioe).getEntityName();
will(returnValue("testEntityName")); //$NON-NLS-1$
+
+ allowing(consoleConfig).getConfiguration();
+ will(returnValue(config));
oneOf(ioe).getEntityName();
will(returnValue("")); //$NON-NLS-1$
@@ -90,7 +95,7 @@
}
});
final OrmDiagram ormDiagram = new OrmDiagram(consoleConfig, ioe);
- ormDiagram.save();
+ ormDiagram.saveInFile();
// test is the folder created
File folder = new File(ormDiagram.getStoreFolderPath().toOSString());
assertTrue(folder.exists() && folder.isDirectory());
16 years, 4 months
JBoss Tools SVN: r17014 - trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-08-07 09:56:57 -0400 (Fri, 07 Aug 2009)
New Revision: 17014
Modified:
trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java
trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4598
Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java 2009-08-07 13:35:56 UTC (rev 17013)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java 2009-08-07 13:56:57 UTC (rev 17014)
@@ -38,7 +38,7 @@
public static final String CSS_EDITOR_VIEW = "org.jboss.tools.jst.css.view.editor"; //$NON-NLS-1$
public static final String CSS_PREVIEW_VIEW = "org.jboss.tools.jst.css.view.preview"; //$NON-NLS-1$
public static final String CSS_EDITOR_ID = "org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
-
+ public static final String CSS_PERSPECTIVE = "org.jboss.tools.jst.cssPerspective"; //$NON-NLS-1$
/**
*
* @param componentPage
Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java 2009-08-07 13:35:56 UTC (rev 17013)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java 2009-08-07 13:56:57 UTC (rev 17014)
@@ -20,6 +20,8 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyRegistry;
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
@@ -45,7 +47,7 @@
public static final String TEST_PAGE_NAME = "test.css"; //$NON-NLS-1$
- public static final int COUNT_TABS = 5; //$NON-NLS-1$
+ public static final int COUNT_TABS = 5;
@Override
public String getProjectName() {
@@ -223,4 +225,12 @@
}
+ /**
+ * @throws WorkbenchException
+ *
+ */
+ public void testPerspective() throws WorkbenchException {
+ PlatformUI.getWorkbench().showPerspective(CSS_PERSPECTIVE,
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ }
}
16 years, 4 months
JBoss Tools SVN: r17013 - in trunk/jst/plugins/org.jboss.tools.jst.css: META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-08-07 09:35:56 -0400 (Fri, 07 Aug 2009)
New Revision: 17013
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/resources/icons/css_prespective_icon.gif
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPerspective.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4598
Modified: trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF 2009-08-07 13:33:35 UTC (rev 17012)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF 2009-08-07 13:35:56 UTC (rev 17013)
@@ -10,7 +10,9 @@
org.jboss.tools.jst.jsp,
org.eclipse.ui.views.properties.tabbed,
org.eclipse.core.databinding,
- org.eclipse.wst.css.core
+ org.eclipse.wst.css.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.debug.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.jst.css,
Modified: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties 2009-08-07 13:33:35 UTC (rev 17012)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties 2009-08-07 13:35:56 UTC (rev 17013)
@@ -6,4 +6,5 @@
css.tabs.property.label=Property Sheet
css.tabs.quickEdit.label=Edited Properties
css.editor_name=CSS Properties
-css.preview_name=CSS Preview
\ No newline at end of file
+css.preview_name=CSS Preview
+css.perspective_name=CSS Editing
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml 2009-08-07 13:33:35 UTC (rev 17012)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml 2009-08-07 13:35:56 UTC (rev 17013)
@@ -105,4 +105,13 @@
restorable="true" category="web.views.category.id">
</view>
</extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.jboss.tools.jst.css.CSSPerspective"
+ icon="resources/icons/css_prespective_icon.gif"
+ id="org.jboss.tools.jst.cssPerspective"
+ name="%css.perspective_name">
+ </perspective>
+ </extension>
</plugin>
Added: trunk/jst/plugins/org.jboss.tools.jst.css/resources/icons/css_prespective_icon.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/resources/icons/css_prespective_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPerspective.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPerspective.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPerspective.java 2009-08-07 13:35:56 UTC (rev 17013)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css;
+
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSPerspective implements IPerspectiveFactory {
+
+ public static final String CSS_EDITOR_VIEW = "org.jboss.tools.jst.css.view.editor"; //$NON-NLS-1$
+ public static final String CSS_PREVIEW_VIEW = "org.jboss.tools.jst.css.view.preview"; //$NON-NLS-1$
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui
+ * .IPageLayout)
+ */
+ public void createInitialLayout(IPageLayout layout) {
+
+ String editorArea = layout.getEditorArea();
+
+ IFolderLayout leftTop = layout.createFolder(
+ "leftTop", IPageLayout.LEFT, (float) 0.2, editorArea); //$NON-NLS-1$
+ leftTop.addView(JavaUI.ID_PACKAGES);
+ leftTop.addView("org.jboss.tools.jst.web.ui.navigator.WebProjectsView"); //$NON-NLS-1$
+ leftTop
+ .addView("org.jboss.tools.seam.ui.views.SeamComponentsNavigator"); //$NON-NLS-1$
+ leftTop.addPlaceholder(IPageLayout.ID_RES_NAV);
+
+ IFolderLayout leftBottom = layout.createFolder(
+ "leftBottom", IPageLayout.BOTTOM, (float) 0.64, "leftTop"); //$NON-NLS-1$ //$NON-NLS-2$
+ leftBottom.addView(IPageLayout.ID_PROP_SHEET);
+
+ IFolderLayout bottomCenter = layout.createFolder(
+ "bottomCenter", IPageLayout.BOTTOM, (float) 0.64, editorArea); //$NON-NLS-1$
+ bottomCenter.addView(CSS_EDITOR_VIEW);
+
+ IFolderLayout bottomRight = layout.createFolder(
+ "bottomRight", IPageLayout.RIGHT, (float) 0.7, "bottomCenter"); //$NON-NLS-1$ //$NON-NLS-2$
+ bottomRight.addView(CSS_PREVIEW_VIEW);
+
+ IFolderLayout rightTop = layout.createFolder(
+ "right", IPageLayout.RIGHT, (float) 0.8, editorArea); //$NON-NLS-1$
+ rightTop.addView(IPageLayout.ID_OUTLINE);
+
+ layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+ layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+
+ // views - seam
+ layout
+ .addShowViewShortcut("org.jboss.tools.seam.ui.views.SeamComponentsNavigator"); //$NON-NLS-1$
+
+ // views - java
+ layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+ layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+ layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+
+ // views - standard workbench
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+
+ // new actions - Java project creation wizard
+ layout
+ .addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
+ layout
+ .addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
+ layout
+ .addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
+ layout
+ .addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
+ layout
+ .addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPerspective.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
16 years, 4 months
JBoss Tools SVN: r17012 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: drop/treeviewer/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-08-07 09:33:35 -0400 (Fri, 07 Aug 2009)
New Revision: 17012
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/ui/AttributeValueLabelProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3571
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java 2009-08-07 11:59:19 UTC (rev 17011)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java 2009-08-07 13:33:35 UTC (rev 17012)
@@ -14,6 +14,8 @@
import org.eclipse.ui.IEditorInput;
import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType;
import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalTypeFactory;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -28,6 +30,7 @@
static String ENUMERATION_TYPE = CustomProposalTypeFactory.ENUMERATION_TYPE;
static String FACELETS_JSFC_TYPE = CustomProposalTypeFactory.FACELETS_JSFC_TYPE;
static String TAGLIB_TYPE = CustomProposalTypeFactory.NAME_SPACE_TYPE;
+ static String ID_TYPE = CustomProposalTypeFactory.ID_TYPE;
static String BUNDLE_PROPERTY_TYPE = "bundleProperty"; //$NON-NLS-1$
static String BEAN_PROPERTY_TYPE = "beanProperty"; //$NON-NLS-1$
static String BEAN_METHOD_BY_SYGNATURE_TYPE = "beanMethodBySignature"; //$NON-NLS-1$
@@ -45,11 +48,14 @@
return INSTANCE;
}
- public AttributeValueResource createResource(IEditorInput editorInput, IPageContext pageContext, ModelElement root, String type) {
- return createResource(editorInput, pageContext, null, root, type);
+ public AttributeValueResource createResource(IEditorInput editorInput, IPageContext pageContext, ModelElement root, CustomProposalType proposalType, String type, KbQuery kbQuery) {
+ return createResource(editorInput, pageContext, null, root, proposalType, type, kbQuery);
}
- public AttributeValueResource createResource(IEditorInput editorInput, IPageContext pageContext, String name, ModelElement root, String type) {
+ public AttributeValueResource createResource(IEditorInput editorInput, IPageContext pageContext, String name, ModelElement root, CustomProposalType proposalType, String type, KbQuery kbQuery) {
+ if(type == null && proposalType != null) {
+ type = proposalType.getType();
+ }
if(BEAN_PROPERTY_TYPE.equals(type)) {
return new ManagedBeansPropertiesResourceElement(editorInput, name, root);
} else if(BEAN_METHOD_BY_SYGNATURE_TYPE.equals(type)) {
@@ -66,6 +72,8 @@
return new JsfVariablesResourceElement(name, root);
} else if(IMAGE_FILE_TYPE.equals(type)) {
return new ImageFileResourceElement(editorInput, root);
+ } else if(ID_TYPE.equals(type)) {
+ return new IDResourceElement(root, pageContext, proposalType, kbQuery);
} else if("seamVariables".equals(type)) { //$NON-NLS-1$
return new SeamVariablesResourceElement(editorInput, "Seam Variables", root); //$NON-NLS-1$
}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java 2009-08-07 13:33:35 UTC (rev 17012)
@@ -0,0 +1,40 @@
+package org.jboss.tools.jst.jsp.drop.treeviewer.model;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType;
+
+public class IDResourceElement extends AttributeValueResource {
+ IPageContext pageContext;
+ CustomProposalType type;
+ KbQuery kbQuery;
+
+ public IDResourceElement(ModelElement parent, IPageContext pageContext, CustomProposalType type, KbQuery kbQuery) {
+ super(parent);
+ this.pageContext = pageContext;
+ this.type = type;
+ this.kbQuery = kbQuery;
+ }
+
+ public ModelElement[] getChildren() {
+ if(type == null || pageContext == null || kbQuery == null) {
+ return new ModelElement[0];
+ }
+ TextProposal[] ps = type.getProposals(kbQuery, pageContext);
+ ModelElement[] result = ps == null ? new ModelElement[0] : new ModelElement[ps.length];
+ if(ps != null) for (int i = 0; i < ps.length; i++) {
+ String s = ps[i].getReplacementString();
+ result[i] = new EnumerationElement(s, this);
+ }
+ return result;
+ }
+
+ /**
+ * @see ModelElement#getName()
+ */
+ public String getName() {
+ return "Component IDs"; //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/ui/AttributeValueLabelProvider.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/ui/AttributeValueLabelProvider.java 2009-08-07 11:59:19 UTC (rev 17011)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/ui/AttributeValueLabelProvider.java 2009-08-07 13:33:35 UTC (rev 17012)
@@ -11,7 +11,6 @@
package org.jboss.tools.jst.jsp.drop.treeviewer.ui;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.viewers.LabelProvider;
@@ -25,6 +24,7 @@
import org.jboss.tools.jst.jsp.drop.treeviewer.model.BundlesPropertiesResourceElement;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.EnumerationElement;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.EnumerationResourceElement;
+import org.jboss.tools.jst.jsp.drop.treeviewer.model.IDResourceElement;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.ImageFileElement;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.ImageFileResourceElement;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.ImageFolderElement;
@@ -50,7 +50,7 @@
*/
public class AttributeValueLabelProvider extends LabelProvider {
- private static Map imagesPathes = new HashMap();
+ private static Map<Class<? extends ModelElement>, String> imagesPathes = new HashMap<Class<? extends ModelElement>, String>();
static {
imagesPathes.put(BundlesNameResourceElement.class, "images/jdo/db_fields_folder.gif"); //$NON-NLS-1$
imagesPathes.put(BundleNameElement.class, "images/navigationtree/properties.gif"); //$NON-NLS-1$
@@ -84,9 +84,11 @@
imagesPathes.put(SeamVariableElement.class, "images/seam/variable.gif"); //$NON-NLS-1$
imagesPathes.put(SeamPropertyElement.class, "images/navigationtree/property.gif"); //$NON-NLS-1$
imagesPathes.put(SeamMethodElement.class, "images/java/method.gif"); //$NON-NLS-1$
+
+ imagesPathes.put(IDResourceElement.class, "images/file/closed_folder.gif"); //$NON-NLS-1$
}
- private static Map texts = new HashMap();
+ private static Map<Class<? extends ModelElement>, String> texts = new HashMap<Class<? extends ModelElement>, String>();
static {
texts.put(BundlesNameResourceElement.class, TreeViewerMessages.BundlesNameResourceElement_name);
texts.put(BundlesPropertiesResourceElement.class, TreeViewerMessages.BundlesPropertiesResourceElement_name);
@@ -97,7 +99,7 @@
texts.put(ViewActionsResorceElement.class, TreeViewerMessages.ViewActionsResorceElement_name);
}
- private Map imageCache = new HashMap();
+ private Map<Object, Image> imageCache = new HashMap<Object, Image>();
/*
* @see ILabelProvider#getImage(Object)
@@ -132,8 +134,8 @@
}
public void dispose() {
- for (Iterator i = imageCache.values().iterator(); i.hasNext();) {
- ((Image) i.next()).dispose();
+ for (Image i: imageCache.values()) {
+ i.dispose();
}
imageCache.clear();
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2009-08-07 11:59:19 UTC (rev 17011)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2009-08-07 13:33:35 UTC (rev 17012)
@@ -131,7 +131,7 @@
List<AttributeValueResource> elements = new ArrayList<AttributeValueResource>();
ModelElement root = new RootElement("root", elements); //$NON-NLS-1$
for (int i = 0; i < proposals.length; i++) {
- AttributeValueResource resource = AttributeValueResourceFactory.getInstance().createResource(getEditorInput(), pageContext, root, proposals[i].getType());
+ AttributeValueResource resource = AttributeValueResourceFactory.getInstance().createResource(getEditorInput(), pageContext, root, proposals[i], proposals[i].getType(), kbQuery);
resource.setParams(proposals[i].getParams());
resource.setQuery(kbQuery, this);
elements.add(resource);
@@ -141,7 +141,7 @@
p.put("file", getFile()); //$NON-NLS-1$
List list = seamPromptingProvider.getList(null, "seam.is_seam_project", null, p); //$NON-NLS-1$
if(list != null) {
- AttributeValueResource resource = AttributeValueResourceFactory.getInstance().createResource(getEditorInput(), pageContext, root, "seamVariables"); //$NON-NLS-1$
+ AttributeValueResource resource = AttributeValueResourceFactory.getInstance().createResource(getEditorInput(), pageContext, root, null, "seamVariables", kbQuery); //$NON-NLS-1$
resource.setQuery(kbQuery, this);
elements.add(resource);
}
16 years, 4 months
JBoss Tools SVN: r17011 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-08-07 07:59:19 -0400 (Fri, 07 Aug 2009)
New Revision: 17011
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/VpeToolBarManager.java
Log:
Unnecessary code removed.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/VpeToolBarManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/VpeToolBarManager.java 2009-08-07 11:28:01 UTC (rev 17010)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/VpeToolBarManager.java 2009-08-07 11:59:19 UTC (rev 17011)
@@ -77,7 +77,6 @@
data.right = new FormAttachment(100);
data.top = new FormAttachment(0);
- cmpToolBar.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
GridLayout layoutTl = new GridLayout(2, false);
layoutTl.marginBottom = 0;
layoutTl.marginHeight = 0;
16 years, 4 months