Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Open SQLEditor programmatically causes NPE
Open SQLEditor programmatically causes NPE [message #590956] Sat, 12 April 2008 12:47 Go to next message
Eclipse UserFriend
Originally posted by: martin.baus.web.de

Hi,

I am trying to open programmatically the SQLEditor after generating some SQL
Code. What I try to do exactly is:

----------------------------------------
SQLEditorStorage output = new SQLEditorStorage(mySQLCode.toString());
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

SQLEditorStorageEditorInput input = new SQLEditorStorageEditorInput(output);

//this works and opens the default text editor
//page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");

//this doesn't work
page.openEditor(input, "org.eclipse.datatools.sqltools.sqleditor.SQLEditor");
----------------------------------------

It works with the DefaultTextEditor and I can also open .sql-Files with the
SQLEditor by Hand.

With the version above I get a java.lang.NullPointerException

at
org.eclipse.datatools.sqltools.sqleditor.SQLEditor.doSetInpu t(SQLEditor.java:872)
at
org.eclipse.ui.texteditor.AbstractTextEditor$19.run(Abstract TextEditor.java:2994)
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:369)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:313)
at
org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:758)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:755)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2451)
at
org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(Ab stractTextEditor.java:3012)
at
org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTe xtEditor.java:3039)
at
org.eclipse.datatools.sqltools.sqleditor.SQLEditor.init(SQLE ditor.java:541)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManag er.java:794)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:643)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:426)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:592)
at
org.eclipse.ui.internal.EditorReference.getEditor(EditorRefe rence.java:263)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2739)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2651)
at org.eclipse.ui.internal.WorkbenchPage.access$13(WorkbenchPag e.java:2643)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2595)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2590)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2574)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2557)
at
de.unibonn.cs.ormod.sqlskriptgenerator.oracle.OracleSQLGener ator.generateSQL(OracleSQLGenerator.java:82)
at
alog.diagram.part.AbstraktLogischesMetaModellGenerateOracleS QLAction.run(AbstraktLogischesMetaModellGenerateOracleSQLAct ion.java:45)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:256)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$
(ActionContributionItem.java:490)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3319)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2971)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

For me it seems that there is a problem with
SQLDevToolsConfiguration toolsConfig =
SQLToolsFacade.getConfigurationByVendorIdentifier(getConnect ionInfo().getDatabaseVendorDefinitionId());

Does anyone know how I can wrap around that? Or is it possible to give the
missing information with the SQLEditorStorageEditorInput Object. I can't
find anything.

By the way I tried DTP 1.5.2 and 1.6.

Thanks,

Martin Baus
Re: Open SQLEditor programmatically causes NPE [message #696380 is a reply to message #590956] Wed, 13 July 2011 20:27 Go to previous message
Swati Sapar is currently offline Swati SaparFriend
Messages: 20
Registered: September 2010
Junior Member
Refer the code in OpenScrapbookAction from package org.eclipse.datatools.sqltools.sqlscrapbook.actions

This resolved the above issue for me :
ISQLEditorConnectionInfo editorConnectionInfo = SQLFileUtil.getDefaultConnectionInfo();

String scrap = "";
SQLEditorStorageEditorInput editorStorageEditorInput = new SQLEditorStorageEditorInput(
"", scrap);

editorStorageEditorInput.setConnectionInfo(SQLFileUtil.getConnectionInfo4Scrapbook(editorConnectionInfo));

// the name will show as the title of the editor
IEditorReference[] editors = window.getActivePage()
.getEditorReferences();
int suffix = 0;
List editorNameList = new ArrayList();
for (int i = 0; i < editors.length; i++) {
editorNameList.add(editors[i].getName());
}

for (;;) {
String name = NLS.bind(
Messages.OpenScrapbookAction_scrapbook_title, Integer
.toString(suffix));
if (!editorNameList.contains(name)) {
editorStorageEditorInput.setName(name);
try {
window.getActivePage().openEditor(editorStorageEditorInput,
SQLScrapbookEditor.EDITOR_ID);
} catch (PartInitException e) {
SqlscrapbookPlugin.log(e);
}
break;
}
suffix++;
}
Previous Topic:DTP for non JDBC dbs
Next Topic:Migration of DTP Source Code Repository from CVS to Git
Goto Forum:
  


Current Time: Fri Apr 26 08:01:35 GMT 2024

Powered by FUDForum. Page generated in 0.03201 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top