List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:br.ufmg.dcc.tabuleta.actions.LoadConcernModelAction.java
License:Open Source License
private boolean shouldProceed() { boolean lReturn = true; if (Tabuleta.getDefault().isDirty()) { lReturn = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Tabuleta.getResourceString("actions.LoadConcernModelAction.QuestionDialogTitle"), Tabuleta.getResourceString("actions.LoadConcernModelAction.WarningOverwrite")); }/*w ww . j av a 2 s . c o m*/ return lReturn; }
From source file:ca.maestrosoft.eclipse.cdt.plugin.studio.option.ui.MaestroFileListControl.java
License:Open Source License
/** * This method will be called when the remove button is pressed *//*from w w w . j a v a 2s.c o m*/ private void removePressed() { if (list.getSelectionCount() == 0 || list.getSelectionIndex() == -1) return; boolean delDir = true; if (promptForDelete) { String quest = Messages.FileListControl_deletedialog_message; String title = Messages.FileListControl_deletedialog_title; delDir = MessageDialog.openQuestion(list.getShell(), title, quest); } if (delDir) { int i; int minIndex = Integer.MAX_VALUE; while ((i = list.getSelectionIndex()) != -1) { minIndex = Math.min(minIndex, i); list.remove(i); } minIndex = Math.min(minIndex, list.getItemCount() - 1); if (minIndex >= 0) { list.setSelection(minIndex); } checkNotificationNeeded(); } selectionChanged(); }
From source file:ca.uvic.cs.tagsea.editing.RoutesTreeItemListener.java
License:Open Source License
public void beforeDelete(TreeItemDeleteEvent event) { if (event.data instanceof Route) { Route route = (Route) event.data; // prompt the user if the route has waypoints if (route.getWaypoints().size() > 0) { String msg = "Are you sure you want to delete " + route.getName() + "?"; event.doit = MessageDialog.openQuestion(event.tree.getShell(), "Delete?", msg); }//from www. j a v a2s . c om } }
From source file:ca.uvic.cs.tagsea.wizards.XMLTagSendWizardPage.java
License:Open Source License
boolean send() { int id = TagSEAPlugin.getDefault().getUserID(); if (id < 0) { boolean result = MessageDialog.openQuestion(getShell(), "Cannot Send", "You must register TagSEA before you can upload your tags. Would you like to register now?"); if (result) { id = TagSEAPlugin.getDefault().askForUserID(); }/* w w w. j a va 2s . c o m*/ } if (id < 0) { MessageDialog.openError(getShell(), "Operation Incomplete", "Error getting ID."); return false; } final int fid = TagSEAPlugin.getDefault().askForUserID(); try { getContainer().run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { TagNetworkSender.send(textData, monitor, fid); } }); } catch (InvocationTargetException ex) { MessageDialog.openError(getShell(), "Error", ex.getLocalizedMessage()); TagSEAPlugin.log(ex.getLocalizedMessage(), ex); return false; } catch (InterruptedException e) { } MessageDialog.openInformation(getShell(), "Complete", "Upload Complete"); return true; }
From source file:ca.uwaterloo.gp.fmp.system.ModelManipulation.java
License:Open Source License
/** * Performs state transition on the given node, given that the user has made a click on the current node * If "commands" is non-null, a SetCommand is created for every state change. Otherwise, * the state change is directly made.//w w w . j av a 2 s .c o m * @return */ protected ConfigState doStateTransition(CompoundCommand commands, EditingDomain editingDomain, Clonable node, boolean controlKeyPressed) { Feature rootFeature = ModelNavigation.INSTANCE.navigateToRootFeature(node); Configurator configurator = ConfiguratorDictionary.INSTANCE.get(rootFeature); // Update the state on the ConfNode ConfigState curState = ((Clonable) node).getState(); ConfigState newState = null; if (node.isOptional()) { if (configurator.getMode() == Configurator.EDIT_MODE_USER_ONLY) { // Only allow the user to go back between user-selected/user-deselected and undecided if (curState == ConfigState.UNDECIDED_LITERAL) { if (controlKeyPressed) { newState = ConfigState.USER_ELIMINATED_LITERAL; configurator.assignValue(node.getId(), 0, false); } else { newState = ConfigState.USER_SELECTED_LITERAL; configurator.assignValue(node.getId(), 1, false); } } else if (curState == ConfigState.USER_ELIMINATED_LITERAL || curState == ConfigState.USER_SELECTED_LITERAL) { newState = ConfigState.UNDECIDED_LITERAL; configurator.removeSelection(node.getId(), true, true, true); } } else if (configurator.getMode() == Configurator.EDIT_MODE_INTERACTIVE || configurator.getMode() == Configurator.EDIT_MODE_AUTORESOLVE_CONFLICTS) { // Save selections before applying the new value so that we can roll back // in case the user decides not to force the new selection //kmpietro CS_VarSelection[] selections = configurator.getSelections(); if (curState == ConfigState.MACHINE_SELECTED_LITERAL) { newState = ConfigState.USER_ELIMINATED_LITERAL; configurator.removeSelection(node.getId(), true, false, false); configurator.assignValue(node.getId(), 0, true); } else if (curState == ConfigState.MACHINE_ELIMINATED_LITERAL) { newState = ConfigState.USER_SELECTED_LITERAL; configurator.removeSelection(node.getId(), true, false, false); configurator.assignValue(node.getId(), 1, true); } else if (curState == ConfigState.USER_SELECTED_LITERAL) { // user wants to express deselection if (controlKeyPressed) { // set it to "deselected" newState = ConfigState.USER_ELIMINATED_LITERAL; configurator.removeSelection(node.getId(), true, true, true); configurator.assignValue(node.getId(), 0, true); } else { // set it to "unchecked" newState = ConfigState.UNDECIDED_LITERAL; configurator.removeSelection(node.getId(), true, true, true); } } else if (curState == ConfigState.USER_ELIMINATED_LITERAL) { if (controlKeyPressed) { // set it to "unchecked" newState = ConfigState.UNDECIDED_LITERAL; configurator.removeSelection(node.getId(), true, true, true); } // user wants to express selection else { // set it to "selected" newState = ConfigState.USER_SELECTED_LITERAL; configurator.removeSelection(node.getId(), true, true, true); configurator.assignValue(node.getId(), 1, true); } } else if (curState == ConfigState.UNDECIDED_LITERAL) { if (controlKeyPressed) { newState = ConfigState.USER_ELIMINATED_LITERAL; configurator.assignValue(node.getId(), 0, true); } else { newState = ConfigState.USER_SELECTED_LITERAL; configurator.assignValue(node.getId(), 1, true); //configRep.getConfigurator().assignValue(configRep.getFeatureMemberSelected(configRep.getExprID((Feature)confNode)), 1, true); } } // Check if there is any conflict Conflicts conflicts = configurator.getConflicts(node.getId()); if (conflicts != null) { boolean forceNewSelection = true; // if interactive mode, then ask if (configurator.getMode() == Configurator.EDIT_MODE_INTERACTIVE) { //kmpietro String question = "Your new selection:\n " + this.formatSelection(configurator, conflicts.m_forced_selection) + "\n"; String question = "Your new selection:\n " + configurator.getVarName(conflicts.m_forced_selection) + "\n"; question += "\nconflicts with the previous selections:\n"; for (int i = 0; i < conflicts.m_conflicting_selections.length; i++) { //kmpietro question += " " + this.formatSelection(configurator, configurator.getVarName(conflicts.m_conflicting_selections[i])) + "\n"; question += " " + configurator.getVarName(conflicts.m_conflicting_selections[i]) + "\n"; } question += "\nWould you like to force the new selection anyway?"; forceNewSelection = MessageDialog.openQuestion(new Shell(), "Conflict", question); } // If the user does not want to force the new selection, roll back the changes /*kmpietro if(!forceNewSelection) { configurator.applySelections(selections); newState = curState; } // otherwise, remove the conflicting selections and force the new selection else */ { for (int i = 0; i < conflicts.m_conflicting_selections.length; i++) { configurator.removeSelection( configurator.getVarName(conflicts.m_conflicting_selections[i]), true, true, true); } } } } if (newState != null && newState != curState) { if (commands != null) commands.append(new SetCommand(editingDomain, node, FmpPackage.eINSTANCE.getClonable_State(), newState)); else node.setState(newState); } } return newState; }
From source file:cc.warlock.rcp.stormfront.ui.wizards.AccountWizardPage.java
License:Open Source License
@Override public void pageExited(int button) { // if (button == WizardWithNotification.NEXT) // { //from w ww . ja v a 2 s. c o m //accountName = account.getText(); savedAccount = AccountProvider.getInstance().getAccount(account.getText()); if (savedAccount == null) { boolean save = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), WizardMessages.AccountWizardPage_saveAccount_title, WizardMessages.AccountWizardPage_saveAccount_description); if (save) { savedAccount = AccountProvider.getInstance().createSetting(); savedAccount.setAccountName(account.getText()); savedAccount.setPassword(password.getText()); WarlockPreferencesScope.getInstance().flush(); } } try { getContainer().run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { listener.setProgressMonitor(monitor); monitor.beginTask(WizardMessages.bind(WizardMessages.AccountWizardPage_progressMessage, account.getText()), 4); if (!connection.isConnected()) { connection.connect(); } else { connection.login(account.getText(), password.getText()); } monitor.worked(1); } }); } catch (Exception e) { e.printStackTrace(); } // } }
From source file:ch.elexis.agenda.util.TermineLockedTimesUpdater.java
License:Open Source License
/** * check whether any appointments collide with the lock time changes * //from w w w.j a va 2s.com * @param appointments * @param monitor * @return list of days to skip when deleting the old boundaries */ private List<String> checkAppointmentCollision(List<Termin> appointments, IProgressMonitor monitor) { List<String> skipUpdate = new ArrayList<String>(); String[] closedTimes = _newValues.split(StringConstants.LF); TimeTool day = new TimeTool(); for (Termin t : appointments) { if (t.getId().equals(StringConstants.ONE)) continue; if (t.getDay() == null || t.getDay().length() < 3) continue; day.set(t.getDay()); if (_startDate.isBeforeOrEqual(day)) { if (day.get(Calendar.DAY_OF_WEEK) == _applyForDay.numericDayValue) { // ignore locktimes if (!t.getType().equals(Termin.typReserviert())) { for (String s : closedTimes) { int von = TimeTool.minutesStringToInt(s.split("-")[0]); //$NON-NLS-1$ int bis = TimeTool.minutesStringToInt(s.split("-")[1]); //$NON-NLS-1$ //check for collision if (t.crossesTimeFrame(von, bis - von)) { boolean keepOldLocktimes = MessageDialog.openQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.TermineLockedTimesUpdater_4, Messages.TermineLockedTimesUpdater_5 + t.getLabel() + Messages.TermineLockedTimesUpdater_6 + s + ". " + Messages.TermineLockedTimesUpdater_7); //update anyway -> add appointment to delete list if (keepOldLocktimes) skipUpdate.add(t.getDay()); } } } } } monitor.worked(1); } return skipUpdate; }
From source file:ch.elexis.core.application.Desk.java
License:Open Source License
/** * @since 3.0.0 log-in has been moved from ApplicationWorkbenchAdvisor to this method *//*from w ww. jav a 2 s. c o m*/ @Override public Object start(IApplicationContext context) throws Exception { // register ElexisEvent and MessageEvent listeners log.debug("Registering " + CoreEventListenerRegistrar.class.getName()); new CoreEventListenerRegistrar(); // Check if we "are complete" - throws Error if not cod = CoreOperationExtensionPoint.getCoreOperationAdvisor(); if (System.getProperty(ElexisSystemPropertyConstants.OPEN_DB_WIZARD) != null) { cod.requestDatabaseConnectionConfiguration(); } // connect to the database try { if (PersistentObject.connect(CoreHub.localCfg) == false) log.error(PersistentObject.class.getName() + " initialization failed."); } catch (Throwable pe) { // error in database connection, we have to exit log.error("Database connection error", pe); pe.printStackTrace(); Shell shell = PlatformUI.createDisplay().getActiveShell(); StringBuilder sb = new StringBuilder(); sb.append("Could not open database connection. Quitting Elexis.\n\n"); sb.append("Message: " + pe.getMessage() + "\n\n"); while (pe.getCause() != null) { pe = pe.getCause(); sb.append("Reason: " + pe.getMessage() + "\n"); } sb.append("\n\nWould you like to re-configure the database connection?"); boolean retVal = MessageDialog.openQuestion(shell, "Error in database connection", sb.toString()); if (retVal) { cod.requestDatabaseConnectionConfiguration(); } return IApplication.EXIT_OK; } // check for initialization parameters args = context.getArguments(); if (args.containsKey("--clean-all")) { //$NON-NLS-1$ String p = CorePreferenceInitializer.getDefaultDBPath(); FileTool.deltree(p); CoreHub.localCfg.clear(); CoreHub.localCfg.flush(); } // check if we should warn of too many instances if (CoreHub.isTooManyInstances()) { MessageDialog.openWarning(UiDesk.getDisplay().getActiveShell(), Messages.Warning_tooManyTitle, Messages.Warning_tooManyMessage + CoreHub.getWritableUserDir().getAbsolutePath()); } // care for log-in WorkbenchPlugin.unsetSplashShell(UiDesk.getDisplay()); cod.performLogin(UiDesk.getDisplay().getActiveShell()); if ((CoreHub.actUser == null) || !CoreHub.actUser.isValid()) { // no valid user, exit (don't consider this as an error) log.warn("Exit because no valid user logged-in"); //$NON-NLS-1$ PersistentObject.disconnect(); System.exit(0); } // make sure identifiers are initialized initIdentifiers(); // start the workbench try { int returnCode = PlatformUI.createAndRunWorkbench(UiDesk.getDisplay(), new ApplicationWorkbenchAdvisor()); // Die Funktion kehrt erst beim Programmende zurck. CoreHub.heart.suspend(); CoreHub.localCfg.flush(); if (CoreHub.globalCfg != null) { CoreHub.globalCfg.flush(); } if (returnCode == PlatformUI.RETURN_RESTART) { return IApplication.EXIT_RESTART; } return IApplication.EXIT_OK; } catch (Exception ex) { log.error("Exception caught", ex); ex.printStackTrace(); return -1; } }
From source file:ch.elexis.core.ui.commands.BillingProposalViewCreateBillsHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { List<Konsultation> kons = getToBill(event); final List<Konsultation> toBill = BillingUtil.getKonsultationsFromSameYear(kons); if (toBill.size() > 0 && toBill.size() != kons.size()) { if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Rechnung Validierung", "Eine Rechnung kann nur Leistungen innerhalb eines Jahres beinhalten.\n\nWollen Sie mit der Erstellung der Rechnung fr das Jahr " + new TimeTool(toBill.get(0).getDatum()).get(TimeTool.YEAR) + " fortsetzen ?")) { LoggerFactory.getLogger(BillingProposalViewCreateBillsHandler.class) .warn("Invoice creation canceled by user"); return null; }//from w ww. jav a2s .co m } ProgressMonitorDialog dialog = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event)); try { dialog.run(true, false, new IRunnableWithProgress() { private int successful = 0; private int errorneous = 0; private StringBuilder errorneousInfo = new StringBuilder(); @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Rechnungen erstellen", 3); List<Konsultation> billable = BillingUtil.filterNotBillable(toBill); monitor.worked(1); Map<Rechnungssteller, Map<Fall, List<Konsultation>>> toBillMap = BillingUtil .getGroupedBillable(billable); monitor.worked(1); // create all bills List<Result<Rechnung>> results = BillingUtil.createBills(toBillMap); // build information to show for (Result<Rechnung> result : results) { if (result.isOK()) { successful++; } else { errorneousInfo.append(result.getSeverity()).append(" -> "); List<Result<Rechnung>.msg> messages = result.getMessages(); for (int i = 0; i < messages.size(); i++) { if (i > 0) { errorneousInfo.append(" / "); } errorneousInfo.append(messages.get(i).getText()); } errorneousInfo.append("\n"); errorneous++; } } monitor.worked(1); monitor.done(); // show information Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Info", MessageFormat.format( "Es wurden {0} Rechnungen erfolgreich erstellt.\nBei {1} Rechnungen traten Fehler auf.\n{2}", successful, errorneous, errorneousInfo.toString())); } }); } }); } catch (InvocationTargetException | InterruptedException e) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler", "Fehler beim Ausfhren der Rechnungserstelltung. Details siehe Log."); LoggerFactory.getLogger(BillingProposalViewCreateBillsHandler.class).error("Error creating bills", e); return null; } return null; }
From source file:ch.elexis.core.ui.commands.ErstelleRnnCommand.java
License:Open Source License
@SuppressWarnings("unchecked") public Object execute(ExecutionEvent eev) throws ExecutionException { Tree<?> tSelection = null;//from ww w . ja v a2s .co m String px = eev.getParameter("ch.elexis.RechnungErstellen.parameter"); //$NON-NLS-1$ try { tSelection = (Tree<?>) new TreeToStringConverter().convertToObject(px); } catch (ParameterValueConversionException pe) { throw new ExecutionException("Bad parameter " + pe.getMessage()); //$NON-NLS-1$ } IProgressMonitor monitor = Handler.getMonitor(eev); Result<Rechnung> res = null; for (Tree tPat = tSelection.getFirstChild(); tPat != null; tPat = tPat.getNextSibling()) { int rejected = 0; for (Tree tFall = tPat.getFirstChild(); tFall != null; tFall = tFall.getNextSibling()) { Fall fall = (Fall) tFall.contents; if (CoreHub.userCfg.get(Preferences.LEISTUNGSCODES_BILLING_STRICT, true)) { if (!fall.isValid()) { rejected++; continue; } } Collection<Tree> lt = tFall.getChildren(); List<Konsultation> lb = new ArrayList<Konsultation>(lt.size() + 1); for (Tree t : lt) { lb.add((Konsultation) t.contents); } List<Konsultation> toBill = BillingUtil.getKonsultationsFromSameYear(lb); if (toBill.size() > 0 && toBill.size() != lb.size()) { if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(eev), "Rechnung Validierung", "Eine Rechnung kann nur Leistungen innerhalb eines Jahres beinhalten.\n\nWollen Sie mit der Erstellung der Rechnung fr das Jahr " + new TimeTool(toBill.get(0).getDatum()).get(TimeTool.YEAR) + " fortsetzen ?")) { LoggerFactory.getLogger(ErstelleRnnCommand.class).warn("Invoice creation canceled by user"); return null; } } res = Rechnung.build(toBill); if (monitor != null) { monitor.worked(1); } if (!res.isOK()) { ErrorDialog.openError(HandlerUtil.getActiveShell(eev), Messages.KonsZumVerrechnenView_errorInInvoice, NLS.bind(Messages.KonsZumVerrechnenView_invoiceForCase, new Object[] { fall.getLabel(), fall.getPatient().getLabel() }), ResultAdapter.getResultAsStatus(res)); } else { tPat.remove(tFall); } } if (rejected != 0) { SWTHelper.showError(Messages.ErstelleRnnCommand_BadCaseDefinition, Integer.toString(rejected) + Messages.ErstelleRnnCommand_BillsNotCreatedMissingData + Messages.ErstelleRnnCommand_ErstelleRnnCheckCaseDetails); } else { tSelection.remove(tPat); } } return res; }