use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method processItems.
protected void processItems(List<ItemVersionObject> objects, RepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode(node)) {
// must be item
ItemVersionObject object = createItemVersionObject(node, property);
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, (RepositoryNode) child);
}
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SaveAsSQLPatternAction method run.
@Override
public void run() {
SaveAsSQLPatternWizard processWizard = new SaveAsSQLPatternWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
SQLPatternItem sqlpatternItem = processWizard.getSQLPatternItem();
// get the IFile
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
// only for talend java version
ISQLPatternSynchronizer sqlPatternSynchronizer = service.getSQLPatternSynchronizer();
IFile file = sqlPatternSynchronizer.getSQLPatternFile(sqlpatternItem);
if (file == null) {
return;
}
// Set readonly to false since created job will always be editable.
RepositoryEditorInput repositoryEditorInput = new RepositoryEditorInput(file, sqlpatternItem);
IWorkbenchPage page = getActivePage();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(repositoryEditorInput.getItem().getProperty().getId(), false);
repositoryEditorInput.setRepositoryNode(repositoryNode);
// here really do the normal save as function
IDocumentProvider provider = ((StandAloneTalendJavaEditor) this.editorPart).getDocumentProvider();
provider.aboutToChange(repositoryEditorInput);
provider.saveDocument(null, repositoryEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
provider.changed(repositoryEditorInput);
// copy back from the *.java file to *.item file.
// @see:StandAloneTalendJavaEditor.doSave(IProgressMonitor monitor)
ByteArray byteArray = sqlpatternItem.getContent();
byteArray.setInnerContentFromFile(repositoryEditorInput.getFile());
IProxyRepositoryFactory repFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
repFactory.save(sqlpatternItem);
// close the old editor
page.closeEditor(this.editorPart, false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
page.openEditor(repositoryEditorInput, StandAloneTalendJavaEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "SQLTemplate could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SaveAsRoutineAction method run.
@Override
public void run() {
SaveAsRoutineWizard processWizard = new SaveAsRoutineWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
RoutineItem routineItem = processWizard.getRoutineItem();
// get the IFile
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ITalendSynchronizer routineSynchronizer = null;
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
}
IFile file = routineSynchronizer.getFile(routineItem);
if (file == null) {
return;
}
// Set readonly to false since created job will always be editable.
RoutineEditorInput routineEditorInput = new RoutineEditorInput(file, routineItem);
IWorkbenchPage page = getActivePage();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(routineEditorInput.getItem().getProperty().getId(), false);
routineEditorInput.setRepositoryNode(repositoryNode);
// here really do the normal save as function
IDocumentProvider provider = ((AbstractTextEditor) this.editorPart).getDocumentProvider();
provider.aboutToChange(routineEditorInput);
provider.saveDocument(null, routineEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
provider.changed(routineEditorInput);
// copy back from the *.java file to *.item file.
// @see:StandAloneTalendJavaEditor.doSave(IProgressMonitor monitor)
ByteArray byteArray = routineItem.getContent();
byteArray.setInnerContentFromFile(routineEditorInput.getFile());
IProxyRepositoryFactory repFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
repFactory.save(routineItem);
// close the old editor
page.closeEditor(this.editorPart, false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
page.openEditor(routineEditorInput, StandAloneTalendJavaEditor.ID, true);
break;
default:
}
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Routine could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class EditProcess method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
final IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
if (RepositoryManager.isOpenedItemInEditor(node.getObject())) {
canWork = false;
} else {
if (IRepositoryNode.ENodeType.REPOSITORY_ELEMENT == node.getType() && node.getObjectType() == getProcessType()) {
final IProxyRepositoryFactory repFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
this.setText(getLabel(repFactory.isPotentiallyEditable(node.getObject())));
} else {
canWork = false;
}
if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.DELETED) {
canWork = false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork = false;
}
// not.
if (canWork) {
canWork = isLastVersion(node);
}
}
}
setEnabled(canWork);
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SapSchemaTypeController method findRepositoryNode.
/**
* yzhang Comment method "findRepositoryNode".
*
* @param label
* @param root
* @return
*/
private RepositoryNode findRepositoryNode(String label, String id, RepositoryNode root) {
String name = (String) root.getProperties(EProperties.LABEL);
String rootID = root.getId();
RepositoryNode toReturn = null;
if (label.equals(name) && !id.equals(rootID)) {
toReturn = root;
} else {
for (IRepositoryNode node : root.getChildren()) {
toReturn = findRepositoryNode(label, id, (RepositoryNode) node);
if (toReturn != null) {
break;
}
}
}
return toReturn;
}
Aggregations