use of org.eclipse.core.commands.operations.IUndoableOperation in project tmdm-studio-se by Talend.
the class DataModelMainPage method dispose.
@Override
public void dispose() {
// clear operationhistory
IOperationHistory history = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
for (IUndoableOperation op : history.getRedoHistory(undoContext)) {
op.dispose();
op = null;
}
for (IUndoableOperation op : history.getUndoHistory(undoContext)) {
op.dispose();
op = null;
}
history.dispose(undoContext, true, true, true);
// clear the big objects,
schemaTreeContentProvider = null;
typesTreeContentProvider = null;
schemaTreeSorter = null;
typeTreeSorter = null;
undoContext = null;
xsdSchema = null;
contextToUndoAction.clear();
contextToRedoAction.clear();
super.dispose();
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project mdw-designer by CenturyLinkCloud.
the class ServiceMixMdwBundleSection method createSection.
@Override
public void createSection(Composite parent) {
super.createSection(parent);
FormToolkit toolkit = new FormToolkit(getShell().getDisplay());
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE | ExpandableComposite.EXPANDED);
section.setText("MDW Bundle");
section.setDescription("Settings for MDW bundle deployment");
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 15;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
// refresh output dir
if (server != null) {
refreshOutputDirectoryCheckbox = toolkit.createButton(composite, "Refresh output directory before publish", SWT.CHECK);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
refreshOutputDirectoryCheckbox.setLayoutData(data);
boolean sel = server.getAttribute(ServiceMixServerBehavior.REFRESH_OUTPUT_DIR_BEFORE_PUBLISH, "true").equalsIgnoreCase("true");
refreshOutputDirectoryCheckbox.setSelection(sel);
refreshOutputDirectoryCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean sel = refreshOutputDirectoryCheckbox.getSelection();
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, ServiceMixServerBehavior.REFRESH_OUTPUT_DIR_BEFORE_PUBLISH, sel, true);
execute(cmd);
}
});
}
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project mdw-designer by CenturyLinkCloud.
the class ServiceMixMdwServerSection method createSection.
@Override
public void createSection(Composite parent) {
super.createSection(parent);
FormToolkit toolkit = new FormToolkit(getShell().getDisplay());
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE | ExpandableComposite.EXPANDED);
section.setText("MDW Server for " + getServerLabel());
section.setDescription(server.getAttribute(ServiceMixServer.LOCATION, ""));
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 15;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
new Label(composite, SWT.NONE).setText("HTTP Port:");
serverPortTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData(GridData.BEGINNING);
gd.widthHint = 125;
serverPortTextField.setLayoutData(gd);
int port = server.getAttribute(ServiceMixServer.SERVER_PORT, 0);
if (port > 0)
serverPortTextField.setText(Integer.toString(port));
serverPortTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
try {
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, ServiceMixServer.SERVER_PORT, Integer.parseInt(serverPortTextField.getText().trim()), 0);
execute(cmd);
} catch (NumberFormatException ex) {
PluginMessages.log(ex);
}
}
});
new Label(composite, SWT.NONE).setText("SSH Port:");
sshPortTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.BEGINNING);
gd.widthHint = 125;
sshPortTextField.setLayoutData(gd);
int sshPort = server.getAttribute(ServiceMixServer.SSH_PORT, 0);
if (sshPort > 0)
sshPortTextField.setText(Integer.toString(sshPort));
sshPortTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
try {
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, ServiceMixServer.SSH_PORT, Integer.parseInt(sshPortTextField.getText().trim()), 0);
execute(cmd);
} catch (NumberFormatException ex) {
PluginMessages.log(ex);
}
}
});
new Label(composite, SWT.NONE).setText("Karaf User:");
userTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.BEGINNING);
gd.widthHint = 125;
userTextField.setLayoutData(gd);
userTextField.setText(server.getAttribute(ServiceMixServer.USER, ""));
userTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, ServiceMixServer.USER, userTextField.getText(), "");
execute(cmd);
}
});
new Label(composite, SWT.NONE).setText("Password:");
passwordTextField = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
gd = new GridData(GridData.BEGINNING);
gd.widthHint = 125;
passwordTextField.setLayoutData(gd);
passwordTextField.setText(server.getAttribute(ServiceMixServer.PASSWORD, ""));
passwordTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, ServiceMixServer.PASSWORD, passwordTextField.getText(), "");
execute(cmd);
}
});
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project polymap4-core by Polymap4.
the class OperationSupport method redo.
public void redo() throws ExecutionException {
IUndoableOperation op = getRedoOperation();
assert op != null && op.canRedo();
OperationJob job = new OperationJob(op) {
protected void run() throws Exception {
// try to preset task name without beginTask()
monitor.setTaskName(op.getLabel());
history.redo(context, monitor, null);
}
};
run(job, true, true);
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project polymap4-core by Polymap4.
the class OperationSupport method execute.
/**
* Executes the given operation inside an {@link UIJob job}.
*
* @param op
* @param async Indicates that the calling thread should not block execution and
* return imediatelly.
* @param progress Indicates the the operation is executed inside a progress
* dialog. Make sure that the operation does not open dialogs as they might get covered up
* by the progress dialog.
* @throws ExecutionException
*/
public void execute(final IUndoableOperation op, boolean async, boolean progress, IJobChangeListener... listeners) {
OperationJob job = new OperationJob(op) {
protected void run() throws Exception {
// try to preset task name without beginTask()
monitor.setTaskName(op.getLabel());
OperationExecutor executor = OperationExecutor.newInstance(op);
IUndoableOperation executorOp = executor.operation();
executorOp.addContext(context);
history.execute(executorOp, monitor, executor.newOperationInfo(-1));
}
};
for (IJobChangeListener l : listeners) {
job.addJobChangeListenerWithContext(l);
}
// check nested
UIJob parent = UIJob.ofThread();
if (parent != null && parent instanceof OperationJob) {
log.info("Nested operation: " + op);
run(job, async, progress);
// IUndoableOperation parentOp = ((OperationJob)parent).op;
//
// SubProgressMonitor subMonitor = new SubProgressMonitor(
// UIJob.monitorForThread(), IProgressMonitor.UNKNOWN, parentOp.getLabel() );
//
// OperationExecutor executor = OperationExecutor.newInstance( op );
// IUndoableOperation executorOp = executor.getOperation();
// executorOp.addContext( context );
//
// history.execute( executorOp, subMonitor, executor.getInfo() );
} else // start job
{
run(job, async, progress);
}
}
Aggregations