private void doSourceChanged(IDocument document) { String text = document.get(); _fTemplate.setPattern(text); _fValidationStatus.setOK(); TemplateContextType contextType = _fContextTypeRegistry.getContextType(_fTemplate.getContextTypeId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { _fValidationStatus.setError(e.getLocalizedMessage()); } } updateUndoAction(); updateButtons(); }
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); } } }