Search in sources :

Example 16 with IUndoableOperation

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);
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractOperation(org.eclipse.core.commands.operations.AbstractOperation) DocumentUndoEvent(org.eclipse.text.undo.DocumentUndoEvent) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) IDocumentUndoListener(org.eclipse.text.undo.IDocumentUndoListener) DocumentUndoManager(org.eclipse.text.undo.DocumentUndoManager) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument)

Example 17 with IUndoableOperation

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);
    }
}
Also used : IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation)

Example 18 with IUndoableOperation

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);
    }
}
Also used : IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation)

Example 19 with IUndoableOperation

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);
}
Also used : Group(org.eclipse.swt.widgets.Group) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) ServerEditorSection(org.eclipse.wst.server.ui.editor.ServerEditorSection) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 20 with IUndoableOperation

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);
        }
    });
}
Also used : Button(org.eclipse.swt.widgets.Button) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

IUndoableOperation (org.eclipse.core.commands.operations.IUndoableOperation)27 ExecutionException (org.eclipse.core.commands.ExecutionException)7 IAdaptable (org.eclipse.core.runtime.IAdaptable)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 GridData (org.eclipse.swt.layout.GridData)4 IOperationHistory (org.eclipse.core.commands.operations.IOperationHistory)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)3 Section (org.eclipse.ui.forms.widgets.Section)3 CreateMarkersOperation (org.eclipse.ui.ide.undo.CreateMarkersOperation)3 ServerEditorSection (org.eclipse.wst.server.ui.editor.ServerEditorSection)3 Cell (eu.esdihumboldt.hale.common.align.model.Cell)2 AbstractRemoveResourcesOperation (eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation)2 HashMap (java.util.HashMap)2