Index: org.lams.toolbuilder/src/org/lams/toolbuilder/renameTool/RenameToolTaskList.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/renameTool/RenameToolTaskList.java,v diff -u -r1.2 -r1.3 --- org.lams.toolbuilder/src/org/lams/toolbuilder/renameTool/RenameToolTaskList.java 10 Sep 2007 07:27:33 -0000 1.2 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/renameTool/RenameToolTaskList.java 12 Sep 2007 14:45:22 -0000 1.3 @@ -36,6 +36,9 @@ //private String toolName; // the name of the new tool private String toolDispName; // the display name of the new tool + private String classPrefix; // the string to replce the tool's java class prefixes with eg JavaClass + private String variablePrefix; // the string to replce the tool's java variable prefixes with eg javaVariable + private List tasklist; // the tasklist created for the rename tool public RenameToolTaskList(String tooltemplate, String toolsig, String tooldispname) @@ -70,6 +73,9 @@ */ public void init() { + classPrefix = toJavaClassString(toolDispName); + variablePrefix = toJavaVariableString(toolDispName); + if (toolTemplate.equals(Constants.CHAT_TOOL_DIR)) {initChat();} else if (toolTemplate.equals(Constants.FORUM_TOOL_DIR)) {initForum();} else if (toolTemplate.equals(Constants.MC_TOOL_DIR)) {initMC();} @@ -85,7 +91,17 @@ public void initChat() {} - public void initForum() {} + public void initForum() + { + System.out.println("Java Class Prefix: " + classPrefix); + System.out.println("Java Variable Prefix: " + variablePrefix); + + + tasklist.add(new String[] {"lafrum11", toolSig}); + tasklist.add(new String[] {"TestForum", "Test" + classPrefix}); + tasklist.add(new String[] {"Forum", classPrefix}); + tasklist.add(new String[] {"forum", variablePrefix}); + } public void initMC() {} @@ -99,23 +115,22 @@ public void initSubmit() { - String submitClassPrefix = toJavaClassString(toolDispName); - String submitVariablePrefix = toJavaVariableString(toolDispName); - System.out.println("Java Class Prefix: " + submitClassPrefix); - System.out.println("Java Variable Prefix: " + submitVariablePrefix); + System.out.println("Java Class Prefix: " + classPrefix); + System.out.println("Java Variable Prefix: " + variablePrefix); + tasklist.add(new String[] {"lasbmt11", toolSig}); - tasklist.add(new String[] {"TestSubmitFiles", "Test" + submitClassPrefix}); - tasklist.add(new String[] {"SubmitFiles", submitClassPrefix}); - tasklist.add(new String[] {"submitFiles", submitVariablePrefix}); + tasklist.add(new String[] {"TestSubmitFiles", "Test" + classPrefix}); + tasklist.add(new String[] {"SubmitFiles", classPrefix}); + tasklist.add(new String[] {"submitFiles", variablePrefix}); tasklist.add(new String[] {"Submit Files", toolDispName}); - tasklist.add(new String[] {"Submit",submitClassPrefix}); - tasklist.add(new String[] {"submit",submitVariablePrefix}); - tasklist.add(new String[] {"sbmt",submitVariablePrefix}); - tasklist.add(new String[] {"Sbmt",submitClassPrefix}); - tasklist.add(new String[] {"Submission",submitClassPrefix}); - tasklist.add(new String[] {"submission",submitVariablePrefix}); + tasklist.add(new String[] {"Submit",classPrefix}); + tasklist.add(new String[] {"submit",variablePrefix}); + tasklist.add(new String[] {"sbmt",variablePrefix}); + tasklist.add(new String[] {"Sbmt",classPrefix}); + tasklist.add(new String[] {"Submission",classPrefix}); + tasklist.add(new String[] {"submission",variablePrefix}); } Index: org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java,v diff -u -r1.5 -r1.6 --- org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java 10 Sep 2007 07:27:33 -0000 1.5 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java 12 Sep 2007 14:45:23 -0000 1.6 @@ -1,4 +1,4 @@ -package org.lams.toolbuilder.wizards; + package org.lams.toolbuilder.wizards; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; @@ -30,6 +30,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.lams.toolbuilder.renameTool.RenameTool; import org.lams.toolbuilder.renameTool.RenameToolTaskList; +import org.lams.toolbuilder.LAMSToolBuilderPlugin; /** * This is a sample new wizard. Its role is to create a new file * resource in the provided container. If the container resource @@ -45,34 +46,125 @@ private LAMSNewToolWizardPage page; private ISelection selection; + private boolean workspaceValid; + // The handle to the new LAMS Tool Project to be created private IProject projectHandle; + private String toolName; + private String vendor; + private String compatibility; + private String toolDisplayName; + private boolean isLAMS; + private boolean toolVisible; - private static String toolSignature; - private static String toolName; - private static String vendor; - private static String compatibility; - private static String toolDisplayName; - private static boolean isLAMS; - private static boolean toolVisible; + // The list of base LAMS projects required for the workspace + private List projectList; /** * Constructor for LAMSNewToolWizard. */ - public LAMSNewToolWizard() { + public LAMSNewToolWizard() throws Exception{ super(); setNeedsProgressMonitor(true); + + initiate(); + + + workspaceValid = checkWorkspace(); + if (!workspaceValid) + { + this.performCancel(); + this.dispose(); + } + } + /** - * Adding the page to the wizard. + * Initiate some local static variblaes */ + public void initiate() + { + projectList = new ArrayList(); + projectList.add("lams_admin"); + projectList.add("lams_central"); + projectList.add("lams_common"); + projectList.add("lams_learning"); + projectList.add("lams_monitoring"); + projectList.add("lams_build"); + projectList.add("lams_tool_deploy"); + projectList.add("lams_www"); + + } + + /** + * Checks the workspace contains the base LAMS project + * @return true if workspace contains the base lams projects + */ + public boolean checkWorkspace() + { + boolean result = true; + List missingList = new ArrayList(); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + LamsToolBuilderLog.logInfo("Checking required LAMS projects exist"); + for (String dir : projectList) { + + + + IPath path = new Path(dir); + if (!root.exists(path)) + { + LamsToolBuilderLog.logInfo("Project not found: " + path.toPortableString()); + missingList.add(dir); + result = false; + } + + } + + if (result==false) + { + // Print a error dialog informing that the workspace is missing projects + String message= "You are missing the following required LAMS projects for your workspace:\n "; + String statusMessage = "Missing LAMS projects in workspace."; + String title = "LAMS Project Creation Error"; + for (String dir : missingList) + message += "\t" + dir + "\n"; + + message += "\nYou can get the required projects from the anonymous CVS account." + + "\n\t* access method: pserver" + + "\n\t* user name: anonymous" + + "\n\t* server name: lamscvs.melcoe.mq.edu.au" + + "\n\t* location: /usr/local/cvsroot"; + IStatus error = new Status( + IStatus.ERROR, + LAMSToolBuilderPlugin.PLUGIN_ID, + IStatus.ERROR, + statusMessage, + null); + ErrorDialog.openError(this.getShell(), title, message, error); + + + this.dispose(); + } + + return result; + } + + + + /** + * Adding the page to the wizard. + */ public void addPages() { - LamsToolBuilderLog.logInfo("Adding pages to LAMS Tool Wizard"); - page = new LAMSNewToolWizardPage(selection); - addPage(page); + if(workspaceValid) + { + LamsToolBuilderLog.logInfo("Adding pages to LAMS Tool Wizard"); + page = new LAMSNewToolWizardPage(selection); + addPage(page); + } } /** @@ -88,7 +180,6 @@ //private static String toolName; vendor = page.getVendor(); - toolSignature = page.getToolSignature(); compatibility = page.getCompatibility(); toolDisplayName = page.getToolDisplayName(); isLAMS = page.getIsLams(); @@ -170,7 +261,7 @@ } //############### test project to template from - String containerName = "lams_tool_sbmt"; + String containerName = "lams_tool_forum"; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject projTemplate = (IProject)root.findMember(new Path(containerName)); @@ -188,12 +279,11 @@ LamsToolBuilderLog.logError(e); } - RenameToolTaskList tasklist = new RenameToolTaskList(Constants.SUBMIT_TOOL_DIR, toolSignature, toolDisplayName); + //TODO: - List commandList = tasklist.getTasklist(); - + //RenameToolTaskList taskList = new RenameToolTaskList(Constants.FORUM_TOOL_DIR, ) - RenameTool rt = new RenameTool(); + //RenameTool rt = new RenameTool(); LamsToolBuilderLog.logInfo(projHandle.getLocation().toPortableString()); try{ rt.renameTool(commandList, projHandle.getLocation().toPortableString()); @@ -216,6 +306,7 @@ + // Get method for the project created by this wizard public IProject getProjectHandle() {