List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL
String NO_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.
Click Source Link
From source file:com.nokia.s60tools.creator.job.ConfirmFileReplaceDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { GridLayout gdl = new GridLayout(1, false); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); parent.setLayout(gdl);//from w ww . j a v a2s .c o m parent.setLayoutData(gd); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); }
From source file:com.nokia.s60tools.hticonnection.ui.dialogs.ErrorDialogWithHelp.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // Creating Ok button. if ((style & SWT.OK) == SWT.OK) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false); okButton.addSelectionListener(this); PlatformUI.getWorkbench().getHelpSystem().setHelp(okButton, DEFAULT_CONTEXT_HELP); }/*ww w . j a va 2 s .c o m*/ // Creating Yes button if ((style & SWT.YES) == SWT.YES) { yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); yesButton.addSelectionListener(this); PlatformUI.getWorkbench().getHelpSystem().setHelp(yesButton, DEFAULT_CONTEXT_HELP); } //Creating No button if ((style & SWT.NO) == SWT.NO) { noButton = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); noButton.addSelectionListener(this); PlatformUI.getWorkbench().getHelpSystem().setHelp(noButton, DEFAULT_CONTEXT_HELP); } }
From source file:com.nokia.s60tools.remotecontrol.ui.dialogs.ConfirmDeleteDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { GridLayout gdl = new GridLayout(1, false); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); parent.setLayout(gdl);/*from w ww. j a v a2 s . c om*/ parent.setLayoutData(gd); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); }
From source file:com.nokia.s60tools.remotecontrol.ui.dialogs.ConfirmReplaceDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { GridLayout gdl = new GridLayout(1, false); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); parent.setLayout(gdl);/*w w w . j a v a 2s . c o m*/ parent.setLayoutData(gd); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); if (multiFile) { createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false); } createButton(parent, RENAME_ID, Messages.getString("ConfirmReplaceDialog.Rename_Button_Label"), false); //$NON-NLS-1$ createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:com.nokia.sdt.uidesigner.events.EventCommands.java
License:Open Source License
public static void navigateToHandlerCode(EventPage page, IEventBinding binding, boolean isNewBinding) { IEventDescriptor eventDescriptor = binding.getEventDescriptor(); IStatus status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); if (status != null) { if (!isNewBinding) { // Hmm, an error. It could be the data model was not saved. // It may just be a problem in the component's sourcegen, hence // the fallthrough to the descriptive error later. MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("EventCommands.Error"), null, //$NON-NLS-1$ Messages.getString("EventCommands.NoEventHandlerFound"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, //$NON-NLS-1$ //$NON-NLS-2$ 0);/*from w w w. ja v a2 s.c o m*/ int result = dialog.open(); if (result == MessageDialog.OK) { if (page.saveDataModel()) { status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); } } } if (status != null) { Logging.log(UIDesignerPlugin.getDefault(), status); } } }
From source file:com.nokia.tools.s60.views.ColorsViewPage.java
License:Open Source License
public void fillTable() { for (ColorQuadruple input : inputs) { if (!table.isDisposed()) { final Composite labelComp = new Composite(table, SWT.NONE); GridLayout gl = new GridLayout(); gl.marginWidth = gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0; labelComp.setLayout(gl);/*from ww w . j a va 2 s . c o m*/ GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; gd.horizontalSpan = 3; gd.verticalIndent = 5; labelComp.setLayoutData(gd); labelComp.setBackground(labelComp.getParent().getBackground()); final Text label = new Text(labelComp, SWT.NONE); label.setEditable(false); label.setData(input); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; gd.grabExcessVerticalSpace = true; label.setLayoutData(gd); label.setFont(ItalicFont); label.setText(input.getQuadrupleName()); label.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (e.button == 1) { label.setFont(null); label.setEditable(true); labelComp.setBackground(ColorConstants.white); } } }); label.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent e) { } public void mouseExit(MouseEvent e) { label.setFont(ItalicFont); label.setEditable(false); // this will call the focus lost event label.setEnabled(false); if (!label.isDisposed()) { label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); } } public void mouseHover(MouseEvent e) { } }); label.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) { ColorQuadruple quad = (ColorQuadruple) label.getData(); if (e.detail == SWT.TRAVERSE_ESCAPE) { label.setText(quad.getQuadrupleName()); } else if (e.detail == SWT.TRAVERSE_RETURN) { //the focus lost will happen // after this // if (!updateName(quad, label.getText())) { // label.setText(quad.getQuadrupleName()); // } } label.setFont(ItalicFont); label.setEditable(false); // this will call the focus lost event label.setEnabled(false); if (!label.isDisposed()) { label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); } } } }); label.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { label.setFont(ItalicFont); label.setEditable(false); label.setEnabled(false); label.setEnabled(true); labelComp.setBackground(labelComp.getParent().getBackground()); ColorQuadruple quad = (ColorQuadruple) label.getData(); if (!updateName(quad, label.getText())) { label.setText(quad.getQuadrupleName()); } } @Override public void focusGained(FocusEvent e) { label.setFont(null); label.setEditable(true); labelComp.setBackground(ColorConstants.white); } }); final Canvas quadrupleComposite = new Canvas(table, SWT.BORDER); quadrupleComposite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; gc.setBackground(ColorConstants.white); // gc.setBackgroundPattern(BG_PATTERN); gc.fillRectangle(0, 0, quadrupleComposite.getSize().x, quadrupleComposite.getSize().y); } }); gl = new GridLayout(4, false); gl.marginWidth = 2; gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0; quadrupleComposite.setLayout(gl); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; quadrupleComposite.setLayoutData(gd); Canvas q1 = new Canvas(quadrupleComposite, SWT.NONE); q1.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q1.setLayoutData(gd); q1.setBackground(q1.getParent().getBackground()); addPaintListener(0, q1); addDragSource(0, q1); addQuadrupleMouseListener(0, q1); createTooltip(0, q1); Canvas q2 = new Canvas(quadrupleComposite, SWT.NONE); q2.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; gd.horizontalIndent = 6; q2.setLayoutData(gd); q2.setBackground(q2.getParent().getBackground()); addPaintListener(1, q2); addDragSource(1, q2); addQuadrupleMouseListener(1, q2); createTooltip(1, q2); Canvas q3 = new Canvas(quadrupleComposite, SWT.NONE); q3.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q3.setLayoutData(gd); q3.setBackground(q3.getParent().getBackground()); addPaintListener(2, q3); addDragSource(2, q3); addQuadrupleMouseListener(2, q3); createTooltip(2, q3); Canvas q4 = new Canvas(quadrupleComposite, SWT.NONE); q4.setData(input); gd = new GridData(); gd.grabExcessVerticalSpace = true; gd.widthHint = QuadrupleColumnWidth; gd.heightHint = rowHeight; gd.verticalAlignment = SWT.CENTER; q4.setLayoutData(gd); q4.setBackground(q4.getParent().getBackground()); addPaintListener(3, q4); addDragSource(3, q4); addQuadrupleMouseListener(3, q4); createTooltip(3, q4); final Button b1 = new Button(table, SWT.FLAT); b1.setData(input); gd = new GridData(); gd.grabExcessHorizontalSpace = false; gd.heightHint = 20; gd.widthHint = 20; gd.verticalAlignment = SWT.CENTER; b1.setLayoutData(gd); b1.setBackground(b1.getParent().getBackground()); b1.setImage(CopyGroupImage); b1.setToolTipText("Copy Color Group as a new Group"); b1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class); Command cmd = new Command() { @Override public boolean canExecute() { return true; } @Override public boolean canUndo() { return false; } @Override public void execute() { ColorQuadruple quad = (ColorQuadruple) b1.getData(); ColorQuadruple newQuad = new ColorQuadruple("copy of " + quad.getQuadrupleName()); ColorGroups grps = getColorGroups(); int idx = 1; while (grps.getGroupByName(newQuad.getQuadrupleName()) != null) { idx++; newQuad = new ColorQuadruple( "copy (" + idx + ") of " + quad.getQuadrupleName()); } for (int i = 0; i < quad.getRgbList().size(); i++) { RGB rgb = quad.getRgbList().get(i); // (add group notifies this observer about // adding // group) if (i == 0) { if (grps.addGroup(newQuad.getQuadrupleName(), rgb) == true) { // newQuad.addRGB(rgb, false); // inputs.add(newQuad); } } else { String newName = newQuad.getQuadrupleName() + " tone" + i; if (grps.addGroup(newName, rgb) == true) { // newQuad.addRGB(rgb, false); ColorGroup added = grps.getGroupByName(newName); added.setParentGroupName(newQuad.getQuadrupleName()); } } } } }; if (stck != null) { stck.execute(cmd); } else { cmd.execute(); } } }); final Button b2 = new Button(table, SWT.FLAT); b2.setData(input); gd = new GridData(); gd.grabExcessHorizontalSpace = false; gd.heightHint = 20; gd.widthHint = 20; gd.verticalAlignment = SWT.CENTER; b2.setLayoutData(gd); b2.setBackground(b2.getParent().getBackground()); b2.setImage(DeleteGroupImage); b2.setToolTipText("Delete Color Group"); b2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class); Command cmd = new Command() { @Override public boolean canExecute() { return true; } @Override public boolean canUndo() { return false; } @Override public void execute() { ColorQuadruple quad = (ColorQuadruple) b2.getData(); IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), ViewMessages.RefColors_Delete_MsgBox_Title, image, MessageFormat.format(ViewMessages.RefColors_Delete_MsgBox_Message, new Object[] { quad.getQuadrupleName() }), 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); dialog.create(); image.dispose(); if (dialog.open() == 0) { inputs.remove(quad); ColorGroups grps = getColorGroups(); grps.removeGroup(quad.getQuadrupleName()); for (int i = 1; i <= 3; i++) { // (remove group notifies this observer // about group // removal grps.removeGroup(quad.getQuadrupleName() + " tone" + i); } } } }; if (stck != null) { stck.execute(cmd); } else { cmd.execute(); } } }); } } }
From source file:com.nokia.tools.screen.ui.actions.NewPackageAction.java
License:Open Source License
public void run() { final IEditorPart currentEditor = EclipseUtils.getActiveSafeEditor(); if (currentEditor == null) return;/*from w ww . j a v a 2 s . c o m*/ if (currentEditor.isDirty()) { boolean saveWithoutConfirm = false; IPreferenceStore store = UiPlugin.getDefault().getPreferenceStore(); saveWithoutConfirm = store.getBoolean(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK); if (!saveWithoutConfirm) { IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog messageDialog = new MessageDialogWithCheckBox( PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.NewPackageAction_Save_MsgBox_Title, image, Messages.NewPackageAction_Save_MsgBox_Message, Messages.NewPackageAction_Save_MsgBox_Confirmation_text, saveWithoutConfirm, null, null, null, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); messageDialog.open(); if (image != null) { image.dispose(); } store.setValue(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK, ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue()); if (messageDialog.getReturnCode() != 0) return; } try { new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).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 { currentEditor.doSave(monitor); } }); } catch (Exception e) { UiPlugin.error(e); } performPackaging(); } else performPackaging(); }
From source file:com.nokia.tools.screen.ui.dialogs.MessageDialogWithCheckBox.java
License:Open Source License
/** * Convenience method to open a customized messagebox with normal message * and optionally any compinations of message with a link to preferences, * checkbox with text and access to help system via Help -button. * // w w w. ja v a 2 s. c o m * @param parent the parent shell of the dialog, or <code>null</code> if * none * @param title the dialog's title, or <code>null</code> if none * @param message the message * @param chkButtonMessage the message for the checkbox, or * <code>null</code> if none * @param chkButtonState the initial state for the checkbox * @param helpID help ID, or <code>null</code> if none * @param linkMessage the message including a link, or <code>null</code> * if none * @param linkAddress the preference address for the link, or * <code>null</code> if none * @return <code>true</code> if the user presses the OK button, * <code>false</code> otherwise */ public static boolean openQuestion(Shell parent, String title, String message, String chkButtonMessage, boolean chkButtonState, String helpID, String linkMessage, String linkAddress) { MessageDialog dialog = new MessageDialogWithCheckBox(parent, title, null, message, chkButtonMessage, chkButtonState, helpID, linkMessage, linkAddress, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return dialog.open() == 0; }
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. j a v a 2 s . c om*/ 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 w w w . j a v a2 s . co 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); }