eclipse plugin: actual implementation...

...of the "show preprocessed config" menus
This commit is contained in:
Timotei Dolean 2010-05-27 20:04:31 +00:00
parent 7e05b5b757
commit 61408ca8f0
4 changed files with 43 additions and 3 deletions

View file

@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
org.wesnoth.wml.ide;bundle-version="1.0.0",
org.wesnoth.wml.ide.generator;bundle-version="1.0.0",
org.wesnoth.wml.ide.ui;bundle-version="1.0.0",
org.apache.ant;bundle-version="1.7.1"
org.apache.ant;bundle-version="1.7.1",
org.eclipse.core.filesystem;bundle-version="1.2.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -5,6 +5,9 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import wesnoth_eclipse_plugin.globalactions.PreprocessorActions;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class ShowPlainPreprocessedConfig implements IObjectActionDelegate
{
public ShowPlainPreprocessedConfig(){}
@ -16,7 +19,8 @@ public class ShowPlainPreprocessedConfig implements IObjectActionDelegate
@Override
public void run(IAction action)
{
PreprocessorActions.openPreprocessedFileInEditor(WorkspaceUtils.getSelectedFile(WorkspaceUtils.getWorkbenchWindow()),
true);
}
@Override

View file

@ -5,6 +5,9 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import wesnoth_eclipse_plugin.globalactions.PreprocessorActions;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class ShowPreprocessedConfig implements IObjectActionDelegate
{
public ShowPreprocessedConfig() { }
@ -16,7 +19,8 @@ public class ShowPreprocessedConfig implements IObjectActionDelegate
@Override
public void run(IAction action)
{
PreprocessorActions.openPreprocessedFileInEditor(WorkspaceUtils.getSelectedFile(WorkspaceUtils.getWorkbenchWindow()),
false);
}
@Override

View file

@ -6,9 +6,16 @@ package wesnoth_eclipse_plugin.globalactions;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.ide.IDE;
import wesnoth_eclipse_plugin.builder.ExternalToolInvoker;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class PreprocessorActions
{
@ -53,4 +60,28 @@ public class PreprocessorActions
return false;
}
}
/**
* Opens the preprocessed version of the specified file
* @param file the file to show preprocessed output
* @param openPlain true if it should open the plain preprocessed version
* or false for the normal one
*/
public static void openPreprocessedFileInEditor(IFile file, boolean openPlain)
{
if (file == null)
return;
IFileStore preprocFile = EFS.getLocalFileSystem().getStore(new Path(WorkspaceUtils.getTemporaryFolder()));
preprocFile = preprocFile.getChild(file.getName() + (openPlain == true? ".plain" : "") );
try
{
IDE.openEditorOnFileStore(WorkspaceUtils.getWorkbenchWindow().getActivePage(), preprocFile);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}