use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.
the class ElementHelper method getElement.
/**
* DOC mhelleboid Comment method "getElement".
*
* @param editPart
* @return
*/
public BusinessItem getElement(EditPart editPart) {
Object model = editPart.getModel();
if (model instanceof View) {
View node = (View) model;
EObject element = node.getElement();
if (element instanceof BusinessItem) {
return (BusinessItem) element;
}
}
return null;
}
use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.
the class ClipboardActionHandler method saveCut.
private void saveCut(ISelection object) {
cutItemIds = new HashMap();
if (object instanceof IStructuredSelection) {
for (Object obj : ((IStructuredSelection) object).toList()) {
if (obj instanceof AbstractEditPart) {
AbstractEditPart editPart = (AbstractEditPart) obj;
EObject element = ((View) editPart.getModel()).getElement();
if (element instanceof BusinessItem) {
BusinessItem businessItem = (BusinessItem) element;
List assignments = new ArrayList();
for (Object assignment : businessItem.getAssignments()) {
BusinessAssignment ba = (BusinessAssignment) assignment;
TalendItem item = ba.getTalendItem();
if (item != null) {
assignments.add(item.getId());
}
}
cutItemIds.put(businessItem, assignments);
}
}
}
}
}
use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.
the class ClipboardActionHandler method transfer.
private void transfer(ISelection object) {
if (object instanceof IStructuredSelection) {
List<BusinessItem> selections = new ArrayList();
for (Object obj : ((IStructuredSelection) object).toList()) {
if (obj instanceof AbstractEditPart) {
AbstractEditPart editPart = (AbstractEditPart) obj;
EObject element = ((View) editPart.getModel()).getElement();
if (element instanceof BusinessItem) {
selections.add((BusinessItem) element);
}
}
}
TemplateTransfer.getInstance().setObject(selections);
}
}
use of org.talend.designer.business.model.business.BusinessItem 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.BusinessItem in project tdi-studio-se by Talend.
the class ElementHelper method updateTooltipFigure.
/**
* DOC Administrator Comment method "getTooltipFigure".
*
* @param figure
*/
public void updateTooltipFigure(Figure figure, BusinessTooltipFigure tooltipFigure, EditPart editPart) {
EObject element = ((View) editPart.getModel()).getElement();
if (element instanceof BusinessItem) {
List assignements = ((BusinessItem) element).getAssignments();
BusinessItemProviderAdapterFactory adapterFactory = new BusinessItemProviderAdapterFactory();
BusinessAssignmentItemProvider provider = (BusinessAssignmentItemProvider) adapterFactory.createBusinessAssignmentAdapter();
Image img = null;
Label label = null;
List<Label> labels = new ArrayList();
try {
for (Object assignment : assignements) {
if (assignment instanceof BusinessAssignment) {
TalendItem talendItem = ((BusinessAssignment) assignment).getTalendItem();
if (talendItem != null) {
IRepositoryViewObject obj = CorePlugin.getDefault().getProxyRepositoryFactory().getLastVersion(talendItem.getId());
if (obj != null) {
ERepositoryObjectType type = obj.getRepositoryObjectType();
Item item = obj.getProperty().getItem();
if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
Image jobletCustomIcon = RepositoryLabelProvider.getJobletCustomIcon(jobletItem.getProperty());
if (jobletCustomIcon != null) {
img = ImageUtils.scale(jobletCustomIcon, ICON_SIZE.ICON_16);
}
} else {
img = CoreImageProvider.getImage(type);
}
//$NON-NLS-1$ //$NON-NLS-2$
label = new Label(obj.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", img);
labels.add(label);
} else {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(talendItem.getId());
Query query = MetadataToolHelper.getQueryFromRepository(talendItem.getId());
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(talendItem.getId());
if (table != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_TABLE_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else if (query != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_QUERY_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else if (talendItem instanceof SQLPattern) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
for (IRepositoryViewObject object : list) {
if (talendItem.getLabel().equals(object.getLabel())) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SQLPATTERN_ICON.getPath()).createImage();
label = new Label(//$NON-NLS-1$
talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
img);
labels.add(label);
}
}
} else if (talendItem instanceof Routine) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject object : list) {
if (talendItem.getLabel().equals(object.getLabel())) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.ROUTINE_ICON.getPath()).createImage();
label = new Label(//$NON-NLS-1$
talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
img);
labels.add(label);
}
}
} else if (function != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SAPCONNECTION_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else {
img = (Image) provider.getImage(assignment);
img = new OverlayImage(img, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
String text = provider.getText(assignment) + " (" + provider.getColumnText(assignment, 0) + //$NON-NLS-1$ //$NON-NLS-2$
")";
label = new Label(text, img);
labels.add(label);
}
}
}
}
}
if (tooltipFigure == null) {
tooltipFigure = new BusinessTooltipFigure();
}
if (labels.size() == 0) {
figure.setToolTip(null);
} else {
tooltipFigure.buildFigures(labels);
figure.setToolTip(tooltipFigure);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations