use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class ComponentSettingsView method getCategories.
/**
* yzhang Comment method "getCategories".
*
* @param elem
* @return
*/
private EComponentCategory[] getCategories(Element elem) {
if (elem instanceof Connection) {
EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
if (PluginChecker.isTeamEdition()) {
Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
// if (((Connection) elem).checkTraceShowEnable()) {
final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
// mrjob and stormjob not add breakpoint
if (!isStormProcess && !isMRProcess) {
list.add(EComponentCategory.BREAKPOINT);
}
if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
list.add(EComponentCategory.PARALLELIZATION);
}
// if it mr group line then add errorRecovery
if (isMRProcess && isMrGroupLine(elem)) {
list.add(EComponentCategory.RESUMING);
}
return list.toArray(new EComponentCategory[0]);
// }
} else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
int length = categories.length;
EComponentCategory[] newCategories;
boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
newCategories = new EComponentCategory[length + 1];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
EComponentCategory resuming = EComponentCategory.RESUMING;
newCategories[length] = resuming;
} else {
newCategories = new EComponentCategory[length];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
}
return newCategories;
}
}
return categories;
} else if (elem instanceof Node) {
// if (isAdvancedType(elem)) {
if (((Node) elem).isELTComponent()) {
if (//$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
//$NON-NLS-1$
return EElementType.ELT_NODE.getCategories();
}
}
EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
// add for bug TDI-8476
if (((Node) elem).getComponent() != null) {
String paletteType = ((Node) elem).getComponent().getPaletteType();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
categories = EElementType.NODE.getCategories();
}
}
if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
// show
EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
System.arraycopy(categories, 0, newCategories, 0, categories.length);
newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
return newCategories;
}
return categories;
} else if (elem instanceof Note) {
return EElementType.NOTE.getCategories();
} else if (elem instanceof SubjobContainer) {
return EElementType.SUBJOB.getCategories();
} else if (elem instanceof ConnectionLabel) {
return getCategories(((ConnectionLabel) elem).getConnection());
}
return null;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method undo.
@SuppressWarnings("unchecked")
@Override
public void undo() {
// remove the current selection
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
if (!multipleCommand) {
viewer.deselectAll();
}
for (Note note : noteList) {
process.removeNote(note);
}
// set the old selection active
if (!multipleCommand) {
StructuredSelection s = new StructuredSelection(oldSelection);
viewer.setSelection(s);
}
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method findLocationForNoteInContainerList.
private Point findLocationForNoteInContainerList(final Point location, Dimension size, int index, int firstIndex) {
Rectangle copiedRect = new Rectangle(location.x, location.y, size.width, size.height);
Point newLocation = new Point(location);
if (!isMultiple) {
for (Note node : noteList) {
Rectangle currentRect = new Rectangle(node.getLocation().x, node.getLocation().y, node.getSize().width, node.getSize().height);
if (currentRect.intersects(copiedRect)) {
newLocation = computeTheDistance(index, firstIndex, newLocation);
// return findLocationForNoteInContainerList(newLocation, size, index, firstIndex);
}
}
} else {
if (getCursorLocation() == null) {
return newLocation;
}
newLocation = computeTheDistance(index, firstIndex, newLocation);
}
return newLocation;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method createNoteList.
@SuppressWarnings("unchecked")
private void createNoteList() {
int firstIndex = 0;
int index = 0;
noteList = new ArrayList<Note>();
// create the notes
for (NoteEditPart copiedNodePart : noteParts) {
Note copiedNote = (Note) copiedNodePart.getModel();
Note pastedNote = new Note();
pastedNote.setOpaque(copiedNote.isOpaque());
pastedNote.setText(copiedNote.getText());
pastedNote.setSize(copiedNote.getSize());
// see bug 0005571: Copy/Paste of Note doesn't keep Format
EParameterName[] params = new EParameterName[] { EParameterName.NOTE_FONT, EParameterName.FONT_SIZE, EParameterName.FONT_BOLD, EParameterName.FONT_ITALIC, EParameterName.NOTE_LINECOLOR, EParameterName.NOTE_COLOR, EParameterName.NOTETXT_COLOR, EParameterName.NOTETXT_LEFT, EParameterName.NOTETXT_RIGHT, EParameterName.NOTETXT_CENTER, EParameterName.NOTELABEL_CENTER, EParameterName.NOTETXT_TOP, EParameterName.NOTETXT_BOTTOM };
for (EParameterName param : params) {
Object value = copiedNote.getElementParameter(param.getName()).getValue();
pastedNote.getElementParameter(param.getName()).setValue(value);
}
pastedNote.setOpaque(copiedNote.isOpaque());
pastedNote.setProcess(process);
Point location = null;
if (getCursorLocation() == null) {
location = copiedNote.getLocation();
} else {
location = getCursorLocation();
index = noteParts.indexOf(copiedNodePart);
}
if (process.isGridEnabled()) {
// replace the component to set it on the grid if it's enabled
int tempVar = location.x / TalendEditor.GRID_SIZE;
location.x = tempVar * TalendEditor.GRID_SIZE;
tempVar = location.y / TalendEditor.GRID_SIZE;
location.y = tempVar * TalendEditor.GRID_SIZE;
}
pastedNote.setLocation(findLocationForNote(location, copiedNote.getSize(), index, firstIndex));
noteList.add(pastedNote);
}
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class MultiplePasteCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.CompoundCommand#execute()
*/
@Override
public void execute() {
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
oldSelection = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
oldSelection.add(editPart);
}
// remove the old selection
viewer.deselectAll();
super.execute();
EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
if (processPart instanceof ProcessPart) {
// can only be ProcessPart but still test
List<EditPart> sel = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
if (editPart instanceof NodePart) {
Node currentNode = (Node) editPart.getModel();
if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
sel.add(editPart);
}
} else if (editPart instanceof NoteEditPart) {
Note currentNode = (Note) editPart.getModel();
if (noteCmd.getNoteList().contains(currentNode)) {
sel.add(editPart);
}
} else if (editPart instanceof SubjobContainerPart) {
// add for the bug TDI-7706
for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
if (subjobChildsPart instanceof NodeContainerPart) {
if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
if (nodePart != null) {
sel.add(nodePart);
}
}
}
}
}
}
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
Aggregations