Author: dgeraskov
Date: 2008-01-29 08:01:36 -0500 (Tue, 29 Jan 2008)
New Revision: 6010
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1500
Added completion proposal to load console configuration when it was not loaded
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java 2008-01-29
12:32:17 UTC (rev 6009)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java 2008-01-29
13:01:36 UTC (rev 6010)
@@ -101,9 +101,8 @@
startWord = getWord( doc, startOffset, wordLength );
if(startWord!=null) {
- char[] cs = new char[0];
try {
- cs = doc.get(0,doc.getLength()).toCharArray();
+ doc.get(0,doc.getLength()).toCharArray();
}
catch (BadLocationException e) {
errorMessage = "Could not get document contents";
@@ -111,7 +110,10 @@
}
Configuration configuration =
consoleConfiguration!=null?consoleConfiguration.getConfiguration():null;
-
+ if(configuration == null && consoleConfiguration!=null) {
+ errorMessage = "Configuration not opened";
+ return new ICompletionProposal[]{ new
LoadConsoleCFGCompletionProposal(consoleConfiguration) };
+ }
IHQLCodeAssist hqlEval = new HQLCodeAssist(configuration);
EclipseHQLCompletionRequestor eclipseHQLCompletionCollector = new
EclipseHQLCompletionRequestor();
hqlEval.codeComplete(doc.get(), currentOffset, eclipseHQLCompletionCollector);
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java 2008-01-29
13:01:36 UTC (rev 6010)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.hqleditor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class LoadConsoleCFGCompletionProposal implements ICompletionProposal {
+
+ private ConsoleConfiguration consoleConfiguration;
+
+ public LoadConsoleCFGCompletionProposal(ConsoleConfiguration consoleConfiguration){
+ this.consoleConfiguration = consoleConfiguration;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+ */
+ public void apply(IDocument document) {
+ //load console configuration
+ if(consoleConfiguration.getConfiguration()==null) {
+ consoleConfiguration.build();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ return "Additional Info";
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+ */
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ return "Load Console Configuration";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return EclipseImages.getImage( ImageConstants.CONFIGURATION );
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+ */
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native