use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ToolbarInputZone method addPreviewToolItems.
private void addPreviewToolItems() {
if (PluginChecker.isTraceDebugPluginLoaded() && getMapperManager().isTracesActive()) {
final RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
if (activeContext == null) {
return;
}
new ToolItem(getToolBarActions(), SWT.SEPARATOR);
previousRow = new ToolItem(getToolBarActions(), SWT.PUSH);
previousRow.setEnabled(activeContext.isRunning());
previousRow.setToolTipText("Previous Row");
previousRow.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
currentRowLabel = new ToolItem(getToolBarActions(), SWT.PUSH | SWT.BORDER);
currentRowLabel.setEnabled(false);
currentRowLabel.setText(getCurrentRowString());
currentRowLabel.setToolTipText("Current Row");
currentRowLabel.setWidth(50);
nextRow = new ToolItem(getToolBarActions(), SWT.PUSH);
nextRow.setEnabled(!getMapperManager().componentIsReadOnly());
nextRow.setToolTipText("Next Row");
nextRow.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
nextBreakpoint = new ToolItem(getToolBarActions(), SWT.PUSH);
nextBreakpoint.setToolTipText("Next Breakpoint");
nextBreakpoint.setImage(ImageProvider.getImage(EImage.RIGHTX_ICON));
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(activeContext.isRunning());
}
killBtn = new ToolItem(getToolBarActions(), SWT.PUSH);
killBtn.setToolTipText("Kill");
killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
killBtn.setEnabled(activeContext.isRunning());
previousRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setPreviousRow(true);
}
});
nextRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!activeContext.isRunning()) {
for (DataMapTableView dataMapTableView : getMapperManager().getUiManager().getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
if (getMapperManager().isDataChanged()) {
boolean closeWindow = MessageDialog.openConfirm(getComposite().getShell(), //$NON-NLS-1$
"tMap configuration modified", //$NON-NLS-1$
"Do you want to apply the modification of the tMap now ?");
// save change and regenerate code
if (closeWindow) {
IExternalNode externalNode = getMapperManager().getAbstractMapComponent().getExternalNode();
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
INode node = externalNode.getOriginalNode();
if (node != null && node instanceof Node) {
Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
}
}
}
}
activeContext.setLastIsRow(true);
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugProcess();
} else {
activeContext.setNextRow(true);
}
}
});
nextBreakpoint.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setNextBreakPoint(true);
}
});
killBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugKill();
killBtn.setEnabled(false);
previousRow.setEnabled(false);
nextBreakpoint.setEnabled(false);
}
});
propertyListener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
final String propName = evt.getPropertyName();
ProcessManager.getInstance().getProcessShell().getDisplay().syncExec(new Runnable() {
public void run() {
if (RunProcessContext.PREVIOUS_ROW.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
} else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
if (!nextBreakpoint.isDisposed() && enabled != nextBreakpoint.isEnabled()) {
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(enabled);
}
}
if (!killBtn.isDisposed() && enabled != killBtn.isEnabled()) {
killBtn.setEnabled(enabled);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.NEXTBREAKPOINT.equals(propName)) {
boolean running = ((Boolean) evt.getNewValue()).booleanValue();
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(running);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.BREAKPOINT_BAR.equals(propName)) {
boolean enable = ((Boolean) evt.getNewValue()).booleanValue();
if (!enable) {
if (!previousRow.isDisposed()) {
previousRow.setEnabled(false);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(false);
}
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(false);
}
}
}
}
});
}
};
activeContext.addPropertyChangeListener(propertyListener);
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method updateItemsVersion.
protected void updateItemsVersion() {
List<ItemVersionObject> JobsOpenedInEditor = new ArrayList<ItemVersionObject>();
List<ItemVersionObject> closedJobs = new ArrayList<ItemVersionObject>();
boolean hasJobOpenedInEditor = false;
StringBuilder builder = new StringBuilder();
for (ItemVersionObject object : checkedObjects) {
if (RepositoryManager.isOpenedItemInEditor(object.getRepositoryNode().getObject())) {
hasJobOpenedInEditor = true;
JobsOpenedInEditor.add(object);
//$NON-NLS-1$
builder.append(object.getRepositoryNode().getObject().getLabel() + ", ");
} else {
closedJobs.add(object);
}
}
if (builder.length() > 0) {
builder.delete(builder.length() - 2, builder.length());
}
if (hasJobOpenedInEditor) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.WarningTitle2"), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.openedInEditorMessage", builder.toString()));
IWorkbenchWindow workBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workBench != null) {
IWorkbenchPage page = workBench.getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreUIService.class)) {
IDesignerCoreUIService service = (IDesignerCoreUIService) GlobalServiceRegister.getDefault().getService(IDesignerCoreUIService.class);
if (service != null) {
for (IEditorReference editorRef : editorRefs) {
IEditorPart editor = editorRef.getEditor(false);
if (editor instanceof IMultiPageTalendEditor) {
IProcess2 process = ((IMultiPageTalendEditor) editor).getProcess();
String version = null;
for (ItemVersionObject object : JobsOpenedInEditor) {
if (object.getItem().getProperty().getId().equals(process.getId())) {
version = object.getNewVersion();
break;
}
}
if (version != null) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(process.getProperty().getVersion());
if (version.equals(jobDefaultVersion)) {
// if default, set null to remove key from property.
version = null;
}
Command command = service.crateMavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, version);
if (process instanceof IGEFProcess) {
service.executeCommand((IGEFProcess) process, command);
}
}
}
}
}
}
}
}
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
project, //$NON-NLS-1$
"Update items Maven version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items Maven version", closedJobs.size());
for (ItemVersionObject object : closedJobs) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
MavenVersionUtils.setItemMavenVersion(itemProperty, object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
FACTORY.save(project, itemProperty);
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException | InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createChildJob.
/**
* DOC qwei Comment method "createChildJob".
*/
private void createChildJob(Object dragModel, EditPart targetEditPart) {
if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
return;
}
RepositoryNode dragNode = (RepositoryNode) dragModel;
NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
if (dragNode.getObject().getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) dragNode.getObject().getProperty().getItem();
Command command = getChangeChildProcessCommand((Node) nodePart.getNodePart().getModel(), processItem);
if (command != null) {
execCommandStack(command);
}
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getSAPCommand.
/**
* Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
*
* @param object
* @param connectionItem
* @param table
* @param node
* @return
*/
private void getSAPCommand(CompoundCommand cc, IRepositoryViewObject object, ConnectionItem connectionItem, MetadataTable table, Node node) {
SAPFunctionUnit functionUnit = null;
if (object instanceof MetadataTableRepositoryObject) {
IElementParameter schemaParam = null;
List<IElementParameter> schemaTypeList = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
for (IElementParameter param : schemaTypeList) {
if (param.getName().equals("SCHEMA")) {
//$NON-NLS-1$
schemaParam = param;
break;
}
}
if (table.eContainer() instanceof SAPFunctionUnit) {
// function parameter table
functionUnit = (SAPFunctionUnit) table.eContainer();
// To judge what the current node is, tSAPOutput or tSAPInput component.
String sapComponentName = node.getComponent().getName();
if ("tSAPBapi".equals(sapComponentName)) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, (SAPFunctionUnit) table.eContainer(), ConvertionHelper.convert(table), null);
cc.add(command);
} else {
if (schemaParam != null) {
// repository id should be connectionid - sapfunctionName/type/tableName
String type = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
String value = connectionItem.getProperty().getId() + " - " + functionUnit.getLabel() + "/" + type + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(changeValueCmd);
}
IElementParameter schemasParam = node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
if (schemasParam != null) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table), functionUnit);
cc.add(sapCmd);
}
}
} else {
// Sap Table : keep repository id as before
if (schemaParam != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection(), table);
cc.add(changeValueCmd);
}
}
} else if (object instanceof SAPFunctionRepositoryObject) {
functionUnit = (SAPFunctionUnit) ((SAPFunctionRepositoryObject) object).getAbstractMetadataObject();
if (node.getComponent() != null && node.getComponent().getName().equals("tSAPBapi")) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, functionUnit, null, null);
cc.add(command);
} else {
for (MetadataTable metadataTable : functionUnit.getTables()) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, metadataTable.getLabel(), ConvertionHelper.convert(metadataTable), functionUnit);
cc.add(sapCmd);
}
}
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createQuery.
private void createQuery(Object dragModel, EditPart targetEditPart) {
if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
return;
}
RepositoryNode dragNode = (RepositoryNode) dragModel;
NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
if (dragNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) dragNode.getObject().getProperty().getItem();
Command command = getChangeQueryCommand(dragNode, (Node) nodePart.getNodePart().getModel(), connectionItem);
if (command != null) {
execCommandStack(command);
}
}
}
Aggregations