Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#openQuestion()

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#openQuestion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQBDataSetWizardPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean openInvalidInputMessageBox( Shell parentShell, boolean askUser )
{
    String userMessage = Messages.sqbWizPage_invalidSqbStateMsg;
    if( askUser )
    {
        userMessage += NEWLINE_CHAR
                        + Messages.sqbWizPage_inputFailOnOpenAskUserMessage;
        return MessageDialog.openQuestion( parentShell,
                    Messages.sqbWizPage_invalidSqbStateTitle, userMessage );
    }
    
    // not an user option, raise warning and continue
    MessageDialog.openWarning( parentShell,
                    Messages.sqbWizPage_invalidSqbStateTitle, userMessage );
    return true; // continue
}
 
Example 2
Source File: CheckBoxExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void switchEditorType() {
    if (!control.isVisible()) {
        switchToExpressionMode();
        bindExpression();
    } else {
        if (MessageDialog.openQuestion(mc.getShell(), Messages.eraseExpressionTitle, Messages.eraseExpressionMsg)) {
            switchToCheckBoxMode();
            //Reset checkbox to false
            final Expression falseExp = ExpressionFactory.eINSTANCE.createExpression();
            falseExp.setName(Boolean.FALSE.toString());
            falseExp.setContent(Boolean.FALSE.toString());
            falseExp.setReturnType(Boolean.class.getName());
            falseExp.setType(ExpressionConstants.CONSTANT_TYPE);
            updateSelection(null, falseExp);
            bindExpression();
        }
    }
    mc.layout(true, true);
}
 
Example 3
Source File: ConnectingFailureHandler.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private void handleConnectionFailed(XMPPAccount account, String errorMessage) {
  // avoid mass dialog popups
  if (isHandling) return;

  try {
    isHandling = true;

    boolean editAccountAndConnectAgain =
        MessageDialog.openQuestion(
            SWTUtils.getShell(),
            CoreMessages.ConnectingFailureHandler_title,
            MessageFormat.format(
                Messages.ConnectingFailureHandler_ask_retry_error_message, errorMessage));
    if (!editAccountAndConnectAgain) return;

    if (WizardUtils.openEditXMPPAccountWizard(account) == null) return;

    XMPPConnectionSupport.getInstance().connect(account, false);
  } finally {
    isHandling = false;
  }
}
 
Example 4
Source File: LocationCopyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
	StringBuffer buf= new StringBuffer();
	for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
		CallLocation location= (CallLocation) iterator.next();
		buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
		buf.append('\n');
	}
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	try {
		fClipboard.setContents(
				new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
				new Transfer[]{ plainTextTransfer });
	} catch (SWTError e){
		if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
			throw e;
		if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
			run();
	}
}
 
Example 5
Source File: BeansEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean handleDirtyConflict() {
	return
		MessageDialog.openQuestion
			(getSite().getShell(),
			 getString("_UI_FileConflict_label"),
			 getString("_WARN_FileConflict"));
}
 
Example 6
Source File: EngineStatusHandler.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object handleStatus(IStatus status, Object source)
		throws CoreException {
	HybridMobileStatus  hs = (HybridMobileStatus) status;
	
	final boolean open = MessageDialog.openQuestion(AbstractStatusHandler.getShell(), "Missing or incomplete Hybrid Mobile Engine", 
			NLS.bind("{0} \n\nWould you like to modify Hybrid Mobile Engine preferences to correct this issue?",hs.getMessage() ));
	
	if(open){
		PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), hs.getProject(), 
				EnginePropertyPage.PAGE_ID, new String[]{EnginePropertyPage.PAGE_ID}, null);
		return (dialog != null && dialog.open() == Window.OK)? Boolean.TRUE: Boolean.FALSE; 
	}
	return Boolean.FALSE;
}
 
Example 7
Source File: FileChooser.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static File selectForPath(String path) {
	File file = new File(path);
	if (!file.exists() || file.isDirectory())
		return file;
	boolean write = MessageDialog.openQuestion(UI.shell(),
			M.FileAlreadyExists, M.OverwriteFileQuestion);
	if (write)
		return file;
	return null;
}
 
Example 8
Source File: MainView.java    From mappwidget with Apache License 2.0 5 votes vote down vote up
protected boolean checkDir(Composite parent, String dir, String name)
{
	String sign = "";

	if (!dir.endsWith("\\"))
	{
		sign = "\\";
	}

	String fileName = dir + sign + name;
	File file = new File(fileName);

	if (file.exists())
	{
		boolean answer = MessageDialog.openQuestion(parent.getShell(), ATTENTION, "Directory \"" + fileName + "\""
				+ " already exist. Do you want to continue(its will remove old files!)?");

		if (answer)
		{
			FileUtils.deleteDir(file);
		}

		return answer;
	}

	return true;
}
 
Example 9
Source File: DeleteConnection.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    logger.info ( "Execute command: {}", event ); //$NON-NLS-1$

    final Collection<ConnectionHolder> connections = getConnections ();

    final boolean result = MessageDialog.openQuestion ( getWorkbenchWindow ().getShell (), Messages.DeleteConnection_MessageDialog_Title, MessageFormat.format ( Messages.DeleteConnection_MessageDialog_Message, connections.size () ) );
    if ( !result )
    {
        // user pressed "NO"
        return null;
    }

    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, Messages.DeleteConnection_MultiStatus_Text, null );

    for ( final ConnectionHolder holder : connections )
    {
        final ConnectionStore store = AdapterHelper.adapt ( holder.getDiscoverer (), ConnectionStore.class );
        if ( store != null )
        {
            try
            {
                store.remove ( holder.getConnectionInformation () );
            }
            catch ( final CoreException e )
            {
                logger.info ( "Failed to remove connection", e ); //$NON-NLS-1$
                status.add ( e.getStatus () );
            }
        }
    }

    return null;
}
 
Example 10
Source File: AbstractOpenWizardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens the new project dialog if the workspace is empty. This method is called on {@link #run()}.
 * @param shell the shell to use
 * @return returns <code>true</code> when a project has been created, or <code>false</code> when the
 * new project has been canceled.
 */
protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell shell) {
	IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
	if (workspaceRoot.getProjects().length == 0) {
		String title= NewWizardMessages.AbstractOpenWizardAction_noproject_title;
		String message= NewWizardMessages.AbstractOpenWizardAction_noproject_message;
		if (MessageDialog.openQuestion(shell, title, message)) {
			new NewProjectAction().run();
			return workspaceRoot.getProjects().length != 0;
		}
		return false;
	}
	return true;
}
 
Example 11
Source File: RefactoringExecutionStarter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void startChangeSignatureRefactoring(final IMethod method, final SelectionDispatchAction action, final Shell shell) throws JavaModelException {
	if (!RefactoringAvailabilityTester.isChangeSignatureAvailable(method))
		return;
	try {
		ChangeSignatureProcessor processor= new ChangeSignatureProcessor(method);
		RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
		if (status.hasFatalError()) {
			final RefactoringStatusEntry entry= status.getEntryMatchingSeverity(RefactoringStatus.FATAL);
			if (entry.getCode() == RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD || entry.getCode() == RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE) {
				Object element= entry.getData();
				if (element != null) {
					String message= Messages.format(RefactoringMessages.RefactoringErrorDialogUtil_okToPerformQuestion, entry.getMessage());
					if (MessageDialog.openQuestion(shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, message)) {
						IStructuredSelection selection= new StructuredSelection(element);
						// TODO: should not hijack this
						// ModifiyParametersAction.
						// The action is set up on an editor, but we use it
						// as if it were set up on a ViewPart.
						boolean wasEnabled= action.isEnabled();
						action.selectionChanged(selection);
						if (action.isEnabled()) {
							action.run(selection);
						} else {
							MessageDialog.openInformation(shell, ActionMessages.ModifyParameterAction_problem_title, ActionMessages.ModifyParameterAction_problem_message);
						}
						action.setEnabled(wasEnabled);
					}
				}
				return;
			}
		}

		Refactoring refactoring= new ProcessorBasedRefactoring(processor);
		ChangeSignatureWizard wizard= new ChangeSignatureWizard(processor, refactoring);
		new RefactoringStarter().activate(wizard, shell, wizard.getDefaultPageTitle(), RefactoringSaveHelper.SAVE_REFACTORING);
	} catch (CoreException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.RefactoringStarter_unexpected_exception);
	}
}
 
Example 12
Source File: DartPreferencePage.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean performOk() {

	boolean ok = super.performOk();
	if (getPreferenceStore().getBoolean(GlobalConstants.P_FLUTTER_ENABLED)) {
		ok = flutterSDKLocationFieldEditor.doCheckState();
	} else {
		ok = dartSDKLocationEditor.doCheckState();
	}
	if (!ok) {
		setValid(false);
		setErrorMessage(Messages.Preference_SDKNotFound_Message);
		return false;
	}

	boolean result = MessageDialog.openQuestion(null, Messages.Preference_RestartRequired_Title,
			Messages.Preference_RestartRequired_Message);

	if (result) {
		try {
			// Manually save the preference store since it doesn't seem to happen when
			// restarting the IDE in the following step.
			save();
		} catch (IOException e) {
			LOG.log(DartLog.createError("Could not save IDE preferences", e)); //$NON-NLS-1$
		}

		Display.getDefault().asyncExec(() -> {
			PlatformUI.getWorkbench().restart(true);
		});
	}
	return ok;
}
 
Example 13
Source File: RelvarDesignerComposite.java    From Rel with Apache License 2.0 5 votes vote down vote up
public boolean hasPendingChanges() {
	if (hasPendingChanges)
		if (MessageDialog.openQuestion(getShell(), "Discard Pending Changes?",
				"There are unapplied changes in the '" + tabIdentifier + "' tab. Discard them?"))
			return false;
	return hasPendingChanges;
}
 
Example 14
Source File: CoreEditor.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean handleDirtyConflict() {
	return
		MessageDialog.openQuestion
			(getSite().getShell(),
			 getString("_UI_FileConflict_label"),
			 getString("_WARN_FileConflict"));
}
 
Example 15
Source File: ImportSelectedTemplateCommand.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	IWorkbenchPage activePage =
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	TextTemplateView textTemplateView =
		(TextTemplateView) activePage.findView(TextTemplateView.ID);
	
	TextTemplate textTemplate = getSelectedTextTemplate(event);
	if (textTemplate == null) {
		logger.warn("No TextTemplate selected - skipping template import");
		return null;
	}
	
	ITextPlugin plugin = textTemplateView.getActiveTextPlugin();
	if (plugin == null) {
		logger.warn("No TextPlugin found - skipping text template import");
		return null;
	}
	
	try {
		String mimeType = plugin.getMimeType();
		FileDialog fdl = new FileDialog(UiDesk.getTopShell());
		fdl.setFilterExtensions(new String[] {
			MimeTypeUtil.getExtensions(mimeType)
		});
		fdl.setFilterNames(new String[] {
			MimeTypeUtil.getPrettyPrintName(mimeType)
		});
		
		String filename = fdl.open();
		if (filename != null) {
			File file = new File(filename);
			if (file.exists()) {
				FileInputStream fis = new FileInputStream(file);
				byte[] contentToStore = new byte[(int) file.length()];
				fis.read(contentToStore);
				fis.close();
				
				List<Brief> existing = TextTemplate.findExistingTemplates(
					textTemplate.isSystemTemplate(),
					textTemplate.getName(), (String) null,
					textTemplate.getMandant() != null ? textTemplate.getMandant().getId() : "");
				if(!existing.isEmpty()) {
					if (MessageDialog.openQuestion(HandlerUtil.getActiveShell(event),
						"Vorlagen existieren",
						String.format(
							"Sollen die (%d) existierenden %s Vorlagen überschrieben werden?",
							existing.size(), textTemplate.getName()))) {
						for (Brief brief : existing) {
							brief.delete();
						}
					}
				}
				
				Brief bTemplate = new Brief(textTemplate.getName(), null, CoreHub.getLoggedInContact(),
					textTemplate.getMandant(), null, Brief.TEMPLATE);
				if (textTemplate.isSystemTemplate()) {
					bTemplate.set(Brief.FLD_KONSULTATION_ID, Brief.SYS_TEMPLATE);
					textTemplate.addSystemTemplateReference(bTemplate);
				} else {
					textTemplate.addFormTemplateReference(bTemplate);
				}
				bTemplate.save(contentToStore, plugin.getMimeType());
				textTemplateView.update(textTemplate);
			}
		}
	} catch (Throwable ex) {
		ExHandler.handle(ex);
	}
	ElexisEventDispatcher.getInstance().fire(new ElexisEvent(Brief.class, null,
		ElexisEvent.EVENT_RELOAD, ElexisEvent.PRIORITY_NORMAL));
	return null;
}
 
Example 16
Source File: Messages.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public static boolean question(final String title, final String message) {
	return MessageDialog.openQuestion(WorkbenchHelper.getShell(), title, message);
}
 
Example 17
Source File: AccessRulesDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
final void doErrorWarningLinkPressed() {
	if (fParentCanSwitchPage && MessageDialog.openQuestion(getShell(), NewWizardMessages.AccessRulesDialog_switch_dialog_title, NewWizardMessages.AccessRulesDialog_switch_dialog_message)) {
        setReturnCode(SWITCH_PAGE);
		close();
	}
}
 
Example 18
Source File: ComponentEditor.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean handleDirtyConflict ()
{
    return MessageDialog.openQuestion ( getSite ().getShell (), getString ( "_UI_FileConflict_label" ), //$NON-NLS-1$
    getString ( "_WARN_FileConflict" ) ); //$NON-NLS-1$
}
 
Example 19
Source File: MemoryEditor.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean handleDirtyConflict ()
{
    return MessageDialog.openQuestion ( getSite ().getShell (), getString ( "_UI_FileConflict_label" ), getString ( "_WARN_FileConflict" ) );
}
 
Example 20
Source File: SetupEditor.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean handleDirtyConflict ()
{
    return MessageDialog.openQuestion ( getSite ().getShell (), getString ( "_UI_FileConflict_label" ), //$NON-NLS-1$
    getString ( "_WARN_FileConflict" ) ); //$NON-NLS-1$
}