[Esbox-commits] r195 - in trunk/org.indt.esbox.python.ui: src/org/indt/esbox/python/ui src/org/indt/esbox/python/ui/wizards templates/PythonHildonHelloWorld templates/PythonOSSOApplication templates/PythonOSSORPC
carolina at garage.maemo.org
carolina at garage.maemo.org
Tue Oct 30 03:19:53 EET 2007
Author: carolina
Date: 2007-10-30 03:19:52 +0200 (Tue, 30 Oct 2007)
New Revision: 195
Modified:
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonProjectNature.java
trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/PythonUIActivator.java
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/PythonProjectWizard.java
trunk/org.indt.esbox.python.ui/templates/PythonHildonHelloWorld/.project
trunk/org.indt.esbox.python.ui/templates/PythonOSSOApplication/.project
trunk/org.indt.esbox.python.ui/templates/PythonOSSORPC/.project
Log:
Now switch to default perspective
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonProjectNature.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonProjectNature.java 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/ESboxPythonProjectNature.java 2007-10-30 01:19:52 UTC (rev 195)
@@ -17,8 +17,7 @@
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.QualifiedName;
-import org.indt.esbox.core.CoreActivator;
+import org.eclipse.core.runtime.NullProgressMonitor;
public class ESboxPythonProjectNature implements IProjectNature {
@@ -30,15 +29,10 @@
* id of ESbox Python Project
* org.indt.esbox.core.esboxPythonNature
*/
- public static final String ESBOX_PYTHON_NATURE_ID = PythonUIActivator.getUniqueIdentifier() + ".esboxNature";
+ public static final String ESBOX_PYTHON_NATURE_ID = PythonUIActivator.getUniqueIdentifierNature() + ".esboxNature";
- /**
- * constant that stores the name of the python version we are using for the project with this nature
- */
- private QualifiedName customizedLocation = null;
+ private ESboxPythonProjectNature() {}
- private ESboxPythonProjectNature() {}
-
/**
* Returns the shared instance
*
@@ -48,15 +42,7 @@
return instance;
}
- public synchronized QualifiedName getCustomizedLocationQualifiedName() {
- if(customizedLocation == null){
- //we need to do this because the plugin ID may not be known on '' time
- customizedLocation = new QualifiedName(CoreActivator.PLUGIN_ID, "ESBOXPYTHON_PROJECT_CUSTOMIZED_LOCATION");
- }
- return customizedLocation;
- }
-
- /**
+ /**
* Adds the ESbox Python project nature to a given project.
* @param _project the project to add the nature.
* @param _monitor a progress monitor to indicate the duration of the operation,
@@ -75,7 +61,7 @@
* @throws CoreException if something goes wrong.
*/
public static void removeESboxPythonNature(IProject project, IProgressMonitor mon) throws CoreException {
- ESboxPythonProjectNature.getDefault().removeNature(project, ESBOX_PYTHON_NATURE_ID, mon);
+ removeNature(project, ESBOX_PYTHON_NATURE_ID, mon);
}
/**
@@ -88,15 +74,24 @@
*/
private static void addNature(IProject project, String natureId,
IProgressMonitor monitor) throws CoreException {
- IProjectDescription description = project.getDescription();
- if (description.hasNature(natureId))
+
+ if (project == null)
return;
- String[] ids = description.getNatureIds();
- String[] newIds = new String[ids.length + 1];
- System.arraycopy(ids, 0, newIds, 0, ids.length);
- newIds[ids.length] = natureId;
- description.setNatureIds(newIds);
- project.setDescription(description, null);
+
+ if(monitor == null)
+ monitor = new NullProgressMonitor();
+
+
+ IProjectDescription desc = project.getDescription();
+ if (desc.hasNature(natureId))
+ return;
+
+ String[] natures = desc.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = ESBOX_PYTHON_NATURE_ID;
+ desc.setNatureIds(newNatures);
+ project.setDescription(desc, monitor);
}
@@ -111,7 +106,7 @@
* a progress monitor to indicate the duration of the operation,
* or <code>null</code> if progress reporting is not required.
*/
- private void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
+ private static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
if (!description.hasNature(natureId))
return;
@@ -156,37 +151,5 @@
public void setProject(IProject project) {
this.project = project;
}
-
- /**
- *
- * @param project
- * @return
- */
- public boolean isESboxPythonProject(IProject project) {
- if(project != null && project.isOpen()){
- try {
- IProjectNature n = project.getNature(ESBOX_PYTHON_NATURE_ID);
- if(n instanceof ESboxPythonProjectNature){
- return true;
- }
- } catch (CoreException e) {
- PythonUIActivator.getDefault().log(e);
- }
- }
- return false;
- }
- public void setCustomizedLocation(final IProject _project, final boolean _customizedLocation) throws CoreException {
- _project.setPersistentProperty(getDefault().getCustomizedLocationQualifiedName(), Boolean.toString(_customizedLocation));
- }
-
- public boolean getCustomizedLocation(final IProject _project) throws CoreException {
- String result = _project.getPersistentProperty(getDefault().getCustomizedLocationQualifiedName());
- if (result != null) {
- return Boolean.parseBoolean(result);
- } else { // When the plug-in is upgraded from versions before 0.1.2
- return true;
- }
- }
-
}
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/PythonUIActivator.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/PythonUIActivator.java 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/PythonUIActivator.java 2007-10-30 01:19:52 UTC (rev 195)
@@ -30,6 +30,9 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.indt.esbox.python.ui";
+ // The plug-in ID
+ private static final String NATURE_ID = "org.indt.esbox.python";
+
private static final int DEFAULT_TIMEOUT = 60;
// The shared instance
@@ -153,5 +156,15 @@
public int getTimeout() {
return DEFAULT_TIMEOUT;
+ }
+
+ public static String getUniqueIdentifierNature() {
+ if (getDefault() == null) {
+ // If the default instance is not yet initialized,
+ // return a static identifier. This identifier must
+ // match the plugin id defined in plugin.xml
+ return NATURE_ID;
+ }
+ return getDefault().getBundle().getSymbolicName();
}
}
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-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/ESboxPythonCommonProjectWizard.java 2007-10-30 01:19:52 UTC (rev 195)
@@ -43,10 +43,14 @@
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
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;
@@ -58,8 +62,9 @@
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 BasicNewResourceWizard implements INewWizard {
+public abstract class ESboxPythonCommonProjectWizard extends Wizard implements INewWizard {
private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
private static final String[] EMPTY_ARR = new String[0];
@@ -79,6 +84,10 @@
private ESboxConfigHandler esboxHandler;
private IWizardPage[] templatePages;
+ private IWorkbench workbench;
+ private IStructuredSelection selection;
+
+
protected List localPages = new ArrayList(); // replacing Wizard.pages since we have to delete them
/**
@@ -144,20 +153,22 @@
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
-
- // create project if it is not created yet
-// if (getProject(fMainPage.isCurrent(), true) == null)
-// return false;
try {
- createNewProject();
+ // create project if it is not created yet
+ createNewProject();
} catch (Exception e) {
- clearProject();
+ //clearProject();
e.printStackTrace();
+ //return false;
+ }
+
+ // Switch to default perspective
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ try {
+ workbench.showPerspective(PythonPerspectiveFactory.PERSPECTIVE_ID, window);
+ } catch (WorkbenchException e) {
return false;
}
-
-// BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
-// selectAndReveal(newProject);
return true;
}
@@ -188,8 +199,8 @@
*/
private void createProject(IProjectDescription description, IProject projectHandle, IProgressMonitor monitor, String projectType) throws CoreException, OperationCanceledException {
try {
- monitor.beginTask("", 2000); //$NON-NLS-1$
-
+
+ monitor.beginTask("", 2000);
projectHandle.create(description, new SubProgressMonitor(monitor, 1000));
if (monitor.isCanceled()){
@@ -218,7 +229,7 @@
*
* @return the created project resource, or <code>null</code> if the project was not created
*/
- private IProject createNewProject() {
+ private IProject createNewProject() throws InvocationTargetException {
// get a project handle
final IProject newProjectHandle = fMainPage.getProjectHandle();
@@ -248,23 +259,22 @@
} catch (InterruptedException e) {
return null;
} catch (InvocationTargetException e) {
- 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");
- e.printStackTrace();
- } else {
- e.printStackTrace();
-// ErrorDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle2", 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());
- }
- return null;
- }
-
+ 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");
+ e.printStackTrace();
+ } else {
+ e.printStackTrace();
+ ErrorDialog.openError(getShell(), "IDEWorkbenchMessages.CreateProjectWizard_errorTitle2", 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());
+ }
+ throw e;
+ }
newProject = newProjectHandle;
return newProjectHandle;
@@ -272,6 +282,17 @@
public abstract String[] getNatures();
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ this.workbench = workbench;
+ this.selection = currentSelection;
+ initializeDefaultPageImageDescriptor();
+ }
/*
* (non-Javadoc)
Modified: trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/PythonProjectWizard.java
===================================================================
--- trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/PythonProjectWizard.java 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/src/org/indt/esbox/python/ui/wizards/PythonProjectWizard.java 2007-10-30 01:19:52 UTC (rev 195)
@@ -12,8 +12,6 @@
package org.indt.esbox.python.ui.wizards;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
import org.indt.esbox.python.ui.ESboxPythonProjectNature;
import org.python.pydev.plugin.nature.PythonNature;
@@ -21,7 +19,7 @@
* A wizard to create an ESbox Project.
*/
public class PythonProjectWizard extends ESboxPythonCommonProjectWizard {
-
+
/**
* Constructor.
* Creates a wizard to new ESbox projects.
@@ -43,9 +41,4 @@
return new String[] { PythonNature.PYTHON_NATURE_ID , ESboxPythonProjectNature.ESBOX_PYTHON_NATURE_ID };
}
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // TODO Auto-generated method stub
-
- }
-
}
Modified: trunk/org.indt.esbox.python.ui/templates/PythonHildonHelloWorld/.project
===================================================================
--- trunk/org.indt.esbox.python.ui/templates/PythonHildonHelloWorld/.project 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/templates/PythonHildonHelloWorld/.project 2007-10-30 01:19:52 UTC (rev 195)
@@ -13,6 +13,6 @@
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
- <nature>org.indt.pluthon.core.pluthonNature</nature>
+ <nature>org.indt.esbox.python.esboxNature</nature>
</natures>
</projectDescription>
Modified: trunk/org.indt.esbox.python.ui/templates/PythonOSSOApplication/.project
===================================================================
--- trunk/org.indt.esbox.python.ui/templates/PythonOSSOApplication/.project 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/templates/PythonOSSOApplication/.project 2007-10-30 01:19:52 UTC (rev 195)
@@ -13,6 +13,6 @@
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
- <nature>org.indt.pluthon.core.pluthonNature</nature>
+ <nature>org.indt.esbox.python.esboxNature</nature>
</natures>
</projectDescription>
Modified: trunk/org.indt.esbox.python.ui/templates/PythonOSSORPC/.project
===================================================================
--- trunk/org.indt.esbox.python.ui/templates/PythonOSSORPC/.project 2007-10-29 20:15:41 UTC (rev 194)
+++ trunk/org.indt.esbox.python.ui/templates/PythonOSSORPC/.project 2007-10-30 01:19:52 UTC (rev 195)
@@ -13,6 +13,6 @@
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
- <nature>org.indt.pluthon.core.pluthonNature</nature>
+ <nature>org.indt.esbox.python.esboxNature</nature>
</natures>
</projectDescription>
More information about the Esbox-commits
mailing list