use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class BasicNotePropertyComposite method updateFontBold.
private void updateFontBold() {
Boolean value = fontBoldButton.getSelection();
Command cmd = new PropertyChangeCommand(note, EParameterName.FONT_BOLD.getName(), value);
getCommandStack().execute(cmd);
note.refresh();
textChanged();
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class BasicNotePropertyComposite method addListener.
private void addListener() {
leftBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = leftBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_RIGHT.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_CENTER.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
rightBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = rightBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_LEFT.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_CENTER.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
centreBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = centreBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_LEFT.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_RIGHT.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
topBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = topBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTELABEL_CENTER.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_BOTTOM.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
bottomBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = bottomBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTELABEL_CENTER.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_TOP.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
centreLabelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Boolean value = centreLabelBtn.getSelection();
if (value) {
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), value);
getCommandStack().execute(cmd);
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_BOTTOM.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), !value);
getCommandStack().execute(cmd);
}
if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_TOP.getName())) {
cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), !value);
getCommandStack().execute(cmd);
}
note.refresh();
}
}
});
}
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);
}
}
}
Aggregations