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.fu_berlin.inf.dpp.ui.actions.DeleteContactAction.java
License:Open Source License
public void runDeleteAction() { RosterEntry rosterEntry = null;//from ww w .ja va2 s . c o m List<RosterEntry> selectedRosterEntries = SelectionRetrieverFactory.getSelectionRetriever(RosterEntry.class) .getSelection(); if (selectedRosterEntries.size() == 1) { rosterEntry = selectedRosterEntries.get(0); } if (rosterEntry == null) { LOG.error("RosterEntry should not be null at this point!"); //$NON-NLS-1$ return; } if (sessionManager != null) { // Is the chosen user currently in the session? ISarosSession sarosSession = sessionManager.getSarosSession(); String entryJid = rosterEntry.getUser(); if (sarosSession != null) { for (User p : sarosSession.getUsers()) { String pJid = p.getJID().getBase(); // If so, stop the deletion from completing if (entryJid.equals(pJid)) { MessageDialog.openError(null, Messages.DeleteContactAction_error_title, DELETE_ERROR_IN_SESSION); return; } } } } if (MessageDialog.openQuestion(null, Messages.DeleteContactAction_confirm_title, MessageFormat.format(Messages.DeleteContactAction_confirm_message, toString(rosterEntry)))) { try { XMPPUtils.removeFromRoster(connectionService.getConnection(), rosterEntry); } catch (XMPPException e) { LOG.error("could not delete contact " + toString(rosterEntry) //$NON-NLS-1$ + ":", e); //$NON-NLS-1$ } } }
From source file:de.fu_berlin.inf.dpp.ui.actions.SendFileAction.java
License:Open Source License
private void handleIncomingFileTransferRequest(final FileTransferRequest request) { final String filename = request.getFileName(); final long fileSize = request.getFileSize(); final JID jid = new JID(request.getRequestor()); String nickname = XMPPUtils.getNickname(null, jid); if (nickname == null) nickname = new JID(request.getRequestor()).getBase(); final boolean accept = MessageDialog.openQuestion(SWTUtils.getShell(), "File Transfer Request", nickname + " wants to send a file." + "\nName: " + filename + "\nSize: " + CoreUtils.formatByte(fileSize) + (fileSize < 1000 ? "yte" : "") + "\n\nAccept the file?"); if (!accept) { request.reject();/* w ww . j a v a 2 s . com*/ return; } final FileDialog fd = new FileDialog(SWTUtils.getShell(), SWT.SAVE); fd.setText(Messages.SendFileAction_filedialog_text); fd.setOverwrite(true); fd.setFileName(filename); final String destination = fd.open(); if (destination == null) { request.reject(); return; } final File file = new File(destination); if (file.isDirectory()) { request.reject(); return; } Job job = new IncomingFileTransferJob(request, file, jid); job.setUser(true); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { event.getJob().removeJobChangeListener(this); // TODO UX this may be to annoying if (event.getResult().getCode() == IStatus.OK) showFileInOSGui(file); } }); job.schedule(); }
From source file:de.fu_berlin.inf.dpp.ui.preferencePages.GeneralPreferencePage.java
License:Open Source License
private void createRemoveAccountButton(Composite composite) { removeAccountButton = createAccountGroupButton(composite, DELETE_IMAGE, REMOVE_BTN_TEXT, new Listener() { @Override/* w ww. ja va 2s . c om*/ public void handleEvent(Event event) { if (MessageDialog.openQuestion(GeneralPreferencePage.this.getShell(), Messages.GeneralPreferencePage_REMOVE_ACCOUNT_DIALOG_TITLE, MessageFormat.format(Messages.GeneralPreferencePage_REMOVE_ACCOUNT_DIALOG_MESSAGE, createHumanDisplayAbleName(getSelectedAccount()))) ) { accountStore.deleteAccount(getSelectedAccount()); activateAccountButton.setEnabled(false); removeAccountButton.setEnabled(false); editAccountButton.setEnabled(false); updateList(); } } }); removeAccountButton.setEnabled(false); }
From source file:de.fu_berlin.inf.dpp.ui.wizards.AddXMPPAccountWizard.java
License:Open Source License
@Override public boolean performCancel() { if (!enterXMPPAccountWizardPage.isXMPPAccountCreated()) return true; return MessageDialog.openQuestion(getShell(), Messages.AddXMPPAccountWizard_account_created, Messages.AddXMPPAccountWizard_account_created_text); }
From source file:de.jcup.egradle.eclipse.ide.launch.EGradleLaunchConfigurationPropertiesTab.java
License:Apache License
/** * Attempts to add the given variable. Returns whether the variable was * added or not (as when the user answers not to overwrite an existing * variable)./*w ww. j a va 2s. c o m*/ * * @param variable * the variable to add * @return <code>true</code> when variable was added */ protected boolean addVariable(PropertyVariable variable) { String name = variable.getName(); TableItem[] items = propertiesTable.getTable().getItems(); for (int i = 0; i < items.length; i++) { PropertyVariable existingVariable = (PropertyVariable) items[i].getData(); if (existingVariable.getName().equals(name)) { boolean overWrite = MessageDialog.openQuestion(getShell(), "Overwrite variable?", MessageFormat .format("A variable named {0} already exists. Overwrite?", new Object[] { name })); // if (!overWrite) { return false; } propertiesTable.remove(existingVariable); break; } } propertiesTable.add(variable); updateLaunchConfigurationDialog(); return true; }
From source file:de.jcup.egradle.eclipse.ide.virtualroot.VirtualRootNewFilesToRealRootProjectBuilder.java
License:Apache License
/** * Method is called when its clear that resource was a link before. The * correct link target which shall be deleted, is already calculated * /*from w w w. ja v a 2s . co m*/ * @param linkTargetFile * @param resource */ protected void handleLinkedFileRemovedFromRootFolder(File linkTargetFile, IResource resource) { /* * eclipse will before the deletion a dialog about ... will not be * deleted... etc. */ /* we have to ask the user if he really wants to delete instead... */ String message = "Do you like to delete " + resource.getName() + " from root project as you have done with the link?\n" + linkTargetFile.getAbsolutePath(); safeAsyncExec(new Runnable() { @Override public void run() { Shell shell = getActiveWorkbenchShell(); boolean deleteTheFile = MessageDialog.openQuestion(shell, "EGradle", message); if (deleteTheFile) { try { getFileHelper().delete(linkTargetFile); } catch (IOException e) { IDEUtil.logError("Was not able to delete link target file:" + linkTargetFile, e); } } } }); }
From source file:de.jcup.egradle.eclipse.virtualroot.VirtualRootNewFilesToRealRootProjectBuilder.java
License:Apache License
/** * Method is called when its clear that resource was a link before. The * correct link target which shall be deleted, is already calculated * // w w w .j a v a 2 s . c om * @param linkTargetFile * @param resource */ protected void handleLinkedFileRemovedFromRootFolder(File linkTargetFile, IResource resource) { /* * eclipse will before the deletion a dialog about ... will not be * deleted... etc. */ /* we have to ask the user if he really wants to delete instead... */ String message = "Do you like to delete " + resource.getName() + " from root project as you have done with the link?\n" + linkTargetFile.getAbsolutePath(); safeAsyncExec(new Runnable() { @Override public void run() { Shell shell = getActiveWorkbenchShell(); boolean deleteTheFile = MessageDialog.openQuestion(shell, "EGradle", message); if (deleteTheFile) { try { getFileHelper().delete(linkTargetFile); } catch (IOException e) { log(e); } } } }); }
From source file:de.kolditz.common.ui.fields.FileField.java
License:Open Source License
/** * TODO support for complex file filters * //from www. j ava 2 s . com * @param e */ protected void widgetSelected(SelectionEvent e) { if (e.widget == btnSet) { FileDialog fd = new FileDialog(text.getShell(), ((style & SWT.OPEN) != 0) ? SWT.OPEN : SWT.SAVE); String filterPath = text.getText(); String fileName = ""; if (filterPath.equals(null_hint)) { filterPath = SystemProperties.USER_DIR; } else { File file = new File(filterPath); if (file.exists()) { if (file.isFile()) { filterPath = file.getAbsoluteFile().getParent(); fileName = file.getName(); } else { filterPath = file.getAbsolutePath(); } } } fd.setFilterPath(filterPath); fd.setFileName(fileName); fd.setFilterExtensions(extensions); fd.setFilterNames(names); if (filterIndex >= 0) fd.setFilterIndex(filterIndex); // TODO multi-file selection support String target = fd.open(); int filterIdx = fd.getFilterIndex(); if (target != null) { boolean doIt = true; if (isOverwriteAsk) { File file = new File(target); fileExists = file.exists(); if (fileExists) { doIt = doOverwrite = MessageDialog.openQuestion(text.getShell(), I18N.get().getString(I18N.FIELDS_FILEFIELD_OVERWRITEDIALOG_MSG), I18N.get().getString(I18N.FIELDS_FILEFIELD_OVERWRITEDIALOG_MSG)); } } if (doIt) { if (filterIdx >= 0 && extensions != null && extensions.length >= filterIdx) { // get (first) extension from the set filters String ext = extensions[filterIdx]; if (ext.contains(";")) { boolean extPresent = false; String[] tempExtensions = ext.split(";"); for (String extension : tempExtensions) { if ((extension.contains(".") && target.endsWith(extension.substring(extension.lastIndexOf('.')))) || Pattern.matches(extension, target)) { extPresent = true; break; } } if (!extPresent) { target += tempExtensions[0].substring(tempExtensions[0].lastIndexOf('.')); } } else if (ext.contains(".")) { ext = ext.substring(ext.lastIndexOf('.')); if (!target.endsWith(ext)) { target += ext; } } } text.setText(target); notifyObservers(target); } } } else if (e.widget == btnClear) { text.setText(null_hint); } }
From source file:de.loskutov.eclipseskins.sessions.OpenSessionAction.java
License:Open Source License
public void run() { final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); /*/*from w ww. j a v a 2 s. c om*/ * get editors, because if this is a "recently closed" session, editors may * change because of updating info on close of current editors */ List/*<EditorInfo>*/ editorInfos = session.getEditors(); if (editorInfos.size() == 0) { MessageDialog.openInformation(null, "Open Session", "No editors to open!"); return; } final IWorkbenchPage page = window.getActivePage(); final IPreferenceStore prefs = PresentationPlugin.getDefault().getPreferenceStore(); boolean close = prefs.getBoolean(ThemeConstants.CLOSE_EDITORS); if (close && page.getEditorReferences().length > 0) { if (prefs.getBoolean(ThemeConstants.ASK_BEFORE_CLOSE)) { close = MessageDialog.openQuestion(window.getShell(), "Load Session", "Close opened editors?"); } if (close) { Sessions.getInstance().createSession(Sessions.RECENTLY_CLOSED, true); boolean ok = page.closeAllEditors(true); if (!ok) { return; } } } Job job = new OpenEditorsJob("Opening editors", editorInfos, window, page); PlatformUI.getWorkbench().getProgressService().showInDialog(window.getShell(), job); job.schedule(); }
From source file:de.loskutov.fs.actions.ForceFileSyncActionDelegate.java
License:Open Source License
/** * Public method to be able to test it/* w ww .j a v a 2s .c o m*/ */ public FileSyncBuilder getOrCreateBuilder() { if (project == null) { FileSyncPlugin.error("Could not run FileSync builder - project is null!", null); return null; } IPreferenceStore store = FileSyncPlugin.getDefault().getPreferenceStore(); boolean askUser = store.getBoolean(FileSyncConstants.KEY_ASK_USER); if (ProjectHelper.isBuilderDisabled(project)) { if (askUser) { MessageDialog.openInformation(FileSyncPlugin.getShell(), "FileSync builder is disabled!", "Please activate FileSync builder for project '" + project.getName() + "' under\n" + "Project->Properties->Builders!"); } return null; } if (!ProjectHelper.hasBuilder(project)) { boolean ok = true; // TODO should be taken from prefs if (askUser) { ok = MessageDialog.openQuestion(FileSyncPlugin.getShell(), "FileSync builder is not enabled!", "Should FileSync builder be enabled for project '" + project.getName() + "' ?"); } if (ok) { ProjectHelper.addBuilder(project); } } return new FileSyncBuilder(project); }