Index: org.lams.toolbuilder/.classpath =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/.classpath,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/.classpath 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,7 @@ + + + + + + + Index: org.lams.toolbuilder/.project =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/.project,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/.project 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,28 @@ + + + org.lams.toolbuilder + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + Index: org.lams.toolbuilder/build.properties =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/build.properties,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/build.properties 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/ Index: org.lams.toolbuilder/plugin.xml =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/plugin.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/plugin.xml 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + Index: org.lams.toolbuilder/META-INF/MANIFEST.MF =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/META-INF/MANIFEST.MF,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/META-INF/MANIFEST.MF 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: LAMS Tool Builder Plug-in +Bundle-SymbolicName: org.lams.toolbuilder; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.lams.toolbuilder.LAMSToolBuilderPlugin +Bundle-Vendor: LAMS +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.jface.text, + org.eclipse.core.resources, + org.eclipse.ui.editors, + org.eclipse.ui.ide, + org.eclipse.ui.workbench.texteditor, + org.eclipse.jdt.core, + org.eclipse.jdt.ui +Eclipse-LazyStart: true Index: org.lams.toolbuilder/icons/dolly.ico =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/icons/dolly.ico,v diff -u Binary files differ Index: org.lams.toolbuilder/icons/sample.gif =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/icons/sample.gif,v diff -u Binary files differ Index: org.lams.toolbuilder/src/org/lams/toolbuilder/LAMSToolBuilderPlugin.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/LAMSToolBuilderPlugin.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/LAMSToolBuilderPlugin.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,61 @@ +package org.lams.toolbuilder; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class LAMSToolBuilderPlugin extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.lams.toolbuilder"; + + // The shared instance + private static LAMSToolBuilderPlugin plugin; + + /** + * The constructor + */ + public LAMSToolBuilderPlugin() { + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static LAMSToolBuilderPlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} Index: org.lams.toolbuilder/src/org/lams/toolbuilder/editors/MultiPageToolEditor.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/editors/Attic/MultiPageToolEditor.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/editors/MultiPageToolEditor.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,239 @@ +package org.lams.toolbuilder.editors; + + +import java.io.StringWriter; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.StringTokenizer; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.ui.*; +import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.MultiPageEditorPart; +import org.eclipse.ui.ide.IDE; + +/** + * An example showing how to create a multi-page editor. + * This example has 3 pages: + * + */ +public class MultiPageToolEditor extends MultiPageEditorPart implements IResourceChangeListener{ + + /** The text editor used in page 0. */ + private TextEditor editor; + + /** The font chosen in page 1. */ + private Font font; + + /** The text widget used in page 2. */ + private StyledText text; + /** + * Creates a multi-page editor example. + */ + public MultiPageToolEditor() { + super(); + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + /** + * Creates page 0 of the multi-page editor, + * which contains a text editor. + */ + void createPage0() { + try { + editor = new TextEditor(); + int index = addPage(editor, getEditorInput()); + setPageText(index, editor.getTitle()); + } catch (PartInitException e) { + ErrorDialog.openError( + getSite().getShell(), + "Error creating nested text editor", + null, + e.getStatus()); + } + } + /** + * Creates page 1 of the multi-page editor, + * which allows you to change the font used in page 2. + */ + void createPage1() { + + Composite composite = new Composite(getContainer(), SWT.NONE); + GridLayout layout = new GridLayout(); + composite.setLayout(layout); + layout.numColumns = 2; + + Button fontButton = new Button(composite, SWT.NONE); + GridData gd = new GridData(GridData.BEGINNING); + gd.horizontalSpan = 2; + fontButton.setLayoutData(gd); + fontButton.setText("Change Font..."); + + fontButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + setFont(); + } + }); + + int index = addPage(composite); + setPageText(index, "Properties"); + } + /** + * Creates page 2 of the multi-page editor, + * which shows the sorted text. + */ + void createPage2() { + Composite composite = new Composite(getContainer(), SWT.NONE); + FillLayout layout = new FillLayout(); + composite.setLayout(layout); + text = new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL); + text.setEditable(false); + + int index = addPage(composite); + setPageText(index, "Preview"); + } + /** + * Creates the pages of the multi-page editor. + */ + protected void createPages() { + createPage0(); + createPage1(); + createPage2(); + } + /** + * The MultiPageEditorPart implementation of this + * IWorkbenchPart method disposes all nested editors. + * Subclasses may extend. + */ + public void dispose() { + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + super.dispose(); + } + /** + * Saves the multi-page editor's document. + */ + public void doSave(IProgressMonitor monitor) { + getEditor(0).doSave(monitor); + } + /** + * Saves the multi-page editor's document as another file. + * Also updates the text for page 0's tab, and updates this multi-page editor's input + * to correspond to the nested editor's. + */ + public void doSaveAs() { + IEditorPart editor = getEditor(0); + editor.doSaveAs(); + setPageText(0, editor.getTitle()); + setInput(editor.getEditorInput()); + } + /* (non-Javadoc) + * Method declared on IEditorPart + */ + public void gotoMarker(IMarker marker) { + setActivePage(0); + IDE.gotoMarker(getEditor(0), marker); + } + /** + * The MultiPageEditorExample implementation of this method + * checks that the input is an instance of IFileEditorInput. + */ + public void init(IEditorSite site, IEditorInput editorInput) + throws PartInitException { + if (!(editorInput instanceof IFileEditorInput)) + throw new PartInitException("Invalid Input: Must be IFileEditorInput"); + super.init(site, editorInput); + } + /* (non-Javadoc) + * Method declared on IEditorPart. + */ + public boolean isSaveAsAllowed() { + return true; + } + /** + * Calculates the contents of page 2 when the it is activated. + */ + protected void pageChange(int newPageIndex) { + super.pageChange(newPageIndex); + if (newPageIndex == 2) { + sortWords(); + } + } + /** + * Closes all project files on project close. + */ + public void resourceChanged(final IResourceChangeEvent event){ + if(event.getType() == IResourceChangeEvent.PRE_CLOSE){ + Display.getDefault().asyncExec(new Runnable(){ + public void run(){ + IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); + for (int i = 0; i/?|\\"); + ArrayList editorWords = new ArrayList(); + while (tokenizer.hasMoreTokens()) { + editorWords.add(tokenizer.nextToken()); + } + + Collections.sort(editorWords, Collator.getInstance()); + StringWriter displayText = new StringWriter(); + for (int i = 0; i < editorWords.size(); i++) { + displayText.write(((String) editorWords.get(i))); + displayText.write(System.getProperty("line.separator")); + } + text.setText(displayText.toString()); + } +} Index: org.lams.toolbuilder/src/org/lams/toolbuilder/editors/MultiPageToolEditorContributor.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/editors/Attic/MultiPageToolEditorContributor.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/editors/MultiPageToolEditorContributor.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,103 @@ +package org.lams.toolbuilder.editors; + +import org.eclipse.jface.action.*; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.ide.IDEActionFactory; +import org.eclipse.ui.part.MultiPageEditorActionBarContributor; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.ITextEditorActionConstants; + +/** + * Manages the installation/deinstallation of global actions for multi-page editors. + * Responsible for the redirection of global actions to the active editor. + * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor. + */ +public class MultiPageToolEditorContributor extends MultiPageEditorActionBarContributor { + private IEditorPart activeEditorPart; + private Action sampleAction; + /** + * Creates a multi-page contributor. + */ + public MultiPageToolEditorContributor() { + super(); + createActions(); + } + /** + * Returns the action registed with the given text editor. + * @return IAction or null if editor is null. + */ + protected IAction getAction(ITextEditor editor, String actionID) { + return (editor == null ? null : editor.getAction(actionID)); + } + /* (non-JavaDoc) + * Method declared in AbstractMultiPageEditorActionBarContributor. + */ + + public void setActivePage(IEditorPart part) { + if (activeEditorPart == part) + return; + + activeEditorPart = part; + + IActionBars actionBars = getActionBars(); + if (actionBars != null) { + + ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; + + actionBars.setGlobalActionHandler( + ActionFactory.DELETE.getId(), + getAction(editor, ITextEditorActionConstants.DELETE)); + actionBars.setGlobalActionHandler( + ActionFactory.UNDO.getId(), + getAction(editor, ITextEditorActionConstants.UNDO)); + actionBars.setGlobalActionHandler( + ActionFactory.REDO.getId(), + getAction(editor, ITextEditorActionConstants.REDO)); + actionBars.setGlobalActionHandler( + ActionFactory.CUT.getId(), + getAction(editor, ITextEditorActionConstants.CUT)); + actionBars.setGlobalActionHandler( + ActionFactory.COPY.getId(), + getAction(editor, ITextEditorActionConstants.COPY)); + actionBars.setGlobalActionHandler( + ActionFactory.PASTE.getId(), + getAction(editor, ITextEditorActionConstants.PASTE)); + actionBars.setGlobalActionHandler( + ActionFactory.SELECT_ALL.getId(), + getAction(editor, ITextEditorActionConstants.SELECT_ALL)); + actionBars.setGlobalActionHandler( + ActionFactory.FIND.getId(), + getAction(editor, ITextEditorActionConstants.FIND)); + actionBars.setGlobalActionHandler( + IDEActionFactory.BOOKMARK.getId(), + getAction(editor, IDEActionFactory.BOOKMARK.getId())); + actionBars.updateActionBars(); + } + } + private void createActions() { + sampleAction = new Action() { + public void run() { + MessageDialog.openInformation(null, "LAMS Tool Builder Plug-in", "Sample Action Executed"); + } + }; + sampleAction.setText("Sample Action"); + sampleAction.setToolTipText("Sample Action tool tip"); + sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). + getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK)); + } + public void contributeToMenu(IMenuManager manager) { + IMenuManager menu = new MenuManager("Editor &Menu"); + manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu); + menu.add(sampleAction); + } + public void contributeToToolBar(IToolBarManager manager) { + manager.add(new Separator()); + manager.add(sampleAction); + } +} 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/util/Constants.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,15 @@ +package org.lams.toolbuilder.util; + +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"; + public static final String PROP_TOOL_VERSION = "tool.version"; + public static final String PROP_PACKAGE = "package"; + public static final String PROP_PACKAGE_PATH = "package.path"; + public static final String PROP_SERVER_VERSION = "min.server.version.number"; + public static final String PROP_LANG_PACKAGE = "language.files.package"; + public static final String PROP_HIDE_TOOL = "hideTool"; +} Index: org.lams.toolbuilder/src/org/lams/toolbuilder/util/LamsToolBuilderLog.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/util/LamsToolBuilderLog.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/util/LamsToolBuilderLog.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,99 @@ +package org.lams.toolbuilder.util; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.lams.toolbuilder.LAMSToolBuilderPlugin; + + +public class LamsToolBuilderLog +{ + /** + * Log the specified information. + * + * @param message, a human-readable message, localized to the + * current locale. + */ + public static void logInfo(String message) { + log(IStatus.INFO, IStatus.OK, message, null); + } + + /** + * Log the specified error. + * + * @param exception, a low-level exception. + */ + public static void logError(Throwable exception) { + logError("Unexpected Exception", exception); + } + + /** + * Log the specified error. + * + * @param message, a human-readable message, localized to the + * current locale. + * @param exception, a low-level exception, or null + * if not applicable. + */ + public static void logError(String message, Throwable exception) { + log(IStatus.ERROR, IStatus.OK, message, exception); + } + + /** + * Log the specified information. + * + * @param severity, the severity; one of the following: + * IStatus.OK, + * IStatus.ERROR, + * IStatus.INFO, or + * IStatus.WARNING. + * @param pluginId. the unique identifier of the relevant + * plug-in. + * @param code, the plug-in-specific status code, or + * OK. + * @param message, a human-readable message, localized to the + * current locale. + * @param exception, a low-level exception, or null + * if not applicable. + */ + public static void log(int severity, int code, String message, + Throwable exception) { + + log(createStatus(severity, code, message, exception)); + } + + /** + * Create a status object representing the specified information. + * + * @param severity, the severity; one of the following: + * IStatus.OK, + * IStatus.ERROR, + * IStatus.INFO, or + * IStatus.WARNING. + * @param pluginId, the unique identifier of the relevant + * plug-in. + * @param code, the plug-in-specific status code, or + * OK. + * @param message, a human-readable message, localized to the + * current locale. + * @param exception, a low-level exception, or null + * if not applicable. + * @return, the status object (not null). + */ + public static IStatus createStatus(int severity, int code, + String message, Throwable exception) { + + return new Status(severity, LAMSToolBuilderPlugin.PLUGIN_ID, code, + message, exception); + } + + /** + * Log the given status. + * + * @param status, the status to log. + */ + public static void log(IStatus status) { + LAMSToolBuilderPlugin.getDefault().getLog().log(status); + } + + +} 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizard.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,262 @@ +package org.lams.toolbuilder.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.core.runtime.*; +import org.eclipse.jface.operation.*; +import java.lang.reflect.InvocationTargetException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.CoreException; +import java.io.*; +import org.eclipse.ui.*; +import org.eclipse.ui.ide.IDE; +import org.lams.toolbuilder.util.LamsToolBuilderLog; +import java.util.Properties; +import org.lams.toolbuilder.util.Constants; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jface.wizard.ProgressMonitorPart; +/** + * This is a sample new wizard. Its role is to create a new file + * resource in the provided container. If the container resource + * (a folder or a project) is selected in the workspace + * when the wizard is opened, it will accept it as the target + * container. The wizard creates one file with the extension + * "mpe". If a sample multi-page editor (also available + * as a template) is registered for the same extension, it will + * be able to open it. + */ + +public class LAMSNewToolWizard extends Wizard implements INewWizard { + private LAMSNewToolWizardPage page; + private ISelection selection; + + private static String toolName; + private static String vendor; + private static String compatibility; + private static String toolSignature; + private static boolean isLAMS; + private static boolean toolVisible; + + /** + * Constructor for LAMSNewToolWizard. + */ + public LAMSNewToolWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + LamsToolBuilderLog.logInfo("Adding pages to LAMS Tool Wizard"); + page = new LAMSNewToolWizardPage(selection); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + LamsToolBuilderLog.logInfo("Attempting to perform finish for LAMS Tool Wizard"); + + // Get the project from the page + final IProject project = page.getProjectHandle(); + + //private static String toolName; + vendor = page.getVendor(); + compatibility = page.getCompatibility(); + toolSignature = page.getToolSignature(); + isLAMS = page.getIsLams(); + toolVisible = page.getVisible(); + + // create a project descriptor + IPath projPath = null; + if (!page.useDefaults()) + { + projPath = page.getLocationPath(); + /*if (newPath.toFile().exists()) { + // add the project key to the path if this folder exists + newPath = newPath.addTrailingSeparator().append(projectKey).addTrailingSeparator(); + System.out.println("Changed project location to: " + newPath); + } + */ + } + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + final IProjectDescription description = workspace.newProjectDescription(project.getName()); + description.setLocation(projPath.append("lams_tool")); + + + // setup java project capability + IJavaProject jproject = JavaCore.create(project); + IPath output = project.getFolder("bin").getFullPath(); + + //ProgressMonitorPart monitor = new ProgressMonitorPart(); + + try{ + + monitor.beginTask("Create LAMS Tool Project", 2); + project.create(description, new SubProgressMonitor(monitor, 1000)); + monitor.done(); + } + catch (CoreException e) + { + + } + + + + return true; + + /* + projectKey = page.getProjectKey().trim(); + projectPackage = page.getProjectPackage().trim(); + PACKAGE_BASE = projectPackage.replaceAll("\\.", "\\/") + "/"; + //System.out.println("AZAZAZ: new PACKAGE_BASE = " + PACKAGE_BASE); + projectType = page.getProjectType(); + projectImpl = page.getProjectImpl(); + addTesting = page.isTesting(); + */ + + /* + final String toolName = page.getToolName(); + final String toolSignature = page.getToolSignature(); + final String vendor = page.getVendor(); + final String compatibility = page.getCompatibility(); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(toolName, toolSignature, vendor, compatibility, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + */ + } + + private void createLamsProject (IProject projectHandle, IProjectDescription description,IProgressMonitor monitor) + throws CoreException, OperationCanceledException + { + monitor.beginTask("Creating LAMS tool project", 10); + + projectHandle.create(description, monitor); + monitor.worked(2); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + + private void doFinish( + String toolName, + String toolSignature, + String vendor, + String compatibility, + IProgressMonitor monitor) + throws CoreException { + // create a sample file + monitor.beginTask("Creating build.properties", 2); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + Properties buildProperties = new Properties(); + buildProperties.setProperty(Constants.PROP_TOOL_NAME, toolName); + buildProperties.setProperty(Constants.PROP_SIGNATURE, toolSignature); + buildProperties.setProperty(Constants.PROP_PACKAGE, "org.lams.testtool"); + buildProperties.setProperty(Constants.PROP_PACKAGE_PATH, "org/lams/testtool"); + buildProperties.setProperty(Constants.PROP_TOOL_VERSION, "20070000"); + buildProperties.setProperty(Constants.PROP_SERVER_VERSION, compatibility); + buildProperties.setProperty(Constants.PROP_HIDE_TOOL, "false"); + + + + + + + + /*IResource resource = root.findMember(new Path(containerName)); + if (!resource.exists() || !(resource instanceof IContainer)) { + throwCoreException("Container \"" + containerName + "\" does not exist."); + } + + IContainer container = (IContainer) resource; + final IFile file = container.getFile(new Path(fileName)); + try { + InputStream stream = openContentStream(); + if (file.exists()) { + file.setContents(stream, true, true, monitor); + } else { + file.create(stream, true, monitor); + } + stream.close(); + } catch (IOException e) { + } + monitor.worked(1); + monitor.setTaskName("Opening file for editing..."); + getShell().getDisplay().asyncExec(new Runnable() { + public void run() { + IWorkbenchPage page = + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, file, true); + } catch (PartInitException e) { + } + } + }); + */ + monitor.worked(1); + } + + /** + * We will initialize file contents with a sample text. + */ + + private InputStream openContentStream() { + String contents = + "This is the initial file contents for *.mpe file that should be word-sorted in the Preview page of the multi-page editor"; + return new ByteArrayInputStream(contents.getBytes()); + } + + private void throwCoreException(String message) throws CoreException { + IStatus status = + new Status(IStatus.ERROR, "org.lams.toolbuilder", IStatus.OK, message, null); + throw new CoreException(status); + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } +} \ No newline at end of file Index: org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardPage.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardPage.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/LAMSNewToolWizardPage.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,437 @@ +package org.lams.toolbuilder.wizards; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; +import org.lams.toolbuilder.util.LamsToolBuilderLog; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; + + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (mpe). + */ + +public class LAMSNewToolWizardPage extends WizardNewProjectCreationPage { + private Text toolName; + private Text vendor; + private Text compatibility; + private Text toolSignature; + private Button LAMSButton; + private Button RAMSButton; + private Button notVisible; + private Button isVisible; + + + private ISelection selection; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public LAMSNewToolWizardPage(ISelection selection) { + super("wizardPage"); + setTitle(WizardConstants.WIZARD_TITLE); + setDescription(WizardConstants.WIZARD_DESCRIPTION); + this.selection = selection; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + LamsToolBuilderLog.logInfo("Drawing LAMS Tool Wizard"); + super.createControl(parent); + + Composite control = (Composite)getControl(); + GridLayout layout = new GridLayout(); + layout.verticalSpacing = 10; + control.setLayout(layout); + + // create a group + Group namesGroup = new Group(control, SWT.NONE); + namesGroup.setText("Tool Project Meta-Data"); + GridLayout namesLayout = new GridLayout(); + namesLayout.numColumns = 2; + namesGroup.setLayout(namesLayout); + namesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // put the key field in the group + createLabel(namesGroup, "Tool Signature"); + toolSignature = createText(namesGroup); + toolSignature.setText(WizardConstants.SAMPLE_TOOL_SIGNATURE); /*createLabel(namesGroup, ""); //$NON-NLS-1$ + Label label = new Label(namesGroup, SWT.WRAP); + label.setText(KEY_INSTRUCTIONS); + GridData gd = new GridData(); + gd.horizontalIndent = 30; + label.setLayoutData(gd); + */ + + // put the package field in the group + createLabel(namesGroup, "Vendor Prefix"); + vendor = createText(namesGroup); + vendor.setText(WizardConstants.SAMPLE_VENDOR); + + createLabel(namesGroup, "Minimum Server Version"); + compatibility = createText(namesGroup); + compatibility.setText(WizardConstants.LAMS_BASE_VERSION); + + // create a group for columns + Group organisingGroup = new Group(control, SWT.NONE); + organisingGroup.setText("Tool Options"); + GridLayout organisingLayout = new GridLayout(); + organisingLayout.numColumns = 3; + organisingGroup.setLayout(organisingLayout); + organisingGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + // create a group + Group typesGroup = new Group(organisingGroup, SWT.NONE); + typesGroup.setText("Tool Type"); + GridLayout typesLayout = new GridLayout(); + typesLayout.numColumns = 1; + typesGroup.setLayout(typesLayout); + typesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + int buttonSpan = 50; + int buttonIndent = 10; + + GridData gdButton = new GridData(); + gdButton.horizontalSpan = buttonSpan; + gdButton.horizontalIndent = buttonIndent; + + LAMSButton = createButton(typesGroup, SWT.RADIO, buttonSpan, buttonIndent); + LAMSButton.setText("LAMS"); + LAMSButton.setSelection(true); + RAMSButton = createButton(typesGroup, SWT.RADIO, buttonSpan, buttonIndent); + RAMSButton.setText("RAMS"); + + // create a group + Group toolVisibleGroup = new Group(organisingGroup, SWT.NONE); + toolVisibleGroup.setText("Make Tool Visible"); + GridLayout toolVisibleLayout = new GridLayout(); + toolVisibleLayout.numColumns = 1; + toolVisibleGroup.setLayout(toolVisibleLayout); + toolVisibleGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + GridData gdButton2 = new GridData(); + gdButton2.horizontalSpan = buttonSpan; + gdButton2.horizontalIndent = buttonIndent; + + isVisible = createButton(toolVisibleGroup, SWT.RADIO, buttonSpan, buttonIndent); + isVisible.setText("Yes"); + isVisible.setSelection(true); + notVisible = createButton(toolVisibleGroup, SWT.RADIO, buttonSpan, buttonIndent); + notVisible.setText("No"); + + + /* + for (int i=0; i 1) + return; + Object obj = ssel.getFirstElement(); + if (obj instanceof IResource) { + IContainer container; + if (obj instanceof IContainer) + container = (IContainer) obj; + else + container = ((IResource) obj).getParent(); + compatibility.setText(container.getFullPath().toString()); + } + } + + compatibility.setText(WizardConstants.LAMS_BASE_VERSION); + toolName.setText(WizardConstants.SAMPLE_TOOL_NAME); + toolSignature.setText(WizardConstants.SAMPLE_TOOL_SIGNATURE); + vendor.setText(WizardConstants.SAMPLE_VENDOR); + } + + /** + * Uses the standard container selection dialog to choose the new value for + * the container field. + */ + + /*private void handleBrowse() { + ContainerSelectionDialog dialog = new ContainerSelectionDialog( + getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, + "Select new file container"); + if (dialog.open() == ContainerSelectionDialog.OK) { + Object[] result = dialog.getResult(); + if (result.length == 1) { + containerText.setText(((Path) result[0]).toString()); + } + } + }*/ + + /** + * Ensures that all required fields are set. + */ + private void dialogChanged() { + //IResource container = ResourcesPlugin.getWorkspace().getRoot() + // .findMember(new Path(getContainerName())); + + + if (getToolName().length() == 0) { + updateStatus("Tool Name must be specified"); + return; + } + if (getToolSignature().length() == 0) { + updateStatus("Tool Signature must be specified"); + return; + } + if (getCompatibility().length() == 0) { + updateStatus("Content Compatibility must be specified"); + return; + } + + + /*if (container == null + || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { + updateStatus("File container must exist"); + return; + } + if (!container.isAccessible()) { + updateStatus("Project must be writable"); + return; + } + */ + + /* + * String fileName = getFileName(); + * if (fileName.length() == 0) { + updateStatus("File name must be specified"); + return; + } + if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { + updateStatus("File name must be valid"); + return; + } + int dotLoc = fileName.lastIndexOf('.'); + if (dotLoc != -1) { + String ext = fileName.substring(dotLoc + 1); + if (ext.equalsIgnoreCase("mpe") == false) { + updateStatus("File extension must be \"mpe\""); + return; + } + }*/ + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + private Button createButton(Composite container, int style, int span, int indent) { + Button button = new Button(container, style); + GridData gd = new GridData(); + gd.horizontalSpan = span; + gd.horizontalIndent = indent; + button.setLayoutData(gd); + return button; + } + + 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; + } + + private Text createText(Composite container) { + Text text = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 300; + text.setLayoutData(gd); + text.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + setPageComplete(validatePage()); + } + }); + return text; + } + + + + public String getToolName(){return toolName.getText();} + public String getVendor(){return vendor.getText();} + public String getToolSignature() {return toolSignature.getText();} + public String getCompatibility(){return compatibility.getText();} + public boolean getIsLams(){return LAMSButton.getSelection();} + public boolean getVisible(){return isVisible.getSelection();} + +} \ No newline at end of file Index: org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/WizardConstants.java =================================================================== RCS file: /usr/local/cvsroot/org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/WizardConstants.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org.lams.toolbuilder/src/org/lams/toolbuilder/wizards/WizardConstants.java 22 Aug 2007 14:07:19 -0000 1.1 @@ -0,0 +1,13 @@ +package org.lams.toolbuilder.wizards; + +public class WizardConstants +{ + // Wizard constants + public static String WIZARD_TITLE = "LAMS Tool Builder Wizard"; + public static String WIZARD_DESCRIPTION = "This wizard creates an empty LAMS tool project"; + public static String LAMS_BASE_VERSION = "2.0"; + public static String TOOL_VERSION="20070000"; + public static String SAMPLE_TOOL_NAME = "Sample Tool"; + public static String SAMPLE_TOOL_SIGNATURE = "lams_tool_smpl"; + public static String SAMPLE_VENDOR = "org.lamsfoundation"; +}