| /*=============================================================================# |
| # Copyright (c) 2010, 2017 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.rj.eclient.core; |
| |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| |
| import org.eclipse.statet.ecommons.ts.core.Tool; |
| import org.eclipse.statet.ecommons.ts.core.ToolRunnable; |
| import org.eclipse.statet.ecommons.ts.core.ToolService; |
| |
| |
| /** |
| * Abstract runnable for R tool. |
| * |
| * Sub class should implement at least the method {@link #run(RToolService, IProgressMonitor)}, |
| * which is called by the R tool and gives access to the {@link RToolService} API. |
| * |
| * @since 1.2 |
| */ |
| public abstract class AbstractRToolRunnable implements ToolRunnable { |
| |
| |
| private final String fTypeId; |
| private final String fLabel; |
| |
| |
| public AbstractRToolRunnable(final String typeId, final String label) { |
| this.fTypeId= typeId; |
| this.fLabel= label; |
| } |
| |
| |
| @Override |
| public String getTypeId() { |
| return this.fTypeId; |
| } |
| |
| @Override |
| public String getLabel() { |
| return this.fLabel; |
| } |
| |
| @Override |
| public boolean canRunIn(final Tool tool) { |
| return tool.isProvidingFeatureSet("org.eclipse.statet.rj.services.RService"); //$NON-NLS-1$ |
| } |
| |
| @Override |
| public boolean changed(final int event, final Tool tool) { |
| return true; |
| } |
| |
| @Override |
| public void run(final ToolService service, |
| final IProgressMonitor monitor) throws CoreException { |
| run((RToolService) service, monitor); |
| } |
| |
| protected abstract void run(RToolService r, |
| IProgressMonitor monitor) throws CoreException; |
| |
| } |