eclipse plugin: add guidance for first-time users on the plugin

This commit is contained in:
Timotei Dolean 2010-07-27 19:08:22 +00:00
parent 5ccd0104b1
commit c9daead9a1
5 changed files with 66 additions and 5 deletions

View File

@ -2,3 +2,4 @@ makereadme:
cd readme; pdflatex README.tex
# cleanup non-needed files
cd readme; rm README.log; rm README.aux;
cd readme; cp README.pdf ..;

View File

@ -0,0 +1 @@
For the README execute 'make' in this directory, and the open the 'README.pdf' file.

View File

@ -8,11 +8,16 @@
*******************************************************************************/
package wesnoth_eclipse_plugin;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import wesnoth_eclipse_plugin.preferences.Preferences;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
/**
* The activator class controls the plug-in life cycle
*/
@ -33,6 +38,17 @@ public class Activator extends AbstractUIPlugin
super.start(context);
plugin = this;
Logger.getInstance().startLogger();
if (!checkConditions())
{
GUIUtils.showInfoMessageBox(
"Hello!\n" +
"Welcome to 'Wesnoth User Made Content Eclipse Plugin'.\n" +
"Since this is the first time you are using it " +
"I'll guide you through setting it up.\n\n" +
"First you'll have to setup your preferences.\n" +
"Press OK to continue.");
WorkspaceUtils.setupWorkspace(true);
}
}
@Override
@ -74,4 +90,25 @@ public class Activator extends AbstractUIPlugin
{
return plugin.getWorkbench().getDisplay().getActiveShell();
}
/**
* Checks if the user has set some needed preferences and if the workspace
* is setup (there exists the "User Addons" project)
*/
private static boolean checkConditions()
{
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 (!WorkspaceUtils.validPath(execDir) || !WorkspaceUtils.validPath(userDir) ||
!WorkspaceUtils.validPath(wmltoolsDir) || !WorkspaceUtils.validPath(workingDir) ||
!ResourcesPlugin.getWorkspace().getRoot().getProject("User Addons").exists())
{
return false;
}
return true;
}
}

View File

@ -17,7 +17,7 @@ public class SetupWorkspaceHandler extends AbstractHandler
{
@Override
public Object execute(ExecutionEvent event) {
WorkspaceUtils.setupWorkspace();
WorkspaceUtils.setupWorkspace(false);
return null;
}
}

View File

@ -267,7 +267,7 @@ public class WorkspaceUtils
* If not, the preferences window will open
* 2) The project "User addons" exists. If not, it will be created
*/
public static void setupWorkspace()
public static void setupWorkspace(boolean guided)
{
if (!checkConditions(false))
{
@ -275,9 +275,21 @@ public class WorkspaceUtils
Activator.getShell(), "plugin_preferences", null, null);
if (pref.open() == Window.CANCEL || !checkConditions(true))
{
GUIUtils.showErrorMessageBox("The workspace was not setup");
GUIUtils.showErrorMessageBox("The workspace was not setup. " +
"Please check the logs for errors.");
return;
}
if (guided)
{
GUIUtils.showInfoMessageBox(
"Good. The preferences were set.\n" +
"Now, I'll make a simple project which will " +
"correspond to\n" +
"'<your wesnoth user directory>/data/addons' directory " +
"where the addons will be stored.\n" +
"Press OK to continue.");
}
}
// automatically import "WesnothUserDir/data/add-ons as a project container
@ -328,8 +340,18 @@ public class WorkspaceUtils
ProjectUtils.setPropertiesForProject(projectToCreate, props);
}
Logger.getInstance().log("setupWorkspace was successful",
"Workspace was set up successfully.");
if (guided)
{
GUIUtils.showInfoMessageBox(
"Congrats!\n" +
"Everything is set up. Now you can use the plugin.\n\n" +
"Good luck and have fun!");
}
else
{
Logger.getInstance().log("setupWorkspace was successful",
"Workspace was set up successfully.");
}
} catch (Exception e)
{
Logger.getInstance().logException(e);