use of org.eclipse.gef.commands.CommandStack 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.CommandStack in project tdi-studio-se by Talend.
the class DynamicComposite method dispose.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
@Override
public void dispose() {
CommandStack cmdStack = getCommandStack();
if (cmdStack != null) {
cmdStack.removeCommandStackEventListener(commandStackEventListener);
}
if (widgetFactory != null)
widgetFactory.dispose();
super.dispose();
process = null;
elem = null;
part = null;
generator.dispose();
generator = null;
hashCurControls.clear();
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method getCommandStack.
/**
* Get the command stack of the Gef editor.
*
* @return
*/
protected CommandStack getCommandStack() {
AbstractTalendEditor talendEditor = part.getTalendEditor();
Object adapter = talendEditor.getAdapter(CommandStack.class);
return (CommandStack) adapter;
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
Aggregations