Author: dgeraskov
Date: 2011-11-10 07:58:33 -0500 (Thu, 10 Nov 2011)
New Revision: 36274
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/schema/consoleextension.exsd
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionDefinition.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionManager.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtensionManager.java
Removed:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/ExtensionManager.java
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/plugin.xml
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor2.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/IdentifierNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PropertyNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TableNode.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TypeNode.java
Log:
Added extension point to Console plugin
Completion proposals are moved to the extension
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -43,7 +43,7 @@
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.console.execution.ExecutionContextHolder;
-import org.hibernate.console.ext.ExtensionManager;
+import org.hibernate.console.ext.HibernateExtensionManager;
import org.hibernate.console.ext.HibernateExtension;
import org.hibernate.console.ext.HibernateExtensionDefinition;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
@@ -69,7 +69,7 @@
private void loadHibernateExtension(){
String version = hibernateVersion == null ? "3.5" : hibernateVersion;//3.5 is
a default version
- HibernateExtensionDefinition def =
ExtensionManager.findHibernateExtensionDefinition(version);
+ HibernateExtensionDefinition def =
HibernateExtensionManager.findHibernateExtensionDefinition(version);
if (def != null){
HibernateExtension hibernateExtension = def.createHibernateExtensionInstance();
hibernateExtension.setConsoleConfigurationPreferences(prefs);
Deleted:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/ExtensionManager.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/ExtensionManager.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/ExtensionManager.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.hibernate.console.ext;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class ExtensionManager {
-
- public static final String HIBERNATEEXTENSION_EXTENSION_ID =
"org.hibernate.eclipse.hibernateextension"; //$NON-NLS-1$
-
- private static Map<String, HibernateExtensionDefinition> hibernateExtensions;
-
- private static IExtension[] findExtensions(String extensionId) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(extensionId);
- return extensionPoint.getExtensions();
- }
-
- public static HibernateExtensionDefinition[] findHiberanteExtensionDefinitions() {
- List<HibernateExtensionDefinition> exporters = new
ArrayList<HibernateExtensionDefinition>();
-
- IExtension[] extensions = findExtensions(HIBERNATEEXTENSION_EXTENSION_ID);
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement elements[] = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- HibernateExtensionDefinition extensiodDefinition = new HibernateExtensionDefinition(
- elements[j]);
- exporters.add(extensiodDefinition);
- }
- }
-
- return exporters.toArray(new HibernateExtensionDefinition[exporters.size()]);
- }
-
- /**
- * return map of ExporterDefinitions keyed by id
- */
- public static synchronized Map<String, HibernateExtensionDefinition>
getExporterDefinitionsAsMap() {
- if (hibernateExtensions == null){
- //TODO add good comparator here(we often need the keys ordered)
- hibernateExtensions = new TreeMap<String, HibernateExtensionDefinition>();
-
- HibernateExtensionDefinition[] findExporterDefinitions =
findHiberanteExtensionDefinitions();
- for (int i = 0; i < findExporterDefinitions.length; i++) {
- HibernateExtensionDefinition exporterDefinition = findExporterDefinitions[i];
- hibernateExtensions.put(exporterDefinition.getHibernateVersion(),
- exporterDefinition);
- }
- }
-
- return hibernateExtensions;
- }
-
- public static HibernateExtensionDefinition findHibernateExtensionDefinition(String
hibernateVersion){
- return getExporterDefinitionsAsMap().get(hibernateVersion);
- }
-
-}
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -45,6 +45,6 @@
//FIXME remove this method
*/
- public CompletionProposalsResult hqlCodeComplete(String query, int position);
-
+
+
}
Copied:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtensionManager.java
(from rev 35281,
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/ExtensionManager.java)
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtensionManager.java
(rev 0)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtensionManager.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.console.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateExtensionManager {
+
+ public static final String HIBERNATEEXTENSION_EXTENSION_ID =
"org.hibernate.eclipse.hibernateextension"; //$NON-NLS-1$
+
+ private static Map<String, HibernateExtensionDefinition> hibernateExtensions;
+
+ private static IExtension[] findExtensions(String extensionId) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ public static HibernateExtensionDefinition[] findHiberanteExtensionDefinitions() {
+ List<HibernateExtensionDefinition> hibernateExtensions = new
ArrayList<HibernateExtensionDefinition>();
+
+ IExtension[] extensions = findExtensions(HIBERNATEEXTENSION_EXTENSION_ID);
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ HibernateExtensionDefinition extensiodDefinition = new HibernateExtensionDefinition(
+ elements[j]);
+ hibernateExtensions.add(extensiodDefinition);
+ }
+ }
+
+ return hibernateExtensions.toArray(new
HibernateExtensionDefinition[hibernateExtensions.size()]);
+ }
+
+ /**
+ * return map of ExporterDefinitions keyed by id
+ */
+ public static synchronized Map<String, HibernateExtensionDefinition>
getHibernateExtensionDefinitionsAsMap() {
+ if (hibernateExtensions == null){
+ //TODO add good comparator here(we often need the keys ordered)
+ hibernateExtensions = new TreeMap<String, HibernateExtensionDefinition>();
+
+ HibernateExtensionDefinition[] findExporterDefinitions =
findHiberanteExtensionDefinitions();
+ for (int i = 0; i < findExporterDefinitions.length; i++) {
+ HibernateExtensionDefinition exporterDefinition = findExporterDefinitions[i];
+ hibernateExtensions.put(exporterDefinition.getHibernateVersion(),
+ exporterDefinition);
+ }
+ }
+
+ return hibernateExtensions;
+ }
+
+ public static HibernateExtensionDefinition findHibernateExtensionDefinition(String
hibernateVersion){
+ return getHibernateExtensionDefinitionsAsMap().get(hibernateVersion);
+ }
+
+}
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -36,7 +36,7 @@
* @author MAX
*
*/
-public class ClassNode extends BaseNode {
+class ClassNode extends BaseNode {
ClassMetadata md;
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -31,7 +31,7 @@
* @author max
*
*/
-public class ConfigurationNode extends BaseNode {
+class ConfigurationNode extends BaseNode {
private final ConsoleConfiguration configuration;
private boolean childrenCreated;
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/IdentifierNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/IdentifierNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/IdentifierNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -28,7 +28,7 @@
* @author MAX
*
*/
-public class IdentifierNode extends TypeNode {
+class IdentifierNode extends TypeNode {
/**
* @param factory
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -39,7 +39,7 @@
* @author MAX
*
*/
-public class PersistentCollectionNode extends BaseNode implements TypedNode{
+class PersistentCollectionNode extends BaseNode implements TypedNode{
BaseNode virtualNode;
CollectionType type;
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PropertyNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PropertyNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PropertyNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -25,7 +25,7 @@
import org.hibernate.HibernateException;
import org.hibernate.metadata.ClassMetadata;
-public class PropertyNode extends TypeNode {
+class PropertyNode extends TypeNode {
ClassMetadata baseMetaData;
public PropertyNode(NodeFactory factory, BaseNode parent, int idx, ClassMetadata
metadata,Object baseObject, boolean objectGraph) {
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TableNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TableNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TableNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -23,7 +23,7 @@
import org.hibernate.mapping.Table;
-public class TableNode extends BaseNode {
+class TableNode extends BaseNode {
public TableNode(BaseNode parent, Table table) {
super(null, parent);
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TypeNode.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TypeNode.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/TypeNode.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -29,7 +29,7 @@
* @author MAX
*
*/
-public class TypeNode extends ClassNode implements TypedNode{
+class TypeNode extends ClassNode implements TypedNode{
Type type;
public TypeNode(NodeFactory factory, BaseNode parent, Type type, ClassMetadata metadata,
Object baseObject, boolean objectGraph) {
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2011-11-10
12:58:33 UTC (rev 36274)
@@ -10,6 +10,7 @@
Export-Package: org.hibernate.eclipse.builder,
org.hibernate.eclipse.console,
org.hibernate.eclipse.console.actions,
+ org.hibernate.eclipse.console.ext,
org.hibernate.eclipse.console.model,
org.hibernate.eclipse.console.model.impl,
org.hibernate.eclipse.console.preferences,
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/plugin.xml 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/plugin.xml 2011-11-10
12:58:33 UTC (rev 36274)
@@ -2,6 +2,7 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="exporters" name="Hibernate Console
Exporter" schema="schema/exporters.exsd"/>
+ <extension-point id="consoleextension" name="ConsoleExtension"
schema="schema/consoleextension.exsd"/>
<extension
point="org.eclipse.ui.perspectives">
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/schema/consoleextension.exsd
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/schema/consoleextension.exsd
(rev 0)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/schema/consoleextension.exsd 2011-11-10
12:58:33 UTC (rev 36274)
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.hibernate.eclipse.console"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.hibernate.eclipse.console"
id="consoleextension" name="ConsoleExtension"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="consoleextension"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="consoleextension">
+ <complexType>
+ <attribute name="classname" type="string"
use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name of the class that implements
org.hibernate.eclipse.console.ext.ConsoleExtension
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.hibernate.eclipse.console.ext.ConsoleExtension"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="version" type="string"
use="required">
+ <annotation>
+ <documentation>
+ The hibernate version which is supported by the extension.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
(rev 0)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.eclipse.console.ext;
+
+import org.hibernate.console.ext.CompletionProposalsResult;
+import org.hibernate.console.ext.HibernateExtension;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface ConsoleExtension {
+
+ public CompletionProposalsResult hqlCodeComplete(String query, int position);
+
+ public void setHibernateException(HibernateExtension hibernateExtension);
+
+ /*public void launchExporters(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException;*/
+
+}
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionDefinition.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionDefinition.java
(rev 0)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionDefinition.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.eclipse.console.ext;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.hibernate.console.ext.HibernateExtension;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleExtensionDefinition {
+
+ public static final String CLASSNAME = "classname"; //$NON-NLS-1$
+
+ public static final String HIBERNATE_VERSION = "version"; //$NON-NLS-1$
+
+ private final String hibernateVersion;
+
+ private IConfigurationElement element;
+
+ public ConsoleExtensionDefinition(IConfigurationElement element) {
+ this(element.getAttribute( CLASSNAME ),
+ element.getAttribute( HIBERNATE_VERSION ));
+ this.element = element;
+ }
+
+ private ConsoleExtensionDefinition(String classname, String hibernateVersion) {
+ this.hibernateVersion = hibernateVersion;
+ }
+
+ public ConsoleExtension createConsoleExtensionInstance(HibernateExtension
hibernateExtension) {
+ if (hibernateExtension != null) {
+ try {
+ ConsoleExtension consoleExtension = (ConsoleExtension) element
+ .createExecutableExtension(CLASSNAME);
+ consoleExtension.setHibernateException(hibernateExtension);
+ return consoleExtension;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return the hibernateVersion
+ */
+ public String getHibernateVersion() {
+ return hibernateVersion;
+ }
+}
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionManager.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionManager.java
(rev 0)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtensionManager.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.eclipse.console.ext;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.hibernate.console.ext.HibernateExtension;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleExtensionManager {
+
+ public static final String CONSOLEEXTENSION_EXTENSION_ID =
"org.hibernate.eclipse.console.consoleextension"; //$NON-NLS-1$
+
+ private static Map<String, ConsoleExtensionDefinition>
consoleExtensionDefinitions;
+
+ private static Map<HibernateExtension, ConsoleExtension> consoleExtensions = new
HashMap<HibernateExtension, ConsoleExtension>();
+
+ private static IExtension[] findExtensions(String extensionId) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ private static ConsoleExtensionDefinition[] findConsoleExtensionDefinitions() {
+ List<ConsoleExtensionDefinition> exporters = new
ArrayList<ConsoleExtensionDefinition>();
+
+ IExtension[] extensions = findExtensions(CONSOLEEXTENSION_EXTENSION_ID);
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ ConsoleExtensionDefinition extensiodDefinition = new ConsoleExtensionDefinition(
+ elements[j]);
+ exporters.add(extensiodDefinition);
+ }
+ }
+
+ return exporters.toArray(new ConsoleExtensionDefinition[exporters.size()]);
+ }
+
+ /**
+ * return map of ExporterDefinitions keyed by id
+ */
+ private static synchronized Map<String, ConsoleExtensionDefinition>
getConsoleExtensionDefinitionsAsMap() {
+ if (consoleExtensionDefinitions == null){
+ //TODO add good comparator here(we often need the keys ordered)
+ consoleExtensionDefinitions = new TreeMap<String,
ConsoleExtensionDefinition>();
+
+ ConsoleExtensionDefinition[] findExporterDefinitions =
findConsoleExtensionDefinitions();
+ for (int i = 0; i < findExporterDefinitions.length; i++) {
+ ConsoleExtensionDefinition exporterDefinition = findExporterDefinitions[i];
+ consoleExtensionDefinitions.put(exporterDefinition.getHibernateVersion(),
+ exporterDefinition);
+ }
+ }
+
+ return consoleExtensionDefinitions;
+ }
+
+ private static ConsoleExtensionDefinition findConsoleExtensionDefinition(String
hibernateVersion){
+ return getConsoleExtensionDefinitionsAsMap().get(hibernateVersion);
+ }
+
+
+ public static ConsoleExtension getConsoleExtension(HibernateExtension
hibernateExtension){
+ if (hibernateExtension != null){
+ if (!consoleExtensions.containsKey(hibernateExtension)){
+ ConsoleExtensionDefinition definition =
findConsoleExtensionDefinition(hibernateExtension.getHibernateVersion());
+ if (definition != null){
+ consoleExtensions.put(hibernateExtension,
definition.createConsoleExtensionInstance(hibernateExtension));
+ }
+ }
+ return consoleExtensions.get(hibernateExtension);
+ }
+ return null;
+ }
+
+}
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor2.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor2.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor2.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -39,6 +39,8 @@
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.QueryEditor;
+import org.hibernate.eclipse.console.ext.ConsoleExtension;
+import org.hibernate.eclipse.console.ext.ConsoleExtensionManager;
/**
* content assist processor for HQL code.
@@ -115,16 +117,21 @@
}
if(consoleConfiguration != null) {
- //EclipseHQLCompletionRequestor eclipseHQLCompletionCollector = new
EclipseHQLCompletionRequestor();
- CompletionProposalsResult codeCompletions =
consoleConfiguration.getHibernateExtension().hqlCodeComplete(doc.get(), currentOffset);
-
- proposalList.addAll(codeCompletions.getCompletionProposals());
- errorMessage =
codeCompletions.getErrorMessage();//eclipseHQLCompletionCollector.getLastErrorMessage();
-
- result = proposalList.toArray(new ICompletionProposal[proposalList.size()]);
- if(result.length==0 && errorMessage==null) {
- errorMessage =
HibernateConsoleMessages.HQLCompletionProcessor_no_hql_completions_available;
- }
+ ConsoleExtension consoleExtension =
ConsoleExtensionManager.getConsoleExtension(consoleConfiguration.getHibernateExtension());
+ if (consoleExtension != null){
+ CompletionProposalsResult codeCompletions =
consoleExtension.hqlCodeComplete(doc.get(), currentOffset);
+
+ proposalList.addAll(codeCompletions.getCompletionProposals());
+ errorMessage =
codeCompletions.getErrorMessage();//eclipseHQLCompletionCollector.getLastErrorMessage();
+
+ result = proposalList.toArray(new ICompletionProposal[proposalList.size()]);
+ if(result.length==0 && errorMessage==null) {
+ errorMessage =
HibernateConsoleMessages.HQLCompletionProcessor_no_hql_completions_available;
+ }
+ } else {
+ errorMessage = "There is no completion proposal implementation for this
hibernate version \'"
+ + consoleConfiguration.getHibernateExtension().getHibernateVersion() +
"\'";
+ }
}
} else {
errorMessage =
HibernateConsoleMessages.HQLCompletionProcessor_no_start_word_found;
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -43,7 +43,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.hibernate.console.ImageConstants;
-import org.hibernate.console.ext.ExtensionManager;
+import org.hibernate.console.ext.HibernateExtensionManager;
import
org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
@@ -130,7 +130,7 @@
Label hLabel = new Label(comp2, SWT.NULL);
hLabel.setText(HibernateConsoleMessages.ConsoleConfigurationMainTab_0);
hibernateVersion = new Combo(comp2, SWT.READ_ONLY);
- hibernateVersion.setItems((String[])ExtensionManager.getExporterDefinitionsAsMap().keySet().toArray(new
String[0]));
+ hibernateVersion.setItems((String[])HibernateExtensionManager.getHibernateExtensionDefinitionsAsMap().keySet().toArray(new
String[0]));
hibernateVersion.select(0);
hibernateVersion.setLayoutData(new GridData(53, -1));
hibernateVersion.addModifyListener(getChangeListener());
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java
===================================================================
---
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java 2011-11-10
12:58:10 UTC (rev 36273)
+++
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java 2011-11-10
12:58:33 UTC (rev 36274)
@@ -36,21 +36,23 @@
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ext.CompletionProposalsResult;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.hqleditor.EclipseHQLCompletionRequestor;
-import org.hibernate.eclipse.hqleditor.HQLCompletionProcessor;
+import org.hibernate.eclipse.console.ext.ConsoleExtension;
+import org.hibernate.eclipse.console.ext.ConsoleExtensionManager;
+import org.hibernate.eclipse.hqleditor.HQLCompletionProcessor2;
import org.hibernate.eclipse.nature.HibernateNature;
import org.hibernate.tool.ide.completion.HQLCodeAssist;
import org.hibernate.tool.ide.completion.IHQLCodeAssist;
public class HQLJavaCompletionProposalComputer implements IJavaCompletionProposalComputer
{
- HQLCompletionProcessor hqlProcessor;
+ HQLCompletionProcessor2 hqlProcessor;
private String errorMessage;
public HQLJavaCompletionProposalComputer() {
super();
- hqlProcessor = new HQLCompletionProcessor(null);
+ hqlProcessor = new HQLCompletionProcessor2(null);
}
ConsoleConfiguration getConfiguration(IJavaProject javaProject) {
@@ -79,18 +81,24 @@
ConsoleConfiguration consoleConfiguration = getConfiguration( ctx.getProject() );
if(consoleConfiguration!=null) {
Configuration configuration = consoleConfiguration.getConfiguration();
-
+
+
IHQLCodeAssist hqlEval = new HQLCodeAssist(configuration);
String query = ""; //$NON-NLS-1$
int stringStart = getStringStart( ctx.getDocument(), ctx.getInvocationOffset() );
int stringEnd = getStringEnd( ctx.getDocument(), ctx.getInvocationOffset() );
query = ctx.getDocument().get(stringStart, stringEnd-stringStart );
- EclipseHQLCompletionRequestor eclipseHQLCompletionCollector = new
EclipseHQLCompletionRequestor(stringStart);
- hqlEval.codeComplete(query, ctx.getInvocationOffset()-stringStart,
eclipseHQLCompletionCollector);
- errorMessage = eclipseHQLCompletionCollector.getLastErrorMessage();
-
- proposals = eclipseHQLCompletionCollector.getCompletionProposals();
+ ConsoleExtension consoleExtension =
ConsoleExtensionManager.getConsoleExtension(consoleConfiguration.getHibernateExtension());
+ if (consoleExtension != null){
+ CompletionProposalsResult codeCompletions =
consoleExtension.hqlCodeComplete(query, ctx.getInvocationOffset()-stringStart);
+
+ errorMessage = codeCompletions.getErrorMessage();
+ proposals = codeCompletions.getCompletionProposals();
+ } else {
+ errorMessage = "There is no completion proposal implementation for this
hibernate version \'"
+ + consoleConfiguration.getHibernateExtension().getHibernateVersion() +
"\'";
+ }
}
} catch(RuntimeException re) {
HibernateConsolePlugin.getDefault().logErrorMessage(
JdtUiMessages.HQLJavaCompletionProposalComputer_errormessage, re );