# HG changeset patch # User Ed Swartz # Date 1258391385 21600 # Node ID 7dbb2f97454afeaed35fdea49791d6ede9dc33ab # Parent e03ece49757c1a580ecf3396bdc83d370ba8b131 Refactor checks for Qt project nature into one place. diff -r e03ece49757c -r 7dbb2f97454a builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java Mon Nov 16 10:25:45 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java Mon Nov 16 11:09:45 2009 -0600 @@ -64,7 +64,6 @@ import com.nokia.carbide.cdt.internal.builder.ICarbideBuilder; import com.nokia.carbide.cdt.internal.builder.ui.BuilderPreferencePage; import com.nokia.carbide.cdt.internal.builder.ui.MMPSelectionDialog; -import com.nokia.carbide.cdt.internal.builder.ui.Messages; import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin; import com.nokia.carbide.cpp.epoc.engine.MMPDataRunnableAdapter; import com.nokia.carbide.cpp.epoc.engine.PKGViewRunnableAdapter; @@ -1220,31 +1219,27 @@ return; } else if (!pkgPath.toFile().exists()) { - try { - // Check to see if this is a Qt project and if the template format could have changed. - IProject project = config.getCarbideProject().getProject(); - if (project != null && project.hasNature(QtCorePlugin.QT_PROJECT_NATURE_ID)){ - final String currentPKGName = pkgPath.lastSegment(); - pkgPath = pkgPath.removeLastSegments(1).append(project.getName() + "_template.pkg" ); //$NON-NLS-N$ - if (pkgPath.toFile().exists()){ - - final IPath finalPkgPath = pkgPath; - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (true == MessageDialog.openQuestion(WorkbenchUtils.getSafeShell(), "Can not find PKG file for SIS builder", "The file \"" + currentPKGName + "\" does not exist for this Qt project. The suggested file is \"" + finalPkgPath.lastSegment() + "\".\n\nDo you want to update your build configuration to use this PKG file?")) { //$NON-NLS-1$ //$NON-NLS-2$ - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IFile ifile= workspace.getRoot().getFileForLocation(finalPkgPath); - sisInfo.setPKGFile(ifile.getLocation().toOSString()); - config.getSISBuilderInfoList().remove(sisInfo); - config.getSISBuilderInfoList().add(sisInfo); - config.saveConfiguration(false); - } - } - }); - } - } - } catch (CoreException e) { - e.printStackTrace(); + // Check to see if this is a Qt project and if the template format could have changed. + IProject project = config.getCarbideProject().getProject(); + if (QtCorePlugin.isQtProject(project)) { + final String currentPKGName = pkgPath.lastSegment(); + pkgPath = pkgPath.removeLastSegments(1).append(project.getName() + "_template.pkg" ); //$NON-NLS-N$ + if (pkgPath.toFile().exists()){ + + final IPath finalPkgPath = pkgPath; + Display.getDefault().syncExec(new Runnable() { + public void run() { + if (true == MessageDialog.openQuestion(WorkbenchUtils.getSafeShell(), "Can not find PKG file for SIS builder", "The file \"" + currentPKGName + "\" does not exist for this Qt project. The suggested file is \"" + finalPkgPath.lastSegment() + "\".\n\nDo you want to update your build configuration to use this PKG file?")) { //$NON-NLS-1$ //$NON-NLS-2$ + IWorkspace workspace= ResourcesPlugin.getWorkspace(); + IFile ifile= workspace.getRoot().getFileForLocation(finalPkgPath); + sisInfo.setPKGFile(ifile.getLocation().toOSString()); + config.getSISBuilderInfoList().remove(sisInfo); + config.getSISBuilderInfoList().add(sisInfo); + config.saveConfiguration(false); + } + } + }); + } } if (!sisInfo.getPKGFullPath().toFile().exists()){ diff -r e03ece49757c -r 7dbb2f97454a builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java Mon Nov 16 10:25:45 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java Mon Nov 16 11:09:45 2009 -0600 @@ -20,7 +20,6 @@ import java.util.Iterator; import java.util.List; -import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.TrayDialog; import org.eclipse.jface.viewers.CheckStateChangedEvent; @@ -183,13 +182,9 @@ new FilteringContentProviderWrapper(treeNodeContentProvider); // add filters for Qt projects - try { - if (cpi.getProject().hasNature(QtCorePlugin.QT_PROJECT_NATURE_ID)) { - filteringContentProviderWrapper.setFilter(new QtSDKFilter()); - filteringContentProviderWrapper.setConfigFilter(new QtConfigFilter()); - } - } catch (CoreException e) { - e.printStackTrace(); + if (QtCorePlugin.isQtProject(cpi.getProject())) { + filteringContentProviderWrapper.setFilter(new QtSDKFilter()); + filteringContentProviderWrapper.setConfigFilter(new QtConfigFilter()); } boolean sbsv2Project = CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(cpi.getProject()); diff -r e03ece49757c -r 7dbb2f97454a builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideSBSv1Builder.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideSBSv1Builder.java Mon Nov 16 10:25:45 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideSBSv1Builder.java Mon Nov 16 11:09:45 2009 -0600 @@ -28,7 +28,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.*; -import org.eclipse.ui.plugin.AbstractUIPlugin; import com.nokia.carbide.cdt.builder.*; import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; @@ -47,7 +46,6 @@ import com.nokia.carbide.cpp.internal.qt.core.QtCorePlugin; import com.nokia.carbide.cpp.sdk.core.*; import com.nokia.cpp.internal.api.utils.core.FileUtils; -import com.nokia.cpp.internal.api.utils.ui.QueryWithTristatePrefDialog; import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; @@ -1940,12 +1938,8 @@ // ignore this for Qt projects since the mmp will be regenerated before each build. final IProject project = buildConfig.getCarbideProject().getProject(); - try { - if (project.hasNature(QtCorePlugin.QT_PROJECT_NATURE_ID)) { - return true; - } - } catch (CoreException e) { - e.printStackTrace(); + if (QtCorePlugin.isQtProject(project)) { + return true; } // we used to ignore this for emulator builds, thinking everything of interest was in the .uid.cpp file. well, a lot of @@ -1975,12 +1969,8 @@ // ignore this for Qt projects since the mmp will be regenerated before each build. final IProject project = buildConfig.getCarbideProject().getProject(); - try { - if (project.hasNature(QtCorePlugin.QT_PROJECT_NATURE_ID)) { - return true; - } - } catch (CoreException e) { - e.printStackTrace(); + if (QtCorePlugin.isQtProject(project)) { + return true; } // we used to ignore this for emulator builds, thinking everything of interest was in the .uid.cpp file. well, a lot of diff -r e03ece49757c -r 7dbb2f97454a builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java Mon Nov 16 10:25:45 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java Mon Nov 16 11:09:45 2009 -0600 @@ -374,17 +374,8 @@ private void enableOrDisableControls() { boolean buildFromInf = buildFromBldInfButton.getSelection(); boolean useProjectSettings = fUseProjectSettings.getSelection(); - boolean isQtProject = false; IProject project = getProject(); - if (project != null) { - try { - if (project.hasNature(QtCorePlugin.QT_PROJECT_NATURE_ID)) { - isQtProject = true; - } - } catch (CoreException e) { - e.printStackTrace(); - } - } + boolean isQtProject = QtCorePlugin.isQtProject(project); selectionUI.setEnabled(!buildFromInf); optionsGroup.setEnabled(useProjectSettings); diff -r e03ece49757c -r 7dbb2f97454a qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java --- a/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java Mon Nov 16 10:25:45 2009 -0600 +++ b/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java Mon Nov 16 11:09:45 2009 -0600 @@ -83,5 +83,16 @@ description.setNatureIds(newNatures); project.setDescription(description, monitor); } + + public static boolean isQtProject(IProject project) { + if (project == null) + return false; + try { + return project.hasNature(QT_PROJECT_NATURE_ID); + } catch (CoreException e) { + getDefault().getLog().log(e.getStatus()); + return false; + } + } }