List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:de.loskutov.fs.properties.ProjectSyncPropertyPage.java
License:Open Source License
private void addEntry() { List elementsToAdd = new ArrayList(10); if (hasMembers(project)) { PathListElement[] srcentries = openFolderDialog(null); if (srcentries != null) { for (int i = 0; i < srcentries.length; i++) { elementsToAdd.add(srcentries[i]); }/*from www . ja v a 2 s. c o m*/ } } else { boolean addRoot = MessageDialog.openQuestion(getShell(), "Project has no folders", "Current project has no folders. Create mapping for project root?"); if (addRoot) { PathListElement entry = newFolderElement(project); elementsToAdd.add(entry); } else { PathListElement entry = openNewFolderDialog(null); if (entry != null) { elementsToAdd.add(entry); } } } if (!elementsToAdd.isEmpty()) { HashSet modifiedElements = new HashSet(); askForAddingExclusionPatternsDialog(elementsToAdd, modifiedElements); foldersList.addElements(elementsToAdd); foldersList.postSetSelection(new StructuredSelection(elementsToAdd)); if (!modifiedElements.isEmpty()) { for (Iterator iter = modifiedElements.iterator(); iter.hasNext();) { Object elem = iter.next(); foldersList.refresh(elem); foldersList.expandElement(elem, 3); } } dialogFieldChanged(destPathDialogField); } }
From source file:de.marw.cdt.cmake.core.ui.DefinesViewer.java
License:Open Source License
private void handleDefineDelButton(TableViewer tableViewer) { final IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); final Shell shell = tableViewer.getControl().getShell(); if (MessageDialog.openQuestion(shell, "CMake-Define deletion confirmation", "Are you sure to delete the selected CMake-defines?")) { @SuppressWarnings("unchecked") ArrayList<CmakeDefine> defines = (ArrayList<CmakeDefine>) tableViewer.getInput(); defines.removeAll(selection.toList()); tableViewer.remove(selection.toArray());// updates the display }//from www .j av a 2s . c o m }
From source file:de.marw.cdt.cmake.core.ui.UnDefinesViewer.java
License:Open Source License
private void handleUnDefineDelButton(TableViewer tableViewer) { final IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); final Shell shell = tableViewer.getControl().getShell(); if (MessageDialog.openQuestion(shell, "CMake-Undefine deletion confirmation", "Are you sure to delete the selected CMake-undefines?")) { @SuppressWarnings("unchecked") ArrayList<String> undefines = (ArrayList<String>) tableViewer.getInput(); undefines.removeAll(selection.toList()); tableViewer.remove(selection.toArray());// updates the display }/*from w ww . j a v a2 s. c o m*/ }
From source file:de.ovgu.featureide.fm.ui.actions.AbstractImportAction.java
License:Open Source License
public void run(IAction action) { if (selection instanceof IStructuredSelection) { for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it.hasNext();) { Object element = it.next(); IFile outputFile = null;/*from w w w . ja v a2s . c o m*/ if (element instanceof IFile) { outputFile = (IFile) element; } else if (element instanceof IAdaptable) { outputFile = (IFile) ((IAdaptable) element).getAdapter(IFile.class); } if (outputFile != null) { try { boolean proceed = MessageDialog.openQuestion(new Shell(), "Warning!", "This will override the current model irrepealable! Proceed?"); if (proceed) { FileDialog fileDialog = new FileDialog(new Shell(), SWT.OPEN); fileDialog.setOverwrite(false); String filepath = fileDialog.open(); if (filepath == null) return; File inputFile = new File(filepath); while (!inputFile.exists()) { MessageDialog.openInformation(new Shell(), "File " + "not Found", "Specified file wasn't found"); inputFile = new File(fileDialog.open()); } FeatureModel fm = new FeatureModel(); modelReader = setModelReader(fm); modelReader.readFromFile(inputFile); FeatureModelWriterIFileWrapper fmWriter = new FeatureModelWriterIFileWrapper( new XmlFeatureModelWriter(fm)); fmWriter.writeToFile(outputFile); outputFile.refreshLocal(IResource.DEPTH_ZERO, null); openFileInEditor(outputFile); } } catch (FileNotFoundException e) { FMUIPlugin.getDefault().logError(e); } catch (UnsupportedModelException e) { String errStr = e.getMessage(); MessageDialog.openWarning(new Shell(), "Warning!", "Error while loading file: \n " + errStr); FMUIPlugin.getDefault().logError(e); } catch (CoreException e) { FMUIPlugin.getDefault().logError(e); } } } } }
From source file:de.ovgu.featureide.fm.ui.actions.ExportGuidslAction.java
License:Open Source License
public void run(IAction action) { if (selection instanceof IStructuredSelection) { for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it.hasNext();) { Object element = it.next(); IFile inputFile = null;/*from www. java 2 s .c o m*/ if (element instanceof IFile) { inputFile = (IFile) element; } else if (element instanceof IAdaptable) { inputFile = (IFile) ((IAdaptable) element).getAdapter(IFile.class); } if (inputFile != null) { try { FeatureModel fm = new FeatureModel(); //XmlFeatureModelReader fmReader = new XmlFeatureModelReader(fm,inputFile.getProject()); FeatureModelReaderIFileWrapper fmReader = new FeatureModelReaderIFileWrapper( new XmlFeatureModelReader(fm)); fmReader.readFromFile(inputFile); GuidslWriter fmWriter = new GuidslWriter(fm); if (fmWriter.hasConcreteCompounds()) { boolean proceed = MessageDialog.openQuestion(new Shell(), "Warning!", "The current feature model cannot be transformed due to concrete compounds! Proceed? (all compound features will be set as abstract)"); if (!proceed) { return; } } FileDialog fileDialog = new FileDialog(new Shell(), SWT.SAVE); fileDialog.setFileName("model.m"); fileDialog.setFilterExtensions(new String[] { "*.m" }); fileDialog.setFilterNames(new String[] { "GUIDSL foramt *.m" }); fileDialog.setOverwrite(true); String filepath = fileDialog.open(); if (filepath == null) return; File outputFile = new File(filepath); fmWriter.writeToFile(outputFile); inputFile.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); } catch (FileNotFoundException e) { FMUIPlugin.getDefault().logError(e); } catch (UnsupportedModelException e) { FMUIPlugin.getDefault().logError(e); } catch (CoreException e) { FMUIPlugin.getDefault().logError(e); } } } } }
From source file:de.ovgu.featureide.fm.ui.handlers.EliminateComplexConstraintsHandler.java
License:Open Source License
@Override protected void singleAction(IFile file) { final IFeatureModel featureModel = readModel(file); IConverterStrategy strategy = new NNFConverter(); ComplexConstraintConverter converter = new ComplexConstraintConverter(); String path = ""; boolean trivial = ComplexConstraintConverter.trivialRefactoring(featureModel); int pseudo = 0, strict = 0; for (IConstraint c : featureModel.getConstraints()) { if (ComplexConstraintConverter.isSimple(c.getNode())) { } else if (ComplexConstraintConverter.isPseudoComplex(c.getNode())) pseudo++;/*from w ww.j a v a2s .c o m*/ else { strict++; } } //count number of constraints //set file extension final EliminateConstraintsWizard wizard = new EliminateConstraintsWizard(file, "Complex-constraints elimination", trivial, pseudo, strict, "xml"); List<Option> options = new ArrayList<Option>(); if (Dialog.OK == new WizardDialog(Display.getCurrent().getActiveShell(), wizard).open()) { strategy = wizard.getStrategy(); if (wizard.preserveConfigurations()) options.add(Option.COHERENT); if (wizard.removeRedundancy()) options.add(Option.REMOVE_RDUNDANCY); path = wizard.getPath(); if ((new File(path)).exists() && !MessageDialog.openQuestion(new Shell(), "Warning!", "Selected file already exists. File will be overwritten.")) { return; } } IFeatureModel result = converter.convert(featureModel, strategy, options.toArray(new Option[options.size()])); final FeatureModelWriterIFileWrapper fmWriter = new FeatureModelWriterIFileWrapper( new XmlFeatureModelWriter(result)); try { fmWriter.writeToFile(new File(path)); file.refreshLocal(IResource.DEPTH_ZERO, null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.ovgu.featureide.fm.ui.handlers.ExportFAMAHandler.java
License:Open Source License
@Override protected void singleAction(IFile file) { final IFeatureModel fm = readModel(file); IConverterStrategy strategy = new NNFConverter(); ComplexConstraintConverter converter = new ComplexConstraintConverter(); String path = ""; boolean trivial = ComplexConstraintConverter.trivialRefactoring(fm); if (!trivial && !MessageDialog.openQuestion(new Shell(), "Warning!", "Complex constraints of current feature model cannot be transformed trivially! Proceed? (Feature model will become bigger.)")) { return;// w w w . j ava2 s . co m } int pseudo = 0, strict = 0; for (IConstraint c : fm.getConstraints()) { if (ComplexConstraintConverter.isSimple(c.getNode())) { } else if (ComplexConstraintConverter.isPseudoComplex(c.getNode())) pseudo++; else { strict++; } } final EliminateConstraintsWizard wizard = new EliminateConstraintsWizard(file, "Complex-constraints elimination", trivial, pseudo, strict, "fm"); List<Option> options = new ArrayList<Option>(); if (Dialog.OK == new WizardDialog(Display.getCurrent().getActiveShell(), wizard).open()) { strategy = wizard.getStrategy(); if (wizard.preserveConfigurations()) options.add(Option.COHERENT); if (wizard.removeRedundancy()) options.add(Option.REMOVE_RDUNDANCY); path = wizard.getPath(); if ((new File(path)).exists() && !MessageDialog.openQuestion(new Shell(), "Warning!", "Selected file already exists. File will be overwritten.")) { return; } } IFeatureModel result = converter.convert(fm, strategy, options.toArray(new Option[options.size()])); FileHandler.save(Paths.get(path), result, new FAMAFormat()); }
From source file:de.ovgu.featureide.fm.ui.handlers.ExportGUIDSLHandler.java
License:Open Source License
@Override protected IFeatureModelWriter getFeatureModelWriter(IFeatureModel fm) { final GuidslWriter fmWriter = new GuidslWriter(fm); if (fmWriter.hasConcreteCompounds() && !MessageDialog.openQuestion(new Shell(), "Warning!", "The current feature model cannot be transformed due to concrete compounds! Proceed? (all compound features will be set as abstract)")) { return null; }//from ww w . ja va 2 s. c o m return fmWriter; }
From source file:de.quamoco.adaptation.view.history.action.DeleteAllAction.java
License:Apache License
@Override public void run() { QualityModel qualityModel = (QualityModel) view.getViewer().getInput(); if (qualityModel != null && MessageDialog.openQuestion(view.getSite().getShell(), "Delete history", "Do you really want to delete the complete history?")) { IStructuredContentProvider contentProvider = (IStructuredContentProvider) view.getViewer() .getContentProvider();// ww w . j a v a2 s. c o m Object[] elementsToDelete = contentProvider.getElements(qualityModel); EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(qualityModel); CompoundCommand command = new CompoundCommand(); for (Object object : elementsToDelete) { EObject eObject = (EObject) object; RemoveCommand removeCommand = new RemoveCommand(editingDomain, eObject.eContainer(), eObject.eContainingFeature(), eObject); if (removeCommand.canExecute()) { command.append(removeCommand); } } command.setLabel("Delete history"); editingDomain.getCommandStack().execute(command); } }
From source file:de.tobject.findbugs.actions.SaveXmlAction.java
License:Open Source License
@Override public void run(final IAction action) { if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) { return;//from w w w .ja v a 2 s . c o m } IStructuredSelection structuredSelection = (IStructuredSelection) selection; IProject project = getProject(structuredSelection); if (project == null) { return; } // Get the file name from a file dialog FileDialog fileDialog = createFileDialog(project); boolean validFileName = false; do { String fileName = openFileDialog(fileDialog); if (fileName == null) { // User cancelled break; } validFileName = validateSelectedFileName(fileName); if (!validFileName) { MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning", fileName + " is not a file or is not writable!"); continue; } if (new File(fileName).exists()) { if (!MessageDialog.openQuestion(Display.getDefault().getActiveShell(), "Warning", fileName + " already exists. Override?")) { continue; } } getDialogSettings().put(SAVE_XML_PATH_KEY, fileName); work(project, fileName); } while (!validFileName); }