Search in sources :

Example 6 with IUndoableOperation

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

Example 7 with IUndoableOperation

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);
            }
        });
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) 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) ServerEditorSection(org.eclipse.wst.server.ui.editor.ServerEditorSection) Section(org.eclipse.ui.forms.widgets.Section)

Example 8 with IUndoableOperation

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);
        }
    });
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) 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) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) GridData(org.eclipse.swt.layout.GridData)

Example 9 with IUndoableOperation

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

Example 10 with IUndoableOperation

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

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