List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.nokia.s60tools.compatibilityanalyser.ui.actions.AnalyseDirOnlyAction.java
License:Open Source License
/** * This method gets invoked when user selects the option, * 'Run static analysis for this directory in project...' from * the submenu of a folder.// w ww . jav a2 s . co m */ public void run(IAction action) { IWorkbenchWindow window = CompatibilityAnalyserPlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow(); ISelection selection = (ISelection) window.getSelectionService().getSelection(); engine = new CompatibilityAnalyserEngine(); currentSdk = new ProductSdkData(); currentSdk.isOpenedFromProject = true; try { isCancelled = false; engine.setHeaderAnalysis(true); if (selection instanceof TreeSelection) { IStructuredSelection treeSelection = (IStructuredSelection) selection; //In Carbide, some folders are instances of ICContainer class. if (treeSelection.getFirstElement() instanceof IFolder || treeSelection.getFirstElement() instanceof ICContainer) { IFolder selectedFolder = null; ICContainer container = null; IProject parentProj = null; if (treeSelection.getFirstElement() instanceof IFolder) { selectedFolder = (IFolder) treeSelection.getFirstElement(); parentProj = selectedFolder.getProject(); folderPath = FileMethods .convertForwardToBackwardSlashes(selectedFolder.getLocation().toString()); } else if (treeSelection.getFirstElement() instanceof ICContainer) { container = (ICContainer) treeSelection.getFirstElement(); parentProj = container.getCProject().getProject(); folderPath = FileMethods .convertForwardToBackwardSlashes(container.getResource().getLocation().toString()); } ICarbideBuildManager mngr = CarbideBuilderPlugin.getBuildManager(); //Selected folder path is added to the list of //directories, in Headers page of the wizard. if (folderPath != null) { currentSdk.defaultHeaderDir = false; currentSdk.currentHeaderDir = new String[] { folderPath }; currentSdk.analyseAll = false; } else { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("ProjectViewPopupAction.CompatibilityAnalyserError"), "Unable to read selected Resource"); currentSdk.isOpenedFromProject = false; return; } if (parentProj != null && mngr.isCarbideProject(parentProj)) { prjInfo = mngr.getProjectInfo(parentProj); } else { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("ProjectViewPopupAction.CompatibilityAnalyserError"), Messages.getString("ProjectViewPopupAction.CouldNotReadInfoFromProject")); currentSdk.isOpenedFromProject = false; return; } currentSdk.projectName = parentProj.getName(); currentSdk.productSdkName = prjInfo.getDefaultConfiguration().getSDK().getUniqueId(); IRunnableWithProgress projProgInfo = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Reading folder data...", 10); filesList = getHeaderFilesFromFolder(folderPath, monitor); ArrayList<String> sysIncList = new ArrayList<String>(); getSystemIncludesFromThisProject(prjInfo, sysIncList, monitor); currentSdk.HeaderFilesList = filesList.toArray(new String[0]); monitor.worked(6); currentSdk.currentIncludes = sysIncList.toArray(new String[0]); if (!isCancelled) { libsList = getCorrespondingDsos(filesList, monitor); monitor.worked(9); } if (libsList.size() != 0) { engine.setLibraryAnalysis(true); currentSdk.analyzeAllLibs = false; currentSdk.libraryFilesList = libsList.toArray(new String[0]); } } catch (Exception e) { e.printStackTrace(); } monitor.done(); } }; new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, projProgInfo); } } engine.setCurrentSdkData(currentSdk); } catch (Exception e) { e.printStackTrace(); } if (isCancelled) return; Runnable showWizardRunnable = new Runnable() { public void run() { WizardDialog wizDialog; AnalysisWizard wiz = new AnalysisWizard(engine); wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz); wizDialog.create(); //wizDialog.getShell().setSize(550, 620); wizDialog.addPageChangedListener(wiz); try { wizDialog.open(); } catch (Exception e) { e.printStackTrace(); } } }; Display.getDefault().syncExec(showWizardRunnable); }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.actions.ProjectViewPopupAction.java
License:Open Source License
public void run(IAction action) { engine = new CompatibilityAnalyserEngine(); ProductSdkData currentSdk = new ProductSdkData(); engine.setCurrentSdkData(currentSdk); isCancelled = false;/*from ww w. ja va2s . co m*/ IRunnableWithProgress projProgInfo = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { getSettingsForGivenSelection(selection, engine, monitor); } catch (Exception e) { e.printStackTrace(); return; } } }; try { new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, projProgInfo); } catch (Exception ex) { ex.printStackTrace(); } if (isCancelled) return; if (engine.isLibraryAnalysisChecked()) { currentSdk.analyzeAllLibs = false; } engine.setCurrentSdkData(currentSdk); Runnable showWizardRunnable = new Runnable() { public void run() { WizardDialog wizDialog; //CompatibilityAnalyserEngine engine = new CompatibilityAnalyserEngine(); AnalysisWizard wiz = new AnalysisWizard(engine); wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz); wizDialog.create(); wizDialog.getShell().setSize(wizDialog.getShell().getSize().x, wizDialog.getShell().getSize().y + 70); wizDialog.addPageChangedListener(wiz); try { wizDialog.open(); } catch (Exception e) { e.printStackTrace(); } } }; Display.getDefault().syncExec(showWizardRunnable); }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.dialogs.AdvancedOptionsDialog.java
License:Open Source License
private void openFilesListDialog() { numOfFiles = new ArrayList<String>(); displayFiles = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); isMonitorCancelled = false;// w w w . java 2 s . c o m addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_table, this, "", true); ArrayList<String> paths = new ArrayList<String>(); for (int i = 0; i < syspath_table.getItems().length; i++) { if (!paths.contains(syspath_table.getItem(i).getText(0))) paths.add(syspath_table.getItem(i).getText(0)); } if (!paths.contains(epocRoot + "epoc32" + File.separator + "include")) paths.add(epocRoot + "epoc32" + File.separator + "include"); 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(); } if (!isMonitorCancelled) { 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(); } }
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; }// w w w.ja v a 2 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.s60tools.compatibilityanalyser.ui.dialogs.RenameDialog.java
License:Open Source License
private void getFilesFromAllPaths(ArrayList<String> headerDirs) { headerDirectories = headerDirs;//w ww . j a v a 2s.co m if (headerDirs == null || headerDirs.size() == 0 || filesDialog == null) return; isMonitorCancelled = false; fileNamesList = new ArrayList<String>(); filesList = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { int i = 1; for (String path : headerDirectories) { currentPath = FileMethods.convertForwardToBackwardSlashes(path); monitor.beginTask("Getting files from " + currentPath, headerDirectories.size()); getAndSetFiles(currentPath, monitor); processSubDirs(currentPath, 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(); } if (!isMonitorCancelled) { Collections.sort(filesList); filesDialog.children = children; filesDialog.subChildren = subChildren; filesDialog.open(); filesDialog.filesList.setItems(filesList.toArray(new String[filesList.size()])); } if (isMonitorCancelled) { //System.out.println("Cancelled the process"); } else if ((filesDialog.filesList == null || filesDialog.filesList.getItemCount() == 0) && fileNamesList.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 (fileNamesList.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 filesDialog.fileNamesList = filesDialog.filesList.getItems(); }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.CompatibilityAnalyserPreferences.java
License:Open Source License
/** * Starts downloading coretools from the URL given. * Displays the version of coretools after downloading the tools * *//*from ww w . j a va 2 s.co m*/ public void showWebToolsProgressBar() { if (webcoreBtn.getSelection()) { currentWebserverPath = webLink.getText(); if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentWebserverPath)) { // if true download latest IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { targetPath = CompatibilityAnalyserEngine.getWorkspacePath() + File.separator + Messages.getString("CompatibilityAnalyserPreferences.WebServerLatest"); //$NON-NLS-1$ extractionStatus = CompatibilityAnalyserEngine .readAndDownloadSupportedCoretools(currentWebserverPath, targetPath, 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 e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } ////After download check the version and display if (extractionStatus == null) { isRefreshInvoked = true; displayVersion(CompatibilityAnalyserEngine.getWebServerToolsPath(), Messages.getString("CompatibilityAnalyserPreferences.67")); //$NON-NLS-1$ } else { if (targetPath != null) { File latest = new File(targetPath); if (latest.exists()) { FileMethods.deleteFolder(latest.getAbsolutePath()); } } MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString("CompatibilityAnalyserPreferences.44"), "Error in Extracting CoreTools: " + extractionStatus); } } else { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("CompatibilityAnalyserPreferences.69"), //$NON-NLS-1$ Messages.getString("CompatibilityAnalyserPreferences.70")); //$NON-NLS-1$ IPreferenceStore store = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); String toolsPath = store .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH); displayVersion(toolsPath, Messages.getString("CompatibilityAnalyserPreferences.71")); //$NON-NLS-1$ } } else if (localcoreBtn.getSelection()) { displayVersion(localCmb.getText(), Messages.getString("CompatibilityAnalyserPreferences.72")); //$NON-NLS-1$ } else if (sdkcoreBtn.getSelection()) { ISymbianSDK[] sdks = rndSdkList.toArray(new ISymbianSDK[0]); String toolsPath = null; if (sdks.length != 0 && sdkCmb.getSelectionIndex() != -1) { String epocRoot = sdks[sdkCmb.getSelectionIndex()].getEPOCROOT(); toolsPath = FileMethods.appendPathSeparator(epocRoot) + Messages.getString("CompatibilityAnalyserPreferences.epoc32") + File.separator //$NON-NLS-1$ + Messages.getString("CompatibilityAnalyserPreferences.tools") + File.separator + //$NON-NLS-1$ Messages.getString("CompatibilityAnalyserPreferences.s60rndtools") + File.separator //$NON-NLS-1$ + Messages.getString("CompatibilityAnalyserPreferences.bctools"); //$NON-NLS-1$ } displayVersion(toolsPath, Messages.getString("CompatibilityAnalyserPreferences.77")); //$NON-NLS-1$ } else if (defaultcoreBtn.getSelection()) { String corePath = FileMethods .appendPathSeparator(CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin()) + Messages.getString("CompatibilityAnalyserPreferences.78"); //$NON-NLS-1$ displayVersion(corePath, Messages.getString("CompatibilityAnalyserPreferences.79")); //$NON-NLS-1$ } }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.HeaderFilesPage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if (e.widget == rootDir) { GridData data = (GridData) header_dir_options_comp.getLayoutData(); data.exclude = !rootDir.getSelection(); header_dir_options_comp.setVisible(rootDir.getSelection()); header_dir_options_comp.getParent().getParent().layout(); currentHdrs_list.setEnabled(rootDir.getSelection()); browse.setEnabled(rootDir.getSelection()); validateFileSet();//from w ww . ja v a 2 s .c o m this.getContainer().updateButtons(); } else if (e.widget == browse) { DirectoryDialog dirDialog = new DirectoryDialog(this.getShell()); ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard().getPreviousPage(this); dirDialog.setFilterPath(productPage.epocDirectory.getText()); String newDir = dirDialog.open(); if (newDir != null) { TableItem item = new TableItem(currentHdrs_list, SWT.NONE); item.setText(newDir); currentHdrs_list.select(0); } validateFileSet(); this.getContainer().updateButtons(); } else if (e.widget == removeBtn_hdrGrp) { currentHdrs_list.remove(currentHdrs_list.getSelectionIndices()); currentHdrs_list.select(0); validateFileSet(); this.getContainer().updateButtons(); } else if (e.widget == removeAllBtn_hdrGrp) { currentHdrs_list.removeAll(); validateFileSet(); this.getContainer().updateButtons(); } else if (e.widget == filesSelection) { if (filesSelection.getSelection() && !prevFilesSelection) { show_btn.notifyListeners(SWT.Selection, new Event()); replaceFileSet.clear(); for (TableItem item : filesList.getItems()) { replaceFileSet.put(item.getText(0), item.getText(1)); } filesList.removeAll(); duplicates.clear(); if (headersFileSet.size() > 0) { String[] keys = headersFileSet.keySet().toArray(new String[0]); for (String s : keys) { String value = headersFileSet.get(s); TableItem item = new TableItem(filesList, SWT.NONE); item.setText(new String[] { s, value }); if (doesBaseOccursManyTimes(value) && !duplicates.contains(value)) { duplicates.add(value); } } } prevFilesSelection = true; } else if (!filesSelection.getSelection() && prevFilesSelection) { headersFileSet.clear(); for (TableItem item : filesList.getItems()) { headersFileSet.put(item.getText(0), item.getText(1)); } filesList.removeAll(); duplicates.clear(); if (replaceFileSet.size() > 0) { String[] keys = replaceFileSet.keySet().toArray(new String[0]); for (String s : keys) { String value = replaceFileSet.get(s); TableItem item = new TableItem(filesList, SWT.NONE); item.setText(new String[] { s, value }); if (doesBaseOccursManyTimes(value) && !duplicates.contains(value)) { duplicates.add(value); } } } prevFilesSelection = false; } replace.setEnabled(filesSelection.getSelection()); //Disabling the controls fileTypes_Grp.setVisible(!filesSelection.getSelection()); useRecursive.setVisible(!filesSelection.getSelection()); addFiles.setVisible(filesSelection.getSelection()); removeNonExisting.setVisible(filesSelection.getSelection()); validateFileSet(); this.getContainer().updateButtons(); } else if (e.widget == selectedTypes) { hrhType.setEnabled(selectedTypes.getSelection()); hType.setEnabled(selectedTypes.getSelection()); rsgType.setEnabled(selectedTypes.getSelection()); mbgType.setEnabled(selectedTypes.getSelection()); hppType.setEnabled(selectedTypes.getSelection()); panType.setEnabled(selectedTypes.getSelection()); this.getContainer().updateButtons(); } else if (e.widget == addFiles) { fileNamesList = new ArrayList<String>(); displayFiles = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); isMonitorCancelled = false; if (rootDir.getSelection() && currentHdrs_list.getItemCount() > 0) { if (currentHdrs_list.getItemCount() == 1) { absolutePath = new String(currentHdrs_list.getItem(0).getText(0)); absolutePath = FileMethods.convertForwardToBackwardSlashes(absolutePath); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), filesList, this, absolutePath, true); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); 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(); } } else { addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), filesList, this, "", true); String[] paths = new String[currentHdrs_list.getItems().length]; for (int i = 0; i < currentHdrs_list.getItems().length; i++) paths[i] = currentHdrs_list.getItem(i).getText(0); allHdrPaths = paths; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { int i = 1; for (String path : allHdrPaths) { absolutePath = FileMethods.convertForwardToBackwardSlashes(path); monitor.beginTask("Getting files from " + absolutePath, allHdrPaths.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 { ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard() .getPreviousPage(this); absolutePath = new String(FileMethods.appendPathSeparator(productPage.epocDirectory.getText()) + Messages.getString("HeaderFilesPage.epoc32Include")); //$NON-NLS-1$ absolutePath = FileMethods.convertForwardToBackwardSlashes(absolutePath); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), filesList, this, absolutePath, true); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); 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) { for (String name : fileNamesList) { if (!isPreviouslySelected(name)) displayFiles.add(name); else { if (subChildren.contains(name)) subChildren.remove(name); if (children.contains(name)) children.remove(name); } } Collections.sort(displayFiles); addDialog.children = children; addDialog.subChildren = subChildren; if (displayFiles.size() == 0 && fileNamesList.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 (fileNamesList.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.open(); addDialog.filesList.setItems(displayFiles.toArray(new String[displayFiles.size()])); addDialog.filesList.select(0); addDialog.fileNamesList = addDialog.filesList.getItems(); } } this.getContainer().updateButtons(); } else if (e.widget == remove) { filesList.remove(filesList.getSelectionIndices()); filesList.select(0); validateFileSet(); validateBaseFiles(); this.getContainer().updateButtons(); } else if (e.widget == replace) { if (filesList.getItemCount() > 0 && filesList.getSelectionIndex() != -1) { String currentFile = filesList.getItem(filesList.getSelectionIndices()[0]).getText(0); String baseFile = filesList.getItem(filesList.getSelectionIndices()[0]).getText(1); dialog = new RenameDialog(Display.getCurrent().getActiveShell(), SWT.OPEN, currentFile, baseFile, this); } else dialog = new RenameDialog(Display.getCurrent().getActiveShell(), SWT.OPEN, null, null, this); ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard().getPreviousPage(this); if (defaultRootDir.getSelection()) { String epocPath = new String(FileMethods.appendPathSeparator(productPage.epocDirectory.getText()) + Messages.getString("HeaderFilesPage.epoc32Include")); //$NON-NLS-1$ epocPath = FileMethods.convertForwardToBackwardSlashes(epocPath); dialog.setCurrentFiles(new String[] { epocPath }); } else { String[] paths = new String[currentHdrs_list.getItems().length]; for (int i = 0; i < currentHdrs_list.getItems().length; i++) paths[i] = currentHdrs_list.getItem(i).getText(0); dialog.setCurrentFiles(paths); } dialog.setBaselineProfile(productPage.profileCombo.getText()); dialog.open(); } else if (e.widget == removeNonExisting) { int[] invalidIndices = new int[invalidHeadersCount]; int j = 0; for (int i = 0; i < filesList.getItemCount(); i++) { if (filesList.getItem(i).getForeground().equals(invalidColor)) { invalidIndices[j] = i; j++; } } filesList.remove(invalidIndices); invalidHeadersCount = 0; this.getContainer().updateButtons(); } else if (e.widget == selectAll) { filesList.removeAll(); if (duplicates.size() > 0) duplicates.clear(); this.getContainer().updateButtons(); } else if (e.widget == filesList) { this.getContainer().updateButtons(); } else if ((e.widget == hType) || (e.widget == hrhType) || (e.widget == rsgType) || (e.widget == mbgType) || (e.widget == hppType) || (e.widget == panType)) { this.getContainer().updateButtons(); } else if (e.widget == show_btn) { GridData data = (GridData) headers_files_options_comp.getLayoutData(); data.exclude = false; headers_files_options_comp.setVisible(true); headers_files_options_comp.getParent().getParent().layout(); ((StackLayout) show_hide_button_comp.getLayout()).topControl = hide_btn; show_hide_button_comp.layout(); headers_files_options_comp.setVisible(true); } else if (e.widget == hide_btn) { GridData data = (GridData) headers_files_options_comp.getLayoutData(); data.exclude = true; headers_files_options_comp.setVisible(false); headers_files_options_comp.getParent().getParent().layout(); ((StackLayout) show_hide_button_comp.getLayout()).topControl = show_btn; show_hide_button_comp.layout(); headers_files_options_comp.setVisible(false); } else if (e.widget == advanced_options_button) { ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard().getPreviousPage(this); AdvancedOptionsDialog adv_opt = new AdvancedOptionsDialog(this.getShell(), currentSdkData, FileMethods.appendPathSeparator(productPage.epocDirectory.getText())); adv_opt.open(); } }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.LibraryFilesPage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if (e.widget == userDirs_radioBtn || e.widget == default_build_target_radioBtn) { removeDsoDir_Btn.setEnabled(userDirs_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); removeAllDsoDir_Btn/*from w w w .j av a 2 s. com*/ .setEnabled(userDirs_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); removeDllDir_Btn.setEnabled(userDirs_radioBtn.getSelection() && userDllPath_list.getItemCount() != 0); removeAllDllDir_Btn .setEnabled(userDirs_radioBtn.getSelection() && userDllPath_list.getItemCount() != 0); GridData data = (GridData) buildTarget_list.getLayoutData(); data.exclude = !buildtarget_radioBtn.getSelection(); buildTarget_list.setVisible(buildtarget_radioBtn.getSelection()); GridData data2 = (GridData) dllPaths_Folder.getLayoutData(); data2.exclude = !userDirs_radioBtn.getSelection(); dllPaths_Folder.setVisible(userDirs_radioBtn.getSelection()); composite.getParent().setSize(composite.getParent().getSize().x + 1, composite.getParent().getSize().y); this.getContainer().updateButtons(); } else if (e.widget == addDsoDir_Btn) { DirectoryDialog dirDialog = new DirectoryDialog(this.getShell()); dirDialog.setFilterPath(releaseRoot); String newDir = dirDialog.open(); if (newDir != null) { new TableItem(userDsoPath_list, SWT.NONE).setText(0, newDir); userDsoPath_list.select(0); } removeDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); removeAllDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } else if (e.widget == addDllDir_Btn) { DirectoryDialog dirDialog = new DirectoryDialog(this.getShell()); dirDialog.setFilterPath(releaseRoot); String newDir = dirDialog.open(); if (newDir != null) { new TableItem(userDllPath_list, SWT.NONE).setText(0, newDir); userDllPath_list.select(0); } removeDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); removeAllDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } else if (e.widget == buildTarget_list) { selectedPlatform = buildTarget_list.getSelection(); } if (e.widget == analyseSelected_radioBtn) { dsoFiles_list.setEnabled(analyseSelected_radioBtn.getSelection()); addDso_Btn.setEnabled(analyseSelected_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); removeDso_Btn .setEnabled(analyseSelected_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); removeAllDso_Btn .setEnabled(analyseSelected_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); removeNonExistingDso_Btn .setEnabled(analyseSelected_radioBtn.getSelection() && userDsoPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } if (e.widget == addDso_Btn) { filesNamesList = new ArrayList<String>(); displayFiles = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); isMonitorCancelled = false; if (userDirs_radioBtn.getSelection() && userDsoPath_list.getItemCount() == 1) { absolutePath = userDsoPath_list.getItem(0).getText(0); absolutePath = FileMethods.convertForwardToBackwardSlashes(absolutePath); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), dsoFiles_list, this, absolutePath, false); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); 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; ProgressMonitorDialog progDlg = new ProgressMonitorDialog(shell); progDlg.run(true, true, op); progDlg.setBlockOnOpen(true); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } } else if (userDirs_radioBtn.getSelection() && userDsoPath_list.getItemCount() > 1) { addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), dsoFiles_list, this, "", false); String[] paths = new String[userDsoPath_list.getItems().length]; for (int i = 0; i < userDsoPath_list.getItems().length; i++) paths[i] = userDsoPath_list.getItem(i).getText(0); allLibsPaths = paths; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { int i = 1; for (String path : allLibsPaths) { absolutePath = FileMethods.convertForwardToBackwardSlashes(path); monitor.beginTask("Getting files from " + absolutePath, allLibsPaths.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; ProgressMonitorDialog progDlg = new ProgressMonitorDialog(shell); progDlg.run(true, true, op); progDlg.setBlockOnOpen(true); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } } else if (buildtarget_radioBtn.getSelection()) { if (releaseRoot != null) { addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), dsoFiles_list, this, "", false); String[] paths = new String[buildTarget_list.getSelectionCount()]; for (int i = 0; i < buildTarget_list.getSelectionCount(); i++) { paths[i] = FileMethods.appendPathSeparator(releaseRoot) + buildTarget_list.getSelection()[i] + File.separator + Messages.getString("LibraryFilesPage.lib"); //$NON-NLS-1$ //$NON-NLS-2$; } allLibsPaths = paths; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { int i = 1; for (String path : allLibsPaths) { absolutePath = FileMethods.convertForwardToBackwardSlashes(path); monitor.beginTask("Getting files from " + absolutePath, allLibsPaths.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; ProgressMonitorDialog progDlg = new ProgressMonitorDialog(shell); progDlg.run(true, true, op); progDlg.setBlockOnOpen(true); } catch (InvocationTargetException err) { err.printStackTrace(); } catch (InterruptedException err) { err.printStackTrace(); } } } else if (default_build_target_radioBtn.getSelection()) { String buildTarget = CompatibilityAnalyserEngine.getDefaultBuildPlatform(releaseRoot, currentSdk.productSdkVersion); absolutePath = FileMethods.appendPathSeparator(releaseRoot) + buildTarget + File.separator + Messages.getString("LibraryFilesPage.lib"); //$NON-NLS-1$ //$NON-NLS-2$ absolutePath = FileMethods.convertForwardToBackwardSlashes(absolutePath); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), dsoFiles_list, this, absolutePath, false); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); 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; ProgressMonitorDialog 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 (filesNamesList.size() != dsoFiles_list.getItemCount()) for (String name : filesNamesList) { if (!isPreviouslySelected(name)) displayFiles.add(name); else { if (subChildren.contains(name)) subChildren.remove(name); if (children.contains(name)) children.remove(name); } } Collections.sort(displayFiles); addDialog.children = children; addDialog.subChildren = subChildren; if (displayFiles.size() == 0 && filesNamesList.size() != 0) { Runnable showMessageRunnable = new Runnable() { public void run() { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$ "All libraries in the root directory are already selected"); //$NON-NLS-1$ } }; Display.getDefault().asyncExec(showMessageRunnable); } else if (filesNamesList.size() == 0) { Runnable showMessageRunnable = new Runnable() { public void run() { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$ "No libraries exist under the given directory path"); //$NON-NLS-1$ } }; Display.getDefault().asyncExec(showMessageRunnable); } else { addDialog.open(); addDialog.filesList.setItems(displayFiles.toArray(new String[displayFiles.size()])); addDialog.filesList.select(0); addDialog.fileNamesList = addDialog.filesList.getItems(); } } this.getContainer().updateButtons(); } else if (e.widget == removeDso_Btn) { dsoFiles_list.remove(dsoFiles_list.getSelectionIndices()); dsoFiles_list.select(0); this.getContainer().updateButtons(); } else if (e.widget == removeAllDso_Btn) { dsoFiles_list.removeAll(); this.getContainer().updateButtons(); } else if (e.widget == removeNonExistingDso_Btn) { int[] invalidIndices = new int[invalidLibsCount]; int j = 0; for (int i = 0; i < dsoFiles_list.getItemCount(); i++) { System.out.println("Item Color is " + dsoFiles_list.getItem(i).getForeground() + " And InvalidColor is " + invalidColor); if (dsoFiles_list.getItem(i).getForeground().equals(invalidColor)) { invalidIndices[j] = i; j++; } } dsoFiles_list.remove(invalidIndices); invalidLibsCount = 0; this.getContainer().updateButtons(); } else if (e.widget == removeDsoDir_Btn) { userDsoPath_list.remove(userDsoPath_list.getSelectionIndices()); userDsoPath_list.select(0); removeDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); removeAllDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } else if (e.widget == removeAllDsoDir_Btn) { userDsoPath_list.removeAll(); removeDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); removeAllDsoDir_Btn.setEnabled(userDsoPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } else if (e.widget == removeDllDir_Btn) { userDllPath_list.remove(userDllPath_list.getSelectionIndices()); userDllPath_list.select(0); removeDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); removeAllDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } else if (e.widget == removeAllDllDir_Btn) { userDllPath_list.removeAll(); removeDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); removeAllDllDir_Btn.setEnabled(userDllPath_list.getItemCount() != 0); this.getContainer().updateButtons(); } }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.PlatformHeadersPage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if (e.widget == addPath) { DirectoryDialog dirDialog = new DirectoryDialog(this.getShell()); ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard().getPreviousPage(this) .getPreviousPage();/*from w ww .ja v a2 s .c o m*/ dirDialog.setFilterPath(productPage.epocDirectory.getText() + "epoc32" + File.separator + "include"); String newDir = dirDialog.open(); if (newDir != null) { TableItem item = new TableItem(dirsList, SWT.NONE); item.setText(0, newDir); } dirsList.select(0); validateForcedHeaders(); this.getContainer().updateButtons(); } else if (e.widget == remove) { dirsList.remove(dirsList.getSelectionIndices()); dirsList.select(0); validateForcedHeaders(); this.getContainer().updateButtons(); } else if (e.widget == forced_hdrs_check) { if (forced_hdrs_check.getSelection()) validateForcedHeaders(); this.getContainer().updateButtons(); } else if (e.widget == forced_addBtn) { numOfFiles = new ArrayList<String>(); displayFiles = new ArrayList<String>(); children = new ArrayList<String>(); subChildren = new ArrayList<String>(); isMonitorCancelled = false; if (dirsList.getItemCount() > 0) { ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard() .getPreviousPage(this).getPreviousPage(); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this, "", true); ArrayList<String> paths = new ArrayList<String>(); for (int i = 0; i < dirsList.getItems().length; i++) paths.add(dirsList.getItem(i).getText(0)); paths.add(productPage.epocDirectory.getText() + "epoc32" + File.separator + "include"); 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 { ProductSDKSelectionPage productPage = (ProductSDKSelectionPage) this.getWizard() .getPreviousPage(this).getPreviousPage(); addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this, productPage.epocDirectory.getText() + "epoc32" + File.separator + "include", true); absolutePath = productPage.epocDirectory.getText() + "epoc32" + File.separator + "include"; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Getting files from " + absolutePath, 10); getFiles(absolutePath, monitor); 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) { 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(); } this.getContainer().updateButtons(); } else if (e.widget == forced_removeBtn) { forced_hdrs_list.remove(forced_hdrs_list.getSelectionIndices()); forced_hdrs_list.select(0); this.getContainer().updateButtons(); } else if (e.widget == forced_removeAllBtn) { forced_hdrs_list.removeAll(); this.getContainer().updateButtons(); } }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.ProductSDKSelectionPage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if ((e.widget == headersButton) || (e.widget == libsButton)) { this.getContainer().updateButtons(); } else if (e.widget == configure) { BaselineEditor dd = null;/* w w w.ja va2 s .c o m*/ if (profileCombo.getSelectionIndex() == 0) dd = new BaselineEditor(Display.getDefault().getActiveShell(), null); else dd = new BaselineEditor(Display.getDefault().getActiveShell(), profileCombo.getText()); dd.setBlockOnOpen(true); int status = dd.open(); if (status == IDialogConstants.OK_ID) { profileCombo.setItems(basics); String[] updatedProfiles = BaselineProfileUtils.getAllBaselinesProfiles(); if (updatedProfiles != null) { for (int i = 0; i < updatedProfiles.length; i++) if (profileCombo.indexOf(updatedProfiles[i]) == -1) { profileCombo.add(updatedProfiles[i]); } if (updatedProfiles.length > 0) { if (profileCombo.indexOf(updatedProfiles[0]) != -1) { Object obj = BaselineProfileUtils.getBaselineProfileData(updatedProfiles[0]); if (obj instanceof BaselineProfile && ((BaselineProfile) obj).isUpdated()) profileCombo.select(profileCombo.indexOf(updatedProfiles[0])); else profileCombo.select(0); } } } else profileCombo.select(0); } else if (status == IDialogConstants.IGNORE_ID) { profileCombo.setItems(basics); String[] updatedProfiles = BaselineProfileUtils.getAllBaselinesProfiles(); if (updatedProfiles != null) for (int i = 0; i < updatedProfiles.length; i++) if (profileCombo.indexOf(updatedProfiles[i]) == -1) profileCombo.add(updatedProfiles[i]); profileCombo.select(0); } engine.setBaselineProfile(profileCombo.getText()); this.getContainer().updateButtons(); } else if (e.widget == profileCombo) { this.setMessage(null); Object obj = BaselineProfileUtils.getBaselineProfileData(profileCombo.getText()); if (obj instanceof BaselineProfile) { BaselineProfile pro = (BaselineProfile) obj; if (pro.isPredefined()) { 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); prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profile.getProfileName()); } else { profileCombo.select(0); MessageDialog.openError(this.getShell(), "Compatibility Analyser", downloadStatus); downloadStatus = null; } } } engine.setBaselineProfile(profileCombo.getText()); } this.getContainer().updateButtons(); } }