List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress
IRunnableWithProgress
From source file:com.nokia.s60tools.compatibilityanalyser.ui.dialogs.RenameDialog.java
License:Open Source License
private void getFilesFromAllPaths(ArrayList<String> headerDirs) { headerDirectories = headerDirs;// www .j av a 2 s . 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 * *//*w w w. ja v a 2 s. c o 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 ww w . j a v a2s . 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 ww.j a v a 2 s . c om*/ .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 www . j a v a 2 s. co 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.j av a 2 s. co 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(); } }
From source file:com.nokia.s60tools.compatibilityanalyser.utils.CompatibilityAnalyserUtils.java
License:Open Source License
/** * Starts the downloading core tools from web server with progress monitor. *//*ww w . j a v a 2 s. com*/ public static String initiateDownloadingCoreTools() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); String urlInPref = prefStore.getString(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL); //If core tools were already downloaded from web server earlier, they will be deleted. String previousContents = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR); if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$ { File oldContents = new File(previousContents); if (oldContents.exists()) FileMethods.deleteFolder(previousContents); } String targetPath = FileMethods.appendPathSeparator(CompatibilityAnalyserEngine.getWorkspacePath()) + Messages.getString("HeaderAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$ String coreToolsExtraction = CompatibilityAnalyserEngine .readAndDownloadSupportedCoretools(urlInPref, targetPath, monitor); if (coreToolsExtraction == null) { temp = null; prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL, urlInPref); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH, CompatibilityAnalyserEngine.getWebServerToolsPath()); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR, targetPath); } else temp = coreToolsExtraction; } }; 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(); return "Error!"; } catch (InterruptedException e) { e.printStackTrace(); return "Error!"; } //If download not successful if (temp != null) return temp; return null; }
From source file:com.nokia.s60tools.crashanalyser.ui.wizards.CrashAnalyserWizard.java
License:Open Source License
public IWizardPage getNextPage(IWizardPage page) { // We are moving from 1st page to 2nd page. // We need to run CrashAnalyser.exe to get summary data for crash files if (page.equals(crashFileOrFolderSelectionPage)) { returnPage = null;/*from www . ja v a 2 s . c om*/ userProvidedCrashFileOrFolder = crashFileOrFolderSelectionPage.getSelectedFileOrFolder(); crashAnalyserExeExecutionSuccess = false; try { getContainer().run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { errorMessage = ""; // run CrashAnalyser.exe for summary information for selected file(s). if (readCrashFileFromDevice && fileProvider != null) { errorMessage = fileProvider .executeFunctionality(DecoderEngine.getTemporaryCrashFileFolder(true)); userProvidedCrashFileOrFolder = DecoderEngine.getTemporaryCrashFileFolder(false); } crashAnalyserExeExecutionSuccess = engine .processSummaryInfoForFiles(userProvidedCrashFileOrFolder, errorLibrary, monitor); } }); } catch (Exception e) { e.printStackTrace(); } // CrashAnalyser.exe execution was successful -> return next wizard page if (crashAnalyserExeExecutionSuccess) { crashFileOrFolderSelectionPage.errorInProcessingNextPress(false); filesSelectionPage.loadTable(); returnPage = filesSelectionPage; // CrashAnalyser.exe execution was unsuccessful, don't proceed to next // wizard page -> return current page } else { if (readCrashFileFromDevice) { if ("".equals(errorMessage)) { showMessage("The device did not contain any crash files"); } else { showMessage("Could not read crash files. Please check PC Suite connection.\n\nError:\n" + errorMessage); } } else { crashFileOrFolderSelectionPage.errorInProcessingNextPress(true); } returnPage = crashFileOrFolderSelectionPage; filesSelectionPage.showOnlyTheseFiles(null); } readCrashFileFromDevice = false; return returnPage; } // We are moving from 2nd page to 3rd/4th page. else if (page.equals(filesSelectionPage)) { // only (already "decoded") output.crashxml files have been selected in 2nd page. // Skip parameterFiles page and go to additionalSettingsPage, because we don't have // to query for symbols etc. because there is nothing to decode. return parameterFilesPage; } return null; }
From source file:com.nokia.s60tools.imaker.internal.model.Environment.java
License:Open Source License
public String getTargetSteps(final String target) { targetSteps = null;//from w w w . ja v a2 s .c o m ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getDisplay().getActiveShell()); try { progressMonitorDialog.run(true, false, new IRunnableWithProgress() { // @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { targetSteps = wrapper.getTargetSteps(target, getCurrentProduct().getFilePath(), monitor); } catch (IMakerCoreExecutionException e) { throw new InvocationTargetException(e); } } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } return targetSteps; }