/** * Return a specific GenericSQLContextType object which identifies the context type of templates used in SQL editor. * * @param dbType * @return */ public static GenericSQLContextType getSQLContextType(String dbType) { SQLService service = getSQLService(null, dbType); if (service != null) { return service.getSQLContextType(); } return null; }
/** * Return all the GenericSQLContextType objects which identify the context type of templates used in SQL editor. * * @return */ public static Collection getSQLContextTypes() { Collection c = getRegistry().getConfigurations(); int size = c.size(); SQLDevToolsConfiguration[] fs = (SQLDevToolsConfiguration[]) c.toArray(new SQLDevToolsConfiguration[size]); Collection ctxTypes = new ArrayList(); for (int i = 0; i < size; i++) { ctxTypes.add(fs[i].getSQLService().getSQLContextType()); } return ctxTypes; }
/** * Returns this plug-in's context type registry. * * @return the context type registry for this plug-in instance */ public ContextTypeRegistry getTemplateContextTypeRegistry() { if (_registry == null) { // create an configure the contexts available in the template editor _registry = new ContributionContextTypeRegistry(); _registry.addContextType(GenericSQLContextType.SQL_CONTEXT_TYPE); Collection c = SQLToolsFacade.getConfigurations(); Collection ctxTypes = new ArrayList(); for (Iterator iter = c.iterator(); iter.hasNext();) { SQLDevToolsConfiguration config = (SQLDevToolsConfiguration) iter.next(); ctxTypes.add(config.getSQLService().getSQLContextType()); } for (Iterator i = ctxTypes.iterator(); i.hasNext();) { //getId() will return null before calling addContextType _registry.addContextType(((GenericSQLContextType) i.next()).getSQLContextId()); } } return _registry; }
.getDatabaseVendorDefinitionId()); if (config != null) { contextType = config.getSQLService().getSQLContextType(); } else { contextType = SQLEditorPlugin.getDefault()
public void run() { Template template = new Template(); template.setPattern(_sqlEditor.getSelectedText()); SQLDevToolsConfiguration config = SQLToolsFacade.getConfigurationByVendorIdentifier(_sqlEditor.getConnectionInfo().getDatabaseVendorDefinitionId()); SQLService sqlService = config.getSQLService(); template.setContextTypeId(sqlService.getSQLContextType().getSQLContextId()); Dialog dialog = new EditTemplateDialog(null, template, false, true, SQLEditorPlugin.getDefault().getTemplateContextTypeRegistry()); if (dialog.open() == Window.OK) { TemplatePersistenceData data = new TemplatePersistenceData(template, true); SQLEditorPlugin.getDefault().getTemplateStore().add(data); try { SQLEditorPlugin.getDefault().getTemplateStore().save(); } catch (IOException e) { openWriteErrorDialog(e); } } }