use of org.eclipse.core.commands.operations.IUndoableOperation in project webtools.sourceediting by eclipse.
the class TextViewerUndoManagerTest method internalTestTransferNonTextOp.
// --- DocumentUndoManager only ---
public void internalTestTransferNonTextOp(final boolean isUndoable) throws Exception {
Object context = new Object();
DocumentUndoManager tempUndoManager = new DocumentUndoManager(new Document());
tempUndoManager.connect(context);
IUndoableOperation operation = new AbstractOperation("") {
public boolean canUndo() {
return isUndoable;
}
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
return Status.OK_STATUS;
}
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
return Status.OK_STATUS;
}
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
return Status.OK_STATUS;
}
};
operation.addContext(tempUndoManager.getUndoContext());
OperationHistoryFactory.getOperationHistory().add(operation);
assertEquals(isUndoable, tempUndoManager.undoable());
final DocumentUndoManager undoManager = new DocumentUndoManager(new Document());
Object newContext = new Object();
undoManager.connect(newContext);
undoManager.addDocumentUndoListener(new IDocumentUndoListener() {
public void documentUndoNotification(DocumentUndoEvent event) {
fail();
}
});
undoManager.transferUndoHistory(tempUndoManager);
tempUndoManager.disconnect(context);
assertEquals(isUndoable, undoManager.undoable());
undoManager.undo();
assertEquals(false, undoManager.undoable());
undoManager.disconnect(newContext);
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project webtools.servertools by eclipse.
the class ServerEditor method updateUndoAction.
/**
* Update the undo action.
*/
protected void updateUndoAction() {
IUndoableOperation command = commandManager.getUndoCommand(serverId);
if (command == null) {
undoAction.setText(Messages.editorUndoDisabled);
undoAction.setToolTipText("");
undoAction.setDescription("");
undoAction.setEnabled(false);
} else {
String text = NLS.bind(Messages.editorUndoEnabled, new Object[] { command.getLabel() });
undoAction.setText(text);
undoAction.setToolTipText(command.getLabel());
undoAction.setDescription(command.getLabel());
undoAction.setEnabled(true);
}
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project webtools.servertools by eclipse.
the class ServerEditor method updateRedoAction.
/**
* Update the redo action.
*/
protected void updateRedoAction() {
IUndoableOperation command = commandManager.getRedoCommand(serverId);
if (command == null) {
redoAction.setText(Messages.editorRedoDisabled);
redoAction.setToolTipText("");
redoAction.setDescription("");
redoAction.setEnabled(false);
} else {
String text = NLS.bind(Messages.editorRedoEnabled, new Object[] { command.getLabel() });
redoAction.setText(text);
redoAction.setToolTipText(command.getLabel());
redoAction.setDescription(command.getLabel());
redoAction.setEnabled(true);
}
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project mdw-designer by CenturyLinkCloud.
the class MdwServerOptionsSection 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 Options");
section.setDescription(getDescription());
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
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);
Label javaOptionsLabel = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 4;
javaOptionsLabel.setLayoutData(gd);
javaOptionsLabel.setText("Java Options:");
javaOptionsTextField = new Text(composite, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
gd.widthHint = 300;
gd.heightHint = 48;
javaOptionsTextField.setLayoutData(gd);
String javaOpts = server.getAttribute(JAVA_OPTIONS, getDefaultJavaOptions());
javaOptionsTextField.setText(javaOpts);
javaOptionsTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String opts = javaOptionsTextField.getText().trim();
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, JAVA_OPTIONS, opts, getDefaultJavaOptions());
execute(cmd);
}
});
// debug options
debugCheckbox = new Button(composite, SWT.CHECK);
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
gd.verticalIndent = 5;
debugCheckbox.setLayoutData(gd);
debugCheckbox.setText(getDebugModeLabel());
boolean debug = server.getAttribute(DEBUG_MODE, getDefaultDebugMode());
debugCheckbox.setSelection(debug);
debugCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean debug = debugCheckbox.getSelection();
enableDebugControls(debug);
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, DEBUG_MODE, debug, getDefaultDebugMode());
execute(cmd);
}
});
debugGroup = new Group(composite, SWT.NONE);
GridLayout gl = new GridLayout();
gl.numColumns = 3;
debugGroup.setLayout(gl);
debugGroup.setText("Debug Settings");
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 4;
debugGroup.setLayoutData(gd);
debugPortLabel = new Label(debugGroup, SWT.NONE);
debugPortLabel.setText("Debug Port:");
debugPortTextField = new Text(debugGroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.BEGINNING);
gd.verticalIndent = 5;
gd.widthHint = 50;
debugPortTextField.setLayoutData(gd);
int port = server.getAttribute(DEBUG_PORT, DEFAULT_DEBUG_PORT);
debugPortTextField.setText(Integer.toString(port));
debugPortTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String port = debugPortTextField.getText().trim();
try {
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, DEBUG_PORT, Integer.parseInt(port), DEFAULT_DEBUG_PORT);
execute(cmd);
} catch (NumberFormatException ex) {
PluginMessages.log(ex);
}
}
});
suspendCheckbox = new Button(debugGroup, SWT.CHECK);
gd = new GridData(GridData.BEGINNING);
gd.horizontalIndent = 20;
gd.verticalIndent = 5;
suspendCheckbox.setLayoutData(gd);
suspendCheckbox.setText("Suspend on Startup");
boolean suspend = server.getAttribute(DEBUG_SUSPEND, DEFAULT_DEBUG_SUSPEND);
suspendCheckbox.setSelection(suspend);
suspendCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean suspend = suspendCheckbox.getSelection();
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, DEBUG_SUSPEND, suspend, DEFAULT_DEBUG_SUSPEND);
execute(cmd);
}
});
// initial enablement
enableDebugControls(debug);
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project mdw-designer by CenturyLinkCloud.
the class TomcatServerOptionsSection method createSection.
@Override
public void createSection(Composite parent) {
super.createSection(parent);
// force stop
forceStopCheckbox = new Button(composite, SWT.CHECK);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
gd.verticalIndent = 5;
forceStopCheckbox.setLayoutData(gd);
forceStopCheckbox.setText("Force Terminate when Stopping");
boolean force = server.getAttribute(FORCE_STOP, false);
forceStopCheckbox.setSelection(force);
forceStopCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean force = forceStopCheckbox.getSelection();
IUndoableOperation cmd = new ServerAttributeSetterCommand(server, FORCE_STOP, force, false);
execute(cmd);
}
});
}
Aggregations