Index: D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java =================================================================== --- D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java (revision 5995) +++ D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCompletionProcessor.java (working copy) @@ -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); Index: D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java =================================================================== --- D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java (revision 0) +++ D:/workspaces/hibernate/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/LoadConsoleCFGCompletionProposal.java (revision 0) @@ -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: D:\workspaces\hibernate\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