--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/ProjectUIPlugin.java Mon May 03 12:10:25 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/ProjectUIPlugin.java Mon May 03 15:57:15 2010 -0500
@@ -16,6 +16,33 @@
*/
package com.nokia.carbide.cpp.internal.project.ui;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.ide.IDEInternalPreferences;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.progress.UIJob;
+import org.osgi.framework.BundleContext;
+
import com.nokia.carbide.cpp.internal.api.project.core.ProjectCorePluginUtility;
import com.nokia.carbide.cpp.internal.api.project.core.ResourceChangeListener;
import com.nokia.carbide.cpp.internal.project.ui.dialogs.MMPSelectionResolver;
@@ -23,21 +50,6 @@
import com.nokia.carbide.cpp.internal.project.ui.preferences.PreferenceConstants;
import com.nokia.cpp.internal.api.utils.core.Logging;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.*;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.resources.ProjectExplorer;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.progress.UIJob;
-import org.osgi.framework.BundleContext;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -49,6 +61,8 @@
// The shared instance
private static ProjectUIPlugin plugin;
+ // YUCK: Project nature copied from QtUtils
+ public static final String QT_NATURE_ID = "com.trolltech.qtcppproject.QtNature";
/**
* The constructor
@@ -168,6 +182,9 @@
job.setRule(null); // no rule needed here - could just block important jobs
job.schedule();
+ if (isQtProject(project))
+ return; // Qt project wizards flip to their own perspective
+
// set the perspective to Carbide C/C++
try {
IWorkbench workbench = getDefault().getWorkbench();
@@ -178,11 +195,49 @@
}
final IPerspectiveDescriptor perspective = workbench.getPerspectiveRegistry().findPerspectiveWithId("com.nokia.carbide.cpp.CarbideCppPerspective"); //$NON-NLS-1$
+
final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if (activePage != null)
+ {
+ if (activePage.getPerspective().getId().equals(perspective.getId()))
+ return; // already on the default perspective for this projects
+ }
if (activePage != null) {
job = new UIJob(""){ //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
- activePage.setPerspective(perspective);
+ boolean switchToDefaultPerspective = false;
+ IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
+ if (store != null){
+ String promptSetting = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
+ if ((promptSetting.equals(MessageDialogWithToggle.ALWAYS)) ){
+ switchToDefaultPerspective = true;
+ }
+ else if ((promptSetting.equals(MessageDialogWithToggle.PROMPT))) {
+ MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(
+ null,
+ Messages.getString("PerspectiveSwitchDialog_Title"),
+ Messages.getString("PerspectiveSwitchDialog_Query"),
+ Messages.getString("PerspectiveSwitchDialog_RememberDecisionText"),
+ false,
+ null,
+ null);
+
+ boolean toggleState = toggleDialog.getToggleState();
+ switchToDefaultPerspective = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
+
+ // set the store
+ if (toggleState){
+ if (switchToDefaultPerspective)
+ store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, MessageDialogWithToggle.ALWAYS);
+ else
+ store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, MessageDialogWithToggle.NEVER);
+ }
+ }
+ }
+
+ if (switchToDefaultPerspective){
+ activePage.setPerspective(perspective);
+ }
return Status.OK_STATUS;
}};
job.setSystem(true);
@@ -194,6 +249,17 @@
}
}
+ private static boolean isQtProject(IProject project) {
+ if (project == null)
+ return false;
+ try {
+ return project.hasNature(QT_NATURE_ID);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
public static boolean keepProjectsInSync() {
IPreferenceStore store = ProjectUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(PreferenceConstants.PREF_KEEP_PROJECTS_IN_SYNC);
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/messages.properties Mon May 03 12:10:25 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/messages.properties Mon May 03 15:57:15 2010 -0500
@@ -104,3 +104,6 @@
CreateSourceFolders.DialogMessage=Select the mmp files to update with this change:\n· add user include path\n
OnDeviceSetupDialog.Title=On-Device Setup
+PerspectiveSwitchDialog_Title=Confirm Perspective Switch
+PerspectiveSwitchDialog_Query=The type of project you are creating is associated with the Carbide C/C++ perspective.\n\nDo you want to switch to this perspective now?
+PerspectiveSwitchDialog_RememberDecisionText=&Remember my decision
\ No newline at end of file
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/QtUIPlugin.java Mon May 03 12:10:25 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/QtUIPlugin.java Mon May 03 15:57:15 2010 -0500
@@ -23,10 +23,15 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.ide.IDEInternalPreferences;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.progress.UIJob;
import org.osgi.framework.BundleContext;
@@ -40,6 +45,7 @@
import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerLoadedHook;
import com.nokia.carbide.cpp.internal.qt.core.QtCorePlugin;
import com.nokia.carbide.cpp.internal.qt.core.QtSDKUtils;
+import com.nokia.carbide.cpp.internal.qt.ui.wizard.Messages;
import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
public class QtUIPlugin extends AbstractUIPlugin implements ICarbideConfigurationChangedListener, ISDKManagerLoadedHook {
@@ -131,11 +137,49 @@
final IPerspectiveDescriptor perspective = workbench.getPerspectiveRegistry().findPerspectiveWithId("com.trolltech.qtcppproject.QtCppPerspective"); //$NON-NLS-1$
final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if (activePage != null)
+ {
+ if (activePage.getPerspective().getId().equals(perspective.getId()))
+ return; // already on the default perspective for this projects
+ }
if (activePage != null) {
UIJob job = new UIJob(""){ //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
- activePage.setPerspective(perspective);
+ boolean switchToDefaultPerspective = false;
+ IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
+
+ if (store != null){
+ String promptSetting = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
+ if ((promptSetting.equals(MessageDialogWithToggle.ALWAYS)) ){
+ switchToDefaultPerspective = true;
+ }
+ else if ((promptSetting.equals(MessageDialogWithToggle.PROMPT))) {
+ MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(
+ null,
+ Messages.PerspectiveSwitchDialog_Title,
+ Messages.PerspectiveSwitchDialog_Query,
+ Messages.PerspectiveSwitchDialog_RememberDecisionText,
+ false,
+ null,
+ null);
+
+ boolean toggleState = toggleDialog.getToggleState();
+ switchToDefaultPerspective = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
+
+ // set the store
+ if (toggleState){
+ if (switchToDefaultPerspective)
+ store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, MessageDialogWithToggle.ALWAYS);
+ else
+ store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, MessageDialogWithToggle.NEVER);
+ }
+ }
+ }
+
+ if (switchToDefaultPerspective){
+ activePage.setPerspective(perspective);
+ }
return Status.OK_STATUS;
}};
job.setSystem(true);
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/Messages.java Mon May 03 12:10:25 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/Messages.java Mon May 03 15:57:15 2010 -0500
@@ -121,6 +121,11 @@
public static String QtBuildTargetsPage_noQtConfigsError;
+ public static String PerspectiveSwitchDialog_Title;
+
+ public static String PerspectiveSwitchDialog_Query;
+
+ public static String PerspectiveSwitchDialog_RememberDecisionText;
static {
// initialize resource bundle
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/messages.properties Mon May 03 12:10:25 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/messages.properties Mon May 03 15:57:15 2010 -0500
@@ -52,3 +52,7 @@
QtBuildTargetsPage_filterCheckboxText=Filter build configurations that don't contain Qt support
QtBuildTargetsPage_filterCheckboxToolTip=Filters any build configurations that don't contain the Qt libraries
QtBuildTargetsPage_noQtConfigsError=No SDK's were found that contain Qt support
+
+PerspectiveSwitchDialog_Title=Confirm Perspective Switch
+PerspectiveSwitchDialog_Query=The type of project you are creating is associated with the Qt C++ perspective.\n\nDo you want to switch to this perspective now?
+PerspectiveSwitchDialog_RememberDecisionText=&Remember my decision