List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID
int CANCEL_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.
Click Source Link
From source file:com.safi.workshop.sqlexplorer.plugin.editors.SQLEditor.java
License:Open Source License
/** * Implementation for save-as; returns true if successfull, false if not (i.e. the user * cancelled the dialog)// w w w .j ava 2 s .co m * * @return true if saved, false if cancelled */ public boolean doSave(boolean saveAs, IProgressMonitor monitor) { IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); boolean haveProjects = projects != null && projects.length > 0; IEditorInput input = getEditorInput(); boolean saveInsideProject = true; File file = null; if (input instanceof SQLEditorInput) { SQLEditorInput seInput = (SQLEditorInput) input; file = seInput.getFile(); } // If we have a file, then we already have a filename outside of the project; // but if we're doing a save-as then recheck with the user if (file != null && !saveAs) saveInsideProject = false; // Either we're doing a save on a file outside a project or we're doing a save-as else if (input instanceof SQLEditorInput) { IConstants.Confirm confirm = SQLExplorerPlugin.getConfirm(IConstants.CONFIRM_YNA_SAVING_INSIDE_PROJECT); // If we're supposed to ask the user... if (confirm == IConstants.Confirm.ASK) { // Build up the message to ask String msg = Messages.getString("Confirm.SaveInsideProject.Intro") + "\n\n"; if (!haveProjects) msg = msg + Messages.getString("Confirm.SaveInsideProject.NoProjectsConfigured") + "\n\n"; msg = msg + Messages.getString("Confirm.SaveInsideProject.SaveInProject"); // Ask them MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion( getSite().getShell(), Messages.getString("SQLEditor.SaveAsDialog.Title"), msg, Messages.getString("Confirm.SaveInsideProject.Toggle"), false, null, null); if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) return false; // If they turned on the toggle ("Use this answer in the future"), update the // preferences if (dialog.getToggleState()) { confirm = dialog.getReturnCode() == IDialogConstants.YES_ID ? IConstants.Confirm.YES : IConstants.Confirm.NO; SQLExplorerPlugin.getDefault().getPreferenceStore() .setValue(IConstants.CONFIRM_YNA_SAVING_INSIDE_PROJECT, confirm.toString()); } // Whether to save inside or outside saveInsideProject = dialog.getReturnCode() == IDialogConstants.YES_ID; } else saveInsideProject = confirm == IConstants.Confirm.YES; } // Saving inside a project - convert SQLEditorInput into a Resource by letting // TextEditor do the work for us if (saveInsideProject) { if (!haveProjects) { MessageDialog.openError(getSite().getShell(), Messages.getString("Confirm.SaveInsideProject.Title"), Messages.getString("Confirm.SaveInsideProject.CreateAProject")); return false; } if (input instanceof SQLEditorInput) saveAs = true; // Save it and use their EditorInput if (saveAs) textEditor.doSaveAs(); else { if (monitor == null) monitor = textEditor.getProgressMonitor(); textEditor.doSave(monitor); } if (input.equals(textEditor.getEditorInput())) return false; input = textEditor.getEditorInput(); setInput(input); // Update the display setPartName(input.getName()); setTitleToolTip(input.getToolTipText()); } else { try { if (file == null || saveAs) { FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SAVE); dialog.setText(Messages.getString("SQLEditor.SaveAsDialog.Title")); dialog.setFilterExtensions(SUPPORTED_FILETYPES); dialog.setFilterNames(SUPPORTED_FILETYPES); dialog.setFileName("*.sql"); String path = dialog.open(); if (path == null) return false; file = new File(path); } // Save it saveToFile(file); // Update the editor input input = new SQLEditorInput(file); setInput(input); setPartName(input.getName()); setTitleToolTip(input.getToolTipText()); } catch (IOException e) { SQLExplorerPlugin.error("Couldn't save sql", e); MessageDialog.openError(getSite().getShell(), Messages.getString("SQLEditor.SaveAsDialog.Error"), e.getMessage()); return false; } } setIsDirty(textEditor.isDirty()); return true; }
From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java
License:Open Source License
public int cancelMessage(String title, String message, int severity) { MessageDialog dialog = new MessageDialog(getShell(), title, null, message, severity, new String[] { IDialogConstants.CANCEL_LABEL }, IDialogConstants.CANCEL_ID); return dialog.open(); }
From source file:com.schmeedy.relaxng.eclipse.ui.internal.preferences.EditRngSchemaBindingDialog.java
License:Open Source License
@Override protected Control createContents(Composite parent) { errorReportColor = new Color(parent.getDisplay(), 200, 0, 0); warningReportColor = new Color(parent.getDisplay(), 204, 102, 0); browseImage = RngUiPlugin.getDefault().getIcon("file_expand.gif").createImage(); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.createFrom(new GridLayout(3, false)).margins(10, 7).create()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label labelNamespace = new Label(composite, SWT.NONE); labelNamespace.setText("Namespace: "); GridData inputLayoutData = new GridData(GridData.FILL_HORIZONTAL); inputLayoutData.widthHint = 270;/*from w ww .j ava2 s . c o m*/ namespaceText = new Text(composite, SWT.SINGLE | SWT.BORDER); namespaceText.setLayoutData(GridDataFactory.createFrom(inputLayoutData).span(2, 1).create()); Label labelSchemaLocation = new Label(composite, SWT.NONE); labelSchemaLocation.setText("Schema Location: "); schemaLocationText = new Text(composite, SWT.SINGLE | SWT.BORDER); schemaLocationText.setLayoutData(inputLayoutData); Button browseControl = createBrowseButton(composite); browseControl.addSelectionListener(new DropDownSelectionListener(schemaLocationText)); Label labelSchemaType = new Label(composite, SWT.NONE); labelSchemaType.setText("Schema Syntax: "); schemaTypeCombo = new Combo(composite, SWT.READ_ONLY); schemaTypeCombo.setLayoutData(GridDataFactory.createFrom(inputLayoutData).span(2, 1).create()); schemaTypeCombo.add("XML", SCHEMA_TYPE_XML_COMBO_IDX); schemaTypeCombo.add("Compact", SCHEMA_TYPE_COMPACT_COMBO_IDX); errorReportArea = new Label(composite, SWT.NONE); errorReportArea.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create()); Composite buttonComposite = new Composite(composite, SWT.NONE); buttonComposite.setLayout(new GridLayout(2, false)); buttonComposite .setLayoutData(GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).span(3, 1).create()); okButton = createButton(buttonComposite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); okButton.setEnabled(false); createButton(buttonComposite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); if (binding != null) { initEditedValues(); } revalidate(); ModifyListener validationListener = new ModifyListener() { public void modifyText(ModifyEvent e) { revalidate(); } }; namespaceText.addModifyListener(validationListener); schemaLocationText.addModifyListener(validationListener); schemaTypeCombo.addModifyListener(validationListener); return composite; }
From source file:com.siteview.ecc.rcp.cnf.ui.SecureLoginDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { Button removeCurrentUser = createButton(parent, IDialogConstants.CLIENT_ID, "&Delete User", false); removeCurrentUser.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { savedDetails.remove(userIdText.getText()); initializeUsers(""); // ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); // ISecurePreferences connections = preferences.node(SAVED); // connections.remove(userIdText.getText()); // preferences.removeNode(); // try { // preferences.flush(); // } catch (IOException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } }// ww w . j a va 2 s .c o m }); createButton(parent, IDialogConstants.OK_ID, "&Login", true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:com.siteview.ecc.rcp.cnf.ui.SecureLoginDialog.java
License:Open Source License
protected void buttonPressed(int buttonId) { String userId = userIdText.getText(); String server = serverText.getText(); String password = passwordText.getText(); connectionDetails = new MonitorServer(userId, server, password); savedDetails.put(userId, connectionDetails); if (buttonId == IDialogConstants.OK_ID || buttonId == IDialogConstants.CANCEL_ID) saveDescriptors();//from w w w.ja v a2s .c o m super.buttonPressed(buttonId); }
From source file:com.siteview.mde.internal.ui.editor.feature.PortabilityChoicesDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:com.siteview.mde.internal.ui.launcher.PluginStatusDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); if (fShowCancelButton) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }// ww w .j av a 2s . c om }
From source file:com.siteview.mde.internal.ui.launcher.PluginValidationStatusHandler.java
License:Open Source License
private void displayValidationError(final LaunchValidationOperation op) throws CoreException { final int[] result = new int[1]; final Display display = LauncherUtilsStatusHandler.getDisplay(); display.syncExec(new Runnable() { public void run() { PluginStatusDialog dialog = new PluginStatusDialog(display.getActiveShell()); dialog.showCancelButton(true); dialog.setInput(op.getInput()); result[0] = dialog.open();//from w w w . j av a 2 s .c o m } }); if (result[0] == IDialogConstants.CANCEL_ID) throw new CoreException(Status.CANCEL_STATUS); }
From source file:com.softberries.klerk.gui.dialogs.AddressDialog.java
License:Open Source License
/** * Create contents of the button bar./*from w ww. ja v a2s . c o m*/ * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); m_bindingContext = initDataBindings(); okButton.setEnabled(getFormValid()); }
From source file:com.spextreme.jenkins.remote.ui.ConfigurationDialog.java
License:Apache License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) * @param parent The parent composite./*from www. j a va 2 s . co m*/ */ @Override protected void createButtonsForButtonBar(final Composite parent) { createButton(parent, IDialogConstants.OK_ID, "Save", true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }