Minor improvements

This commit is contained in:
Alexey Andreev 2014-09-28 16:14:42 +04:00
parent 9d12bffc1b
commit edb9bcb02e
3 changed files with 43 additions and 9 deletions

View File

@ -23,15 +23,16 @@ import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.*; import java.util.*;
import org.eclipse.core.resources.*; import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
import org.teavm.dependency.*; import org.teavm.dependency.*;
import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassHolderTransformer;
import org.teavm.model.InstructionLocation; import org.teavm.model.InstructionLocation;
@ -131,6 +132,7 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
putMarkers(tool.getDependencyViolations()); putMarkers(tool.getDependencyViolations());
} else if (!tool.wasCancelled()) { } else if (!tool.wasCancelled()) {
setClasses(profile, classesToResources(tool.getClasses())); setClasses(profile, classesToResources(tool.getClasses()));
refreshTarget(tool.getTargetDirectory());
} }
if (!monitor.isCanceled()) { if (!monitor.isCanceled()) {
monitor.done(); monitor.done();
@ -140,6 +142,28 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
} }
} }
private void refreshTarget(File targetDirectory) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IContainer[] targetContainers = workspaceRoot.findContainersForLocationURI(targetDirectory.toURI());
for (final IContainer container : targetContainers) {
if (container.exists()) {
Job job = new Job("Refreshing target directory") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
container.refreshLocal(IContainer.DEPTH_INFINITE, monitor);
} catch (CoreException e) {
TeaVMEclipsePlugin.logError(e);
return TeaVMEclipsePlugin.makeError(e);
}
return Status.OK_STATUS;
}
};
job.schedule();
}
}
}
private RuntimeCopyOperation mapRuntime(TeaVMRuntimeMode runtimeMode) { private RuntimeCopyOperation mapRuntime(TeaVMRuntimeMode runtimeMode) {
switch (runtimeMode) { switch (runtimeMode) {
case MERGE: case MERGE:

View File

@ -26,10 +26,10 @@ import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IValueDetailListener; import org.eclipse.debug.ui.IValueDetailListener;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.FileEditorInput;
import org.teavm.debugging.CallFrame; import org.teavm.debugging.CallFrame;
@ -47,10 +47,19 @@ import org.teavm.model.ValueType;
public class TeaVMDebugModelPresentation extends LabelProvider implements IDebugModelPresentation { public class TeaVMDebugModelPresentation extends LabelProvider implements IDebugModelPresentation {
@Override @Override
public String getEditorId(IEditorInput input, Object element) { public String getEditorId(IEditorInput input, Object element) {
if (element instanceof IFile || element instanceof ILineBreakpoint || element instanceof IStorage) { IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
return JavaUI.ID_CU_EDITOR; if (element instanceof IFile) {
IFile file = (IFile)element;
return registry.getDefaultEditor(file.getName()).getId();
} else if (element instanceof ILineBreakpoint) {
String fileName = ((ILineBreakpoint)element).getMarker().getResource().getName();
return registry.getDefaultEditor(fileName).getId();
} else if (element instanceof IStorage) {
IStorage storage = (IStorage)element;
return registry.getDefaultEditor(storage.getName()).getId();
} else if (element instanceof URL) { } else if (element instanceof URL) {
return EditorsUI.DEFAULT_TEXT_EDITOR_ID; URL url = (URL)element;
return registry.getDefaultEditor(url.getFile()).getId();
} }
return null; return null;
} }

View File

@ -10,6 +10,7 @@
<properties> <properties>
<java.version>1.7</java.version> <java.version>1.7</java.version>
<teavm.version>0.2-SNAPSHOT</teavm.version> <teavm.version>0.2-SNAPSHOT</teavm.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>