From: Elwin <ecl...@us...> - 2004-10-28 17:24:03
|
Update of /cvsroot/smartfrog/core/extras/eclipse/smartfrog-plugin/smartfrog-plugin-project/src/org/smartfrog/tools/eclipse/ui/project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2136/smartfrog-plugin/smartfrog-plugin-project/src/org/smartfrog/tools/eclipse/ui/project Added Files: messages.properties Configuration.java Messages.java IJavaCoreWrapper.java SmartFrogProject.java OpenCreationWizard.java JavaCoreWrapper.java SmartFrogProjectAction.java Log Message: Plug-in project, init check-in --- NEW FILE: messages.properties --- OpenCreationWizard.Title.CreateWizardError=Create Wizard Error OpenCreationWizard.Error.CreateWizardError=Create Wizard Error --- NEW FILE: SmartFrogProject.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.smartfrog.tools.eclipse.core.ui.NewJavaProjectWizardBase; import org.smartfrog.tools.eclipse.model.builder.SmartFrogProjectBuilder; /** * SmartFrog projet wizard */ public class SmartFrogProject extends NewJavaProjectWizardBase { private static final String LIB_DIR = "lib"; //$NON-NLS-1$ private static String[] sourceFolders = { "src" }; //$NON-NLS-1$ private static String binaryFolder = "bin"; //$NON-NLS-1$ /** * The constructor. */ public SmartFrogProject() { super(( new Configuration(new JavaCoreWrapper()) ), ( "SmartFrog" ), //$NON-NLS-1$ ( "SmartFrog project" ), sourceFolders, binaryFolder); //$NON-NLS-1$ } /** * Creates project structure. * * @param project object * @param progress monitor to show while in the process * * @exception error while creating project structure. */ protected void processPages(IProject arg0, IProgressMonitor monitor) throws CoreException { monitor.worked(1); SmartFrogProjectBuilder.configureSmartFrogProjectBuilder( this.getNewProject( ) ); } } --- NEW FILE: Configuration.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IClasspathEntry; import org.osgi.framework.Bundle; import org.smartfrog.tools.eclipse.SmartFrogPlugin; import org.smartfrog.tools.eclipse.core.SDKEnvironment; import org.smartfrog.tools.eclipse.model.ISmartFrogConstants; import org.smartfrog.tools.eclipse.ui.preference.SmartFrogPreferencePage; import java.net.URL; /** * Configure SmartFrog project properties: libs */ public class Configuration implements SDKEnvironment { private IJavaCoreWrapper fJavaCoreWrapper = null; private static final int LIB_NUM = 1; /** * Constructor for Configuration. */ public Configuration(IJavaCoreWrapper javaCoreWrapper) { super(); fJavaCoreWrapper = javaCoreWrapper; } /** * Constructor for Configuration. */ private Configuration() { super(); } /** * Returns an array of classpaths to libraries. */ public IClasspathEntry[] getClasspath() { IClasspathEntry[] cpe = null; Bundle bundle = SmartFrogPlugin.getDefault().getBundle(); URL installURL = bundle.getEntry("/"); //$NON-NLS-1$ URL localURL = null; cpe = new IClasspathEntry[ ISmartFrogConstants.SMARTFROG_LIBS.length ]; for (int i = 0; i < ISmartFrogConstants.SMARTFROG_LIBS.length; i++) { String libPathStr = SmartFrogPreferencePage.getSmartFrogLocation() + ISmartFrogConstants.SMARTFROG_LIBS[ i ]; Path libPath = new Path(libPathStr); String sourcePathStr = SmartFrogPreferencePage.getSmartFrogLocation() + "/src.zip"; //$NON-NLS-1$ Path sourcePath = new Path(sourcePathStr); cpe[ i ] = fJavaCoreWrapper.newLibraryEntry(libPath, sourcePath, null); } return cpe; } /** * Returns home directory for libraries */ public String getHomeDirectory() { return ""; //$NON-NLS-1$ } } --- NEW FILE: Messages.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import java.util.MissingResourceException; import java.util.ResourceBundle; public class Messages { private static final String BUNDLE_NAME = "org.smartfrog.tools.eclipse.ui.project.messages"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(BUNDLE_NAME); private Messages() { } public static String getString(String key) { try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key + '!'; } } } --- NEW FILE: IJavaCoreWrapper.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IClasspathEntry; /** * Wrapper for JavaCore */ public interface IJavaCoreWrapper { public IClasspathEntry newLibraryEntry(Path entryPath, Path sourcePath, Path sourceRoot); } --- NEW FILE: SmartFrogProjectAction.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.wizard.Wizard; /** * Action to launch SmartFrog project wizard */ public class SmartFrogProjectAction extends OpenCreationWizard { /* (non-Javadoc) * @see org.smartfrog.tools.eclipse.ui.project.OpenCreationWizard#createWizard() */ protected Wizard createWizard() throws CoreException { return new SmartFrogProject(); } } --- NEW FILE: JavaCoreWrapper.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; /** * Wrapper for JavaCore */ public class JavaCoreWrapper implements IJavaCoreWrapper { /** * Constructor for JavaCoreWrapper. */ public JavaCoreWrapper() { super(); } /** * Returns an array of classpath entries */ public IClasspathEntry newLibraryEntry(Path entryPath, Path sourcePath, Path sourceRoot) { return JavaCore.newLibraryEntry(entryPath, sourcePath, sourceRoot); } } --- NEW FILE: OpenCreationWizard.java --- /** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ package org.smartfrog.tools.eclipse.ui.project; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.IWorkbenchWizard; import org.smartfrog.tools.eclipse.model.ExceptionHandler; public abstract class OpenCreationWizard extends Action implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow mWindow = null; private IStructuredSelection mSelection = null; /** * Creates the specific wizard. * (to be implemented by a subclass) */ abstract protected Wizard createWizard() throws CoreException; /** * The user has invoked this action. * @see IActionDelegate#run(IAction) */ public void run(IAction action) { Shell mShell = mWindow.getShell(); try { Wizard wizard = createWizard(); if (wizard instanceof IWorkbenchWizard) { ( (IWorkbenchWizard)wizard ).init(mWindow.getWorkbench(), mSelection); } WizardDialog dialog = new WizardDialog(mShell, wizard); dialog.create(); dialog.open(); } catch (Exception e) { ExceptionHandler.handle(e, mShell, ( Messages.getString( "OpenCreationWizard.Title.CreateWizardError") ), //$NON-NLS-1$ ( Messages.getString( "OpenCreationWizard.Error.CreateWizardError") )); //$NON-NLS-1$ } } public void dispose() { } /* * save the window * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) */ public void init(IWorkbenchWindow window) { this.mWindow = window; } /* * save the selection if of kind IStructuredSelection or * create an empty structured selection. * @see IActionDelegate#selectionChanged(IAction, ISelection) */ public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof IStructuredSelection) { this.mSelection = (IStructuredSelection)selection; } else { this.mSelection = new StructuredSelection(); } } } |