[Esbox-commits] r206 - in trunk/org.indt.esbox.python.ui: . src/org/indt/esbox/python/ui src/org/indt/esbox/python/ui/wizards
carolina at garage.maemo.org
carolina at garage.maemo.org
Tue Oct 30 23:59:04 EET 2007
Author: carolina
Date: 2007-10-30 23:59:01 +0200 (Tue, 30 Oct 2007)
New Revision: 206
Added:
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonConfigHandler.java
Modified:
trunk/org.indt.esbox.python.ui/plugin.xml
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonCommonProjectWizard.java
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonConfigWizardPage.java
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonMainWizardPage.java
Log:
Showing python templates.
Modified: trunk/org.indt.esbox.python.ui/plugin.xml
===================================================================
--- trunk/org.indt.esbox.python.ui/plugin.xml 2007-10-30 19:53:48 UTC (rev 205)
+++ trunk/org.indt.esbox.python.ui/plugin.xml 2007-10-30 21:59:01 UTC (rev 206)
@@ -44,17 +44,9 @@
<runtime>
<run class="org.indt.esbox.python.ui.ESboxPythonProjectNature"/>
</runtime>
- <builder id="org.indt.esbox.python.ui.pluthonBuilder"/>
- </extension>
- <extension
- id="esboxBuilder"
- name="Builder for ESbox Python Projects"
- point="org.eclipse.core.resources.builders">
<builder
- hasNature="true"
- isConfigurable="false">
- <run class="org.indt.esbox.python.ui.ESboxPythonBuilder"/>
- </builder>
+ id="org.python.pydev.PyDevBuilder">
+ </builder>
</extension>
</plugin>
Added: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonConfigHandler.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonConfigHandler.java (rev 0)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonConfigHandler.java 2007-10-30 21:59:01 UTC (rev 206)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.python.ui;
+
+import org.eclipse.cdt.ui.templateengine.Template;
+import org.indt.esbox.core.maemosdk.MaemoSDKInfo;
+import org.indt.esbox.core.platform.PlatformInfo;
+
+
+/**
+ * Contains elements used to configure an ESbox Project:
+ * <br>
+ * - A template info to identify which is the project type;
+ * - A platform info to identify which is the target platform of the project;
+ * - A Maemo SDK info to identify which is the current project SDK;
+ * - A platform toolchain and a project type to configure elements to build project;
+ */
+public class ESboxPythonConfigHandler {
+
+ private Template template;
+ private PlatformInfo platformInfo;
+ private MaemoSDKInfo sdkInfo;
+// private IToolChain esboxToolChain;
+// private IProjectType projectType;
+ private String targetName;
+
+
+
+ /**
+ * Constructor.
+ * @param templateInfo information about the template of the project.
+ * @param platformInfo information about platform of project.
+ * @param sdkInfo information about Maemo SDK used by project.
+ */
+ public ESboxPythonConfigHandler(Template template,
+ PlatformInfo platformInfo, MaemoSDKInfo sdkInfo) {
+ this.template = template;
+ this.platformInfo = platformInfo;
+ this.sdkInfo = sdkInfo;
+// initializeProjectType();
+ // initializeESboxToolChain();
+
+ }
+
+ /**
+ * Constructor.
+ * Constructs an empty configure handler.
+ */
+ public ESboxPythonConfigHandler() {
+ this(null,null,null);
+ }
+
+// /**
+// * Initialize the project type. It is used to configure initial settings of project.
+// * The project type has id "cdt.managedbuild.target.gnu.exe".
+// * Such project type is already defined on plug-in org.eclipse.cdt.managedbuilder.gnu.ui.
+// * For more information, see the plugin.xml file of such plug-in
+// * (org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point).
+// */
+// private void initializeProjectType() {
+// SortedMap sm = ManagedBuildManager.getExtensionProjectTypeMap();
+// final String pt = "cdt.managedbuild.target.gnu.exe";
+// projectType = (IProjectType)sm.get(pt);
+// }
+
+// /**
+// * Initialize the project toolchain. It is used to configure initial settings of project.
+// * The project toolchain is Linux GCC.
+// * Such project type is already defined on plug-in org.eclipse.cdt.managedbuilder.gnu.ui.
+// * For more information, see the plugin.xml file of such plug-in
+// * (org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point).
+// */
+// private void initializeESboxToolChain() {
+// IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(MBSWizardHandler.ARTIFACT, MBSWizardHandler.ARTIFACT + ".exe", false);
+// for (int i = 0; i < tcs.length; i++) {
+// IToolChain toolChain = tcs[i];
+// if (toolChain.getName().equals("Linux GCC")) {
+// esboxToolChain = toolChain;
+// }
+// }
+// }
+
+ /**
+ * Return the template info.
+ * @return the template info.
+ */
+ public Template getTemplate() {
+ return template;
+ }
+
+ /**
+ * Modify the current template info.
+ * @param template the new template info.
+ */
+ public void setTemplate(Template template) {
+ this.template = template;
+ }
+
+ /**
+ * Return the platform info.
+ * @return the platform info
+ */
+ public PlatformInfo getPlatformInfo() {
+ return platformInfo;
+ }
+
+ /**
+ * Modify the current platform info.
+ * @param platformInfo the new platform info.
+ */
+ public void setPlatformInfo(PlatformInfo platformInfo) {
+ this.platformInfo = platformInfo;
+ }
+
+ /**
+ * Return the Maemo SDK info.
+ * @return the Maemo SDK info.
+ */
+ public MaemoSDKInfo getSdkInfo() {
+ return sdkInfo;
+ }
+
+ /**
+ * Modify the current Maemo SDK info.
+ * @param sdkInfo the new Maemo SDK info.
+ */
+ public void setSdkInfo(MaemoSDKInfo sdkInfo) {
+ this.sdkInfo = sdkInfo;
+ }
+
+// /**
+// * Return the toolchain of ESbox projects.
+// * @return the ESbox toolchain project.
+// */
+// public IToolChain getESboxToolChain() {
+// return esboxToolChain;
+// }
+
+ /**
+// * Return the type of ESbox projects.
+// * @return the ESbox project type.
+// */
+// public IProjectType getProjectType() {
+// return projectType;
+// }
+//
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(String newTargetName) {
+ this.targetName = newTargetName;
+ }
+
+ public String createTargetName() {
+ String platformName = getPlatformInfo().getName();
+ String sdkVersion = getSdkInfo().getVersion();
+ sdkVersion = sdkVersion.replace('.', '_');
+ String targetName = "SDK_" + platformName + "_" + sdkVersion;
+ return targetName;
+ }
+}
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonCommonProjectWizard.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonCommonProjectWizard.java 2007-10-30 19:53:48 UTC (rev 205)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonCommonProjectWizard.java 2007-10-30 21:59:01 UTC (rev 206)
@@ -12,6 +12,7 @@
package org.indt.esbox.python.ui.wizards;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -25,6 +26,7 @@
import org.eclipse.cdt.ui.templateengine.Template;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUIUtil;
import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage;
+import org.eclipse.cdt.ui.wizards.IWizardWithMemory;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -33,10 +35,10 @@
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -45,31 +47,30 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxPreferenceConstants;
import org.indt.esbox.core.ESboxProjectProperties;
import org.indt.esbox.core.ErrorLogger;
import org.indt.esbox.core.scratchbox.ScratchboxException;
import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.python.ui.ESboxPythonConfigHandler;
import org.indt.esbox.python.ui.ESboxPythonProjectNature;
-import org.indt.esbox.ui.ESboxConfigHandler;
import org.indt.esbox.ui.UIActivator;
import org.python.pydev.plugin.PydevPlugin;
import org.python.pydev.plugin.nature.PythonNature;
import org.python.pydev.ui.perspective.PythonPerspectiveFactory;
-public abstract class ESboxPythonCommonProjectWizard extends Wizard implements INewWizard {
+public abstract class ESboxPythonCommonProjectWizard extends BasicNewResourceWizard implements INewWizard, IWizardWithMemory {
private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
private static final String[] EMPTY_ARR = new String[0];
-
- protected IConfigurationElement fConfigElement;
+
protected CfgHolder[] cfgs = new CfgHolder[0];
protected ESboxPythonMainWizardPage fMainPage;
protected ESboxPythonConfigWizardPage configPage;
@@ -81,7 +82,7 @@
private boolean existingPath = false;
private String lastProjectName = null;
private IPath lastProjectLocation = null;
- private ESboxConfigHandler esboxHandler;
+ private ESboxPythonConfigHandler esboxHandler;
private IWizardPage[] templatePages;
private IWorkbench workbench;
@@ -133,8 +134,81 @@
setDefaultPageImageDescriptor(desc);
}
+ /**
+ * @return true if user has changed settings since project creation
+ */
+ private boolean isChanged() {
+ if (!fMainPage.getProjectName().equals(lastProjectName))
+ return true;
+
+ IPath projectLocation = fMainPage.getProjectLocation();
+ if (projectLocation == null) {
+ if (lastProjectLocation != null)
+ return true;
+ } else if (!projectLocation.equals(lastProjectLocation))
+ return true;
+
+ return true;
+ }
+
/**
+ * Return the project created by this wizard.
+ * @param defaults use default configurations.
+ * @return the project created by this wizard.
+ */
+ public IProject getProject(boolean defaults) {
+ return getProject(defaults, true);
+ }
+
+ /**
+ *
+ * @param defaults
+ * @param onFinish
+ * @return
+ */
+ public IProject getProject(boolean defaults, boolean onFinish) {
+ if (newProject != null && isChanged())
+ clearProject();
+ if (newProject == null) {
+ existingPath = false;
+ IPath p = fMainPage.getProjectLocation();
+ if (p == null) {
+ p = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ p = p.append(fMainPage.getProjectName());
+ }
+ File f = p.toFile();
+ if (f.exists() && f.isDirectory()) {
+ if (p.append(".project").toFile().exists()) { //$NON-NLS-1$
+ if (!
+ MessageDialog.openConfirm(getShell(),
+ UIMessages.getString("CDTCommonProjectWizard.0"), //$NON-NLS-1$
+ UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$
+ )
+ return null;
+ }
+ existingPath = true;
+ }
+ lastProjectName = fMainPage.getProjectName();
+ lastProjectLocation = fMainPage.getProjectLocation();
+
+ // start creation process
+ try {
+ createNewProject();
+ setProject(newProject, new NullProgressMonitor());
+ } catch (InvocationTargetException e) {
+ clearProject();
+ e.printStackTrace();
+ } catch (CoreException e) {
+ clearProject();
+ e.printStackTrace();
+ }
+ }
+ return newProject;
+ }
+
+
+ /**
* Remove created project either after error
* or if user returned back from config page.
*/
@@ -153,26 +227,20 @@
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
- try {
- // create project if it is not created yet
- createNewProject();
- } catch (Exception e) {
- //clearProject();
- e.printStackTrace();
- //return false;
- }
- // Switch to default perspective
+ // create project if it is not created yet
+ if (getProject(fMainPage.isCurrent(), true) == null)
+ return false;
+
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
try {
workbench.showPerspective(PythonPerspectiveFactory.PERSPECTIVE_ID, window);
- } catch (WorkbenchException e) {
- return false;
+ } catch (WorkbenchException e) {
+ e.printStackTrace();
}
return true;
}
-
/*
* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performCancel()
@@ -182,10 +250,6 @@
return true;
}
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- fConfigElement= config;
- }
-
/**
* Creates a project resource given the project handle and description.
*
@@ -262,21 +326,20 @@
Throwable t = e.getTargetException();
if (t instanceof CoreException) {
if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- MessageDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle1", "IDEWorkbenchMessages.CreateProjectWizard_caseVariantExistsError");
+ MessageDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle", "IDEWorkbenchMessages.CreateProjectWizard_caseVariantExistsError");
e.printStackTrace();
} else {
e.printStackTrace();
- ErrorDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle2", null, ((CoreException) t).getStatus());
+ ErrorDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle", null, ((CoreException) t).getStatus());
}
} else {
//Unexpected runtime exceptions and errors may still occur.
PydevPlugin.log(IStatus.ERROR, t.toString(), t);
- MessageDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle3", t.getMessage());
+ MessageDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle", t.getMessage());
}
throw e;
}
- newProject = newProjectHandle;
-
+ newProject = newProjectHandle;
return newProjectHandle;
}
@@ -353,8 +416,7 @@
projectProperties.setPlatform(project, esboxHandler.getPlatformInfo().getName());
projectProperties.setTargetName(project, esboxHandler.getTargetName());
- doPostProcess(project);
-
+ doPostProcess(project);
}
public String getBuildSystemId(){
@@ -365,7 +427,7 @@
configureScratchbox();
if (newProject != null)
- configureTemplate();
+ configureTemplate();
}
private void configureScratchbox() {
@@ -407,7 +469,7 @@
}
public Template getInitializedTemplate(Map map) {
- Template template = esboxHandler.getTemplate();
+ Template template = esboxHandler.getTemplate();
if(template != null){
Map/*<String, String>*/ valueStore = template.getValueStore();
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonConfigWizardPage.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonConfigWizardPage.java 2007-10-30 19:53:48 UTC (rev 205)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonConfigWizardPage.java 2007-10-30 21:59:01 UTC (rev 206)
@@ -24,13 +24,10 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-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.Control;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -38,6 +35,7 @@
import org.indt.esbox.core.ErrorLogger;
import org.indt.esbox.core.scratchbox.ScratchboxException;
import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.python.ui.ESboxPythonConfigHandler;
import org.indt.esbox.ui.ESboxConfigHandler;
import org.indt.esbox.ui.UIActivator;
@@ -52,22 +50,21 @@
private Table table;
//private CheckboxTableViewer tv;
private Label l_projtype;
- private Label l_chain;
+// private Label l_chain;
private Label l_platform;
private Label l_maemoSDK;
private Composite parent;
private TableColumn column;
-
- private String propertyId;
+
public boolean isVisible = false;
- private ESboxConfigHandler esboxHandler;
+ private ESboxPythonConfigHandler esboxHandler;
public boolean pagesLoaded = false;
/**
* Constructor.
* @param esboxHandler handler of ESbox project configuration.
*/
- public ESboxPythonConfigWizardPage(ESboxConfigHandler esboxHandler) {
+ public ESboxPythonConfigWizardPage(ESboxPythonConfigHandler esboxHandler) {
super(UIMessages.getString("CDTConfigWizardPage.0")); //$NON-NLS-1$
setPageComplete(false);
setImageDescriptor(UIActivator.getImageDescriptor("./icons/new_maemo_prj_wiz.gif"));
@@ -86,8 +83,8 @@
setupLabel(parent, UIMessages.getString("CConfigWizardPage.4"), 1, GridData.BEGINNING); //$NON-NLS-1$
l_projtype = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
- setupLabel(parent, UIMessages.getString("CConfigWizardPage.5"), 1, GridData.BEGINNING); //$NON-NLS-1$
- l_chain = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+// setupLabel(parent, UIMessages.getString("CConfigWizardPage.5"), 1, GridData.BEGINNING); //$NON-NLS-1$
+// l_chain = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
setupLabel(parent, "Platform:", 1, GridData.BEGINNING); //$NON-NLS-1$
l_platform = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
setupLabel(parent, "Maemo SDK:", 1, GridData.BEGINNING); //$NON-NLS-1$
@@ -170,7 +167,7 @@
initTable();
l_projtype.setText(esboxHandler.getTemplate().getLabel());
- l_chain.setText(esboxHandler.getESboxToolChain().getName());
+// l_chain.setText(esboxHandler.getESboxToolChain().getName());
l_platform.setText(esboxHandler.getPlatformInfo().getName());
l_maemoSDK.setText(esboxHandler.getSdkInfo().toString());
setPageComplete(isCustomPageComplete());
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonMainWizardPage.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonMainWizardPage.java 2007-10-30 19:53:48 UTC (rev 205)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonMainWizardPage.java 2007-10-30 21:59:01 UTC (rev 206)
@@ -53,6 +53,7 @@
import org.indt.esbox.core.maemosdk.MaemoSDKInfo;
import org.indt.esbox.core.platform.PlatformEngine;
import org.indt.esbox.core.platform.PlatformInfo;
+import org.indt.esbox.python.ui.ESboxPythonConfigHandler;
import org.indt.esbox.python.ui.PythonUIActivator;
import org.indt.esbox.ui.ESboxConfigHandler;
import org.indt.esbox.ui.UIActivator;
@@ -83,7 +84,7 @@
private boolean checkSrcFolderSelected = true;
- private ESboxConfigHandler esboxHandler;
+ private ESboxPythonConfigHandler esboxHandler;
private ESboxProjectContentsArea locationArea;
// initial value stores
@@ -99,7 +100,7 @@
super(pageName);
setPageComplete(false);
setImageDescriptor(UIActivator.getImageDescriptor("./icons/new_maemo_prj_wiz.gif"));
- esboxHandler = new ESboxConfigHandler();
+ esboxHandler = new ESboxPythonConfigHandler();
}
/** (non-Javadoc)
* Method declared on IDialogPage.
@@ -539,7 +540,7 @@
return isCurrentPage();
}
- public ESboxConfigHandler getHandler() {
+ public ESboxPythonConfigHandler getHandler() {
return esboxHandler;
}
More information about the Esbox-commits
mailing list