use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tdi-studio-se by Talend.
the class OpentRunJobComponentAction method run.
@Override
public void run() {
List selection = getSelectedObjects();
Object input = selection.get(0);
if (input instanceof NodePart) {
NodePart part = (NodePart) input;
Node node = (Node) part.getModel();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
if (processName != null && !"".equals(processName)) {
//$NON-NLS-1$
try {
ItemCacheManager.clearCache();
ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
if (processItem != null) {
ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true);
IEditorPart editorPart = page.findEditor(fileEditorInput);
if (editorPart == null) {
ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(processItem);
IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(processItem, true));
} else {
page.activate(editorPart);
}
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
}
} else {
try {
// modified for feature 2454.
page.showView(ComponentSettingsView.ID);
} catch (PartInitException e) {
ExceptionHandler.process(e);
}
}
}
}
use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tdi-studio-se by Talend.
the class ProcessPart method getAdapter.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
*/
@Override
public Object getAdapter(final Class adapter) {
if (adapter.equals(RepositoryNode.class)) {
if (node == null) {
RootEditPart rootEditPart = getRoot();
if (rootEditPart instanceof TalendScalableFreeformRootEditPart) {
TalendScalableFreeformRootEditPart rootEditPart2 = (TalendScalableFreeformRootEditPart) rootEditPart;
IEditorInput editorInput = rootEditPart2.getEditorInput();
if (editorInput instanceof ProcessEditorInput) {
ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
node = processEditorInput.getRepositoryNode();
}
}
}
return node;
}
if (adapter == SnapToHelper.class) {
List<Object> snapStrategies = new ArrayList<Object>();
Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
if (val != null && val.booleanValue()) {
snapStrategies.add(new NodeSnapToGeometry(this));
}
val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
if (val != null && val.booleanValue()) {
snapStrategies.add(new SnapToGrid(this));
}
if (snapStrategies.size() == 0) {
return null;
}
if (snapStrategies.size() == 1) {
return snapStrategies.get(0);
}
SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
for (int i = 0; i < snapStrategies.size(); i++) {
ss[i] = (SnapToHelper) snapStrategies.get(i);
}
return new CompoundSnapToHelper(ss);
}
return super.getAdapter(adapter);
}
use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method getEditorInput.
protected RepositoryEditorInput getEditorInput(final Item item, final boolean readonly, final IWorkbenchPage page) throws SystemException {
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return new ProcessEditorInput(processItem, true, false, readonly);
} else if (item instanceof BusinessProcessItem) {
BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
IFile file = CorePlugin.getDefault().getDiagramModelService().getDiagramFileAndUpdateResource(page, businessProcessItem);
return new RepositoryEditorInput(file, businessProcessItem);
} else if (item instanceof RoutineItem) {
final RoutineItem routineItem = (RoutineItem) item;
final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ITalendSynchronizer routineSynchronizer = codeGenService.createRoutineSynchronizer();
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion = routineItem.getProperty().getVersion();
routineSynchronizer.syncRoutine(routineItem, true, true);
final IFile file;
if (curVersion != null && curVersion.equals(lastVersion)) {
file = routineSynchronizer.getFile(routineItem);
} else {
file = routineSynchronizer.getRoutinesFile(routineItem);
}
if (file != null) {
return new RoutineEditorInput(file, routineItem);
}
} else if (item instanceof SQLPatternItem) {
SQLPatternItem patternItem = (SQLPatternItem) item;
final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ISQLPatternSynchronizer SQLPatternSynchronizer = codeGenService.getSQLPatternSynchronizer();
SQLPatternSynchronizer.syncSQLPattern(patternItem, true);
IFile file = SQLPatternSynchronizer.getSQLPatternFile(patternItem);
if (file != null) {
return new RepositoryEditorInput(file, patternItem);
}
}
return null;
}
use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.
the class UpdateLastServerCommand method saveLastServer.
private void saveLastServer(Item item, MDMServerDef serverDef) {
if (item.eResource() == null) {
try {
IRepositoryViewObject viewObj = factory.getLastVersion(item.getProperty().getId());
if (viewObj == null) {
// when object is match rule map info object,it must not exist and return null
return;
}
Property property = viewObj.getProperty();
item = property.getItem();
ContainerCacheService.put(property, viewObj);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
RepositoryResourceUtil.setLastServerDef(item, serverDef);
if (!(item instanceof ProcessItem)) {
// for common object except job
try {
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
} else {
if (isWorkInUI()) {
// for job object
try {
RepositoryViewObjectResourceChangeManager.stopListening();
IEditorReference editorRef = getJobEditor(item);
if (editorRef != null) {
IEditorPart editor = editorRef.getEditor(false);
if (editor != null && editor.isDirty()) {
// when save job editor, it only keep the additional properties that Process have
ProcessEditorInput processEditorInput = (ProcessEditorInput) editor.getEditorInput();
EMap additionalProperties = item.getProperty().getAdditionalProperties();
Iterator iterator = additionalProperties.keySet().iterator();
Map<Object, Object> processAdditionalProperties = processEditorInput.getLoadedProcess().getAdditionalProperties();
processAdditionalProperties.putAll(additionalProperties.map());
editor.doSave(new NullProgressMonitor());
return;
}
}
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
RepositoryViewObjectResourceChangeManager.startListening();
}
} else {
// save under command line
try {
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
}
}
use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.
the class NewProcessAction method refreshJobEditorTitle.
private void refreshJobEditorTitle(Item item) {
String label = item.getProperty().getLabel();
// job name can not contains '#' and '$', see job's create procedure
// $NON-NLS-1$ //$NON-NLS-2$
label = label.replaceAll("#|\\$", "");
IWorkbenchPage activePage = getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
if (editorReferences != null) {
for (IEditorReference editorPart : editorReferences) {
IEditorInput editorInput = editorPart.getEditor(false).getEditorInput();
if (editorInput instanceof ProcessEditorInput) {
ProcessEditorInput processInput = (ProcessEditorInput) editorInput;
ProcessItem jobItem = (ProcessItem) processInput.getItem();
MultiPageTalendEditor jobEditor = (MultiPageTalendEditor) editorPart.getEditor(false);
String jobLabel = jobItem.getProperty().getLabel();
if (jobLabel.equals(label)) {
jobEditor.refreshName();
break;
}
}
}
}
}
Aggregations