use of org.talend.core.model.properties.SQLPatternItem in project tdi-studio-se by Talend.
the class EditPropertiesAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = selection.size() == 1;
if (canWork) {
Object o = selection.getFirstElement();
if (o instanceof IRepositoryNode) {
IRepositoryNode node = (IRepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
if (node.getObjectType() == ERepositoryObjectType.BUSINESS_PROCESS || node.getObjectType() == ERepositoryObjectType.PROCESS) {
canWork = true;
} else if (node.getObjectType() == ERepositoryObjectType.ROUTINES) {
Item item = node.getObject().getProperty().getItem();
if (item instanceof RoutineItem) {
canWork = !((RoutineItem) item).isBuiltIn();
} else {
canWork = false;
}
} else if (node.getObjectType() == ERepositoryObjectType.SQLPATTERNS) {
Item item = node.getObject().getProperty().getItem();
if (item instanceof SQLPatternItem) {
canWork = !((SQLPatternItem) item).isSystem();
} else {
canWork = false;
}
} else if (node.getObjectType() == ERepositoryObjectType.JOB_SCRIPT) {
Item item = node.getObject().getProperty().getItem();
if (item instanceof JobScriptItem) {
canWork = true;
} else {
canWork = false;
}
} else {
canWork = isInstanceofCamelRoutes(node.getObjectType()) || isInstanceofCamelBeans(node.getObjectType());
}
break;
default:
canWork = false;
break;
}
if (canWork) {
canWork = (node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED);
}
if (canWork) {
canWork = isLastVersion(node);
}
}
}
setEnabled(canWork);
}
use of org.talend.core.model.properties.SQLPatternItem in project tdi-studio-se by Talend.
the class SQLTemplateRepoViewLinker method isRelation.
/*
* (non-Javadoc)
*
* @see org.talend.core.repository.link.AbstractRepositoryEditorInputLinker#isRelation(org.eclipse.ui.IEditorInput,
* java.lang.String)
*/
@Override
public boolean isRelation(IEditorInput editorInput, String repoNodeId) {
if (editorInput instanceof RepositoryEditorInput) {
RepositoryEditorInput repoEditorInput = (RepositoryEditorInput) editorInput;
Item item = repoEditorInput.getItem();
if (item instanceof SQLPatternItem) {
// must be SQL template item
return super.isRelation(editorInput, repoNodeId);
}
}
return false;
}
use of org.talend.core.model.properties.SQLPatternItem in project tdi-studio-se by Talend.
the class ReadSqlpatternAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
Property property = (Property) node.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
// node.getObject().setProperty(updatedProperty);
SQLPatternItem sqlpatternItem = (SQLPatternItem) node.getObject().getProperty().getItem();
try {
openSQLPatternEditor(sqlpatternItem, true);
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (SystemException e) {
MessageBoxExceptionHandler.process(e);
}
}
use of org.talend.core.model.properties.SQLPatternItem in project tdi-studio-se by Talend.
the class AbstractSqlpatternAction method openSQLPatternEditor.
/**
* DOC smallet Comment method "openRoutineEditor".
*
* @param item
* @throws SystemException
* @throws PartInitException
*/
public IEditorPart openSQLPatternEditor(SQLPatternItem item, boolean readOnly) throws SystemException, PartInitException {
if (item == null) {
return null;
}
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ISQLPatternSynchronizer routineSynchronizer = service.getSQLPatternSynchronizer();
// check if the related editor is open.
IWorkbenchPage page = getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
boolean found = false;
IEditorPart talendEditor = null;
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
// TextEditor talendEditor = (TextEditor) editor;
RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
Item item2 = editorInput.getItem();
if (item2 != null && item2 instanceof SQLPatternItem && item2.getProperty().getId().equals(item.getProperty().getId())) {
if (item2.getProperty().getVersion().equals(item.getProperty().getVersion())) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
} else {
page.closeEditor(editor, false);
}
}
}
}
if (!found) {
routineSynchronizer.syncSQLPattern(item, true);
IFile file = routineSynchronizer.getSQLPatternFile(item);
if (file == null) {
return null;
}
RepositoryEditorInput input = new RepositoryEditorInput(file, item);
input.setReadOnly(readOnly);
//$NON-NLS-1$
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
Aggregations