List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:com.nokia.s60tools.compatibilityanalyser.ui.dialogs.BaselineEditor.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if (e.widget == saveBtn) { if (profileCmb.getText().length() == 0) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString("BaselineEditor.Error"), //$NON-NLS-1$ Messages.getString("BaselineEditor.ProfileNameMustNotBeEmpty")); //$NON-NLS-1$ return; }/*from w w w. j av a2 s. c o m*/ String profileName = profileCmb.getText(); Object profile = BaselineProfileUtils.getBaselineProfileData(profileName); if (profile instanceof BaselineProfile && ((BaselineProfile) profile).isPredefined()) { prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText()); shell.getParent().dispose(); return; } if (isProfileDataCorrect()) { if (profileCmb.indexOf(profileCmb.getText()) != -1) { String[] str = { Messages.getString("BaselineEditor.Yes"), //$NON-NLS-1$ Messages.getString("BaselineEditor.69"), Messages.getString("BaselineEditor.No") }; //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog dlg = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.getString("BaselineEditor.Confirmation"), null, //$NON-NLS-1$ Messages.getString("BaselineEditor.ThisProfileAlreadyExists"), MessageDialog.QUESTION, //$NON-NLS-1$ str, 0); dlg.create(); int res = dlg.open(); if (res == 0) { saveProfile(); prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText()); } } else { saveProfile(); prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText()); } //Delete the project, if the profile is created by using blf.inf try { if (selectedProj != null) { prevData.saveValue(SavingUserData.ValueTypes.BLDINF_PATH, bldInfPath.getText()); if (selectedProj.exists() && projDeletionReq) { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); projDeletionReq = false; } } } catch (Exception ex) { ex.printStackTrace(); } shell.getParent().dispose(); } } else if (e.widget == deleteBtn) { String[] str = { Messages.getString("BaselineEditor.Yes"), Messages.getString("BaselineEditor.No2"), Messages.getString("BaselineEditor.Cancel") }; MessageDialog dlg = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.getString("BaselineEditor.Confirmation"), null, Messages.getString("BaselineEditor.DoUWantToDeleteTheProfile") + profileCmb.getText() + "'?", MessageDialog.QUESTION, str, 0); dlg.create(); int res = dlg.open(); if (res == 0) { BaselineProfileUtils.deleteProfile(profileCmb.getText()); shell.getParent().dispose(); } } else if (e.widget == cancelBtn) { try { if (selectedProj != null && selectedProj.exists() && projDeletionReq) { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); projDeletionReq = false; } } catch (Exception ex) { ex.printStackTrace(); } shell.getParent().dispose(); } else if (e.widget == profileCmb) { Object obj = BaselineProfileUtils.getBaselineProfileData(profileCmb.getText()); if (obj instanceof BaselineProfile) { BaselineProfile pro = (BaselineProfile) obj; if (!pro.isPredefined()) openBaselineProfileIfExists(profileCmb.getText()); else { if (!pro.isUpdated()) { targetPath = "c:\\apps\\ca-baselines\\" + pro.getProfileName(); targetURL = pro.getSdkUrl(); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { if (new File(targetPath).exists()) FileMethods.deleteFolder(targetPath); downloadStatus = CompatibilityAnalyserEngine.downloadAndExtractFileFromWebServer( targetURL, targetPath, CompatibilityAnalyserEngine.ElementTypes.FolderType, "include", monitor); } }; IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); Shell shell = win != null ? win.getShell() : null; try { new ProgressMonitorDialog(shell).run(true, true, op); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } if (downloadStatus == null) { File epocRoot = new File(CompatibilityAnalyserEngine.getEpocFolderPath()); BaselineProfile profile = (BaselineProfile) obj; profile.setSdkName(profile.getProfileName()); profile.setRadio_default_hdr(true); profile.setRadio_dir_hdr(false); profile.setRadio_default_build_target(true); profile.setRadio_build_target(false); profile.setRadio_dir_libs(false); profile.setSdkEpocRoot( FileMethods.appendPathSeparator(epocRoot.getParentFile().getAbsolutePath())); profile.setUpdated(true); BaselineProfileUtils.saveProfileOnFileSystem(profile); openBaselineProfileIfExists(profileCmb.getText()); prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profile.getProfileName()); } else { openBaselineProfileIfExists(null); MessageDialog.openError(this.getShell(), "Compatibility Analyser", downloadStatus); downloadStatus = null; } } openBaselineProfileIfExists(pro.getProfileName()); } } hdrGrp.layout(); shell.layout(); } else if (e.widget == sdkCmb) { sdkrootLbl.setText(sdkItems[sdkCmb.getSelectionIndex()].getEPOCROOT()); if (versionCmb .indexOf(sdkItems[sdkCmb.getSelectionIndex()].getSDKVersion().toString().substring(0, 3)) != -1) versionCmb.select(versionCmb .indexOf(sdkItems[sdkCmb.getSelectionIndex()].getSDKVersion().toString().substring(0, 3))); else versionCmb.setText(""); //$NON-NLS-1$ String[] platformsList = CompatibilityAnalyserUtils .getPlatformList(sdkItems[sdkCmb.getSelectionIndex()]); if (platformsList != null) list_build_Config.setItems(platformsList); if (list_build_Config.getItemCount() > 0) { int i = list_build_Config.indexOf(Messages.getString("BaselineEditor.armv5")); //$NON-NLS-1$ if (i != -1) list_build_Config.select(i); else list_build_Config.select(0); String selected = list_build_Config.getItem(list_build_Config.getSelectionIndex()); radio_build_target.setText(Messages.getString("BaselineEditor.UseLibrariesUnder") + selected //$NON-NLS-1$ + Messages.getString("BaselineEditor.BuildConfig")); //$NON-NLS-1$ } if (infCheck.getSelection() && bldInfPath.getText().length() != 0) { String bldPath = bldInfPath.getText(); File bldFile = new File(bldPath); File Project = bldFile.getParentFile().getParentFile(); userFiles = new ArrayList<File>(); systemFiles = new ArrayList<File>(); projName = Project.getName(); projLocation = Project.getAbsolutePath(); projExists = false; selectedSdk = sdkItems[sdkCmb.getSelectionIndex()]; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { isCancelled = false; selectedProj = ResourcesPlugin.getWorkspace().getRoot() .getProject("CompatibilityAnalyser_" + projName); if (selectedProj.exists()) { projExists = true; } else { for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { projLocation = FileMethods.convertForwardToBackwardSlashes(projLocation); if (FileMethods.convertForwardToBackwardSlashes(wsProj.getLocation().toString()) .equals(projLocation)) { projExists = true; selectedProj = wsProj; break; } } } java.util.List<ISymbianBuildContext> buildList = selectedSdk .getFilteredBuildConfigurations(); if (projExists) { monitor.beginTask("Reading system includes using selected SDK Configuration ...", 10); selectedProj.open(null); ICarbideBuildManager buildMgr = CarbideBuilderPlugin.getBuildManager(); ICarbideProjectModifier modifier = buildMgr.getProjectModifier(selectedProj); monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; monitor.done(); return; } ICarbideProjectInfo projectInfo = buildMgr.getProjectInfo(selectedProj); ICarbideBuildConfiguration origConf = projectInfo.getDefaultConfiguration(); ICarbideBuildConfiguration configTobeSet = null; configTobeSet = modifier.createNewConfiguration(buildList.get(0), true); configTobeSet.saveConfiguration(false); modifier.setDefaultConfiguration(configTobeSet); modifier.saveChanges(); monitor.worked(5); if (monitor.isCanceled()) { modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); monitor.done(); return; } if (projectInfo != null) { EpocEngineHelper.getProjectIncludePaths(projectInfo, projectInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projectInfo, userFiles); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); } monitor.worked(8); modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); monitor.worked(10); if (monitor.isCanceled()) isCancelled = true; monitor.done(); } else { monitor.beginTask("Getting system includes using selected SDK Configuration...", 10); selectedProj = ProjectCorePlugin.createProject(projName, projLocation); projDeletionReq = true; monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } java.util.List<String> infsList = new ArrayList<String>(); ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf", buildList, infsList, null, null, new NullProgressMonitor()); monitor.worked(5); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(selectedProj); if (projInfo != null) { EpocEngineHelper.getProjectIncludePaths(projInfo, projInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projInfo, userFiles); monitor.worked(7); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); monitor.worked(9); if (monitor.isCanceled()) isCancelled = true; } monitor.done(); } } catch (CoreException ex) { ex.printStackTrace(); try { if (selectedProj != null && selectedProj.exists() && projDeletionReq) { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); projDeletionReq = false; } return; } catch (Exception e1) { e1.printStackTrace(); } } } }; try { new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runnable); } catch (Exception ex) { ex.printStackTrace(); } String[] sysIncludes = new String[systemFiles.size()]; int s = 0; if (isCancelled) return; for (File f : systemFiles) { sysIncludes[s] = f.toString(); s++; } if (srcRoots != null && srcRoots.length > 0) { forced_hdrs_list.setItems(srcRoots); } if (userFiles.size() > 0) { ArrayList<String> userIncludes = new ArrayList<String>(); for (int i = 0; i < userFiles.size(); i++) { if (userFiles.get(i).exists()) userIncludes .add(FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString())); } Event modEvent = new Event(); modEvent.type = SWT.Selection; radio_Hdr_dir.setSelection(true); hdr_dir_list.setItems(userIncludes.toArray(new String[0])); hdr_dir_list.select(0); radio_Hdr_dir.notifyListeners(SWT.Selection, modEvent); } if (sysIncludes.length > 0) { list_systemInc.setItems(sysIncludes); removeBtn_sysIncGrp.setEnabled(true); removeAllBtn_sysIncGrp.setEnabled(true); list_systemInc.select(0); } updateButtons(); return; } } else if (e.widget == addBtn_hdrGrp) { DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell()); String dirName = null; if ((dirName = dirDlg.open()) != null) { hdr_dir_list.add(dirName); hdr_dir_list.select(0); updateButtons(); } else return; } else if (e.widget == removeBtn_hdrGrp) { hdr_dir_list.remove(hdr_dir_list.getSelectionIndices()); hdr_dir_list.select(0); updateButtons(); } else if (e.widget == removeAllBtn_hdrGrp) { hdr_dir_list.removeAll(); updateButtons(); } else if (e.widget == addDsoDir_btn) { DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell()); String dirName = null; if ((dirName = dirDlg.open()) != null) { dso_dir_list.add(dirName); dso_dir_list.select(0); updateButtons(); } else return; } else if (e.widget == addDllDir_btn) { DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell()); String dirName = null; if ((dirName = dirDlg.open()) != null) { dll_dir_list.add(dirName); dll_dir_list.select(0); updateButtons(); } else return; } else if (e.widget == removeDsoDir_Btn) { dso_dir_list.remove(dso_dir_list.getSelectionIndices()); dso_dir_list.select(0); updateButtons(); } else if (e.widget == removeDllDir_btn) { dll_dir_list.remove(dll_dir_list.getSelectionIndices()); dll_dir_list.select(0); updateButtons(); } else if (e.widget == removeAllDsoDirs_Btn) { dso_dir_list.removeAll(); updateButtons(); } else if (e.widget == removeAllDllDir_Btn) { dll_dir_list.removeAll(); updateButtons(); } else if (e.widget == addBtn_sysIncGrp) { DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell()); String dirName = null; if ((dirName = dirDlg.open()) != null) { list_systemInc.add(dirName); list_systemInc.select(0); updateButtons(); } else return; } else if (e.widget == removeBtn_sysIncGrp) { list_systemInc.remove(list_systemInc.getSelectionIndices()); list_systemInc.select(0); updateButtons(); } else if (e.widget == radio_Hdr_dir) { GridData d = (GridData) hdr_dirs_comp.getLayoutData(); d.exclude = !radio_Hdr_dir.getSelection(); hdr_dirs_comp.setVisible(radio_Hdr_dir.getSelection()); hdr_dir_list.setEnabled(radio_Hdr_dir.getSelection()); addBtn_hdrGrp.setEnabled(radio_Hdr_dir.getSelection()); updateButtons(); } else if (e.widget == radio_dir_Libs || e.widget == radio_build_target) { //dso_dir_list.setEnabled(radio_dir_Libs.getSelection()); addDsoDir_btn.setEnabled(radio_dir_Libs.getSelection()); addDllDir_btn.setEnabled(radio_dir_Libs.getSelection()); //removeDsoDir_Btn.setEnabled(radio_dir_Libs.getSelection()); //removeAllDsoDirs_Btn.setEnabled(radio_dir_Libs.getSelection()); //list_build_Config.setEnabled(!radio_dir_Libs.getSelection()); GridData data = (GridData) list_build_Config.getLayoutData(); data.exclude = !radio_build_target.getSelection(); list_build_Config.setVisible(radio_build_target.getSelection()); GridData data2 = (GridData) dllPaths_Folder.getLayoutData(); data2.exclude = !radio_dir_Libs.getSelection(); dllPaths_Folder.setVisible(radio_dir_Libs.getSelection()); dllPaths_Folder.getParent().layout(false); updateButtons(); } else if (e.widget == list_build_Config) { if (list_build_Config.getSelectionCount() > 1) radio_build_target.setText("Use libraries under selected build configurations"); else { String selected = list_build_Config.getItem(list_build_Config.getSelectionIndex()); radio_build_target.setText(Messages.getString("BaselineEditor.UseLibrariesUnder") + selected //$NON-NLS-1$ + Messages.getString("BaselineEditor.BuildConfig")); //$NON-NLS-1$ } } else if (e.widget == removeAllBtn_sysIncGrp) { list_systemInc.removeAll(); updateButtons(); } else if (e.widget == browseBld) { FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell()); dialog.setFilterExtensions(new String[] { "*.inf" }); String fileName = null; if ((fileName = dialog.open()) != null) { bldInfPath.add(fileName, 0); bldInfPath.select(0); Event event = new Event(); event.type = SWT.Selection; bldInfPath.notifyListeners(SWT.Selection, event); } } else if (e.widget == infCheck) { projExists = false; if (infCheck.getSelection()) { bldInfPath.setEnabled(true); browseBld.setEnabled(true); if (bldInfPath.getText().length() > 0) { userFiles = new ArrayList<File>(); systemFiles = new ArrayList<File>(); bldPath = bldInfPath.getText(); selectedSdk = sdkItems[sdkCmb.getSelectionIndex()]; File bldFile = new File(bldPath); File Project = bldFile.getParentFile().getParentFile(); if (!bldFile.exists()) { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), "Given Bld.inf does not exist. Please provide a valid path"); return; } projName = Project.getName(); projLocation = Project.getAbsolutePath(); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { isCancelled = false; selectedProj = ResourcesPlugin.getWorkspace().getRoot() .getProject("CompatibilityAnalyser_" + projName); if (selectedProj.exists()) { projExists = true; } else { for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { projLocation = FileMethods.convertForwardToBackwardSlashes(projLocation); if (FileMethods .convertForwardToBackwardSlashes(wsProj.getLocation().toString()) .equals(projLocation)) { projExists = true; selectedProj = wsProj; break; } } } java.util.List<ISymbianBuildContext> buildList = selectedSdk .getFilteredBuildConfigurations(); java.util.List<String> infsList = new ArrayList<String>(); if (!projExists) { monitor.beginTask("Getting Project Info", 10); selectedProj = ProjectCorePlugin .createProject("CompatibilityAnalyser_" + projName, projLocation); projDeletionReq = true; monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf", buildList, infsList, null, null, monitor); monitor.worked(5); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(selectedProj); if (projInfo != null) { EpocEngineHelper.getProjectIncludePaths(projInfo, projInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projInfo, userFiles); monitor.worked(7); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); monitor.worked(9); if (monitor.isCanceled()) isCancelled = true; } monitor.done(); } else { monitor.beginTask("Reading Project Info..", 10); selectedProj.open(null); monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; monitor.done(); return; } ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(selectedProj); ICarbideBuildManager manager = CarbideBuilderPlugin.getBuildManager(); ICarbideProjectModifier modifier = manager.getProjectModifier(selectedProj); ICarbideBuildConfiguration origConf = projInfo.getDefaultConfiguration(); ICarbideBuildConfiguration configTobeSet = null; java.util.List<ISymbianBuildContext> all = selectedSdk .getFilteredBuildConfigurations(); configTobeSet = modifier.createNewConfiguration(all.get(0), true); configTobeSet.saveConfiguration(false); modifier.setDefaultConfiguration(configTobeSet); modifier.saveChanges(); if (monitor.isCanceled()) { isCancelled = true; modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); monitor.done(); return; } monitor.worked(5); if (projInfo != null) { EpocEngineHelper.getProjectIncludePaths(projInfo, projInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projInfo, userFiles); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); } monitor.worked(8); modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); if (monitor.isCanceled()) isCancelled = true; monitor.worked(10); monitor.done(); } } catch (CoreException ex) { ex.printStackTrace(); try { if (selectedProj != null && selectedProj.exists() && projDeletionReq) { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); projDeletionReq = false; } return; } catch (Exception e1) { e1.printStackTrace(); } } } }; try { new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runnable); } catch (Exception ex) { ex.printStackTrace(); } if (isCancelled) return; if (srcRoots != null && srcRoots.length > 0) { forced_hdrs_list.setItems(srcRoots); } if (systemFiles != null && systemFiles.size() > 0) { String[] sysIncludes = new String[systemFiles.size()]; for (int i = 0; i < systemFiles.size(); i++) sysIncludes[i] = systemFiles.get(i).toString(); list_systemInc.setItems(sysIncludes); list_systemInc.select(0); removeBtn_sysIncGrp.setEnabled(true); removeAllBtn_sysIncGrp.setEnabled(true); } if (userFiles != null && userFiles.size() > 0) { ArrayList<String> userIncludes = new ArrayList<String>(); for (int i = 0; i < userFiles.size(); i++) { if (userFiles.get(i).exists()) userIncludes.add( FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString())); } radio_default_Hdr.setSelection(false); radio_Hdr_dir.setSelection(true); hdr_dir_list.setItems(userIncludes.toArray(new String[0])); hdr_dir_list.select(0); Event selEvent = new Event(); selEvent.type = SWT.Selection; radio_Hdr_dir.notifyListeners(SWT.Selection, selEvent); } } } else { bldInfPath.setEnabled(false); browseBld.setEnabled(false); if (bldInfPath.getText().length() > 0) { Event modEvent = new Event(); modEvent.type = SWT.Selection; radio_default_Hdr.setSelection(true); radio_Hdr_dir.setSelection(false); list_systemInc.removeAll(); hdr_dir_list.removeAll(); forced_hdrs_list.removeAll(); radio_default_Hdr.notifyListeners(SWT.Selection, modEvent); } } } else if (e.widget == bldInfPath) { radio_default_Hdr.setSelection(true); radio_Hdr_dir.setSelection(false); list_systemInc.removeAll(); forced_hdrs_list.removeAll(); Event modEvent = new Event(); modEvent.type = SWT.Selection; radio_default_Hdr.notifyListeners(SWT.Selection, modEvent); bldPath = bldInfPath.getText(); selectedSdk = sdkItems[sdkCmb.getSelectionIndex()]; projExists = false; if (bldPath.length() > 0 && infCheck.getSelection()) { userFiles = new ArrayList<File>(); systemFiles = new ArrayList<File>(); File bldFile = new File(bldPath); File Project = bldFile.getParentFile().getParentFile(); if (!bldFile.exists()) { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), "Given Bld.inf does not exist. Please provide a valid path"); return; } if (!bldFile.getName().equalsIgnoreCase("bld.inf")) { return; } projName = Project.getName(); projLocation = Project.getAbsolutePath(); if (selectedProj != null && selectedProj.exists() && projDeletionReq) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } projDeletionReq = false; } IRunnableWithProgress runP = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { isCancelled = false; selectedProj = ResourcesPlugin.getWorkspace().getRoot() .getProject("CompatibilityAnalyser_" + projName); if (selectedProj.exists()) { projExists = true; } else { for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (FileMethods.convertForwardToBackwardSlashes(wsProj.getLocation().toString()) .equals(FileMethods.convertForwardToBackwardSlashes(projLocation))) { projExists = true; selectedProj = wsProj; break; } } } java.util.List<ISymbianBuildContext> buildList = selectedSdk .getFilteredBuildConfigurations(); java.util.List<String> infsList = new ArrayList<String>(); if (!projExists) { monitor.beginTask("Getting Project Info...", 10); selectedProj = ProjectCorePlugin.createProject("CompatibilityAnalyser_" + projName, projLocation); projDeletionReq = true; monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf", buildList, infsList, null, null, monitor); if (monitor.isCanceled()) { isCancelled = true; if (selectedProj != null && selectedProj.exists()) { try { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); } catch (Exception e1) { e1.printStackTrace(); } } monitor.done(); projDeletionReq = false; return; } monitor.worked(5); ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(selectedProj); if (projInfo != null) { EpocEngineHelper.getProjectIncludePaths(projInfo, projInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projInfo, userFiles); monitor.worked(7); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); monitor.worked(9); if (monitor.isCanceled()) isCancelled = true; } monitor.done(); } else { monitor.beginTask("Reading Project Info..", 10); selectedProj.open(null); monitor.worked(2); if (monitor.isCanceled()) { isCancelled = true; monitor.done(); return; } ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(selectedProj); ICarbideBuildManager manager = CarbideBuilderPlugin.getBuildManager(); ICarbideProjectModifier modifier = manager.getProjectModifier(selectedProj); ICarbideBuildConfiguration origConf = projInfo.getDefaultConfiguration(); ICarbideBuildConfiguration configTobeSet = null; configTobeSet = modifier.createNewConfiguration(buildList.get(0), true); configTobeSet.saveConfiguration(false); modifier.setDefaultConfiguration(configTobeSet); modifier.saveChanges(); if (monitor.isCanceled()) { isCancelled = true; monitor.done(); modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); return; } monitor.worked(5); if (projInfo != null) { EpocEngineHelper.getProjectIncludePaths(projInfo, projInfo.getDefaultConfiguration(), userFiles, systemFiles); getExportPathsAndFiles(projInfo, userFiles); srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj) .toArray(new String[0]); } if (monitor.isCanceled()) { isCancelled = true; monitor.done(); } monitor.worked(8); modifier.setDefaultConfiguration(origConf); modifier.saveChanges(); monitor.worked(10); monitor.done(); } } catch (CoreException ex) { ex.printStackTrace(); try { if (selectedProj != null && selectedProj.exists() && projDeletionReq) { selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null); projDeletionReq = false; } return; } catch (Exception e1) { e1.printStackTrace(); } } } }; try { new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runP); } catch (Exception ex) { ex.printStackTrace(); } if (isCancelled) return; if (srcRoots != null && srcRoots.length > 0) { Event eve = new Event(); eve.type = SWT.Selection; forced_hdrs_list.setItems(srcRoots); } if (userFiles != null && userFiles.size() > 0) { ArrayList<String> userIncludes = new ArrayList<String>(); for (int i = 0; i < userFiles.size(); i++) { if (userFiles.get(i).exists()) userIncludes .add(FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString())); } radio_default_Hdr.setSelection(false); radio_Hdr_dir.setSelection(true); hdr_dir_list.setItems(userIncludes.toArray(new String[0])); hdr_dir_list.select(0); Event selEvent = new Event(); selEvent.type = SWT.Selection; radio_Hdr_dir.notifyListeners(SWT.Selection, selEvent); } if (systemFiles != null && systemFiles.size() > 0) { String[] sysIncludes = new String[systemFiles.size()]; for (int i = 0; i < systemFiles.size(); i++) sysIncludes[i] = systemFiles.get(i).toString(); list_systemInc.setItems(sysIncludes); list_systemInc.select(0); removeBtn_sysIncGrp.setEnabled(true); removeAllBtn_sysIncGrp.setEnabled(true); } } } else if (e.widget == forced_addBtn) { displayFiles = new ArrayList<String>(); numOfFiles = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); isMonitorCancelled = false; if (list_systemInc.getItemCount() > 0) { ArrayList<String> paths = new ArrayList<String>(Arrays.asList(list_systemInc.getItems())); paths.add(FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator + "include" + File.separator); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this, "", true); allSysIncHdrPaths = paths.toArray(new String[paths.size()]); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { int i = 1; for (String path : allSysIncHdrPaths) { absolutePath = FileMethods.convertForwardToBackwardSlashes(path); monitor.beginTask("Getting files from " + absolutePath, allSysIncHdrPaths.length); getFiles(absolutePath, monitor); getFilesFromSubDirs(absolutePath, monitor); monitor.worked(i++); } monitor.done(); } catch (Exception e1) { e1.printStackTrace(); } } }; try { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); Shell shell = win != null ? win.getShell() : null; progDlg = new ProgressMonitorDialog(shell); progDlg.run(true, true, op); progDlg.setBlockOnOpen(true); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } } else { addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this, FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator + "include" + File.separator, true); absolutePath = FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator + "include" + File.separator; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { addFiles_monitor = monitor; monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); addFiles_monitor.worked(5); getFilesFromSubDirs(absolutePath, monitor); monitor.done(); } catch (Exception e1) { e1.printStackTrace(); } } }; try { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); Shell shell = win != null ? win.getShell() : null; progDlg = new ProgressMonitorDialog(shell); progDlg.run(true, true, op); progDlg.setBlockOnOpen(true); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } } if (!isMonitorCancelled) { if (numOfFiles.size() != forced_hdrs_list.getItemCount()) for (String name : numOfFiles) if (!isPreviouslySelected(name)) displayFiles.add(name); if (displayFiles.size() != 0) { Collections.sort(displayFiles); addDialog.children = children; addDialog.subChildren = subChildren; addDialog.open(); addDialog.filesList.setItems(displayFiles.toArray(new String[displayFiles.size()])); addDialog.filesList.select(0); } } if (isMonitorCancelled) { } else if (displayFiles.size() == 0 && numOfFiles.size() != 0) { Runnable showMessageRunnable = new Runnable() { public void run() { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$ Messages.getString("HeaderFilesPage.hdrsAlreadyExists")); //$NON-NLS-1$ } }; Display.getDefault().asyncExec(showMessageRunnable); } else if (numOfFiles.size() == 0) { Runnable showMessageRunnable = new Runnable() { public void run() { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$ Messages.getString("HeaderFilesPage.NoHdrsExists")); //$NON-NLS-1$ } }; Display.getDefault().asyncExec(showMessageRunnable); } else { addDialog.fileNamesList = addDialog.filesList.getItems(); } } else if (e.widget == forced_removeBtn) { forced_hdrs_list.remove(forced_hdrs_list.getSelectionIndices()); forced_hdrs_list.select(0); forced_removeBtn.setEnabled(forced_hdrs_list.getItemCount() > 0); forced_removeAllBtn.setEnabled(forced_hdrs_list.getItemCount() > 0); } else if (e.widget == forced_removeAllBtn) { forced_hdrs_list.removeAll(); forced_removeBtn.setEnabled(false); forced_removeAllBtn.setEnabled(false); } else if (e.widget == show_btn) { GridData data = (GridData) adv_options_comp.getLayoutData(); data.exclude = false; adv_options_comp.setVisible(true); ((StackLayout) show_hide_button_comp.getLayout()).topControl = hide_btn; show_hide_button_comp.layout(); } else if (e.widget == hide_btn) { GridData data = (GridData) adv_options_comp.getLayoutData(); data.exclude = true; adv_options_comp.setVisible(false); ((StackLayout) show_hide_button_comp.getLayout()).topControl = show_btn; show_hide_button_comp.layout(); } if (!shell.isDisposed()) { hdrGrp.layout(); shell.layout(); } }
From source file:com.nokia.sdt.symbian.ui.appeditor.ApplicationEditor.java
License:Open Source License
/** * Because of the app editor's synchronize on save behavior we need to customize * the close->ask save changes flow. If the user says "yes" to the built-in "Save changes" * query, the editor is definitely going to close. But our "confirm application changes" dialog * has a cancel. If they cancel there the changes would be thrown away *//*from w w w. ja v a 2s. co m*/ public int promptToSaveOnClose() { if (!isDirty()) { return NO; } PreflightInfo pi = calcPreflightInfo(true); if (pi.changeFlags == 0 || pi.dialogMessage == null) { return DEFAULT; } String title = Messages.getString("ApplicationEditor.saveDialogTitle"); //$NON-NLS-1$ String labels[]; if (pi.preSaveOtherEditorsNeeded) { labels = new String[] { Messages.getString("ApplicationEditor.saveAllButton"), //$NON-NLS-1$ Messages.getString("ApplicationEditor.dontSaveButton"), //$NON-NLS-1$ Messages.getString("ApplicationEditor.cancelButton") }; //$NON-NLS-1$ } else { labels = new String[] { Messages.getString("ApplicationEditor.saveButton"), //$NON-NLS-1$ Messages.getString("ApplicationEditor.dontSaveButton"), //$NON-NLS-1$ Messages.getString("ApplicationEditor.cancelButton") }; //$NON-NLS-1$ } MessageDialog dialog = new MessageDialog(getEditorSite().getShell(), title, null, pi.dialogMessage, MessageDialog.QUESTION, labels, YES); int result = dialog.open(); if (result == YES) { // set after user approves actions, so we don't requery from doSave closingEditorPreflightInfo = pi; } return result; }
From source file:com.nokia.sdt.uidesigner.events.EventCommands.java
License:Open Source License
public static void navigateToHandlerCode(EventPage page, IEventBinding binding, boolean isNewBinding) { IEventDescriptor eventDescriptor = binding.getEventDescriptor(); IStatus status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); if (status != null) { if (!isNewBinding) { // Hmm, an error. It could be the data model was not saved. // It may just be a problem in the component's sourcegen, hence // the fallthrough to the descriptive error later. MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("EventCommands.Error"), null, //$NON-NLS-1$ Messages.getString("EventCommands.NoEventHandlerFound"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, //$NON-NLS-1$ //$NON-NLS-2$ 0);/*from w w w . j a v a2s . co m*/ int result = dialog.open(); if (result == MessageDialog.OK) { if (page.saveDataModel()) { status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); } } } if (status != null) { Logging.log(UIDesignerPlugin.getDefault(), status); } } }
From source file:com.nokia.tools.variant.resourcelibrary.handlers.commands.ImportCommand.java
License:Open Source License
public static boolean openCheckDialog(FileSystemElement existing) { MessageDialog dialog = new MessageDialog(SWTUtil.getStandardDisplay().getActiveShell(), "Replace existing resource", null, "Replace existing resource " + existing.getName() + "?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return dialog.open() == 0 ? true : false; }
From source file:com.nokia.tracebuilder.view.TraceViewDialogs.java
License:Open Source License
/** * Shows a query dialog, where the buttons have been defined by client * // w w w .j a v a 2 s . c o m * @param parameters * the dialog parameters * @param shell * the parent shell * @return the index of the selected button */ private int showExtendedQueryDialog(QueryDialogParameters parameters, Shell shell) { MessageDialog md = new MessageDialog(shell, Messages.getString("TraceView.TraceBuilder"), //$NON-NLS-1$ null, ((ExtendedQueryParameters) parameters).message, MessageDialog.QUESTION, ((ExtendedQueryParameters) parameters).buttonTitles, 0); // Returns the index of the button defined in extended query parameters return md.open(); }
From source file:com.palantir.typescript.Builders.java
License:Apache License
/** * Prompts user to rebuild either the project or the whole workspace. * * @param shell// w w w . j av a2 s . c o m * parent shell * @param onlyProject * the project to be rebuilt or null if the whole workpsace has to be rebuilt * @return true if user accepted the recompilation */ public static boolean promptRecompile(Shell shell, IProject onlyProject) { String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title"); String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL }; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels, 2); int result = dialog.open(); boolean process = false; if (result != 1) { // cancel process = true; // rebuild the workspace if (result == 2) { if (onlyProject != null) { Builders.rebuildProject(onlyProject); } else { Builders.rebuildWorkspace(); } } } return process; }
From source file:com.palantir.typescript.CompilerPreferencePage.java
License:Apache License
@Override public boolean performOk() { final boolean process; // offer to rebuild the workspace if the compiler preferences were modified if (this.compilerPreferencesModified) { String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title"); String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL }; MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 2);//from w ww . ja v a 2 s. co m int result = dialog.open(); if (result == 1) { // cancel process = false; } else { // yes/no process = super.performOk(); // rebuild the workspace if (result == 2) { String name = Resources.BUNDLE.getString("preferences.compiler.rebuild.job.name"); Job job = new Job(name) { @Override protected IStatus run(IProgressMonitor monitor) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); job.schedule(); } } this.compilerPreferencesModified = false; } else { process = super.performOk(); } return process; }
From source file:com.palantir.typescript.preferences.GeneralPreferencePage.java
License:Apache License
@Override public boolean performOk() { String oldNodePath = this.getPreferenceStore().getString(IPreferenceConstants.GENERAL_NODE_PATH); String newNodePath = this.nodePathText.getText(); if (!oldNodePath.equals(newNodePath)) { String title = Resources.BUNDLE.getString("preferences.general.node.path.dialog.title"); String message = Resources.BUNDLE.getString("preferences.general.node.path.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.OK_LABEL }; MessageDialog dialog = new MessageDialog(this.getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 2);// w w w.j a v a 2s . c o m dialog.open(); this.getPreferenceStore().setValue(IPreferenceConstants.GENERAL_NODE_PATH, newNodePath); } return true; }
From source file:com.rcpcompany.uibindings.tests.application.ApplicationWorkbenchAdvisor.java
License:Open Source License
@Override public boolean preShutdown() { final IManager manager = IManager.Factory.getManager(); final EditingDomain editingDomain = manager.getEditingDomain(); int res = 1; // == NO if (editingDomain.getCommandStack().canUndo()) { final IWorkbenchWindow window = getWorkbenchConfigurer().getWorkbench().getActiveWorkbenchWindow(); final MessageDialog dialog = new MessageDialog(window.getShell(), "Save Shop?", null, "Changes has been made to the shop. Save these?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);//w w w. j a v a 2s . co m res = dialog.open(); if (res == 0) { final ICommandService cs = (ICommandService) window.getService(ICommandService.class); final IHandlerService hs = (IHandlerService) window.getService(IHandlerService.class); try { final String c = manager.getCommandIDs().get(IWorkbenchCommandConstants.FILE_SAVE); final ParameterizedCommand command = cs.deserialize(c); hs.executeCommand(command, null); } catch (final Exception ex) { LogUtils.error(this, ex); } } } return res != 2; }
From source file:com.redhat.ceylon.eclipse.code.preferences.CeylonBuildPathsBlock.java
License:Open Source License
public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) { return new IRemoveOldBinariesQuery() { public boolean doQuery(final boolean removeFolder, final IPath oldOutputLocation) throws OperationCanceledException { final int[] res = new int[] { 1 }; Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh = shell != null ? shell : JavaPlugin.getActiveWorkbenchShell(); String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message; String pathLabel = BasicElementLabels.getPathLabel(oldOutputLocation, false); if (removeFolder) { message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveOldOutputFolder_description, pathLabel); } else { message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, pathLabel); }/* ww w . ja v a 2 s. c o m*/ MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); res[0] = dialog.open(); } }); if (res[0] == 0) { return true; } else if (res[0] == 1) { return false; } throw new OperationCanceledException(); } }; }