eclipse plugin: fixes, cleanups and minor features

This commit is contained in:
Timotei Dolean 2010-07-09 18:23:21 +00:00
parent e30cca95d5
commit e0a3c8240c
27 changed files with 506 additions and 290 deletions

View file

@ -47,6 +47,12 @@
label="Wesnoth project report"
menubarPath="_wesnoth">
</action>
<action
class="wesnoth_eclipse_plugin.action.RunWMLIndentOnSelection"
id="Wesnoth Eclipse Plugin.action7"
label="Run &quot;wmlindent&quot; on the project this file"
menubarPath="_wesnoth">
</action>
</objectContribution>
<objectContribution
adaptable="true"
@ -132,7 +138,7 @@
menubarPath="plugin.wmltoolsMenu/wmltoolsMenuMarker">
</action>
<action
class="wesnoth_eclipse_plugin.action.RunWMLIndentOnFile"
class="wesnoth_eclipse_plugin.action.RunWMLIndentOnSelection"
id="Wesnoth Eclipse Plugin.action7"
label="Run &quot;wmlindent&quot; on this file"
menubarPath="plugin.wmltoolsMenu/wmltoolsMenuMarker">
@ -291,17 +297,22 @@
name="openMapInEditor">
</command>
<command
defaultHandler="wesnoth_eclipse_plugin.handlers.ReloadFiles"
defaultHandler="wesnoth_eclipse_plugin.handlers.ReloadFilesHandler"
description="Setups the workspace"
id="Wesnoth_Eclipse_Plugin.commands.setupWorkspace"
name="setupWorkspace">
</command>
<command
defaultHandler="wesnoth_eclipse_plugin.handlers.ReloadFiles"
defaultHandler="wesnoth_eclipse_plugin.handlers.ReloadFilesHandler"
description="Reloads all plugin related files"
id="Wesnoth_Eclipse_Plugin.commands.reloadFiles"
name="reloadFiles">
</command>
<command
defaultHandler="wesnoth_eclipse_plugin.handlers.TestHandler"
id="Wesnoth_Eclipse_Plugin.commands.test"
name="test command">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
@ -361,6 +372,11 @@
value="plugin_preferences">
</parameter>
</command>
<command
commandId="Wesnoth_Eclipse_Plugin.commands.test"
label="Test"
style="push">
</command>
</menu>
</menuContribution>
</extension>
@ -375,7 +391,7 @@
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="wesnoth_eclipse_plugin.preferences.PreferenceInitializer">
class="wesnoth_eclipse_plugin.preferences.Preferences">
</initializer>
</extension>

View file

@ -8,8 +8,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
import wesnoth_eclipse_plugin.wizards.generator.SchemaParser;
@ -86,10 +85,10 @@ public class Activator extends AbstractUIPlugin
*/
private static void checkConditions()
{
String execDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_EXEC_PATH);
String userDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR);
String wmltoolsDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR);
String workingDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WORKING_DIR);
String execDir = Preferences.getString(Constants.P_WESNOTH_EXEC_PATH);
String userDir = Preferences.getString(Constants.P_WESNOTH_USER_DIR);
String wmltoolsDir = Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR);
String workingDir = Preferences.getString(Constants.P_WESNOTH_WORKING_DIR);
if (!validPath(execDir) || !validPath(userDir) || !validPath(wmltoolsDir) || !validPath(workingDir))
{

View file

@ -0,0 +1,21 @@
package wesnoth_eclipse_plugin;
/**
* Constant definitions for plug-in preferences
*/
public class Constants
{
/** Preferences Constants **/
public static final String P_WESNOTH_EXEC_PATH = "wesnoth_exec_path";
public static final String P_WESNOTH_WORKING_DIR = "wesnoth_working_dir";
public static final String P_WESNOTH_WMLTOOLS_DIR = "wesnoth_wmltools_dir";
public static final String P_WESNOTH_USER_DIR = "wesnoth_user_dir";
/** Wizards Constants **/
public static final int WIZ_TextBoxHeight = 21;
public static final int WIZ_MaxTextBoxesOnPage = 10;
public static final int WIZ_MaxGroupsOnPage = 4;
public static final int WIZ_MaxWizardPageHeight = 220;
}

View file

@ -10,9 +10,9 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.builder.ExternalToolInvoker;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.ProjectUtils;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
@ -59,14 +59,14 @@ public class OpenScenarioInGame implements IObjectActionDelegate
args.add(campaignId);
args.add(scenarioId);
String wesnothExec = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_EXEC_PATH);
String wesnothExec = Preferences.getString(Constants.P_WESNOTH_EXEC_PATH);
if (wesnothExec.isEmpty())
{
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(), "Please set the wesnoth's executable path first.");
return;
}
String workingDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WORKING_DIR);
String workingDir = Preferences.getString(Constants.P_WESNOTH_WORKING_DIR);
if (workingDir.isEmpty())
workingDir = wesnothExec.substring(0,wesnothExec.lastIndexOf(new File(wesnothExec).getName()));

View file

@ -1,33 +0,0 @@
/**
* @author Timotei Dolean
*/
package wesnoth_eclipse_plugin.action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import wesnoth_eclipse_plugin.utils.WMLTools;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class RunWMLIndentOnFile implements IObjectActionDelegate
{
public RunWMLIndentOnFile() { }
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart){
}
@Override
public void run(IAction action)
{
WMLTools.runWMLIndent(WorkspaceUtils.getPathRelativeToUserDir(WorkspaceUtils.getSelectedFile()),
true, true,false);
}
@Override
public void selectionChanged(IAction action, ISelection selection){
}
}

View file

@ -0,0 +1,63 @@
/**
* @author Timotei Dolean
*/
package wesnoth_eclipse_plugin.action;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import wesnoth_eclipse_plugin.utils.EditorUtils;
import wesnoth_eclipse_plugin.utils.WMLTools;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class RunWMLIndentOnSelection implements IObjectActionDelegate
{
public RunWMLIndentOnSelection() {
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
}
@Override
public void run(IAction action)
{
IFile selFile = WorkspaceUtils.getSelectedFile();
if (selFile != null)
{
EditorUtils.openEditor(selFile, true);
String stdin = EditorUtils.getEditorDocument().get();
EditorUtils.replaceEditorText(WMLTools.runWMLIndent(null, stdin, false, false, false));
//WMLTools.runWMLIndent(WorkspaceUtils.getPathRelativeToUserDir(WorkspaceUtils.getSelectedFile()), null,
// false, true, false);
}
else
// project selection
{
// save currently opened files
final IEditorReference[] files =
WorkspaceUtils.getWorkbenchWindow().getPages()[0].getEditorReferences();
for (IEditorReference file : files)
{
if (file.isDirty())
file.getEditor(false).doSave(null);
}
// run wmlindent on project
IProject project = WorkspaceUtils.getSelectedProject();
WMLTools.runWMLIndent(project.getLocation().toOSString(), null, false, true, false);
}
}
@Override
public void selectionChanged(IAction action, ISelection selection)
{
}
}

View file

@ -13,20 +13,23 @@ import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class RunWMLLintOnFile implements IObjectActionDelegate
{
public RunWMLLintOnFile(){ }
public RunWMLLintOnFile() {
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart){
public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
}
@Override
public void run(IAction action)
{
WMLTools.runWMLLint(WorkspaceUtils.getPathRelativeToUserDir(WorkspaceUtils.getSelectedFile()),
true, true,false);
true, true, true);
}
@Override
public void selectionChanged(IAction action, ISelection selection){
public void selectionChanged(IAction action, ISelection selection)
{
}
}

View file

@ -10,20 +10,22 @@ import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class ShowPreprocessedConfig implements IObjectActionDelegate
{
public ShowPreprocessedConfig() { }
public ShowPreprocessedConfig() {
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart){
public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
}
@Override
public void run(IAction action)
{
PreprocessorActions.openPreprocessedFileInEditor(WorkspaceUtils.getSelectedFile(WorkspaceUtils.getWorkbenchWindow()),
false);
PreprocessorActions.openPreprocessedFileInEditor(WorkspaceUtils.getSelectedFile(), false);
}
@Override
public void selectionChanged(IAction action, ISelection selection){
public void selectionChanged(IAction action, ISelection selection)
{
}
}

View file

@ -1,4 +1,5 @@
package wesnoth_eclipse_plugin.builder;
package wesnoth_eclipse_plugin.builder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -13,45 +14,54 @@ import wesnoth_eclipse_plugin.utils.GUIUtils;
/**
* @author Timotei Dolean
*
*
*/
public class ExternalToolInvoker {
private Process process_;
private ProcessBuilder processBuilder_;
private Thread processThread_;
private BufferedReader bufferedReaderOutput_;
private BufferedReader bufferedReaderError_;
public class ExternalToolInvoker
{
private Process process_;
private ProcessBuilder processBuilder_;
private Thread processThread_;
private BufferedReader bufferedReaderOutput_;
private BufferedReader bufferedReaderError_;
private boolean threadStarted_;
/**
* Creates an external tool invoker with specified options
*
* @param fileName the file name to be invoked
* @param arguments the arguments passed to the file
* @param useThread true if the process will run in a thread
* @throws IOException
*/
public ExternalToolInvoker(String fileName, List<String> arguments, boolean useThread) throws IOException
{
public ExternalToolInvoker(String fileName, List<String> arguments, boolean useThread) throws IOException {
List<String> commandline = new ArrayList<String>();
commandline.add(fileName);
commandline.addAll(arguments);
if (arguments != null)
commandline.addAll(arguments);
processBuilder_ = new ProcessBuilder(commandline);
if (useThread)
{
threadStarted_ = true;
processThread_ = new Thread(new Runnable() {
@Override
public void run() {
try {
public void run()
{
try
{
process_ = processBuilder_.start();
bufferedReaderOutput_ = new BufferedReader(new InputStreamReader(process_.getInputStream()));
bufferedReaderError_ = new BufferedReader(new InputStreamReader(process_.getErrorStream()));
} catch (IOException e) {
threadStarted_ = true;
} catch (IOException e)
{
e.printStackTrace();
}
}
});
}
}
public void run() throws IOException
@ -66,8 +76,10 @@ public class ExternalToolInvoker {
else
processThread_.start();
}
/**
* Waits for the current tool, and returns the return value
*
* @return the return value of the tool
*/
public int waitFor()
@ -75,38 +87,46 @@ public class ExternalToolInvoker {
if (process_ == null)
return 0;
try{
try
{
return process_.waitFor();
}
catch (Exception e) {
} catch (Exception e)
{
e.printStackTrace();
return -1;
}
}
public String readOutputLine()
{
if (process_ == null || bufferedReaderOutput_ == null)
if (process_ == null || bufferedReaderOutput_ == null)
return null;
try {
try
{
return bufferedReaderOutput_.readLine();
} catch (IOException e) {
} catch (IOException e)
{
e.printStackTrace();
return null;
}
}
public String readErrorLine()
{
if (process_ == null || bufferedReaderError_ == null)
return null;
try {
try
{
return bufferedReaderError_.readLine();
} catch (IOException e) {
} catch (IOException e)
{
e.printStackTrace();
return null;
}
}
public OutputStream getOutputStream()
{
if (process_ == null)
@ -114,6 +134,7 @@ public class ExternalToolInvoker {
return process_.getOutputStream();
}
public InputStream getInputStream()
{
if (process_ == null)
@ -121,6 +142,7 @@ public class ExternalToolInvoker {
return process_.getInputStream();
}
public InputStream getErrorStream()
{
if (process_ == null)
@ -131,40 +153,66 @@ public class ExternalToolInvoker {
public boolean processEnded()
{
try{
try
{
if (process_ != null)
{
process_.exitValue();
bufferedReaderError_.close();
bufferedReaderOutput_.close();
}
else
return false;
}
catch (IllegalThreadStateException e) {
} catch (IOException e)
{
e.printStackTrace();
} catch (IllegalThreadStateException e)
{
// the process hasn't exited
return false;
}
return true;
}
public void waitForThreadStart()
{
// no thread
if (processThread_ == null)
return;
try
{
while (!threadStarted_)
Thread.sleep(1);
} catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println("start");
}
/**
* Launches the specified tool, with the specified argument list
*
* @param fileName the full path to the executable to be launched
* @param args the arguments list
* @param showOutput true to show tool's ouput (stdout and stderr)
* @param waitFor true to wait till the program ends and show the output
* at the end of the program or false to show it as it arrises
* at the end of the program or false to show it as it arrises
* @param useThread true to launch the tool on a separate thread
* @param workbenchWindow the workbench window used to show messages
* (if null no messages will be triggered)
* (if null no messages will be triggered)
* @return
*/
public static boolean launchTool(final String fileName,final List<String> args,final boolean showOutput,
final boolean waitFor,final boolean useThread,final IWorkbenchWindow workbenchWindow)
public static boolean launchTool(final String fileName, final List<String> args, final boolean showOutput,
final boolean waitFor, final boolean useThread, final IWorkbenchWindow workbenchWindow)
{
// we need a new thread so we won't block the caller
Thread launcherThread = new Thread(new Runnable() {
@Override
public void run()
{
try{
try
{
final ExternalToolInvoker toolInvoker = new ExternalToolInvoker(fileName, args, useThread);
toolInvoker.run();
@ -180,24 +228,25 @@ public class ExternalToolInvoker {
{
if (waitFor)
{
String line="";
while((line = toolInvoker.readOutputLine()) != null)
String line = "";
while ((line = toolInvoker.readOutputLine()) != null)
{
System.out.println(line);
}
while((line = toolInvoker.readErrorLine()) != null)
while ((line = toolInvoker.readErrorLine()) != null)
{
System.out.println(line);
}
System.out.println("tool exited.");
}
else {
else
{
Thread outputStreamThread = new Thread(new Runnable() {
@Override
public void run()
{
String line="";
while(!toolInvoker.processEnded())
String line = "";
while (!toolInvoker.processEnded())
{
if ((line = toolInvoker.readOutputLine()) != null)
System.out.println(line);
@ -208,8 +257,8 @@ public class ExternalToolInvoker {
@Override
public void run()
{
String line="";
while(!toolInvoker.processEnded())
String line = "";
while (!toolInvoker.processEnded())
{
if ((line = toolInvoker.readErrorLine()) != null)
System.out.println(line);
@ -227,7 +276,8 @@ public class ExternalToolInvoker {
}
}
}
catch (Exception e) {
catch (Exception e)
{
e.printStackTrace();
}
}

View file

@ -19,10 +19,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.Logger;
import wesnoth_eclipse_plugin.globalactions.PreprocessorActions;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.AntUtils;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.Pair;
@ -115,7 +115,7 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
monitor.beginTask("Building...", 100);
monitor.subTask("Checking conditions...");
if (PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR).isEmpty())
if (Preferences.getString(Constants.P_WESNOTH_USER_DIR).isEmpty())
{
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(), "Please set the wesnoth user dir before creating the content");
return null;
@ -152,7 +152,7 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
// Ant copy
monitor.subTask("Copying resources...");
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("wesnoth.user.dir", PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR) + Path.SEPARATOR);
properties.put("wesnoth.user.dir", Preferences.getString(Constants.P_WESNOTH_USER_DIR) + Path.SEPARATOR);
System.out.println("Ant result:");
String result = AntUtils.runAnt(getProject().getLocation().toOSString() + "/build.xml", properties, true);
System.out.println(result);

View file

@ -7,9 +7,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.builder.ExternalToolInvoker;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
@ -17,8 +17,8 @@ public class EditorActions
{
public static void startEditor(String mapName)
{
String editorPath = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_EXEC_PATH);
String workingDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WORKING_DIR);
String editorPath = Preferences.getString(Constants.P_WESNOTH_EXEC_PATH);
String workingDir = Preferences.getString(Constants.P_WESNOTH_WORKING_DIR);
if (workingDir.isEmpty())
workingDir = editorPath.substring(0, editorPath.lastIndexOf(new File(editorPath).getName()));

View file

@ -13,9 +13,9 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.ide.IDE;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.builder.ExternalToolInvoker;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class PreprocessorActions
@ -52,7 +52,7 @@ public class PreprocessorActions
arguments.add(targetDirectory);
ExternalToolInvoker wesnoth = new ExternalToolInvoker(
PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_EXEC_PATH),
Preferences.getString(Constants.P_WESNOTH_EXEC_PATH),
arguments, useThread);
System.out.printf("preprocessing : %s\n", arguments);
wesnoth.run();

View file

@ -10,7 +10,7 @@ import org.eclipse.core.commands.ExecutionException;
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
import wesnoth_eclipse_plugin.wizards.generator.SchemaParser;
public class ReloadFiles extends AbstractHandler
public class ReloadFilesHandler extends AbstractHandler
{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException

View file

@ -0,0 +1,29 @@
/**
* @author Timotei Dolean
*/
package wesnoth_eclipse_plugin.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import wesnoth_eclipse_plugin.Activator;
public class TestHandler extends AbstractHandler
{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
//String stdin = EditorUtils.getEditorDocument().get();
//EditorUtils.replaceEditorText(WMLTools.runWMLIndent(null, stdin, false, false, false));
IEditorReference[] files =
Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getPages()[0].getEditorReferences();
for (IEditorReference file : files)
{
if (file.isDirty())
file.getEditor(false).doSave(null);
}
return null;
}
}

View file

@ -1,13 +0,0 @@
package wesnoth_eclipse_plugin.preferences;
/**
* Constant definitions for plug-in preferences
*/
public class PreferenceConstants {
public static final String P_WESNOTH_EXEC_PATH = "wesnoth_exec_path";
public static final String P_WESNOTH_WORKING_DIR = "wesnoth_working_dir";
public static final String P_WESNOTH_WMLTOOLS_DIR = "wesnoth_wmltools_dir";
public static final String P_WESNOTH_USER_DIR = "wesnoth_user_dir";
}

View file

@ -4,11 +4,12 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import wesnoth_eclipse_plugin.Activator;
import wesnoth_eclipse_plugin.Constants;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
public class Preferences extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
@ -18,9 +19,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.P_WESNOTH_EXEC_PATH, "");
store.setDefault(PreferenceConstants.P_WESNOTH_WORKING_DIR, "");
store.setDefault(PreferenceConstants.P_WESNOTH_USER_DIR, "");
store.setDefault(Constants.P_WESNOTH_EXEC_PATH, "");
store.setDefault(Constants.P_WESNOTH_WORKING_DIR, "");
store.setDefault(Constants.P_WESNOTH_USER_DIR, "");
}
/**

View file

@ -12,6 +12,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import wesnoth_eclipse_plugin.Activator;
import wesnoth_eclipse_plugin.Constants;
/**
* This class represents a preference page that
@ -48,14 +49,14 @@ public class WesnothEditorPreferences
@Override
public void createFieldEditors()
{
addField(new FileFieldEditor(PreferenceConstants.P_WESNOTH_EXEC_PATH,
addField(new FileFieldEditor(Constants.P_WESNOTH_EXEC_PATH,
"Wesnoth executable path:", getFieldEditorParent()));
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WORKING_DIR,
addField(new DirectoryFieldEditor(Constants.P_WESNOTH_WORKING_DIR,
"Working directory:", getFieldEditorParent()));
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_USER_DIR,
addField(new DirectoryFieldEditor(Constants.P_WESNOTH_USER_DIR,
"User data directory:", getFieldEditorParent()));
wmlToolsField = new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR,
wmlToolsField = new DirectoryFieldEditor(Constants.P_WESNOTH_WMLTOOLS_DIR,
"WML* tools directory:", getFieldEditorParent());
addField(wmlToolsField);
}

View file

@ -0,0 +1,100 @@
/**
* @author Timotei Dolean
*
*/
package wesnoth_eclipse_plugin.utils;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import wesnoth_eclipse_plugin.Activator;
public class EditorUtils
{
public static void writeInEditor(String content)
{
writeInEditor(getEditedFile(), content);
}
public static void replaceEditorText(String content)
{
replaceEditorText(getEditedFile(), content);
}
public static IDocument getEditorDocument()
{
return getEditorDocument(getEditedFile());
}
public static ITextEditor getTextEditor()
{
return getTextEditor(getEditedFile());
}
public static IEditorPart getEditedFile()
{
return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getPages()[0].getActiveEditor();
}
public static void openEditor(IFile file, boolean activatePage)
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try
{
IDE.openEditor(page, file, activatePage);
} catch (PartInitException e)
{
}
}
public static IDocument getEditorDocument(IEditorPart targetEditor)
{
IDocumentProvider dp = getTextEditor(targetEditor).getDocumentProvider();
return dp.getDocument(targetEditor.getEditorInput());
}
public static ITextEditor getTextEditor(IEditorPart targetEditor)
{
if (targetEditor == null)
return null;
IEditorPart part = targetEditor;
if (!(part instanceof AbstractTextEditor))
return null;
return (ITextEditor) part;
}
public static void writeInEditor(IEditorPart targetEditor, String content)
{
int offset = ((ITextSelection) getTextEditor(targetEditor).getSelectionProvider().getSelection()).getOffset();
try
{
getEditorDocument(targetEditor).replace(offset, 0, content);
} catch (BadLocationException e)
{
}
}
public static void replaceEditorText(IEditorPart targetEditor, String content)
{
if (targetEditor == null)
return;
try
{
getEditorDocument(targetEditor).replace(0, getEditorDocument(targetEditor).getLength(), content);
} catch (BadLocationException e)
{
}
}
}

View file

@ -39,7 +39,7 @@ public class GUIUtils
*/
public static void showMessageBox(final IWorkbenchWindow window, final String message, final int style)
{
if (window == null || window.getShell() == null)
if (window == null || window.getShell() == null || message == null)
return;
try
{

View file

@ -3,7 +3,9 @@
*/
package wesnoth_eclipse_plugin.utils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
@ -13,14 +15,15 @@ import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.builder.ExternalToolInvoker;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
public class WMLTools
{
/**
* Runs "wmllint" on the specified file
*
* @param filePath the full path of the target file where "wmllint" will be runned on
* @param writeToConsole true to write the output of "wmllint" in console
* @param dryrun true to run "wmllint" in dry mode - i.e. no changes in the config file.
@ -31,64 +34,82 @@ public class WMLTools
if (!checkPrerequisites(filePath, "wmllint"))
return null;
File wmllintFile = new File(PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR) +
File wmllintFile = new File(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR) +
Path.SEPARATOR + "wmllint");
List<String> arguments = new ArrayList<String>();
arguments.add(wmllintFile.getAbsolutePath());
if (dryrun) arguments.add("--dryrun");
if (dryrun)
arguments.add("--dryrun");
arguments.add("--verbose");
//arguments.add("-v");
//arguments.add("-v");
arguments.add("--nospellcheck");
// add default core directory
arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR) +
Path.SEPARATOR + "data/core");
arguments.add(filePath);
return runPythonScript(arguments, useThread, writeToConsole, "Wmllint result: ");
return runPythonScript(arguments, null, useThread, writeToConsole, "Wmllint result: ");
}
/**
* Runs "wmlindent" on the specified file
*
* @param filePath the full path of the target file where "wmlindent" will be runned on
* @param writeToConsole true to write the output of "wmlindent" in console
* @param dryrun true to run "wmlindent" in dry mode - i.e. no changes in the config file.
* @param useThread whether the tool should be runned in a new thread
*/
public static String runWMLIndent(String filePath, boolean dryrun, boolean writeToConsole, boolean useThread)
public static String runWMLIndent(String filePath, String stdin,
boolean dryrun, boolean writeToConsole, boolean useThread)
{
if (!checkPrerequisites(filePath, "wmlindent"))
if (!checkPrerequisites(null, "wmlindent")) // wmlindent only check first
return null;
File wmllintFile = new File(PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR) +
File wmllintFile = new File(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR) +
Path.SEPARATOR + "wmlindent");
List<String> arguments = new ArrayList<String>();
arguments.add(wmllintFile.getAbsolutePath());
if (dryrun) arguments.add("--dryrun");
arguments.add("--verbose");
arguments.add(filePath);
return runPythonScript(arguments, useThread, writeToConsole,"Wmlindent result: ");
if (filePath != null)
{
if (!checkPrerequisites(filePath, null))
return null;
if (dryrun)
arguments.add("--dryrun");
arguments.add("--verbose");
arguments.add(filePath);
}
return runPythonScript(arguments, stdin, useThread, writeToConsole, "Wmlindent result: ");
}
/**
* Checks if a wmlTool (that is in the wml tools directory) and
* an additional file that is target of the tool exist / are valid.
*
* @param filePath the file to be processed by the wml tool
* @param wmlTool the wml tool file
* @return
*/
private static boolean checkPrerequisites(String filePath, String wmlTool)
public static boolean checkPrerequisites(String filePath, String wmlTool)
{
File wmlToolFile = new File(PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR) +
Path.SEPARATOR + wmlTool);
if (!wmlToolFile.exists())
if (wmlTool != null)
{
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(),
"Please set the wmltools directory in the preferences before you use this feature.");
return false;
}
File wmlToolFile = new File(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR) +
Path.SEPARATOR + wmlTool);
if (filePath == null || filePath.isEmpty() || !new File(filePath).exists())
if (!wmlToolFile.exists())
{
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(),
"Please set the wmltools directory in the preferences before you use this feature.");
return false;
}
}
if (filePath != null &&
(filePath.isEmpty() || !new File(filePath).exists()))
return false;
return true;
@ -96,44 +117,55 @@ public class WMLTools
/**
* Runs a specified python script with the specified arguments
*
* @param arguments the arguments of the "python" executable.
* The first argument should be the script file name
* The first argument should be the script file name
* @param useThread
* @param writeToConsole true to write the script output to user's console
* @return
*/
private static String runPythonScript(List<String> arguments, boolean useThread,
public static String runPythonScript(List<String> arguments, String stdin, boolean useThread,
boolean writeToConsole, String consoleTitle)
{
String result = "";
try
{
ExternalToolInvoker pyscript = new ExternalToolInvoker("python", arguments, useThread);
System.out.println(arguments);
pyscript.run();
pyscript.waitFor();
if (stdin != null && !stdin.isEmpty())
{
//pyscript.waitForThreadStart();
BufferedWriter stdinStream = new BufferedWriter(new OutputStreamWriter(pyscript.getOutputStream()));
stdinStream.write(stdin);
stdinStream.close();
}
MessageConsoleStream stream = null;
if (writeToConsole)
{
MessageConsole console = new MessageConsole(consoleTitle, null);
console.activate();
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ console });
MessageConsoleStream stream = console.newMessageStream();
String line = "";
while((line = pyscript.readOutputLine())!= null)
{
stream.write(line);
result += line;
}
while((line = pyscript.readErrorLine())!= null)
{
stream.write(line);
result += line;
}
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
stream = console.newMessageStream();
}
}
catch (Exception e)
String line = "";
while ((line = pyscript.readOutputLine()) != null)
{
if (writeToConsole)
stream.write(line + "\n");
result += (line + "\n");
}
while ((line = pyscript.readErrorLine()) != null)
{
if (writeToConsole)
stream.write(line + "\n");
result += (line + "\n");
}
} catch (Exception e)
{
GUIUtils.showMessageBox(e.getMessage());
e.printStackTrace();
}
return result;

View file

@ -18,9 +18,9 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import wesnoth_eclipse_plugin.Activator;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.builder.WesnothProjectNature;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
@ -88,10 +88,13 @@ public class WorkspaceUtils
/**
* Returns the first WorkbenchWindow available. This is not always the same
* with ActiveWorkbecnWindow
*
* @return
*/
public static IWorkbenchWindow getWorkbenchWindow()
{
if (Activator.getDefault().getWorkbench().getActiveWorkbenchWindow() != null)
return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow();
if (Activator.getDefault().getWorkbench().getWorkbenchWindowCount() == 0)
return null;
return Activator.getDefault().getWorkbench().getWorkbenchWindows()[0];
@ -99,6 +102,7 @@ public class WorkspaceUtils
/**
* Returns the temporary folder where the plugin can write resources
*
* @return
*/
public static String getTemporaryFolder()
@ -116,12 +120,13 @@ public class WorkspaceUtils
/**
* Returns the resource path relative to the user directory
*
* @param resource the resource to be computed
* @return
*/
public static String getPathRelativeToUserDir(IResource resource)
{
String result = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR) + Path.SEPARATOR + "data/add-ons/";
String result = Preferences.getString(Constants.P_WESNOTH_USER_DIR) + Path.SEPARATOR + "data/add-ons/";
if (!resource.getProject().getName().toLowerCase(new Locale("English")).equals("user addons"))
result += (resource.getProject().getName() + Path.SEPARATOR);
result += resource.getProjectRelativePath().toOSString();
@ -132,7 +137,7 @@ public class WorkspaceUtils
{
// automatically import "WesnothUserDir/data/add-ons as a project
// container
String userDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR);
String userDir = Preferences.getString(Constants.P_WESNOTH_USER_DIR);
if (userDir.isEmpty() || !new File(userDir).exists())
{
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(),
@ -166,7 +171,6 @@ public class WorkspaceUtils
ResourceUtils.createFile(proj, "build.xml",
TemplateProvider.getInstance().getProcessedTemplate("build_xml", param), true);
// we need to skip the already created projects (if any) in the addons directory
String skipList = "";
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects())
@ -176,7 +180,7 @@ public class WorkspaceUtils
skipList += (StringUtils.trimPathSeparators(getPathRelativeToUserDir(project)) + "\n");
}
ResourceUtils.createFile(proj, ".ignore",skipList, true);
ResourceUtils.createFile(proj, ".ignore", skipList, true);
}
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(),
"Workspace was set up successfully.");

View file

@ -1,15 +0,0 @@
/**
* @author Timotei Dolean
*
*/
package wesnoth_eclipse_plugin.wizards;
public class WizardsConstants
{
public static final int TextBoxHeight = 21;
public static final int MaxTextBoxesOnPage = 10;
public static final int MaxGroupsOnPage = 4;
public static final int MaxWizardPageHeight = 220;
}

View file

@ -8,9 +8,9 @@ import java.io.File;
import java.util.HashMap;
import java.util.Stack;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.Logger;
import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.ResourceUtils;
import wesnoth_eclipse_plugin.utils.StringUtils;
@ -43,8 +43,8 @@ public class SchemaParser
}
Logger.print("parsing schema " + (force == true ? "forced" : ""));
File schemaFile = new File(PreferenceInitializer.getString(
PreferenceConstants.P_WESNOTH_WORKING_DIR) + "/data/schema.cfg");
File schemaFile = new File(Preferences.getString(
Constants.P_WESNOTH_WORKING_DIR) + "/data/schema.cfg");
String res = ResourceUtils.getFileContents(schemaFile);
String[] lines = StringUtils.getLines(res);
Stack<String> tagStack = new Stack<String>();

View file

@ -6,9 +6,9 @@ package wesnoth_eclipse_plugin.wizards.generator;
import org.eclipse.jface.wizard.IWizardPage;
import wesnoth_eclipse_plugin.Constants;
import wesnoth_eclipse_plugin.utils.StringUtils;
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
import wesnoth_eclipse_plugin.wizards.WizardsConstants;
public class WizardGenerator extends NewWizardTemplate
{
@ -28,13 +28,13 @@ public class WizardGenerator extends NewWizardTemplate
{
// keys section
int keysNr = tagContent.KeyChildren.size();
int startKey = 0, pgsKey = (keysNr / WizardsConstants.MaxTextBoxesOnPage);
int startKey = 0, pgsKey = (keysNr / Constants.WIZ_MaxTextBoxesOnPage);
WizardGeneratorPageKey tempPageKey;
for (int i = 0; i < pgsKey; i++)
{
tempPageKey = new WizardGeneratorPageKey(tagName, tagContent.KeyChildren, startKey,
startKey + WizardsConstants.MaxTextBoxesOnPage, (byte) (indent_ + 1));
startKey += WizardsConstants.MaxTextBoxesOnPage;
startKey + Constants.WIZ_MaxTextBoxesOnPage, (byte) (indent_ + 1));
startKey += Constants.WIZ_MaxTextBoxesOnPage;
addPage(tempPageKey);
}
if (keysNr - 1 > 0)
@ -46,13 +46,13 @@ public class WizardGenerator extends NewWizardTemplate
// tags section
int tagsNr = tagContent.TagChildren.size();
int startTag = 0, pgsTag = (tagsNr / WizardsConstants.MaxGroupsOnPage);
int startTag = 0, pgsTag = (tagsNr / Constants.WIZ_MaxGroupsOnPage);
WizardGeneratorPageTag tempPageTag;
for (int i = 0; i < pgsTag; i++)
{
tempPageTag = new WizardGeneratorPageTag(tagName, tagContent.TagChildren, startTag,
startTag + WizardsConstants.MaxGroupsOnPage, (byte) (indent_ + 1));
startTag += WizardsConstants.MaxTextBoxesOnPage;
startTag + Constants.WIZ_MaxGroupsOnPage, (byte) (indent_ + 1));
startTag += Constants.WIZ_MaxTextBoxesOnPage;
addPage(tempPageTag);
}
if (tagsNr - 1 > 0)

View file

@ -137,13 +137,12 @@ public class WizardGeneratorPageKey extends WizardPage
continue;
String text = "";
if (child instanceof Text)
text = ((Text) child).getText();
text = (child.getData("trans").toString().equals("true") == true ? "_" : "") +
"\"" + ((Text) child).getText() + "\"";
else
text = ((Combo) child).getText();
result.append(StringUtils.multiples("\t", indent_) +
child.getData("name") + "=" +
(child.getData("trans").toString().equals("true") == true ? "_" : "") // translatable flag
+ "\"" + text + "\"\n");
child.getData("name") + "=" + text + "\n");
}
return result.toString();
}

View file

@ -13,22 +13,12 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import wesnoth_eclipse_plugin.utils.EditorUtils;
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
import wesnoth_eclipse_plugin.wizards.WizardUtils;
@ -67,16 +57,8 @@ public class WizardLauncher extends NewWizardTemplate
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException
{
try
{
doFinish(monitor);
} catch (CoreException e)
{
throw new InvocationTargetException(e);
} finally
{
monitor.done();
}
doFinish(monitor);
monitor.done();
}
};
try
@ -94,41 +76,27 @@ public class WizardLauncher extends NewWizardTemplate
return true;
}
private void doFinish(IProgressMonitor monitor) throws CoreException
private void doFinish(IProgressMonitor monitor)
{
// The file is opened in the editor -> just copy-paste the text
if (!(page0_.getIsTargetNewFile()))
{
try
{
IEditorPart part = page0_.getEditedFile();
if (!(part instanceof AbstractTextEditor))
return;
ITextEditor editor = (ITextEditor) part;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
int offset = ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset();
doc.replace(offset, 0, wizard_.getData().toString());
} catch (Exception e)
{
e.printStackTrace();
}
return;
}
final String containerName = page0_.getDirectoryName();
final String fileName = page0_.getFileName();
// create the file
monitor.beginTask("Creating " + fileName, 10);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(containerName));
IContainer container = (IContainer) resource;
final IFile file = container.getFile(new Path(fileName));
try
{
// The file is opened in the editor -> just copy-paste the text
if (!(page0_.getIsTargetNewFile()))
{
EditorUtils.writeInEditor(EditorUtils.getEditedFile(), wizard_.getData().toString());
return;
}
final String containerName = page0_.getDirectoryName();
final String fileName = page0_.getFileName();
// create the file
monitor.beginTask("Creating " + fileName, 10);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(containerName));
IContainer container = (IContainer) resource;
final IFile file = container.getFile(new Path(fileName));
InputStream stream = new ByteArrayInputStream(wizard_.getData().toString().getBytes());
if (file.exists())
@ -141,26 +109,20 @@ public class WizardLauncher extends NewWizardTemplate
}
stream.close();
monitor.worked(5);
monitor.setTaskName("Opening file for editing...");
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run()
{
EditorUtils.openEditor(file, true);
}
});
monitor.worked(5);
} catch (Exception e)
{
e.printStackTrace();
}
monitor.worked(5);
monitor.setTaskName("Opening file for editing...");
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run()
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try
{
IDE.openEditor(page, file, true);
} catch (PartInitException e)
{
}
}
});
monitor.worked(5);
}
}

View file

@ -21,10 +21,9 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import wesnoth_eclipse_plugin.Activator;
import wesnoth_eclipse_plugin.utils.EditorUtils;
public class WizardLauncherPage0 extends WizardPage
{
@ -199,9 +198,9 @@ public class WizardLauncherPage0 extends WizardPage
else
{
// current file checking
if (getEditedFile() != null)
if (EditorUtils.getEditedFile() != null)
{
lblCurrentFileOpened.setText("File " + getEditedFile().getEditorInput().getName() + " opened.");
lblCurrentFileOpened.setText("File " + EditorUtils.getEditedFile().getEditorInput().getName() + " opened.");
}
else
{
@ -214,11 +213,6 @@ public class WizardLauncherPage0 extends WizardPage
setErrorMessage(null);
}
public IEditorPart getEditedFile()
{
return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getPages()[0].getActiveEditor();
}
public void updateEnabledStatus()
{
// new file section
@ -280,7 +274,8 @@ public class WizardLauncherPage0 extends WizardPage
public String getFileName()
{
return radioNewFile.getSelection() == true ? txtFileName_.getText() : getEditedFile().getEditorInput().getName();
return radioNewFile.getSelection() == true ? txtFileName_.getText() :
EditorUtils.getEditedFile().getEditorInput().getName();
}
public String getDirectoryName()