Index: org.lams.toolbuilder/src/org/lams/toolbuilder/util/Constants.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/util/Constants.java,v diff -u -r1.2 -r1.3 --- org.lams.toolbuilder/src/org/lams/toolbuilder/util/Constants.java 6 Sep 2007 07:19:22 -0000 1.2 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/util/Constants.java 18 Sep 2007 05:56:54 -0000 1.3 @@ -1,8 +1,10 @@ package org.lams.toolbuilder.util; +import java.util.List; +import java.util.ArrayList; + public class Constants { - //public static final String - + // Constants used for build.properties file generation public static final String PROP_TOOL_NAME = "tool.name"; public static final String PROP_SIGNATURE = "signature"; @@ -27,4 +29,59 @@ public static final String SURVEY_TOOL_DIR = "lams_tool_survey"; public static final String VOTE_TOOL_DIR = "lams_tool_vote"; + // A list of LAMS default tools + public static String[] defaultTools; + + /** + * Instantiates the defaultTools variable + */ + public static void initToolProjects() + { + defaultTools = new String[] + { + CHAT_TOOL_DIR, + FORUM_TOOL_DIR, + MC_TOOL_DIR, + QA_TOOL_DIR, + SHARE_RESOURCE_TOOL_DIR, + NOTICEBOARD_TOOL_DIR, + NOTEBOOK_TOOL_DIR, + SUBMIT_TOOL_DIR, + SCRIBE_TOOL_DIR, + SURVEY_TOOL_DIR, + VOTE_TOOL_DIR + }; + } + + // All the LAMS core tools + public static final String LAMS_ADMIN_DIR = "lams_admin"; + public static final String LAMS_CENTRAL_DIR = "lams_central"; + public static final String LAMS_COMMON_DIR = "lams_common"; + public static final String LAMS_LEARNING_DIR = "lams_learning"; + public static final String LAMS_MONITORING_DIR = "lams_monitoring"; + public static final String LAMS_BUILD_DIR = "lams_build"; + public static final String LAMS_TOOL_DEPLOY = "lams_tool_deploy"; + public static final String LAMS_WWW_DIR = "lams_www"; + + // A list of LAMS core projects + public static List coreProjects; + + /* + * Instantiates the coreProjects list + */ + public static void initCorePrjects() + { + coreProjects = new ArrayList(); + + coreProjects.add(LAMS_ADMIN_DIR); + coreProjects.add(LAMS_CENTRAL_DIR); + coreProjects.add(LAMS_COMMON_DIR); + coreProjects.add(LAMS_LEARNING_DIR); + coreProjects.add(LAMS_MONITORING_DIR); + coreProjects.add(LAMS_BUILD_DIR); + coreProjects.add(LAMS_TOOL_DEPLOY); + coreProjects.add(LAMS_WWW_DIR); + } + + } 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.6 -r1.7 --- org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java 12 Sep 2007 14:45:23 -0000 1.6 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java 18 Sep 2007 05:56:54 -0000 1.7 @@ -31,6 +31,7 @@ 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 @@ -44,14 +45,17 @@ public class LAMSNewToolWizard extends Wizard implements INewWizard { private LAMSNewToolWizardPage page; + private LAMSNewToolWizardTemplatePage page2; + 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 toolTemplate; + private String toolSignature; private String vendor; private String compatibility; private String toolDisplayName; @@ -68,7 +72,8 @@ super(); setNeedsProgressMonitor(true); - initiate(); + Constants.initCorePrjects(); + projectList = Constants.coreProjects; workspaceValid = checkWorkspace(); @@ -102,7 +107,7 @@ * Checks the workspace contains the base LAMS project * @return true if workspace contains the base lams projects */ - public boolean checkWorkspace() + public boolean checkWorkspace() { boolean result = true; List missingList = new ArrayList(); @@ -147,7 +152,8 @@ ErrorDialog.openError(this.getShell(), title, message, error); - this.dispose(); + + } return result; @@ -164,7 +170,10 @@ LamsToolBuilderLog.logInfo("Adding pages to LAMS Tool Wizard"); page = new LAMSNewToolWizardPage(selection); addPage(page); - } + + page2 = new LAMSNewToolWizardTemplatePage(selection); + addPage(page2); + } } /** @@ -184,6 +193,7 @@ toolDisplayName = page.getToolDisplayName(); isLAMS = page.getIsLams(); toolVisible = page.getVisible(); + toolSignature = page.getToolDisplayName(); // create a project descriptor IPath projPath = null; @@ -261,13 +271,13 @@ } //############### test project to template from - String containerName = "lams_tool_forum"; + toolTemplate = page2.getTemplate(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject projTemplate = (IProject)root.findMember(new Path(containerName)); + IProject projTemplate = (IProject)root.findMember(new Path(toolTemplate)); if (!projTemplate.exists() || !(projTemplate instanceof IContainer)) { - throwCoreException("Project \"" + containerName + "\" does not exist."); + throwCoreException("Project \"" + toolTemplate + "\" does not exist."); } monitor.worked(2); @@ -281,12 +291,11 @@ //TODO: - //RenameToolTaskList taskList = new RenameToolTaskList(Constants.FORUM_TOOL_DIR, ) - - //RenameTool rt = new RenameTool(); + RenameToolTaskList taskList = new RenameToolTaskList(Constants.FORUM_TOOL_DIR, toolSignature, toolDisplayName ); + RenameTool rt = new RenameTool(); LamsToolBuilderLog.logInfo(projHandle.getLocation().toPortableString()); try{ - rt.renameTool(commandList, projHandle.getLocation().toPortableString()); + rt.renameTool(taskList.getTasklist(), projHandle.getLocation().toPortableString()); } catch (Exception e) { Index: org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardTemplatePage.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardTemplatePage.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardTemplatePage.java 18 Sep 2007 05:56:54 -0000 1.1 @@ -0,0 +1,193 @@ +package org.lams.toolbuilder.wizards; + +import java.util.ArrayList; + +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; + + + +import org.lams.toolbuilder.LAMSToolBuilderPlugin; +import org.lams.toolbuilder.util.LamsToolBuilderLog; +import org.lams.toolbuilder.util.Constants; + + + +/** + * The second page of the wizard contains a checkbox list of key/value + * pairs that can be extracted from the source file. Rather than + * initializing its contents when first created, this page updates its + * contents whenever it becomes visible by overriding the setVisible() + * method. + */ +public class LAMSNewToolWizardTemplatePage extends WizardPage +{ + + private ArrayList availableTemplates; // a list of available lams tool templates from the workspace + private String chosenTemplate; // the template chosen + private boolean templatesAvailable; // false if there are no templates available + private List dispList; + ISelection selection; + + /** + * Constructor + */ + public LAMSNewToolWizardTemplatePage(ISelection selection) + { + super("selectTemplate"); + this.selection = selection; + setTitle("Select a Template"); + setDescription("Select a LAMS tool template to build your tool from"); + templatesAvailable = false; // set to false to begin with + setAvailableTemplates(); + + } + + /** + * Checks the workspace to find what tool projects are present + * Sets the availableTemplates list + */ + public void setAvailableTemplates() + { + availableTemplates = new ArrayList(); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + LamsToolBuilderLog.logInfo("Getting available templates from workspace"); + + Constants.initToolProjects(); + String[] defaultTools = Constants.defaultTools; + for (String dir : defaultTools) + { + IPath path = new Path(dir); + if (root.exists(path)) + { + LamsToolBuilderLog.logInfo("Tool project found: " + path.toPortableString()); + availableTemplates.add(dir); + } + + } + + if (availableTemplates.size() > 0) + { + templatesAvailable = true; + } + else + { + LamsToolBuilderLog.logInfo("No templates found in workspace"); + //this.setVisible(false); + //TODO: Dialog box goes here "Do you want to use default template?" + // choose a default template to use. Hopefully an empty example tool + } + + } + + /** + * Creates the top level control for this wizard page under the + * given parent composite, then calls setControl so + * that the created control can be accessed via + * getControl + * + * @param parent the parent composite + */ + public void createControl(Composite parent) + { + Composite container = new Composite(parent, SWT.NULL); + container.setLayout(new FormLayout()); + setControl(container); + + LamsToolBuilderLog.logInfo("Drawing LAMS Tool Template Wizard"); + Composite control = (Composite)getControl(); + + GridLayout layout = new GridLayout(); + layout.verticalSpacing = 10; + control.setLayout(layout); + + createLabel(control, "Please choose a LAMS tool template from the list below to build a new tool." + + "\n\nThis list is derived from your current workspace. To add more tools to your workspace," + + "\nsimply use the 'import' option from the file menu, then enter the following details in" + + "\nthe 'Import Projects From CVS' menu:" + + "\n\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\n\n"); + + //create a group + Group templatesGroup = new Group(control, SWT.NONE); + templatesGroup.setText("Available LAMS Tool Templates"); + GridLayout templatesGroupLayout = new GridLayout(); + templatesGroupLayout.numColumns = 1; + templatesGroup.setLayout(templatesGroupLayout); + templatesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + Group templatesGroup2 = new Group(templatesGroup, SWT.NONE); + + FillLayout fillLayout = new FillLayout(); + fillLayout.type = SWT.VERTICAL; + templatesGroup2.setLayout(fillLayout); + templatesGroup2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + dispList = new List(templatesGroup2, SWT.SINGLE); + + // add all available templates to the list + for(String dir:availableTemplates) + { + dispList.add(dir); + } + + // select the first entry on the displist + if (dispList.getItemCount()>=1) + dispList.select(0); + + // add an event listenter that is run when the user selects a list item + dispList.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent event) + { + String[] selected = dispList.getSelection(); + if (selected.length==1) + { + chosenTemplate = selected[0]; + } + } + + }); + + } + + private Label createLabel(Composite container, String text) { + Label label = new Label(container, SWT.NONE); + label.setText(text); + GridData gd = new GridData(); + gd.horizontalIndent = 30; + label.setLayoutData(gd); + return label; + } + + public String getTemplate () {return chosenTemplate;} + +} + + +