use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof NodeLabelEditPart) {
boolean nodeSelected;
// if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
// nodeSelected = true;
// } else {
nodeSelected = false;
// }
MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
return locationCommand;
} else if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
} else {
return null;
}
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class GEFDeleteAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
objectsToDelete = new ArrayList();
List objects = getSelectedObjects();
objectsToDelete.addAll(objects);
if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
return false;
}
if (!(objects.get(0) instanceof EditPart)) {
return false;
}
AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (pProvider != null) {
Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
boolean nodeInJoblet = false;
boolean allJunitnode = true;
boolean hasNode = false;
int i = 0;
for (Object o : objects) {
if (o instanceof NodePart) {
hasNode = true;
NodePart nodePart = (NodePart) o;
Node no = (Node) ((NodePart) o).getModel();
if (no.getProcess().isReadOnly()) {
return false;
}
if (no.isReadOnly()) {
i++;
}
if (no.getJunitNode() == null) {
allJunitnode = false;
}
if (!pProvider.canDeleteNode(no)) {
return false;
}
boolean isCollapsedNode = false;
if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
isCollapsedNode = true;
}
if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
if (jobletNodeParts == null) {
jobletNodeParts = new ArrayList<NodePart>();
jobletMap.put(jobletContainer, jobletNodeParts);
}
jobletNodeParts.add(nodePart);
}
} else if (o instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) o).getModel();
if (conn.getSource().getProcess().isReadOnly()) {
return false;
}
if (conn.isReadOnly()) {
i++;
}
} else if (o instanceof ConnLabelEditPart) {
ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
return false;
}
if (connLabel.getConnection().isReadOnly()) {
i++;
}
} else if (o instanceof NoteEditPart) {
allJunitnode = false;
Note note = (Note) ((NoteEditPart) o).getModel();
if (note.isReadOnly()) {
i++;
}
} else if (o instanceof SubjobContainerPart) {
SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
if (subjob.getProcess().isReadOnly()) {
return false;
}
if (subjob.isReadOnly()) {
i++;
continue;
}
boolean isAllReadonly = true;
boolean subjobAllJunit = true;
for (NodeContainer nc : subjob.getNodeContainers()) {
Node node = nc.getNode();
if (!node.isReadOnly()) {
isAllReadonly = false;
}
if (node.getJunitNode() == null) {
subjobAllJunit = false;
}
}
if (isAllReadonly || subjobAllJunit) {
i++;
}
}
}
for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
boolean copyJobletNode = true;
List<NodePart> list = jobletMap.get(jobletContainer);
for (Object obj : jobletContainer.getChildren()) {
if (obj instanceof NodePart) {
if (!list.contains(obj)) {
copyJobletNode = false;
break;
}
}
}
if (copyJobletNode) {
objectsToDelete.removeAll(list);
PartFactory factory = new PartFactory();
NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
createEditPart.setParent(jobletContainer);
createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
objectsToDelete.add(createEditPart);
} else {
nodeInJoblet = true;
}
}
if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
return false;
}
}
return true;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class ComponentSettingsView method createDynamicComposite.
/**
* yzhang Comment method "createDynamicComposite".
*
* @param parent
* @param element
* @param category
*/
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
// DynamicComposite dc = null;
getParentMap().put(ComponentSettingsView.PARENT, parent);
getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
if (element instanceof Node) {
IComponent component = ((Node) element).getComponent();
IGenericWizardService wizardService = null;
boolean generic = false;
if (EComponentType.GENERIC.equals(component.getComponentType())) {
generic = true;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
if (category == EComponentCategory.BASIC) {
// getElementMap().put(ComponentSettingsView.ELEMENT, element);
createButtonListener();
boolean isCompactView = true;
if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
isCompactView = false;
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
} else {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
}
} else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.SQL_PATTERN) {
dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.ADVANCED) {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
}
} else {
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
} else if (element instanceof Connection) {
dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
} else if (element instanceof Note) {
if (category == EComponentCategory.BASIC) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.setMinWidth(600);
scrolled.setMinHeight(400);
Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
scrolled.setContent(composite);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(0, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(0, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
// AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
// tabFactory);
// FormData data = new FormData();
// data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
// data.left = new FormAttachment(0, 0);
// data.right = new FormAttachment(100, 0);
// c2.getComposite().setLayoutData(data);
parent.layout();
}
} else if (element instanceof SubjobContainer) {
if (category == EComponentCategory.BASIC) {
dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
}
} else {
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
if (parent.getChildren().length == 0) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(2, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(5, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
Label alertText = new Label(composite, SWT.NONE);
//$NON-NLS-1$
alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
parent.layout();
}
if (dc != null) {
dc.refresh();
}
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class ComponentSettingsView method setPropertiesViewerTitle.
/**
* yzhang Comment method "setPropertiesViewerTitle".
*
* @param elem
*/
private void setPropertiesViewerTitle(Element elem) {
String label = null;
Image image = null;
if (elem instanceof Node) {
label = ((Node) elem).getLabel();
String uniqueName = ((Node) elem).getUniqueName();
if (!label.equals(uniqueName)) {
//$NON-NLS-1$ //$NON-NLS-2$
label = label + "(" + uniqueName + ")";
}
image = CoreImageProvider.getComponentIcon(((Node) elem).getComponent(), ICON_SIZE.ICON_24);
} else if (elem instanceof Connection) {
label = ((Connection) elem).getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
} else if (elem instanceof Note) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.note");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof SubjobContainer) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.subjob");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof ConnectionLabel) {
label = ((ConnectionLabel) elem).getConnection().getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
}
tabFactory.setTitle(label, image);
super.setTitleToolTip(label);
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class PartFactory method createEditPart.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
@Override
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof SubjobContainer) {
part = new SubjobContainerPart();
} else if (model instanceof Process) {
part = new ProcessPart();
} else if (model instanceof Node) {
part = new NodePart();
} else if (model instanceof Connection) {
part = new ConnectionPart();
} else if (model instanceof ConnectionLabel) {
part = new ConnLabelEditPart();
} else if (model instanceof MonitorConnectionLabel) {
part = new MonitorConnectionLabelPart();
} else if (model instanceof ConnectionPerformance) {
part = new ConnectionPerformanceEditPart();
} else if (model instanceof ConnectionTrace) {
part = new ConnectionTraceEditPart();
} else if (model instanceof ConnectionResuming) {
part = new ConnectionResumingEditPart();
} else if (model instanceof NodeLabel) {
part = new NodeLabelEditPart();
} else if (model instanceof NodeContainer) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
if (testContainerService != null) {
part = testContainerService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
if (((NodeContainer) model).getNode().isSparkJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isStandardJoblet()) {
part = new JobletContainerPart();
} else if (((NodeContainer) model).getNode().isMapReduce()) {
part = new JobletContainerPart();
} else {
part = new NodeContainerPart();
}
} else if (model instanceof Note) {
part = new NoteEditPart();
} else if (model instanceof NodeError) {
part = new NodeErrorEditPart();
} else if (model instanceof NodeProgressBar) {
part = new NodeProgressBarPart();
} else {
return null;
}
// tell the newly created part about the model object
part.setModel(model);
return part;
}
Aggregations