List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_ID
int YES_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_ID.
Click Source Link
From source file:org.eclipse.andmore.android.common.utilities.FileUtil.java
License:Apache License
public static boolean extractZipArchive(File file, File destination, List<String> selectedEntries, IProgressMonitor monitor) throws IOException { SubMonitor subMonitor = SubMonitor.convert(monitor); ZipFile zipFile = null;/* w w w . j a v a2 s . c o m*/ CRC32 crc = new CRC32(); byte[] buf = new byte[BUFFER_SIZE]; File extractDestination = destination != null ? destination : file.getParentFile(); if (!extractDestination.exists()) { extractDestination.mkdirs(); } boolean unziped = true; try { zipFile = new ZipFile(file); } catch (Throwable e) { unziped = false; AndmoreLogger.error(FileUtil.class, "Error extracting file: " + file.getAbsolutePath() //$NON-NLS-1$ + " to " + extractDestination, e); //$NON-NLS-1$ } if (zipFile != null) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); subMonitor.beginTask("Extracting files", Collections.list(entries).size()); //$NON-NLS-1$ entries = zipFile.entries(); InputStream input = null; FileOutputStream output = null; int diagReturn = IDialogConstants.YES_ID; while (entries.hasMoreElements()) { crc.reset(); try { ZipEntry entry = entries.nextElement(); if (selectedEntries.contains(entry.getName())) { File newFile = new File(extractDestination, entry.getName()); if ((diagReturn != IDialogConstants.YES_TO_ALL_ID) && newFile.exists()) { diagReturn = EclipseUtils.showQuestionYesAllCancelDialog( UtilitiesNLS.FileUtil_File_Exists_Title, NLS.bind(UtilitiesNLS.FileUtil_File_Exists_Message, newFile.getAbsolutePath())); } if ((diagReturn == IDialogConstants.YES_ID) || (diagReturn == IDialogConstants.YES_TO_ALL_ID)) { newFile.delete(); if (entry.isDirectory()) { newFile.mkdirs(); } else { newFile.getParentFile().mkdirs(); if (newFile.createNewFile()) { input = zipFile.getInputStream(entry); output = new FileOutputStream(newFile); int length = 0; while ((length = input.read(buf, 0, BUFFER_SIZE)) > 1) { output.write(buf, 0, length); crc.update(buf, 0, length); } if (crc.getValue() != entry.getCrc()) { throw new IOException(); } } } } else { diagReturn = IDialogConstants.YES_ID; // Attempt to // extract // next // entry } } } catch (IOException e) { unziped = false; AndmoreLogger.error(FileUtil.class, "Error extracting file: " + file.getAbsolutePath() + " to " //$NON-NLS-1$ //$NON-NLS-2$ + extractDestination, e); throw e; } catch (Throwable t) { unziped = false; AndmoreLogger.error(FileUtil.class, "Error extracting file: " + file.getAbsolutePath() + " to " //$NON-NLS-1$ //$NON-NLS-2$ + extractDestination, t); } finally { try { if (input != null) { input.close(); } if (output != null) { output.close(); } } catch (Throwable t) { // do nothing } subMonitor.worked(1); } } } return unziped; }
From source file:org.eclipse.andmore.android.db.core.ui.wizards.createdb.CreateDatabaseWizard.java
License:Apache License
private boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor perspective) { IPreferenceStore store = DbCoreActivator.getDefault().getPreferenceStore(); String preference = store.getString(SWITCH_ANDMORE_DATABASE_PERSPECTIVE); if (preference.equals("")) //$NON-NLS-1$ {//from w w w . j av a2s .c om store.setValue(SWITCH_ANDMORE_DATABASE_PERSPECTIVE, MessageDialogWithToggle.PROMPT); preference = MessageDialogWithToggle.PROMPT; } boolean result; if (MessageDialogWithToggle.ALWAYS.equals(preference)) { result = true; } else if (MessageDialogWithToggle.NEVER.equals(preference)) { result = false; } else { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), DbCoreNLS.UI_CreateDatabaseWizard_ChangePerspectiveTitle, DbCoreNLS.UI_CreateDatabaseWizard_ChangePerspectiveQuestion, null, false, store, SWITCH_ANDMORE_DATABASE_PERSPECTIVE); int dialogResult = dialog.getReturnCode(); result = dialogResult == IDialogConstants.YES_ID; } return result; }
From source file:org.eclipse.andmore.internal.editors.layout.properties.XmlPropertyEditor.java
License:Open Source License
@Override protected boolean setEditorText(Property property, String text) throws Exception { Object oldValue = property.getValue(); String old = oldValue != null ? oldValue.toString() : null; // If users enters a new id without specifying the @id/@+id prefix, insert it boolean isId = isIdProperty(property); if (isId && !text.startsWith(PREFIX_RESOURCE_REF)) { text = NEW_ID_PREFIX + text;//w w w .j a va 2 s . c o m } // Handle id refactoring: if you change an id, may want to update references too. // Ask user. if (isId && property instanceof XmlProperty && old != null && !old.isEmpty() && text != null && !text.isEmpty() && !text.equals(old)) { XmlProperty xmlProperty = (XmlProperty) property; IPreferenceStore store = AndmoreAndroidPlugin.getDefault().getPreferenceStore(); String refactorPref = store.getString(AdtPrefs.PREFS_REFACTOR_IDS); boolean performRefactor = false; Shell shell = AndmoreAndroidPlugin.getShell(); if (refactorPref == null || refactorPref.isEmpty() || refactorPref.equals(MessageDialogWithToggle.PROMPT)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, "Update References?", "Update all references as well? " + "This will update all XML references and Java R field references.", "Do not show again", false, store, AdtPrefs.PREFS_REFACTOR_IDS); switch (dialog.getReturnCode()) { case IDialogConstants.CANCEL_ID: return false; case IDialogConstants.YES_ID: performRefactor = true; break; case IDialogConstants.NO_ID: performRefactor = false; break; } } else { performRefactor = refactorPref.equals(MessageDialogWithToggle.ALWAYS); } if (performRefactor) { CommonXmlEditor xmlEditor = xmlProperty.getXmlEditor(); if (xmlEditor != null) { IProject project = xmlEditor.getProject(); if (project != null && shell != null) { RenameResourceWizard.renameResource(shell, project, ResourceType.ID, stripIdPrefix(old), stripIdPrefix(text), false); } } } } property.setValue(text); return true; }
From source file:org.eclipse.ant.internal.ui.preferences.AntClasspathBlock.java
License:Open Source License
public boolean validateToolsJAR() { validated++;// w w w. j av a2s . co m boolean check = AntUIPlugin.getDefault().getPreferenceStore() .getBoolean(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING); if (check && !AntUIPlugin.isMacOS()) { Object[] entries = antContentProvider.getModel().getEntries(ClasspathModel.ANT_HOME); boolean valid = !JARPresent(entries, TOOLS).isEmpty(); if (!valid) { entries = antContentProvider.getModel().getEntries(ClasspathModel.GLOBAL_USER); valid = !JARPresent(entries, TOOLS).isEmpty(); if (!valid) { entries = antContentProvider.getModel().getEntries(ClasspathModel.USER); valid = !JARPresent(entries, TOOLS).isEmpty(); if (!valid) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( AntUIPlugin.getActiveWorkbenchWindow().getShell(), AntPreferencesMessages.AntClasspathBlock_31, AntPreferencesMessages.AntClasspathBlock_32, AntPreferencesMessages.AntClasspathBlock_33, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING); valid = dialog.getReturnCode() == IDialogConstants.YES_ID; } } } if (!valid) { container.setErrorMessage(AntPreferencesMessages.AntClasspathBlock_34); setValidated(); } return valid; } return true; }
From source file:org.eclipse.birt.report.designer.internal.ui.editors.schematic.tools.LibraryElementsToolHandleExtends.java
License:Open Source License
@Override public boolean postHandleCreation() { Object model = getModel();/*from w w w . j a v a 2 s. c o m*/ boolean isMove = false; if (needProcessDataItem(model)) { String prompt = ReportPlugin.getDefault().getPreferenceStore() .getString(ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE); MessageDialogWithToggle dialog; if (MessageDialogWithToggle.ALWAYS.equals(prompt)) { moveBindToHost((DataItemHandle) model); isMove = true; } else if ((prompt == null || MessageDialogWithToggle.PROMPT.equals(prompt)) && ((dialog = MessageDialogWithToggle.openYesNoQuestion(UIUtil.getDefaultShell(), Messages.getString("LibraryElementsToolHandleExtends_question"), //$NON-NLS-1$ Messages.getString("LibraryElementsToolHandleExtends_message"), //$NON-NLS-1$ Messages.getString("LibraryElementsToolHandleExtends_toggle"), //$NON-NLS-1$ false, ReportPlugin.getDefault().getPreferenceStore(), ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE)) != null)) { if (dialog.getReturnCode() == IDialogConstants.YES_ID) { moveBindToHost((DataItemHandle) model); isMove = true; } if (dialog.getToggleState()) { if (dialog.getReturnCode() == IDialogConstants.YES_ID) { ReportPlugin.getDefault().getPreferenceStore().setValue( ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE, MessageDialogWithToggle.ALWAYS); } else if (dialog.getReturnCode() == IDialogConstants.NO_ID) { ReportPlugin.getDefault().getPreferenceStore().setValue( ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE, MessageDialogWithToggle.NEVER); } } } } if (!isMove && model instanceof DataItemHandle) { DataItemHandle dataHandle = (DataItemHandle) model; Iterator iter = dataHandle.columnBindingsIterator(); String resultColumnName = dataHandle.getResultSetColumn(); ComputedColumnHandle activeBinding = null; while (iter.hasNext()) { ComputedColumnHandle computedColumnHandle = (ComputedColumnHandle) iter.next(); if (computedColumnHandle.getName().equals(resultColumnName)) { Expression newExpression = (Expression) computedColumnHandle .getExpressionProperty(ComputedColumn.EXPRESSION_MEMBER).getValue(); if (newExpression == null || newExpression.getExpression() == null) { activeBinding = computedColumnHandle; } else if (newExpression.getExpression() instanceof String && ((String) newExpression.getExpression()).length() == 0) { activeBinding = computedColumnHandle; } break; } } if (activeBinding != null) { DataColumnBindingDialog dialog = new DataColumnBindingDialog(false); dialog.setNeedPrompt(false); dialog.setInput(dataHandle, activeBinding); if (dialog.open() == Dialog.OK) { //do nothing now } } } return super.postHandleCreation(); }
From source file:org.eclipse.birt.report.item.crosstab.internal.ui.editors.model.CrosstabAdaptUtil.java
License:Open Source License
public static boolean needRemoveInvaildBindings(CrosstabReportItemHandle handle) { String preferenceData = PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault()) .getString(CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS); if (preferenceData == null || preferenceData.length() == 0 || preferenceData.equals(MessageDialogWithToggle.PROMPT)) { MessageDialogWithToggle msgDlg = MessageDialogWithToggle.openYesNoQuestion(UIUtil.getDefaultShell(), Messages.getString("DeleteBindingDialog.Title"), //$NON-NLS-1$ Messages.getString("DeleteBindingDialog.Message"), //$NON-NLS-1$ Messages.getString("DeleteBindingDialog.ToggleMessage"), //$NON-NLS-1$ false, null, null);//w w w. jav a 2 s .co m if (msgDlg.getToggleState()) { String value = ""; if (msgDlg.getReturnCode() == IDialogConstants.YES_ID) { value = MessageDialogWithToggle.ALWAYS; } else if (msgDlg.getReturnCode() == IDialogConstants.NO_ID) { value = MessageDialogWithToggle.NEVER; } PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault()) .setValue(CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS, value); } if (msgDlg.getReturnCode() == IDialogConstants.YES_ID) { return true; // removeInvalidBindings( handle ); } else if (msgDlg.getReturnCode() == IDialogConstants.NO_ID) { return false; // dothing } } else if (preferenceData != null && preferenceData.equals(MessageDialogWithToggle.ALWAYS)) { return true; // removeInvalidBindings( handle ); } return false; // removeInvalidBindings(handle); }
From source file:org.eclipse.bpmn2.modeler.core.validation.BPMN2ProjectValidator.java
License:Open Source License
public static boolean validateOnSave(Resource resource, IProgressMonitor monitor) { boolean needValidation = false; URI uri = resource.getURI();//from w w w . ja v a2 s . c om if (uri.isPlatformResource()) { String pathString = uri.toPlatformString(true); IPath path = Path.fromOSString(pathString); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); IProject project = file.getProject(); if (project != null) { try { IProjectNature nature = project.getNature(BPMN2Nature.NATURE_ID); if (nature == null) { Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(project); if (preferences.getCheckProjectNature()) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String title = Messages.BPMN2ProjectValidator_Title; String message = NLS.bind(Messages.BPMN2ProjectValidator_No_Project_Nature, project.getName()); MessageDialogWithToggle result = MessageDialogWithToggle.open(MessageDialog.QUESTION, shell, title, message, Messages.BPMN2ProjectValidator_Dont_Ask_Again, // toggle message false, // toggle state null, // pref store null, // pref key SWT.NONE); if (result.getReturnCode() == IDialogConstants.YES_ID) { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = BPMN2Nature.NATURE_ID; description.setNatureIds(newNatures); project.setDescription(description, null); needValidation = true; } if (result.getToggleState()) { // don't ask again preferences.setCheckProjectNature(false); } } } else needValidation = true; } catch (CoreException e) { e.printStackTrace(); } } if (needValidation) { // validation will be done by the Project Validation builder return true; } } return false; }
From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { _yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); }
From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (IDialogConstants.YES_ID == buttonId) { setReturnCode(IDialogConstants.YES_ID); if (_testDialog.getShell() != null) { _testDialog.close();/*from w w w . j a v a 2 s . c om*/ } close(); } else if (IDialogConstants.NO_ID == buttonId) { handleFailure(); } }
From source file:org.eclipse.cdt.internal.ui.actions.ActionUtil.java
License:Open Source License
public static boolean isEditable(Shell shell, ICElement element) { if (!isProcessable(shell, element)) return false; ICElement cu = element.getAncestor(ICElement.C_UNIT); if (cu != null) { IResource resource = cu.getResource(); if (resource != null && resource.isDerived()) { // see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState() final String warnKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED; IPreferenceStore store = EditorsUI.getPreferenceStore(); if (!store.getBoolean(warnKey)) return true; MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(shell, ActionMessages.ActionUtil_warning_derived_title, Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), ActionMessages.ActionUtil_warning_derived_dontShowAgain, false, null, null); EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState()); return toggleDialog.getReturnCode() == IDialogConstants.YES_ID; }//from w w w . jav a2s . com } return true; }