Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
Removed remaining deps on JFace.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Sep 13, 2016
1 parent 99d01fd commit fbddf11
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 52 deletions.
1 change: 0 additions & 1 deletion plugin_ide.core/META-INF/MANIFEST.MF
Expand Up @@ -15,7 +15,6 @@ Require-Bundle: LANG_PROJECT_ID.tooling;visibility:=reexport,
org.eclipse.core.filesystem;bundle-version="1.4.0",
org.eclipse.core.filebuffers;bundle-version="3.5.0",
org.eclipse.core.expressions;bundle-version="3.4.0",
org.eclipse.jface;bundle-version="3.9.1",
org.eclipse.debug.core;bundle-version="3.6.0",
org.eclipse.text;bundle-version="3.6.0"
Bundle-ClassPath: .
Expand Down
Expand Up @@ -15,7 +15,6 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.file.Path;
Expand All @@ -41,15 +40,12 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;

import melnorme.lang.ide.core.EclipseCore;
import melnorme.lang.tooling.LocationHandle;
import melnorme.lang.tooling.common.ops.Operation;
import melnorme.lang.tooling.common.ops.IOperationMonitor;
import melnorme.lang.tooling.common.ops.Operation;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.core.fntypes.RunnableX;
Expand Down Expand Up @@ -256,47 +252,6 @@ public abstract void execute_do(IProgressMonitor pm)

}

public static void runOperation(IRunnableContext context, Operation op, boolean isCancellable)
throws OperationCancellation, CommonException {
try {
context.run(true, isCancellable, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
op.execute(EclipseUtils.om(monitor));
} catch(CommonException e) {
throw new InvocationTargetException(e);
} catch(OperationCancellation | OperationCanceledException e) {
throw new InterruptedException();
}
}
});
} catch (InterruptedException e) {
throw new OperationCancellation();
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if(targetException instanceof InterruptedException) {
throw new OperationCancellation();
}
if(targetException instanceof CommonException) {
throw (CommonException) targetException;
}
if(targetException instanceof RuntimeException) {
throw (RuntimeException) targetException;
}

assertFail(); // Should not be possible
}
}

public static void runOperationInWorkspace(IRunnableContext context, boolean isCancellable, Operation op)
throws OperationCancellation, CommonException {

runOperation(context, (pm) -> {
ResourceUtils.runOperation(ResourceUtils.getWorkspaceRoot(), pm, op);
}, isCancellable);
}

/* ----------------- Direct resource operations ----------------- */

public static void refresh(IResource resource, IOperationMonitor om) throws CommonException {
Expand Down
Expand Up @@ -27,6 +27,7 @@
import melnorme.lang.ide.core.utils.ResourceUtils;
import melnorme.lang.ide.core.utils.ResourceUtils.CoreOperation;
import melnorme.lang.ide.ui.utils.UIOperationsStatusHandler;
import melnorme.lang.ide.ui.utils.operations.RunnableContextUtils;
import melnorme.utilbox.collections.ArrayList2;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
Expand Down Expand Up @@ -67,7 +68,7 @@ public IProject getCreatedProject() {

protected boolean runOperation(boolean isCancellabe, String errorTitle, CoreOperation operation) {
try {
ResourceUtils.runOperationInWorkspace(getRunnableContext(), isCancellabe, operation);
RunnableContextUtils.runOperationInWorkspace(getRunnableContext(), isCancellabe, operation);
return true;
} catch(OperationCancellation e) {
return false;
Expand Down
Expand Up @@ -40,7 +40,6 @@
import melnorme.lang.ide.core.LangCore;
import melnorme.lang.ide.core.operations.ToolchainPreferences;
import melnorme.lang.ide.core.utils.EclipseUtils;
import melnorme.lang.ide.core.utils.prefs.EclipsePreferencesAdapter;
import melnorme.lang.ide.ui.EditorSettings_Actual;
import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;
import melnorme.lang.ide.ui.LangImages;
Expand All @@ -51,6 +50,7 @@
import melnorme.lang.ide.ui.editor.text.LangPairMatcher;
import melnorme.lang.ide.ui.text.AbstractLangSourceViewerConfiguration;
import melnorme.lang.ide.ui.utils.PluginImagesHelper.ImageHandle;
import melnorme.lang.ide.ui.utils.prefs.EclipsePreferencesAdapter;
import melnorme.lang.utils.EnablementCounter;
import melnorme.utilbox.concurrency.ICancelMonitor;
import melnorme.utilbox.misc.ArrayUtil;
Expand Down
@@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2016 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package melnorme.lang.ide.ui.utils.operations;

import static melnorme.utilbox.core.Assert.AssertNamespace.assertFail;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;

import melnorme.lang.ide.core.utils.EclipseUtils;
import melnorme.lang.ide.core.utils.ResourceUtils;
import melnorme.lang.tooling.common.ops.Operation;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;

public class RunnableContextUtils {

public static void runOperation(IRunnableContext context, Operation op, boolean isCancellable)
throws OperationCancellation, CommonException {
try {
context.run(true, isCancellable, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
op.execute(EclipseUtils.om(monitor));
} catch(CommonException e) {
throw new InvocationTargetException(e);
} catch(OperationCancellation | OperationCanceledException e) {
throw new InterruptedException();
}
}
});
} catch (InterruptedException e) {
throw new OperationCancellation();
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if(targetException instanceof InterruptedException) {
throw new OperationCancellation();
}
if(targetException instanceof CommonException) {
throw (CommonException) targetException;
}
if(targetException instanceof RuntimeException) {
throw (RuntimeException) targetException;
}

assertFail(); // Should not be possible
}
}

public static void runOperationInWorkspace(IRunnableContext context, boolean isCancellable, Operation op)
throws OperationCancellation, CommonException {

runOperation(context, (pm) -> {
ResourceUtils.runOperation(ResourceUtils.getWorkspaceRoot(), pm, op);
}, isCancellable);
}

}
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package melnorme.lang.ide.core.utils.prefs;
package melnorme.lang.ide.ui.utils.prefs;

import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Expand Down
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package melnorme.lang.ide.core.utils.prefs;
package melnorme.lang.ide.ui.utils.prefs;

import java.util.List;

Expand Down
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package melnorme.lang.ide.core.utils.prefs;
package melnorme.lang.ide.ui.utils.prefs;

import org.eclipse.jface.preference.IPreferenceStore;

Expand Down

0 comments on commit fbddf11

Please sign in to comment.