List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
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);/*w w w. j a va 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 w w w .j a v a 2s.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;// w ww .ja v a 2 s.c o m 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.palantir.typescript.Builders.java
License:Apache License
/** * Prompts user to rebuild either the project or the whole workspace. * * @param shell/*from ww w . j a v a 2s. c om*/ * 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 w w w .ja v a 2 s.co m 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.persistent.winazureroles.WARComponents.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected component.//w ww. ja va2 s .c om */ protected void removeBtnListener() { int selIndex = tblViewer.getTable().getSelectionIndex(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); WindowsAzureRoleComponent component = listComponents.get(selIndex); if (selIndex > -1) { try { /* First condition: Checks component is part of a JDK, * server configuration * Second condition: For not showing error message * "Disable Server JDK Configuration" * while removing server application * when server or JDK is already disabled. */ if (component.getIsPreconfigured() && (!(component.getType().equals(Messages.typeSrvApp) && windowsAzureRole.getServerName() == null))) { PluginUtil.displayErrorDialog(getShell(), Messages.jdkDsblErrTtl, Messages.jdkDsblErrMsg); } else { boolean choice = MessageDialog.openQuestion(getShell(), Messages.cmpntRmvTtl, Messages.cmpntRmvMsg); if (choice) { String cmpntPath = String.format("%s%s%s%s%s", root.getProject(waProjManager.getProjectName()).getLocation(), File.separator, windowsAzureRole.getName(), Messages.approot, component.getDeployName()); File file = new File(cmpntPath); // Check import source is equal to approot if (component.getImportPath().isEmpty() && file.exists()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.cmpntSrcRmvTtl, null, Messages.cmpntSrcRmvMsg, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); switch (dialog.open()) { case 0: //yes component.delete(); tblViewer.refresh(); fileToDel.add(file); break; case 1: //no component.delete(); tblViewer.refresh(); break; case 2: //cancel break; default: break; } } else { component.delete(); tblViewer.refresh(); fileToDel.add(file); } } } if (tblComponents.getItemCount() == 0) { // table is empty i.e. number of rows = 0 btnRemove.setEnabled(false); btnEdit.setEnabled(false); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cmpntSetErrTtl, Messages.cmpntRmvErrMsg, e); } } updateMoveButtons(); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java
License:Open Source License
@Override protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell();/* w ww . j ava 2s.c om*/ final IEditorInput input = getEditorInput(); // Customize save as if the file is linked, and it is in the special external link project // if (input instanceof IFileEditorInput && ((IFileEditorInput) input).getFile().isLinked() && ((IFileEditorInput) input).getFile().getProject().getName() .equals(ExtLinkedFileHelper.AUTOLINK_PROJECT_NAME)) { final IEditorInput newInput; IDocumentProvider provider = getDocumentProvider(); // 1. If file is "untitled" suggest last save location // 2. ...otherwise use the file's location (i.e. likely to be a rename in same folder) // 3. If a "last save location" is unknown, use user's home // String suggestedName = null; String suggestedPath = null; { // is it "untitled" java.net.URI uri = ((IURIEditorInput) input).getURI(); String tmpProperty = null; try { tmpProperty = ((IFileEditorInput) input).getFile() .getPersistentProperty(TmpFileStoreEditorInput.UNTITLED_PROPERTY); } catch (CoreException e) { // ignore - tmpProperty will be null } boolean isUntitled = tmpProperty != null && "true".equals(tmpProperty); // suggested name IPath oldPath = URIUtil.toPath(uri); // TODO: input.getName() is probably always correct suggestedName = isUntitled ? input.getName() : oldPath.lastSegment(); // suggested path try { suggestedPath = isUntitled ? ((IFileEditorInput) input).getFile().getWorkspace().getRoot() .getPersistentProperty(LAST_SAVEAS_LOCATION) : oldPath.toOSString(); } catch (CoreException e) { // ignore, suggestedPath will be null } if (suggestedPath == null) { // get user.home suggestedPath = System.getProperty("user.home"); } } FileDialog dialog = new FileDialog(shell, SWT.SAVE); if (suggestedName != null) dialog.setFileName(suggestedName); if (suggestedPath != null) dialog.setFilterPath(suggestedPath); dialog.setFilterExtensions(new String[] { "*.pp", "*.*" }); String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null, path + " already exists.\nDo you want to replace it?", MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { EditorsPlugin.log(ex.getStatus()); String title = "Problems During Save As..."; String msg = "Save could not be completed. " + ex.getMessage(); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else { IURIEditorInput uriInput = new FileStoreEditorInput(fileStore); java.net.URI uri = uriInput.getURI(); IFile linkedFile = ExtLinkedFileHelper.obtainLink(uri, false); newInput = new FileEditorInput(linkedFile); } if (provider == null) { // editor has been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = "Problems During Save As..."; String msg = "Save could not be completed. " + x.getMessage(); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); // the linked file must be removed (esp. if it is an "untitled" link). ExtLinkedFileHelper.unlinkInput(((IFileEditorInput) input)); // remember last saveAs location String lastLocation = URIUtil.toPath(((FileEditorInput) newInput).getURI()).toOSString(); try { ((FileEditorInput) newInput).getFile().getWorkspace().getRoot() .setPersistentProperty(LAST_SAVEAS_LOCATION, lastLocation); } catch (CoreException e) { // ignore } } if (progressMonitor != null) progressMonitor.setCanceled(!success); return; } super.performSaveAs(progressMonitor); }
From source file:com.rcpcompany.uibindings.tests.application.ApplicationWorkbenchAdvisor.java
License:Open Source License
@Override public boolean preShutdown() { final IManager manager = IManager.Factory.getManager(); final EditingDomain editingDomain = manager.getEditingDomain(); int res = 1; // == NO if (editingDomain.getCommandStack().canUndo()) { final IWorkbenchWindow window = getWorkbenchConfigurer().getWorkbench().getActiveWorkbenchWindow(); final MessageDialog dialog = new MessageDialog(window.getShell(), "Save Shop?", null, "Changes has been made to the shop. Save these?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);//from w ww.java 2s.c om res = dialog.open(); if (res == 0) { final ICommandService cs = (ICommandService) window.getService(ICommandService.class); final IHandlerService hs = (IHandlerService) window.getService(IHandlerService.class); try { final String c = manager.getCommandIDs().get(IWorkbenchCommandConstants.FILE_SAVE); final ParameterizedCommand command = cs.deserialize(c); hs.executeCommand(command, null); } catch (final Exception ex) { LogUtils.error(this, ex); } } } return res != 2; }
From source file:com.redhat.ceylon.eclipse.code.preferences.CeylonBuildPathsBlock.java
License:Open Source License
public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) { return new IRemoveOldBinariesQuery() { public boolean doQuery(final boolean removeFolder, final IPath oldOutputLocation) throws OperationCanceledException { final int[] res = new int[] { 1 }; Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh = shell != null ? shell : JavaPlugin.getActiveWorkbenchShell(); String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message; String pathLabel = BasicElementLabels.getPathLabel(oldOutputLocation, false); if (removeFolder) { message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveOldOutputFolder_description, pathLabel); } else { message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, pathLabel); }//from ww w . j a v a2s . co m MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); res[0] = dialog.open(); } }); if (res[0] == 0) { return true; } else if (res[0] == 1) { return false; } throw new OperationCanceledException(); } }; }