From edb9bcb02ecb1f1f66908f0a9609f5c4d5f1b00c Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 28 Sep 2014 16:14:42 +0400 Subject: [PATCH] Minor improvements --- .../teavm/eclipse/TeaVMProjectBuilder.java | 32 ++++++++++++++++--- .../ui/TeaVMDebugModelPresentation.java | 19 ++++++++--- .../resources/archetype-resources/pom.xml | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java index 650662b1a..4e40e7168 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java @@ -23,15 +23,16 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.*; import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; 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.model.ClassHolderTransformer; import org.teavm.model.InstructionLocation; @@ -131,6 +132,7 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder { putMarkers(tool.getDependencyViolations()); } else if (!tool.wasCancelled()) { setClasses(profile, classesToResources(tool.getClasses())); + refreshTarget(tool.getTargetDirectory()); } if (!monitor.isCanceled()) { 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) { switch (runtimeMode) { case MERGE: diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java index 85bb05cc3..76ff3502f 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java @@ -26,10 +26,10 @@ import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IValueDetailListener; -import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.viewers.LabelProvider; 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.part.FileEditorInput; import org.teavm.debugging.CallFrame; @@ -47,10 +47,19 @@ import org.teavm.model.ValueType; public class TeaVMDebugModelPresentation extends LabelProvider implements IDebugModelPresentation { @Override public String getEditorId(IEditorInput input, Object element) { - if (element instanceof IFile || element instanceof ILineBreakpoint || element instanceof IStorage) { - return JavaUI.ID_CU_EDITOR; + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); + 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) { - return EditorsUI.DEFAULT_TEXT_EDITOR_ID; + URL url = (URL)element; + return registry.getDefaultEditor(url.getFile()).getId(); } return null; } diff --git a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml index d62cdf9b7..9210cedc6 100644 --- a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml +++ b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml @@ -10,6 +10,7 @@ 1.7 0.2-SNAPSHOT + UTF-8