List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:com.nokia.tools.screen.ui.wizards.AbstractPackagingOperation.java
License:Open Source License
public void run(IProgressMonitor parentMonitor) throws InvocationTargetException, InterruptedException { SubProgressMonitor childMonitor;//from w ww.j a v a2 s .c om String progressString = "Packaging theme..."; String subProgressString = ""; File workingDir; IFolder folder = null, folderTemp = null; String dir = UiPlugin.getDefault().getPreferenceStore().getString(IScreenConstants.PREF_PACKAGING_DIR); parentMonitor.beginTask(progressString, IProgressMonitor.UNKNOWN); //parentMonitor.worked(INCREMENT); parentMonitor.subTask(subProgressString); childMonitor = new SubProgressMonitor(parentMonitor, IProgressMonitor.UNKNOWN); if (dir == null || !IScreenConstants.PACKAGING_DIR_PROJECT.equalsIgnoreCase(dir)) { workingDir = new File(System.getProperty("java.io.tmpdir") + File.separator + project.getName() + "_" + IScreenConstants.PACKAGING_DIR_NAME); if (workingDir.isFile()) { workingDir.delete(); } workingDir.mkdirs(); File[] files = workingDir.listFiles(); if (files != null) { for (File file : files) { file.delete(); } } } else { folder = project.getFolder(IScreenConstants.PACKAGING_DIR_NAME); folderTemp = project.getFolder(IScreenConstants.PACKAGING_DIR_NAME + "_temp"); if (!folder.exists()) { try { folder.create(true, true, childMonitor); } catch (Exception e) { UiPlugin.error(e); } } try { folderTemp.delete(true, false, childMonitor); } catch (CoreException e1) { UiPlugin.error(e1); } if (!folderTemp.exists()) { try { folderTemp.create(true, true, childMonitor); } catch (Exception e) { UiPlugin.error(e); } } workingDir = folderTemp.getLocation().toFile(); } parentMonitor.subTask(subProgressString); childMonitor = new SubProgressMonitor(parentMonitor, IProgressMonitor.UNKNOWN); context.setAttribute(PackagingAttribute.workingDir.name(), workingDir.getAbsolutePath()); try { doPackaging(childMonitor); if (folder != null && folderTemp != null) { try { folder.delete(true, false, null); } catch (Exception e) { showErrorMessage(); UiPlugin.error(e); return; } try { folderTemp.move(folder.getProjectRelativePath(), true, false, null); } catch (Exception e) { UiPlugin.error(e); } } PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { /* * (non-Javadoc) * * @see java.lang.Runnable#run() */ public void run() { try { IPreferenceStore store = UiPlugin.getDefault().getPreferenceStore(); String file = (String) context.getAttribute(PackagingAttribute.sisFile.name()); if (file == null) { file = (String) context.getAttribute(PackagingAttribute.output.name()); } IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } String message = MessageFormat.format( WizardMessages.New_Package_Package_Created_Description, new Object[] { file }); String[] dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.New_Package_Package_Created_Title, image, message, 2, dialogButtonLabels, 0); dialog.open(); if (image != null) { image.dispose(); } } catch (Exception e) { UiPlugin.error(e); } } }); parentMonitor.subTask(subProgressString); childMonitor = new SubProgressMonitor(parentMonitor, IProgressMonitor.UNKNOWN); // cleans up the temporary folder only when the packaging is // successful, so we could examine more easily what is wrong. if (folderTemp != null) { try { folderTemp.delete(true, false, childMonitor); } catch (final CoreException e) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.New_Package_Package_Creation_Error_Title, WizardMessages.New_Package_Package_Deleting_Temp_Folder_Problem); } }); } } else { FileUtils.deleteDirectory(workingDir); } } catch (final Exception e) { UiPlugin.error(e); String sisTempFile = (String) context.getAttribute(PackagingAttribute.sisTempFile.name()); if (sisTempFile != null) { // removes the sis temporary file in case signing failed new File(sisTempFile).delete(); } PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialogWithTextContent.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.New_Package_Package_Creation_Error_Title, MessageFormat.format(WizardMessages.New_Package_Package_Creation_Error_Description, new Object[] { e.getMessage() }), e instanceof PackagingException ? ((PackagingException) e).getDetails() : StringUtils.dumpThrowable(e)); } }); } finally { parentMonitor.setTaskName(""); parentMonitor.subTask(subProgressString); childMonitor = new SubProgressMonitor(parentMonitor, IProgressMonitor.UNKNOWN); childMonitor.done(); parentMonitor.done(); try { project.refreshLocal(IProject.DEPTH_INFINITE, childMonitor); } catch (Exception e) { UiPlugin.error(e); } } }
From source file:com.nokia.tools.theme.s60.ui.dialogs.KeyPairsDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), KeyPairsDialog.KEY_PAIRS_DIALOG_CONTEXT); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayoutData(new GridData(GridData.FILL_BOTH)); setTitle(WizardMessages.Key_Pairs_Banner_Title); setMessage(WizardMessages.Key_Pairs_Banner_Message); GridLayout layout = new GridLayout(); container.setLayout(layout);// ww w. ja v a 2 s .co m layout.numColumns = 5; layout.marginHeight = 13; layout.marginWidth = 13; layout.verticalSpacing = 7; lblKeyPairs = new Label(container, SWT.NONE); lblKeyPairs.setText(WizardMessages.Key_Pairs_lblKeyPairs_Text); GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.verticalSpan = 2; lblKeyPairs.setLayoutData(gd); lstKeyPairs = new List(container, SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 3; gd.verticalSpan = 2; gd.widthHint = 280; gd.heightHint = 77; lstKeyPairs.setLayoutData(gd); lstKeyPairs.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (lstKeyPairs.getSelectionIndex() != -1) { strSelKeyPair = lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex()); updateKeyPairContent(strSelKeyPair); updateStates(); } } }); btnEdit = new Button(container, SWT.NONE); initializeDialogUnits(btnEdit); setButtonLayoutData(btnEdit); btnEdit.setText(WizardMessages.Key_Pairs_btnEdit_Text); gd = new GridData(SWT.FILL, SWT.TOP, false, false); btnEdit.setLayoutData(gd); btnEdit.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { strSelKeyPair = lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex()); contentChanged = false; dialogMode = 3; updateStates(); txtKeyPairName.setFocus(); } public void widgetDefaultSelected(SelectionEvent e) { } }); btnDelete = new Button(container, SWT.NONE); initializeDialogUnits(btnDelete); setButtonLayoutData(btnDelete); btnDelete.setText(WizardMessages.Key_Pairs_btnDelete_Text); gd = new GridData(SWT.FILL, SWT.TOP, false, false); btnDelete.setLayoutData(gd); btnDelete.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.Key_Pairs_Delete_MsgBox_Title, image, WizardMessages.Key_Pairs_Delete_MsgBox_Message, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == 0) { int index = lstKeyPairs.getSelectionIndex(); strSelKeyPair = lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex()); deleteKeyPair(index, strSelKeyPair); updateKeyPairList(); dialogMode = 1; if (lstKeyPairs.getItemCount() > 0) { lstKeyPairs.select(0); updateKeyPairContent(lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex())); updateStates(); } else { clearTextBoxes(); } dialogChanged(); } if (image != null) { image.dispose(); } } public void widgetDefaultSelected(SelectionEvent e) { } }); final Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 5; separator.setLayoutData(gd); lblKeyPairName = new Label(container, SWT.NONE); lblKeyPairName.setText(WizardMessages.Key_Pairs_lblKeyPairName_Text); txtKeyPairName = new Text(container, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; gd.widthHint = 280; txtKeyPairName.setLayoutData(gd); txtKeyPairName.setTextLimit(TEXT_LIMIT); txtKeyPairName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { strPairName = txtKeyPairName.getText().trim(); if (dialogMode == 3) contentChanged = true; dialogChanged(); } }); // Dummy label to fill a column new Label(container, SWT.NONE); lblPublicKeyFile = new Label(container, SWT.NONE); lblPublicKeyFile.setText(WizardMessages.Key_Pairs_lblPublicKeyFile_Text); txtPrivateKeyFile = new Text(container, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 282; gd.horizontalSpan = 3; txtPrivateKeyFile.setLayoutData(gd); txtPrivateKeyFile.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { strSelKey = txtPrivateKeyFile.getText(); if (dialogMode == 3) contentChanged = true; dialogChanged(); } }); shell = this.getShell(); class OpenKey implements SelectionListener { public void widgetSelected(SelectionEvent event) { FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); fileDialog.setText(WizardMessages.Key_Pairs_keyFileDialog_Title); fileDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); fileDialog.setFilterExtensions(keyFilterExt); if (strSelKey != "") fileDialog.setFileName(strSelKey); if (fileDialog.open() != null) { String separator = ""; int length = fileDialog.getFilterPath().trim().length(); if (length > 0 && fileDialog.getFilterPath().charAt(length - 1) != File.separatorChar) separator = File.separator; strSelKey = new Path(fileDialog.getFilterPath() + separator + fileDialog.getFileName()) .toOSString(); txtPrivateKeyFile.setText(strSelKey); } txtPrivateKeyFile.setFocus(); } public void widgetDefaultSelected(SelectionEvent event) { } } btnKeyBrowse = new Button(container, SWT.NONE); initializeDialogUnits(btnKeyBrowse); setButtonLayoutData(btnKeyBrowse); btnKeyBrowse.setText(WizardMessages.Key_Pairs_btnKeyBrowse_Text); btnKeyBrowse.addSelectionListener(new OpenKey()); lblCerFile = new Label(container, SWT.NONE); lblCerFile.setText(WizardMessages.Key_Pairs_lblCerFile_Text); txtCerFile = new Text(container, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 280; gd.horizontalSpan = 3; txtCerFile.setLayoutData(gd); txtCerFile.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { strSelCer = txtCerFile.getText(); if (dialogMode == 3) contentChanged = true; dialogChanged(); } }); class OpenCer implements SelectionListener { public void widgetSelected(SelectionEvent event) { FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); fileDialog.setText(WizardMessages.Key_Pairs_cerFileDialog_Title); fileDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); fileDialog.setFilterExtensions(cerFilterExt); if (strSelCer != "") fileDialog.setFileName(strSelCer); if (fileDialog.open() != null) { String separator = ""; int length = fileDialog.getFilterPath().length(); if (length > 0 && fileDialog.getFilterPath().charAt(length - 1) != File.separatorChar) separator = File.separator; strSelCer = new Path(fileDialog.getFilterPath() + separator + fileDialog.getFileName()) .toOSString(); txtCerFile.setText(strSelCer); } txtCerFile.setFocus(); } public void widgetDefaultSelected(SelectionEvent event) { } } btnCerBrowse = new Button(container, SWT.NONE); initializeDialogUnits(btnCerBrowse); setButtonLayoutData(btnCerBrowse); btnCerBrowse.setText(WizardMessages.Key_Pairs_btnCerBrowse_Text); btnCerBrowse.addSelectionListener(new OpenCer()); lblPassword = new Label(container, SWT.NONE); lblPassword.setText(WizardMessages.Key_Pairs_lblPassword_Text); txtPassword = new Text(container, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; txtPassword.setLayoutData(gd); txtPassword.setEchoChar('*'); txtPassword.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { strPassword = txtPassword.getText(); if (dialogMode == 3) contentChanged = true; dialogChanged(); } }); warningContainer = new Composite(container, SWT.NONE); layout = new GridLayout(); warningContainer.setLayout(layout); gd = new GridData(SWT.RIGHT, SWT.TOP, false, false); gd.verticalSpan = 2; warningContainer.setLayoutData(gd); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; warningContainer.setVisible(false); warningImage = ISharedImageDescriptor.ICON16_WARNING.createImage(); infoImage = ISharedImageDescriptor.ICON16_INFO.createImage(); Label lblInfo2Image = new Label(warningContainer, SWT.NONE); gd = new GridData(SWT.RIGHT, SWT.TOP, false, false); lblInfo2Image.setLayoutData(gd); lblInfo2Image.setImage(warningImage); Label lblInfo2Text = new Label(warningContainer, SWT.WRAP); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 150; lblInfo2Text.setLayoutData(gd); lblInfo2Text.setText(WizardMessages.Key_Pairs_lblInfo2Text_Text); // Dummy labels to fill columns new Label(container, SWT.NONE); new Label(container, SWT.NONE); chkSavePassword = new Button(container, SWT.CHECK); chkSavePassword.setText(WizardMessages.Key_Pairs_chkSavePassword_Text); chkSavePassword.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (dialogMode == 3) { contentChanged = true; } dialogChanged(); } public void widgetDefaultSelected(SelectionEvent e) { } }); // Dummy label to fill a column Label label4 = new Label(container, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); label4.setLayoutData(gd); // Dummy label to fill a column new Label(container, SWT.NONE); lblSavePasswordInfoImage = new Label(container, SWT.NONE); gd = new GridData(SWT.RIGHT, SWT.TOP, false, false); lblSavePasswordInfoImage.setLayoutData(gd); lblSavePasswordInfoImage.setImage(warningImage); lblSavePasswordInfo = new Label(container, SWT.WRAP); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 300; gd.horizontalSpan = 3; lblSavePasswordInfo.setLayoutData(gd); lblSavePasswordInfo.setText(WizardMessages.Key_Pairs_chkSavePasswordWarning_Text); // Dummy label to fill a column new Label(container, SWT.NONE); Composite container2 = new Composite(container, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 5; gd.verticalIndent = 5; container2.setLayoutData(gd); GridLayout layout2 = new GridLayout(); container2.setLayout(layout2); layout2.numColumns = 5; layout2.marginHeight = 0; layout2.marginWidth = 0; layout2.verticalSpacing = 7; // Dummy label to fill a column Label label5 = new Label(container2, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); label5.setLayoutData(gd); btnNew = new Button(container2, SWT.NONE); initializeDialogUnits(btnNew); setButtonLayoutData(btnNew); btnNew.setText(WizardMessages.Key_Pairs_btnNew_Text); btnNew.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { clearTextBoxes(); dialogMode = 2; updateStates(); txtKeyPairName.setFocus(); } public void widgetDefaultSelected(SelectionEvent e) { } }); btnKeys = new Button(container2, SWT.NONE); initializeDialogUnits(btnKeys); setButtonLayoutData(btnKeys); btnKeys.setText(WizardMessages.Key_Pairs_btnKeys_Text); btnKeys.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { MakeKeysDialog makeKeysDialog = new MakeKeysDialog(getShell()); makeKeysDialog.create(); makeKeysDialog.open(); if (makeKeysDialog.getReturnCode() == 0) { strSelKey = makeKeysDialog.getKeyDestination(); txtPrivateKeyFile.setText(strSelKey); strSelCer = makeKeysDialog.getCerDestination(); txtCerFile.setText(strSelCer); strPassword = makeKeysDialog.getPassword(); if (strPassword.equals("")) { txtPassword.setText(""); txtPassword.setEnabled(false); } else txtPassword.setText(strPassword); if (dialogMode == 3) contentChanged = true; dialogChanged(); } } public void widgetDefaultSelected(SelectionEvent e) { } }); btnSave = new Button(container2, SWT.NONE); initializeDialogUnits(btnSave); setButtonLayoutData(btnSave); btnSave.setText(WizardMessages.Key_Pairs_btnSave_Text); btnSave.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { // Case creating a new key pair if (dialogMode == 2) { shell.setEnabled(false); shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); txtKeyPairName.setText(strPairName); if (validateKeyPairContent(strSelKey, strSelCer, strPassword)) { saveKeyPair(strPairName, strSelKey, strSelCer, strPassword); updateKeyPairList(); dialogMode = 1; shell.setEnabled(true); shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); lstKeyPairs.select(lstKeyPairs.indexOf(strPairName)); dialogChanged(); // if (chkSavePassword.getSelection() != true) // txtPassword.setText(""); return; } shell.setEnabled(true); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW)); IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.Key_Pairs_Generate_MsgBox_Error_Title, image, WizardMessages.Key_Pairs_Generate_MsgBox_Error_Message, 1, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); if (image != null) { image.dispose(); } } // saving an existing key pair if (dialogMode == 3) { shell.setEnabled(false); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT)); txtKeyPairName.setText(strPairName); if (validateKeyPairContent(strSelKey, strSelCer, strPassword)) { int index = lstKeyPairs.getSelectionIndex(); strSelKeyPair = lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex()); deleteKeyPair(index, strSelKeyPair); updateKeyPairList(); saveKeyPair(strPairName, strSelKey, strSelCer, strPassword); updateKeyPairList(); dialogMode = 1; shell.setEnabled(true); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW)); lstKeyPairs.select(lstKeyPairs.indexOf(strPairName)); dialogChanged(); // if (chkSavePassword.getSelection() != true) // txtPassword.setText(""); return; } shell.setEnabled(true); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW)); IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.Key_Pairs_Save_MsgBox_Error_Title, image, WizardMessages.Key_Pairs_Save_MsgBox_Error_Message, 1, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); if (image != null) { image.dispose(); } } } public void widgetDefaultSelected(SelectionEvent e) { } }); btnCancel = new Button(container2, SWT.NONE); initializeDialogUnits(btnCancel); setButtonLayoutData(btnCancel); btnCancel.setText(WizardMessages.Key_Pairs_btnCancel_Text); btnCancel.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (dialogMode == 2) { if (lstKeyPairs.getSelectionIndex() != -1) { strSelKeyPair = lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex()); updateKeyPairContent(strSelKeyPair); } else if (lstKeyPairs.getItemCount() > 0) { lstKeyPairs.select(0); updateKeyPairContent(lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex())); } else clearTextBoxes(); } else updateKeyPairContent(lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex())); dialogMode = 1; dialogChanged(); } public void widgetDefaultSelected(SelectionEvent e) { } }); Composite container3 = new Composite(area, SWT.NONE); container3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout3 = new GridLayout(); container3.setLayout(layout3); layout3.numColumns = 1; layout3.marginHeight = 0; layout3.marginWidth = 0; layout3.verticalSpacing = 0; final Label separator2 = new Label(container3, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL); separator2.setLayoutData(gd); updateKeyPairList(); if (lstKeyPairs.getItemCount() > 0) { updateKeyPairContent(lstKeyPairs.getItem(lstKeyPairs.getSelectionIndex())); } updateStates(); return area; }
From source file:com.nokia.tools.theme.s60.ui.dialogs.MakeKeysDialog.java
License:Open Source License
protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { File cerFile = new File(strCerDestination); if (cerFile.exists()) { IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null;/*from ww w. jav a 2 s .c o m*/ if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), WizardMessages.Make_Keys_CerFile_Exist_MsgBox_Title, image, WizardMessages.Make_Keys_CerFile_Exist_MsgBox_Message, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int ret = dialog.open(); if (image != null) { image.dispose(); } if (ret != Window.OK) { return; } } shell.setEnabled(false); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT)); try { generateKeyPair(); } catch (Exception e) { shell.setEnabled(true); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW)); String message = null; if (e instanceof PackagingException) { message = ((PackagingException) e).getDetails(); if (message != null) { MessageDialogWithTextContent.openError(getShell(), WizardMessages.Key_Pairs_Generate_Error_Title, WizardMessages.Key_Pairs_Generate_Error_Message, message); } } if (message == null) { MessageDialog.openError(getShell(), WizardMessages.Key_Pairs_Generate_Error_Title, e.getMessage()); } return; } shell.setEnabled(true); shell.setCursor(new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW)); } if (buttonId == IDialogConstants.CANCEL_ID) { setMessage(null); this.close(); } super.buttonPressed(buttonId); }
From source file:com.nokia.tools.theme.s60.ui.wizards.NewPackagePage2.java
License:Open Source License
public boolean performFinish() { File file = new File(selDestination); IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null;/*www . j a va2s .c om*/ if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } // Check for password in keypairs KeyPair[] keyPairs = null; try { keyPairs = KeyPair.getKeyPairs(); } catch (PackagingException e1) { e1.printStackTrace(); } if (btnNoSign.getSelection() == false) { if (keyPairs.length > 0) { if (keyPairs[cboKeyPairs.getSelectionIndex()].getPassword() != null && !("".equals(keyPairs[cboKeyPairs.getSelectionIndex()].getPassword().equals("")))) { if (txtPassword != null && !(keyPairs[cboKeyPairs.getSelectionIndex()].getPassword() .equals(txtPassword.getText()))) { MessageDialog dialog1 = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Mismatch_Password_Error_Message_Title, image, com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Mismatch_Password_Error_Message, 1, new String[] { IDialogConstants.OK_LABEL }, 0); getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW)); dialog1.open(); if (image != null) { image.dispose(); } return false; } } } } // End key pairs password checks. if (file.exists()) { MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Package_Exist_MsgBox_Title, image, com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Package_Exist_MsgBox_Message, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int ret = dialog.open(); if (image != null) { image.dispose(); } if (ret != Window.OK) { return false; } } if (txtPassword != null) { getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); String cerFile = (String) context.getAttribute(PackagingAttribute.certificateFile.name()); String keyFile = (String) context.getAttribute(PackagingAttribute.privateKeyFile.name()); String password = (String) context.getAttribute(PackagingAttribute.passphrase.name()); try { SymbianUtil.testKey(cerFile, keyFile, password, context); } catch (Exception e) { Activator.error(e); IBrandingManager branding1 = BrandingExtensionManager.getBrandingManager(); Image image1 = null; if (branding1 != null) { image1 = branding1.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Create_MsgBox_Error_Title, image1, com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Create_MsgBox_Error_Message, 1, new String[] { IDialogConstants.OK_LABEL }, 0); getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW)); dialog.open(); if (image1 != null) { image1.dispose(); } return false; } getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW)); } return true; }
From source file:com.nokia.tools.variant.resourcelibrary.handlers.commands.ImportCommand.java
License:Open Source License
public static boolean openCheckDialog(FileSystemElement existing) { MessageDialog dialog = new MessageDialog(SWTUtil.getStandardDisplay().getActiveShell(), "Replace existing resource", null, "Replace existing resource " + existing.getName() + "?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return dialog.open() == 0 ? true : false; }
From source file:com.nokia.tracebuilder.view.TraceViewDialogs.java
License:Open Source License
/** * Shows a query dialog, where the buttons have been defined by client * /*from www. j a v a2 s.co m*/ * @param parameters * the dialog parameters * @param shell * the parent shell * @return the index of the selected button */ private int showExtendedQueryDialog(QueryDialogParameters parameters, Shell shell) { MessageDialog md = new MessageDialog(shell, Messages.getString("TraceView.TraceBuilder"), //$NON-NLS-1$ null, ((ExtendedQueryParameters) parameters).message, MessageDialog.QUESTION, ((ExtendedQueryParameters) parameters).buttonTitles, 0); // Returns the index of the button defined in extended query parameters return md.open(); }
From source file:com.palantir.typescript.Builders.java
License:Apache License
/** * Prompts user to rebuild either the project or the whole workspace. * * @param shell//from www .ja va 2 s .c o m * parent shell * @param onlyProject * the project to be rebuilt or null if the whole workpsace has to be rebuilt * @return true if user accepted the recompilation */ public static boolean promptRecompile(Shell shell, IProject onlyProject) { String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title"); String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL }; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels, 2); int result = dialog.open(); boolean process = false; if (result != 1) { // cancel process = true; // rebuild the workspace if (result == 2) { if (onlyProject != null) { Builders.rebuildProject(onlyProject); } else { Builders.rebuildWorkspace(); } } } return process; }
From source file:com.palantir.typescript.CompilerPreferencePage.java
License:Apache License
@Override public boolean performOk() { final boolean process; // offer to rebuild the workspace if the compiler preferences were modified if (this.compilerPreferencesModified) { String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title"); String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL }; MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 2);//from www .ja v a 2 s. com int result = dialog.open(); if (result == 1) { // cancel process = false; } else { // yes/no process = super.performOk(); // rebuild the workspace if (result == 2) { String name = Resources.BUNDLE.getString("preferences.compiler.rebuild.job.name"); Job job = new Job(name) { @Override protected IStatus run(IProgressMonitor monitor) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); job.schedule(); } } this.compilerPreferencesModified = false; } else { process = super.performOk(); } return process; }
From source file:com.palantir.typescript.preferences.BuildPathPropertyPage.java
License:Apache License
private Button createUseTsConfigField(final Composite composite) { Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(GridData.BEGINNING, SWT.CENTER, false, false)); label.setText("Use tsconfig"); final Button button = new Button(composite, SWT.CHECK); button.setLayoutData(new GridData(GridData.BEGINNING, SWT.CENTER, false, false)); button.addListener(SWT.Selection, new Listener() { @Override/*from w ww .j a v a2 s. co m*/ public void handleEvent(Event e) { projectPreferenceStore.setUsingTsConfigFile(button.getSelection()); if (button.getSelection()) { Builders.promptRecompile(getShell(), getProject()); } updateFieldStates(); updateFieldValues(); } }); button.setSelection(projectPreferenceStore.isUsingTsConfigFile()); Button forceReloadButton = new Button(composite, SWT.NONE); forceReloadButton.setLayoutData(new GridData(GridData.CENTER, SWT.CENTER, false, false)); forceReloadButton.setText("Force reload"); forceReloadButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { boolean loaded = projectPreferenceStore.getTsConfigPreferences().reloadTsConfigFile(); if (!loaded) { String title = Resources.BUNDLE.getString("title.error"); String message = Resources.BUNDLE.getString("preferences.tsconfig.loadError"); String[] buttonLabels = new String[] { IDialogConstants.OK_LABEL }; MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, buttonLabels, 1); dialog.open(); return; } projectPreferenceStore.setUsingTsConfigFile(true); Builders.promptRecompile(getShell(), getProject()); updateFieldStates(); updateFieldValues(); } }); return button; }
From source file:com.palantir.typescript.preferences.GeneralPreferencePage.java
License:Apache License
@Override public boolean performOk() { String oldNodePath = this.getPreferenceStore().getString(IPreferenceConstants.GENERAL_NODE_PATH); String newNodePath = this.nodePathText.getText(); if (!oldNodePath.equals(newNodePath)) { String title = Resources.BUNDLE.getString("preferences.general.node.path.dialog.title"); String message = Resources.BUNDLE.getString("preferences.general.node.path.dialog.message"); String[] buttonLabels = new String[] { IDialogConstants.OK_LABEL }; MessageDialog dialog = new MessageDialog(this.getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 2);// w w w.jav a 2 s. co m dialog.open(); this.getPreferenceStore().setValue(IPreferenceConstants.GENERAL_NODE_PATH, newNodePath); } return true; }