List of usage examples for org.eclipse.jface.dialogs MessageDialog create
@Override public void create()
From source file:com.nokia.s60tools.analyzetool.global.Util.java
License:Open Source License
/** * Opens confirmation Dialog./* w w w .j a v a 2s .c o m*/ * * @param text * Dialog info text * @return int User selected index */ public static int openConfirmationDialogWithCancel(final String text) { Activator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { String[] labels = new String[3]; labels[0] = "Yes"; labels[1] = "No"; labels[2] = "Cancel"; MessageDialog mDialog = new MessageDialog(new Shell(), Constants.ANALYZE_TOOL_TITLE, null, text, 0, labels, 0); mDialog.open(); mDialog.create(); retValue = mDialog.getReturnCode(); } }); return retValue; }
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 a va2s.c om*/ 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.tools.s60.views.ColorsViewPage.java
License:Open Source License
public void fillTable() { for (ColorQuadruple input : inputs) { if (!table.isDisposed()) { final Composite labelComp = new Composite(table, SWT.NONE); GridLayout gl = new GridLayout(); gl.marginWidth = gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0; labelComp.setLayout(gl);/*from w w w . jav a2s . c o m*/ GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; gd.horizontalSpan = 3; gd.verticalIndent = 5; labelComp.setLayoutData(gd); labelComp.setBackground(labelComp.getParent().getBackground()); final Text label = new Text(labelComp, SWT.NONE); label.setEditable(false); label.setData(input); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; gd.grabExcessVerticalSpace = true; label.setLayoutData(gd); label.setFont(ItalicFont); label.setText(input.getQuadrupleName()); label.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (e.button == 1) { label.setFont(null); label.setEditable(true); labelComp.setBackground(ColorConstants.white); } } }); label.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent e) { } public void mouseExit(MouseEvent e) { label.setFont(ItalicFont); label.setEditable(false); // this will call the focus lost event label.setEnabled(false); if (!label.isDisposed()) { label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); } } public void mouseHover(MouseEvent e) { } }); label.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) { ColorQuadruple quad = (ColorQuadruple) label.getData(); if (e.detail == SWT.TRAVERSE_ESCAPE) { label.setText(quad.getQuadrupleName()); } else if (e.detail == SWT.TRAVERSE_RETURN) { //the focus lost will happen // after this // if (!updateName(quad, label.getText())) { // label.setText(quad.getQuadrupleName()); // } } label.setFont(ItalicFont); label.setEditable(false); // this will call the focus lost event label.setEnabled(false); if (!label.isDisposed()) { label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); } } } }); label.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { label.setFont(ItalicFont); label.setEditable(false); label.setEnabled(false); label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); ColorQuadruple quad = (ColorQuadruple) label.getData(); if (!updateName(quad, label.getText())) { label.setText(quad.getQuadrupleName()); } } @Override public void focusGained(FocusEvent e) { label.setFont(null); label.setEditable(true); labelComp.setBackground(ColorConstants.white); } }); final Canvas quadrupleComposite = new Canvas(table, SWT.BORDER); quadrupleComposite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; gc.setBackground(ColorConstants.white); // gc.setBackgroundPattern(BG_PATTERN); gc.fillRectangle(0, 0, quadrupleComposite.getSize().x, quadrupleComposite.getSize().y); } }); gl = new GridLayout(4, false); gl.marginWidth = 2; gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0; quadrupleComposite.setLayout(gl); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; quadrupleComposite.setLayoutData(gd); Canvas q1 = new Canvas(quadrupleComposite, SWT.NONE); q1.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q1.setLayoutData(gd); q1.setBackground(q1.getParent().getBackground()); addPaintListener(0, q1); addDragSource(0, q1); addQuadrupleMouseListener(0, q1); createTooltip(0, q1); Canvas q2 = new Canvas(quadrupleComposite, SWT.NONE); q2.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; gd.horizontalIndent = 6; q2.setLayoutData(gd); q2.setBackground(q2.getParent().getBackground()); addPaintListener(1, q2); addDragSource(1, q2); addQuadrupleMouseListener(1, q2); createTooltip(1, q2); Canvas q3 = new Canvas(quadrupleComposite, SWT.NONE); q3.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q3.setLayoutData(gd); q3.setBackground(q3.getParent().getBackground()); addPaintListener(2, q3); addDragSource(2, q3); addQuadrupleMouseListener(2, q3); createTooltip(2, q3); Canvas q4 = new Canvas(quadrupleComposite, SWT.NONE); q4.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q4.setLayoutData(gd); q4.setBackground(q4.getParent().getBackground()); addPaintListener(3, q4); addDragSource(3, q4); addQuadrupleMouseListener(3, q4); createTooltip(3, q4); final Button b1 = new Button(table, SWT.FLAT); b1.setData(input); gd = new GridData(); gd.grabExcessHorizontalSpace = false; gd.heightHint = 20; gd.widthHint = 20; gd.verticalAlignment = SWT.CENTER; b1.setLayoutData(gd); b1.setBackground(b1.getParent().getBackground()); b1.setImage(CopyGroupImage); b1.setToolTipText("Copy Color Group as a new Group"); b1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class); Command cmd = new Command() { @Override public boolean canExecute() { return true; } @Override public boolean canUndo() { return false; } @Override public void execute() { ColorQuadruple quad = (ColorQuadruple) b1.getData(); ColorQuadruple newQuad = new ColorQuadruple("copy of " + quad.getQuadrupleName()); ColorGroups grps = getColorGroups(); int idx = 1; while (grps.getGroupByName(newQuad.getQuadrupleName()) != null) { idx++; newQuad = new ColorQuadruple( "copy (" + idx + ") of " + quad.getQuadrupleName()); } for (int i = 0; i < quad.getRgbList().size(); i++) { RGB rgb = quad.getRgbList().get(i); // (add group notifies this observer about // adding // group) if (i == 0) { if (grps.addGroup(newQuad.getQuadrupleName(), rgb) == true) { // newQuad.addRGB(rgb, false); // inputs.add(newQuad); } } else { String newName = newQuad.getQuadrupleName() + " tone" + i; if (grps.addGroup(newName, rgb) == true) { // newQuad.addRGB(rgb, false); ColorGroup added = grps.getGroupByName(newName); added.setParentGroupName(newQuad.getQuadrupleName()); } } } } }; if (stck != null) { stck.execute(cmd); } else { cmd.execute(); } } }); final Button b2 = new Button(table, SWT.FLAT); b2.setData(input); gd = new GridData(); gd.grabExcessHorizontalSpace = false; gd.heightHint = 20; gd.widthHint = 20; gd.verticalAlignment = SWT.CENTER; b2.setLayoutData(gd); b2.setBackground(b2.getParent().getBackground()); b2.setImage(DeleteGroupImage); b2.setToolTipText("Delete Color Group"); b2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class); Command cmd = new Command() { @Override public boolean canExecute() { return true; } @Override public boolean canUndo() { return false; } @Override public void execute() { ColorQuadruple quad = (ColorQuadruple) b2.getData(); IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), ViewMessages.RefColors_Delete_MsgBox_Title, image, MessageFormat.format(ViewMessages.RefColors_Delete_MsgBox_Message, new Object[] { quad.getQuadrupleName() }), 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); dialog.create(); image.dispose(); if (dialog.open() == 0) { inputs.remove(quad); ColorGroups grps = getColorGroups(); grps.removeGroup(quad.getQuadrupleName()); for (int i = 1; i <= 3; i++) { // (remove group notifies this observer // about group // removal grps.removeGroup(quad.getQuadrupleName() + " tone" + i); } } } }; if (stck != null) { stck.execute(cmd); } else { cmd.execute(); } } }); } } }
From source file:com.toedter.e4.demo.contacts.rap.views.DetailsView.java
License:Open Source License
@Inject public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0); dialog.create(); ThemeUtil.applyDialogStyles(engine, dialog.getShell()); if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); }/*w ww. ja v a 2s . c o m*/ } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); detailComposite.update(contact); }
From source file:com.toedter.e4.demo.contacts.swt.views.DetailsView.java
License:Open Source License
@Inject public void setSelection(@Optional Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); dialog.create(); if (engine != null) { ThemeUtil.applyDialogStyles(engine, dialog.getShell()); }//from w w w .j av a 2 s . c o m if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); } } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); detailComposite.update(contact); }
From source file:de.uni_koeln.ub.drc.ui.handlers.ExitHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); EditView ev = (EditView) activeWorkbenchWindow.getActivePage().findView(EditView.ID); if (ev != null && ev.isDirty()) { MessageDialog dialog = new MessageDialog(ev.getSite().getShell(), Messages.get().SavePage, null, Messages.get().CurrentPageModified, MessageDialog.CONFIRM, new String[] { IDialogConstantsHelper.getYesLabel(), IDialogConstantsHelper.getNoLabel() }, 0); dialog.create(); if (dialog.open() == Window.OK) { ev.doSave(new NullProgressMonitor()); }/* ww w .ja v a 2s . co m*/ } // SessionContextSingleton.getInstance().exit(); return PlatformUI.getWorkbench().close(); }
From source file:de.uni_koeln.ub.drc.ui.views.EditView.java
License:Open Source License
private void attachSelectionListener() { ISelectionService selectionService = (ISelectionService) getSite().getService(ISelectionService.class); ScrolledCompositeHelper.fixWrapping(sc, editComposite); selectionService.addSelectionListener(new ISelectionListener() { @Override//from w w w. j a v a 2 s. co m public void selectionChanged(IWorkbenchPart part, ISelection selection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.getFirstElement() instanceof Page) { @SuppressWarnings("unchecked") List<Page> pages = structuredSelection.toList(); if (pages != null && pages.size() > 0) { Page page = pages.get(0); if (dirtyable) { MessageDialog dialog = new MessageDialog(editComposite.getShell(), Messages.get().SavePage, null, Messages.get().CurrentPageModified, MessageDialog.CONFIRM, new String[] { IDialogConstantsHelper.getYesLabel(), IDialogConstantsHelper.getNoLabel() }, 0); dialog.create(); if (dialog.open() == Window.OK) { doSave(new NullProgressMonitor()); } } editComposite.update(page); sc.setMinHeight(editComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); if (page.id().equals(SessionContextSingleton.getInstance().getCurrentUser().latestPage())) { focusLatestWord(); } } } } }); }
From source file:org.eclipse.e4.demo.contacts.views.DetailsView.java
License:Open Source License
@Inject public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); dialog.create(); ThemeUtil.applyDialogStyles(engine, dialog.getShell()); if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); }/*from w ww. j a va 2s . c o m*/ } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); if (!detailComposite.isDisposed()) { detailComposite.update(contact); } }
From source file:org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock.java
License:Open Source License
@Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return;//from www. j a va 2 s . c o m } if (changedKey != null) { if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) || PREF_PB_DEPRECATION.equals(changedKey) || PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) || PREF_15_PB_INCOMPLETE_ENUM_SWITCH.equals(changedKey) || PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey) || PREF_PB_SUPPRESS_WARNINGS.equals(changedKey) || PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey)) { updateEnableStates(); } if (checkValue(PREF_ANNOTATION_NULL_ANALYSIS, ENABLED) && (PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey) || PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey))) { boolean badNullRef = lessSevere(getValue(PREF_PB_NULL_REFERENCE), getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); boolean badPotNullRef = lessSevere(getValue(PREF_PB_POTENTIAL_NULL_REFERENCE), getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); boolean ask = false; ask |= badNullRef && (PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey)); ask |= badPotNullRef && (PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey)); ask |= (badNullRef || badPotNullRef) && PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey); if (ask) { final Combo comboBoxNullRef = getComboBox(PREF_PB_NULL_REFERENCE); final Label labelNullRef = fLabels.get(comboBoxNullRef); int highlightNullRef = getHighlight(labelNullRef); final Combo comboBoxPotNullRef = getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE); final Label labelPotNullRef = fLabels.get(comboBoxPotNullRef); int highlightPotNullRef = getHighlight(labelPotNullRef); getShell().getDisplay().asyncExec(new Runnable() { public void run() { highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, HIGHLIGHT_FOCUS); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, HIGHLIGHT_FOCUS); } }); MessageDialog messageDialog = new MessageDialog(getShell(), PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_title, null, PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); messageDialog.create(); Shell messageShell = messageDialog.getShell(); messageShell.setLocation(messageShell.getLocation().x, getShell().getLocation().y + 40); if (messageDialog.open() == 0) { if (badNullRef) { setValue(PREF_PB_NULL_REFERENCE, getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); updateCombo(getComboBox(PREF_PB_NULL_REFERENCE)); } if (badPotNullRef) { setValue(PREF_PB_POTENTIAL_NULL_REFERENCE, getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); updateCombo(getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE)); } } highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, highlightNullRef); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, highlightPotNullRef); } } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) { // merging the two options setValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue); } else if (INTR_DEFAULT_NULL_ANNOTATIONS.equals(changedKey)) { if (ENABLED.equals(newValue)) { setValue(PREF_NULLABLE_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[0]); setValue(PREF_NONNULL_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[1]); setValue(PREF_NONNULL_BY_DEFAULT_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[2]); } else { openNullAnnotationsConfigurationDialog(); } } else { return; } } else { updateEnableStates(); updateNullAnnotationsSetting(); } }
From source file:org.eclipse.jubula.client.ui.rcp.controllers.dnd.DropFileOperation.java
License:Open Source License
/** * Asks the user to confirm the import operation * @param files the list of file URLs//from ww w . j av a 2s . c o m * @return whether the operation can proceed */ private static boolean canProceed(List<URL> files) { StringBuilder builder = new StringBuilder(); builder.append(Messages.ConfirmImportDialogText); File f; URI uri; for (URL url : files) { builder.append(StringConstants.SPACE); builder.append(StringConstants.SPACE); try { uri = url.toURI(); builder.append(Paths.get(uri).getFileName().toString()); f = new File(uri); builder.append(StringConstants.SPACE); builder.append(StringConstants.LEFT_PARENTHESES); builder.append(f.length()); builder.append(StringConstants.SPACE); builder.append(Messages.Bytes); builder.append(StringConstants.RIGHT_PARENTHESES); builder.append(StringConstants.NEWLINE); } catch (URISyntaxException e) { // nothing, we just don't list this 'file's } } MessageDialog dialog = new MessageDialog(null, Messages.ConfirmImportDialogTitle, null, builder.toString(), MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }