Search in sources :

Example 1 with AbstractRemoveResourcesOperation

use of eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation in project hale by halestudio.

the class OrientInstanceService method clearInstances.

/**
 * @see InstanceService#clearInstances()
 */
@Override
public void clearInstances() {
    IUndoableOperation operation = new AbstractRemoveResourcesOperation("Clear source data", InstanceService.ACTION_READ_SOURCEDATA) {

        /**
         * @see eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
         *      org.eclipse.core.runtime.IAdaptable)
         */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            notifyDatasetAboutToChange(null);
            source.clear();
            transformed.clear();
            notifyDatasetChanged(null);
            return super.execute(monitor, info);
        }
    };
    IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
    operation.addContext(operationSupport.getUndoContext());
    try {
        operationSupport.getOperationHistory().execute(operation, null, null);
    } catch (ExecutionException e) {
        log.error("Error executing operation on instance service", e);
    }
}
Also used : AbstractRemoveResourcesOperation(eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation) IAdaptable(org.eclipse.core.runtime.IAdaptable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) IWorkbenchOperationSupport(org.eclipse.ui.operations.IWorkbenchOperationSupport) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 2 with AbstractRemoveResourcesOperation

use of eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation in project hale by halestudio.

the class SchemaServiceImpl method clearSchemas.

/**
 * @see SchemaService#clearSchemas(SchemaSpaceID)
 */
@Override
public void clearSchemas(final SchemaSpaceID spaceID) {
    Preconditions.checkNotNull(spaceID);
    IUndoableOperation operation = new AbstractRemoveResourcesOperation("Clear " + (spaceID == SchemaSpaceID.SOURCE ? "source" : "target") + " schema", spaceID == SchemaSpaceID.SOURCE ? ACTION_READ_SOURCE : ACTION_READ_TARGET) {

        /**
         * @see eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
         *      org.eclipse.core.runtime.IAdaptable)
         */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            synchronized (spaces) {
                spaces.remove(spaceID);
            }
            notifySchemasCleared(spaceID);
            return super.execute(monitor, info);
        }
    };
    IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
    operation.addContext(operationSupport.getUndoContext());
    try {
        operationSupport.getOperationHistory().execute(operation, null, null);
    } catch (ExecutionException e) {
        log.error("Error executing operation on schema service", e);
    }
}
Also used : AbstractRemoveResourcesOperation(eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation) IAdaptable(org.eclipse.core.runtime.IAdaptable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) IWorkbenchOperationSupport(org.eclipse.ui.operations.IWorkbenchOperationSupport) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

AbstractRemoveResourcesOperation (eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IUndoableOperation (org.eclipse.core.commands.operations.IUndoableOperation)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IWorkbenchOperationSupport (org.eclipse.ui.operations.IWorkbenchOperationSupport)2