List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.nokia.testfw.codegen.ui.wizard.AbstractTemplateWizard.java
License:Open Source License
@Override public boolean performFinish() { int oldAddFilesOption = ProjectUIPlugin.getAddFilesToProjectOption(); int oldChangedFilesOption = ProjectUIPlugin.getChangedFilesInProjectOption(); ProjectUIPlugin.setAddFilesToProjectOption(2); ProjectUIPlugin.setChangedFilesInProjectOption(2); ResourceChangeListener.setEnable(false); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask("Starting...", IProgressMonitor.UNKNOWN); try { if (iTargetProject == null) { iTargetProject = createTargetProject(monitor); }/*from w w w.j av a2 s . com*/ if (iResultMap == null) { iResultMap = generateFiles(monitor); } if (iResultMap != null && iTargetProject != null) { writeResultMapToFiles(iTargetProject, monitor); } else { MessageDialog.openError(getShell(), "Error", "Exception was thrown while generating files"); } } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while generating files.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); MessageDialog.openError(getShell(), "Exception was thrown while generating files", e.getTargetException().getMessage()); } finally { ProjectUIPlugin.setAddFilesToProjectOption(oldAddFilesOption); ProjectUIPlugin.setChangedFilesInProjectOption(oldChangedFilesOption); ResourceChangeListener.setEnable(true); } return true; }
From source file:com.nokia.testfw.codegen.ui.wizard.AbstractTemplateWizard.java
License:Open Source License
@Override public boolean performCancel() { if (iSelfCreateProject && iTargetProject != null) { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { iTargetProject.delete(true, null); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done();//from w ww.j a va2s .c o m } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while delete temporary project.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); } } return super.performCancel(); }
From source file:com.nokia.testfw.codegen.ui.wizard.AbstractTemplateWizard.java
License:Open Source License
public Map<String, ChangeFileContent> getPreviewResult() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask("Creating new test codes", IProgressMonitor.UNKNOWN); try { iResultMap = generateFiles(monitor); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done();// w w w . j a va 2s .co m } } }; try { new ProgressMonitorDialog(getShell()).run(true, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while generating files.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); MessageDialog.openError(getShell(), "Exception was thrown while generating files", e.getTargetException().getMessage()); return null; } return iResultMap; }
From source file:com.nokia.testfw.codegen.ui.wizard.GenTestMethodDialog.java
License:Open Source License
private void showAST(final IPath header) { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask("Starting syntax analysis...", IProgressMonitor.UNKNOWN); try { ICProject cproject = CoreModel.getDefault().create(iProject); ITranslationUnit tu = CCorePlugin.getDefault().getCoreModel() .createTranslationUnitFrom(cproject, header); iHeaderNode = Parser.parseTranslationUnit(tu, Parser.PUBLIC); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done();//from w w w . ja va 2 s .c om } } }; try { new ProgressMonitorDialog(getParent()).run(true, false, op); iCheckboxTreeViewer.setInput(iHeaderNode); iCheckboxTreeViewer.setCheckedElements(iHeaderNode.getChildren().toArray(new ClassNodeImpl[0])); iCheckboxTreeViewer.expandAll(); } catch (InterruptedException e) { } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while analysis header file.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); MessageDialog.openError(getParent(), "Exception was thrown while analysis header file.", e.getTargetException().getMessage()); } }
From source file:com.nokia.testfw.codegen.ui.wizard.GenTestMethodPage.java
License:Open Source License
/** * Implement method of IDialogPage to create UI of this wizard page *//* ww w.j a va2 s . c om*/ public void createControl(Composite aComposite) { initializeDialogUnits(aComposite); final Composite lComposite = new Composite(aComposite, SWT.NONE); { lComposite.setLayout(new GridLayout(1, false)); lComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(lComposite); iTreeViewer = new TreeViewer(lComposite, SWT.BORDER); // Content Provider iTreeViewer.setContentProvider(new ClassMethodContentProvider()); // Label Provider iTreeViewer.setLabelProvider(new ClassMethodLabelProvider()); // Filter iTreeViewer.addFilter(new ClassMethodViewerFilter()); // Selection Changed listener iTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { checkButtonState(); } }); iTreeViewer.setComparator(new ViewerComparator()); // Double Click Listener iTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); iSelectedItem = (NodeImpl) selection.getFirstElement(); if (iSelectedItem instanceof MethodNodeImpl) { iBtnEditMethod.notifyListeners(SWT.Selection, null); } } }); iTree = iTreeViewer.getTree(); iTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } final Composite lBtnComposite = new Composite(lComposite, SWT.NONE); { lBtnComposite.setLayout(new GridLayout(4, true)); lBtnComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Add Method Button iBtnAddMethod = new Button(lBtnComposite, SWT.PUSH); iBtnAddMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnAddMethod.setText(Messages.getString("GenTestMethodPage.AddMethod")); iBtnAddMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { try { MethodEditDialog dialog = new MethodEditDialog(lBtnComposite.getShell(), Messages.getString("MethodDialog.AddMethodTitle"), iClassNode); if (dialog.open()) { addMethod(dialog.getMethodItem().getName()); iTreeViewer.refresh(); } setPageComplete(isPageComplete()); } catch (Exception e) { IStatus lStatus = new Status(IStatus.WARNING, GenTestMethodPage.class.getName(), "Exception was thrown while adding method.", e); CodegenUIPlugin.getDefault().getLog().log(lStatus); } } }); // Edit Method Button iBtnEditMethod = new Button(lBtnComposite, SWT.PUSH); iBtnEditMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnEditMethod.setText(Messages.getString("GenTestMethodPage.EditMethod")); iBtnEditMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MethodNodeImpl item = (MethodNodeImpl) iSelectedItem; MethodEditDialog dialog = new MethodEditDialog(lBtnComposite.getShell(), Messages.getString("MethodDialog.EditMethodTitle"), item); if (dialog.open()) { iTreeViewer.update(item, null); } setPageComplete(isPageComplete()); } }); // Delete Method Button iBtnDeleteMethod = new Button(lBtnComposite, SWT.PUSH); iBtnDeleteMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnDeleteMethod.setText(Messages.getString("GenTestMethodPage.DeleteMethod")); iBtnDeleteMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MethodNodeImpl item = (MethodNodeImpl) iSelectedItem; boolean rlt = MessageDialog.openQuestion(lBtnComposite.getShell(), Messages.getString("GenTestMethodPage.ConfirmDelete"), Messages.getString("GenTestMethodPage.WhetherDeleteMethod", item.getName())); if (rlt) { ((ClassNodeImpl) item.getParent()).removeChild(item); iTreeViewer.remove(item); } setPageComplete(isPageComplete()); } }); // HeaderButton iHeaderButton = new Button(lBtnComposite, SWT.PUSH); iHeaderButton.setText(Messages.getString("GenTestMethodPage.BindMethod")); iHeaderButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iHeaderButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { iHeaderButton.setEnabled(false); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { iTargetProject = ((AbstractTemplateWizard) getWizard()).getTargetProject(); if (iTargetProject == null) { try { iTargetProject = ((AbstractTemplateWizard) getWizard()) .createTargetProject(monitor); } catch (CoreException e) { CodegenUIPlugin.getDefault().getLog().log(e.getStatus()); MessageDialog.openError(getShell(), "Exception was thrown while generating files", e.getMessage()); } } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while creating project.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); MessageDialog.openError(getShell(), "Exception was thrown while creating project.", e.getTargetException().getMessage()); } ISymbianSDK sdk = ((AbstractTemplateWizard) getWizard()).getDefaultSDK(); GenTestMethodDialog dialog = new GenTestMethodDialog(iHeaderButton.getShell(), iTargetProject, sdk); try { if (dialog.open()) { IPath includePath = new Path(dialog.getHeaderFilePath()); iClassNode.addIIncludeHeader(includePath.lastSegment()); includePath = includePath.removeLastSegments(1); int match = includePath.matchingFirstSegments(new Path(sdk.getEPOCROOT())); if (match > 0) { includePath = includePath.removeFirstSegments(match); } includePath = includePath.setDevice(null); iProjectNode.getSystemIncludes().add(includePath.toString()); iProjectNode.getLibrarys().add(dialog.getLib()); for (INode classNode : dialog.getHeaderNode().getChildren()) { for (INode methodNode : classNode.getChildren()) { if (((UIMethodNode) methodNode).isSelected()) { addMethod(classNode.getName() + "_" + methodNode.getName()); } } } iTreeViewer.refresh(); setPageComplete(isPageComplete()); } } catch (Exception e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while creating project.", e); CodegenUIPlugin.getDefault().getLog().log(lStatus); } finally { iHeaderButton.setEnabled(true); } } }); } }
From source file:com.nokia.tools.s60.editor.Series60EditorPart.java
License:Open Source License
public void showEditorInput(final IEditorInput editorInput, final boolean isNew) { if (!isNew && getEditorInput().equals(editorInput)) { return;//from ww w .j av a 2s .c om } try { new ProgressMonitorDialog(getSite().getShell()).run(!isNew, false, new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { beginProgressMonitorProgress(editorInput, monitor); final GraphicalViewer viewer = mediator.getViewer(editorInput, monitor); boolean refreshGallery = viewer != graphicalViewer; if (refreshGallery) { mediator.clearGalleryScreens(); } if (viewer == null) { try { mediator.initialize(editorInput, monitor); } catch (final Exception e) { processException(e); return; } setEditorInputWhileInProgressMonitor(editorInput); } monitor.worked(ScreenModelMediator.OTHER_WORK * 3 / 5); refreshElements(isNew, monitor, viewer); if (refreshGallery) { refreshGallery(); } } }); } catch (Exception e) { e.printStackTrace(); S60WorkspacePlugin.error(e); } }
From source file:com.nokia.tools.s60.editor.Series60EditorPart.java
License:Open Source License
protected void reloadContent() { try {/*from w w w .j a v a 2s . co m*/ new ProgressMonitorDialog(getSite().getShell()).run(false, false, new IRunnableWithProgress() { /* * (non-Javadoc) * * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask( MessageFormat.format(EditorMessages.Editor_ReloadTheme, getEditorInput().getName()), ScreenModelMediator.TOTAL_WORK); refreshEditor(false, monitor); refreshGallery(); monitor.done(); } }); } catch (Exception e) { S60WorkspacePlugin.error(e); } }
From source file:com.nokia.tools.s60.preferences.ExampleThemesPreferencePage.java
License:Open Source License
/** * /*w w w .ja v a 2 s .co m*/ */ public void widgetSelected(SelectionEvent e) { if (e.getSource() == btnAdd) { FileDialog fd = new FileDialog(new Shell(), SWT.SYSTEM_MODAL | SWT.OPEN); fd.setFilterExtensions(externalToolFilter); if (selImportTheme != "") { fd.setFileName(selImportTheme); } source = fd.open(); if (source != null) { final Map<String, String> details = getThemeDetails(); final String project = details.get(PRJ_NAME) == null ? null : details.get(PRJ_NAME); final String model = details.get(MODEL) == null ? null : details.get(MODEL); final String tdfPath = details.get(TDFPATH) == null ? null : details.get(TDFPATH); try { if (project != null) { // check for importing theme is exist already // if so error message dialog is shown final String path = themeFolderLocation + THEME_FOLDER; if (new File(path + project).mkdir()) { ProgressMonitorDialog dialog = new ProgressMonitorDialog( Display.getCurrent().getActiveShell()); dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask( NLS.bind(Messages.ExampleThemesPreferencePage_AddThemeMsg, project), IProgressMonitor.UNKNOWN); try { copyZipDirectory(source, new File(path + project)); // Writing into properties file String value = THEME_FOLDER + project + tdfPath; writeIntoFile(value, model, TYPE.Add); clearAndRefreshComponentPool(); Display.getDefault().syncExec(new Runnable() { public void run() { refreshTableViewer(); } }); } catch (Exception e) { e.printStackTrace(); } monitor.done(); } }); } else { MessageDialog.openError(null, Messages.ExampleThemesPreferencePage_ErrorNoteTitle, NLS.bind(Messages.ExampleThemesPreferencePage_ThemeAlreadyExist, project)); } } else { MessageDialog.openError(null, Messages.ExampleThemesPreferencePage_ErrorNoteTitle, Messages.ExampleThemesPreferencePage_NotValidZip); } } catch (Throwable e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } if (e.getSource() == btnRemove) { if (selectedBean != null) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(NLS.bind(Messages.ExampleThemesPreferencePage_RemoveThemeMsg, selectedBean.getName()), IProgressMonitor.UNKNOWN); String path = selectedBean.getPath() .substring(selectedBean.getPath().indexOf(File.separator) + 1); String toRemove = themeFolderLocation + THEME_FOLDER + selectedBean.getName(); toRemove = themeFolderLocation + THEME_FOLDER + path.substring(0, path.indexOf(File.separator)); writeIntoFile(selectedBean.getKey(), null, TYPE.Remove); deleteThemeDir(new File(toRemove)); clearAndRefreshComponentPool(); Display.getDefault().syncExec(new Runnable() { public void run() { refreshTableViewer(); // refresh buttons state if ((exampleThemesViewer.getTable().getItemCount()) == 0) btnRemove.setEnabled(false); } }); monitor.done(); } }); } catch (InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }
From source file:com.nokia.tools.s60.preferences.PluginHandlingPreferencePage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { if (e.getSource() == btnAdd) { PluginInstallationDialog pluginInstallationDialog = new PluginInstallationDialog(shell); if (Window.OK == pluginInstallationDialog.open()) { pluginViewer.refresh();//from w w w .j a va2s. c o m setSystemPluginsGrayed(); Bundle newEntry = pluginInstallationDialog.getBundle(); if (newEntry != null) { pluginViewer.setSelection(new StructuredSelection(newEntry), true); } } } if (e.getSource() == btnRemove) { ISelection selection = pluginViewer.getSelection(); if (selection instanceof IStructuredSelection) { Bundle bundle = (Bundle) ((IStructuredSelection) selection).getFirstElement(); IEditorReference[] editorsToClose = getEditorsToClose(bundle); StringBuilder sb = new StringBuilder(); for (int i = 0; i < editorsToClose.length; i++) { try { IEditorInput input = editorsToClose[i].getEditorInput(); String name; if (input instanceof IFileEditorInput) { name = ((IFileEditorInput) input).getFile().getProject().getName(); } else { name = input.getName(); } sb.append(name + ", "); } catch (Exception ex) { S60WorkspacePlugin.error(ex); } } if (sb.length() > 0) { sb.delete(sb.length() - 2, sb.length()); } if (MessageDialog.openConfirm(getShell(), Messages.PluginHandlingPreferencePage_Uninstall_Confirm_Title, sb.length() > 0 ? MessageFormat.format( Messages.PluginHandlingPreferencePage_Uninstall_Confirm_Message2, new Object[] { bundle.getSymbolicName(), sb.toString() }) : MessageFormat.format( Messages.PluginHandlingPreferencePage_Uninstall_Confirm_Message, new Object[] { bundle.getSymbolicName() }))) { for (IEditorReference ref : editorsToClose) { ref.getEditor(false).doSave(null); } try { new ProgressMonitorDialog(getShell()).run(true, false, new UninstallPluginOperation(bundle)); pluginViewer.refresh(); } catch (Exception ex) { MessageDialogWithTextContent.openError(getShell(), Messages.PluginHandlingPreferencePage_Uninstall_Error_Title, Messages.PluginHandlingPreferencePage_Uninstall_Error_Message, StringUtils.dumpThrowable(ex)); } if (editorsToClose.length > 0) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .closeEditors(editorsToClose, true); } } } } }
From source file:com.nokia.tools.s60.wizards.PluginInstallationDialog.java
License:Open Source License
@Override protected void okPressed() { try {//from w ww . j av a2s .c o m new ProgressMonitorDialog(getShell()).run(true, false, new InstallPluginOperation(new File(fileText.getText().trim()))); super.okPressed(); } catch (Exception e) { S60WorkspacePlugin.error(e); MessageDialogWithTextContent.openError(getShell(), WizardMessages.Plugin_Installation_Install_Error_Title, WizardMessages.Plugin_Installation_Install_Error_Message, StringUtils.dumpThrowable(e)); } }