use of org.talend.designer.business.model.business.BusinessProcess in project tdi-studio-se by Talend.
the class ImportItemUtil method resetItemReference.
/**
*
* cLi Comment method "resetItemReference".
*
* resolve the encode some special character(bug 6252), maybe, It's not better to resolve this by manually.
*
* such as, "[" is "%5B", "]" is "%5D", etc.
*/
@SuppressWarnings("unchecked")
private void resetItemReference(ItemRecord itemRecord, Resource resource) {
Item item = itemRecord.getItem();
EList<EObject> contents = resource.getContents();
/*
* ignore job. no need, because it can't be allowed input special char for name.
*/
if (item instanceof ProcessItem) {
// ((ProcessItem) item).setProcess((ProcessType) EcoreUtil.getObjectByType(contents,
// TalendFilePackage.eINSTANCE
// .getProcessType()));
} else /*
* ignore joblet. no need, because it can't be allowed input special char for name.
*/
if (item instanceof JobletProcessItem) {
// JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
//
// jobletProcessItem.setJobletProcess((JobletProcess) EcoreUtil.getObjectByType(contents,
// JobletPackage.eINSTANCE
// .getJobletProcess()));
// jobletProcessItem
// .setIcon((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
} else // connectionItem
if (item instanceof ConnectionItem) {
((ConnectionItem) item).setConnection((Connection) EcoreUtil.getObjectByType(contents, ConnectionPackage.eINSTANCE.getConnection()));
} else // context
if (item instanceof ContextItem) {
EList contexts = ((ContextItem) item).getContext();
contexts.clear();
contexts.addAll(EcoreUtil.getObjectsByType(contents, TalendFilePackage.eINSTANCE.getContextType()));
} else // file
if (item instanceof FileItem) {
/*
* ignore routine, no need, because it can't be allowed input special char for name.
*/
if (item instanceof RoutineItem) {
return;
}
FileItem fileItem = (FileItem) item;
fileItem.setContent((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
} else // snippet
if (item instanceof SnippetItem) {
EList variables = ((SnippetItem) item).getVariables();
variables.clear();
variables.addAll(EcoreUtil.getObjectsByType(contents, PropertiesPackage.eINSTANCE.getSnippetVariable()));
} else // link doc
if (item instanceof LinkDocumentationItem) {
((LinkDocumentationItem) item).setLink((LinkType) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getLinkType()));
} else // business
if (item instanceof BusinessProcessItem) {
BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
businessProcessItem.setSemantic((BusinessProcess) EcoreUtil.getObjectByType(contents, BusinessPackage.eINSTANCE.getBusinessProcess()));
businessProcessItem.setNotationHolder((NotationHolder) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getNotationHolder()));
}
}
use of org.talend.designer.business.model.business.BusinessProcess in project tdi-studio-se by Talend.
the class FindAssignmentAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
IEditorPart activeEditor = getActiveEditor();
// remove frames draw last time
for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
shapFigure.setDrawFrame(false);
shapFigure.revalidate();
shapFigure.repaint();
}
if (activeEditor instanceof BusinessDiagramEditor) {
BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
// PTODO mhelleboid use OCL or using a visitor
List list = new ArrayList();
for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
BusinessItem businessItem = (BusinessItem) iter.next();
for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
TalendItem talendItem = businessAssignment.getTalendItem();
IRepositoryViewObject obj = repositoryNode.getObject();
if (talendItem.getId().equals(repositoryNode.getId())) {
list.add(businessItem);
} else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
list.add(businessItem);
}
}
}
}
IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
List editParts = new ArrayList();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
BusinessItem businessItem = (BusinessItem) iter.next();
editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
}
diagramGraphicalViewer.deselectAll();
// add a frame when use findAassignment
for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
EditPart editPart = (EditPart) iter.next();
if (editPart instanceof BusinessItemShapeEditPart) {
BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
IFigure figure = shapEditPart.getFigure();
for (Object child : figure.getChildren()) {
if (child instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
shapFigure.setDrawFrame(true);
shapFigure.revalidate();
shapFigure.repaint();
repaintedFigures.add(shapFigure);
}
}
}
diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
}
ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
}
}
use of org.talend.designer.business.model.business.BusinessProcess in project tdi-studio-se by Talend.
the class ClipboardActionHandler method getCommand.
@Override
public ICommand getCommand(IGlobalActionContext cntxt) {
IWorkbenchPart part = cntxt.getActivePart();
if (!(part instanceof IDiagramWorkbenchPart)) {
return null;
}
IDiagramWorkbenchPart workbenchPart = (IDiagramWorkbenchPart) part;
DiagramEditPart diagramEditPart = workbenchPart.getDiagramEditPart();
ICommand command = null;
String actionId = cntxt.getActionId();
if (actionId.equals(GlobalActionId.COPY)) {
command = getCopyCommand(cntxt, workbenchPart, false);
transfer(cntxt.getSelection());
isCut = false;
older = workbenchPart;
orginalCopyFrom = workbenchPart;
clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
} else if (actionId.equals(GlobalActionId.CUT) && cntxt.getSelection() != null) {
saveCut(cntxt.getSelection());
command = getCutCommand(cntxt, workbenchPart);
transfer(cntxt.getSelection());
isCut = true;
older = workbenchPart;
clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
} else if (actionId.equals(GlobalActionId.SAVE)) {
if (workbenchPart instanceof IEditorPart) {
IEditorPart editorPart = (IEditorPart) workbenchPart;
if (editorPart.isDirty()) {
IWorkbenchPage page = editorPart.getSite().getPage();
page.saveEditor(editorPart, false);
}
}
}
if (actionId.equals(GlobalActionId.PASTE)) {
// diagramPart.getDiagramGraphicalViewer().setSelection(new
// StructuredSelection(diagramPart.getDiagramEditPart()));
PasteViewRequest pasteReq = createPasteViewRequest();
CommandStack cs = workbenchPart.getDiagramEditDomain().getDiagramCommandStack();
IStructuredSelection selection = (IStructuredSelection) cntxt.getSelection();
if (!(selection.getFirstElement() instanceof BusinessProcessEditPart)) {
selection = new StructuredSelection(workbenchPart.getDiagramEditPart());
}
Object[] objects = selection.toArray();
Collection returnValues = null;
if (objects.length == 1) {
Command paste = ((EditPart) objects[0]).getCommand(pasteReq);
if (paste != null) {
cs.execute(paste);
workbenchPart.getDiagramEditPart().getFigure().invalidate();
workbenchPart.getDiagramEditPart().getFigure().validate();
returnValues = DiagramCommandStack.getReturnValues(paste);
// selectAddedObject(diagramPart.getDiagramGraphicalViewer(), returnValues);
}
}
Object elements = TemplateTransfer.getInstance().getObject();
if (elements instanceof List) {
List<BusinessItem> list = (List<BusinessItem>) elements;
boolean inEditors = false;
if (older != workbenchPart) {
inEditors = true;
} else if (!this.isCut && orginalCopyFrom != workbenchPart) {
// bug 16065 fixed, by xtan. to resolve the copy(A)/parse(B)/parse(B)/parse(B)... problem.
inEditors = true;
}
// always keep the last one as the current selection.
older = workbenchPart;
GmfPastCommand pastBusiness = new GmfPastCommand((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement(), list, diagramEditPart, this.cutItemIds, this.isCut | inEditors);
pastBusiness.setClonedSourceProcessItemsList(clonedSourceProcessItemsList);
try {
pastBusiness.execute(null, null);
} catch (ExecutionException e) {
ExceptionHandler.process(e);
}
}
if (returnValues != null) {
selectAddedObject(workbenchPart.getDiagramGraphicalViewer(), returnValues);
}
return null;
}
return command;
}
use of org.talend.designer.business.model.business.BusinessProcess in project tdi-studio-se by Talend.
the class BusinessDiagramEditorUtil method createNewDiagramFile.
/**
* <p>
* This method should be called within a workspace modify operation since it creates resources.
* </p>
*
* @generated
* @return the created file resource, or <code>null</code> if the file was not created
*/
public static final IFile createNewDiagramFile(DiagramFileCreator diagramFileCreator, IPath containerFullPath, String fileName, InputStream initialContents, String kind, Shell shell, IProgressMonitor progressMonitor) {
TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
//$NON-NLS-1$
progressMonitor.beginTask("Creating diagram and model files", 4);
final IProgressMonitor subProgressMonitor = new SubProgressMonitor(progressMonitor, 1);
final IFile diagramFile = diagramFileCreator.createNewFile(containerFullPath, fileName, initialContents, shell, new IRunnableContext() {
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
runnable.run(subProgressMonitor);
}
});
final Resource diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFile.getFullPath().toString()));
List affectedFiles = new ArrayList();
affectedFiles.add(diagramFile);
final String kindParam = kind;
AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, //$NON-NLS-1$
"Creating diagram and model", //$NON-NLS-1$
affectedFiles) {
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
BusinessProcess model = createInitialModel();
diagramResource.getContents().add(model);
Diagram diagram = ViewService.createDiagram(model, kindParam, BusinessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
if (diagram != null) {
diagramResource.getContents().add(diagram);
diagram.setName(diagramFile.getName());
diagram.setElement(model);
}
try {
diagramResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
BusinessDiagramEditorPlugin.getInstance().logError("Unable to store model and diagram resources", //$NON-NLS-1$
e);
}
return CommandResult.newOKCommandResult();
}
};
try {
OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), null);
} catch (ExecutionException e) {
//$NON-NLS-1$
BusinessDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e);
}
try {
//$NON-NLS-1$
diagramFile.setCharset("UTF-8", new SubProgressMonitor(progressMonitor, 1));
} catch (CoreException e) {
//$NON-NLS-1$
BusinessDiagramEditorPlugin.getInstance().logError("Unable to set charset for diagram file", e);
}
return diagramFile;
}
use of org.talend.designer.business.model.business.BusinessProcess in project tdi-studio-se by Talend.
the class DiagramResourceManager method updateFromResource.
public void updateFromResource(BusinessProcessItem businessProcessItem, IFile file) {
Resource resource = createResource(file);
BusinessProcess semantic = (BusinessProcess) EcoreUtil.getObjectByType(resource.getContents(), BusinessPackage.eINSTANCE.getBusinessProcess());
Diagram notation = (Diagram) EcoreUtil.getObjectByType(resource.getContents(), NotationPackage.eINSTANCE.getDiagram());
businessProcessItem.setSemantic(semantic);
businessProcessItem.setNotation(notation);
}
Aggregations