当前位置: 首页>>代码示例>>Java>>正文


Java InputDialog.setBlockOnOpen方法代码示例

本文整理汇总了Java中org.eclipse.jface.dialogs.InputDialog.setBlockOnOpen方法的典型用法代码示例。如果您正苦于以下问题:Java InputDialog.setBlockOnOpen方法的具体用法?Java InputDialog.setBlockOnOpen怎么用?Java InputDialog.setBlockOnOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.dialogs.InputDialog的用法示例。


在下文中一共展示了InputDialog.setBlockOnOpen方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: queryNewResourceName

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * Return the new name to be given to the target resource.
 *
 * @return java.lang.String
 * @param resource
 *            the resource to query status on
 */
protected String queryNewResourceName(final IResource resource) {
	final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
	final IPath prefix = resource.getFullPath().removeLastSegments(1);
	final IInputValidator validator = string -> {
		if (resource.getName()
				.equals(string)) { return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent; }
		final IStatus status = workspace.validateName(string, resource.getType());
		if (!status.isOK()) { return status.getMessage(); }
		if (workspace.getRoot()
				.exists(prefix.append(string))) { return IDEWorkbenchMessages.RenameResourceAction_nameExists; }
		return null;
	};

	final InputDialog dialog =
			new InputDialog(WorkbenchHelper.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
					IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
	dialog.setBlockOnOpen(true);
	final int result = dialog.open();
	if (result == Window.OK)
		return dialog.getValue();
	return null;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:30,代码来源:RenameResourceAction.java

示例2: promptForCommitInsideDisplayThread

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
private static void promptForCommitInsideDisplayThread(Shell shell, Optional<String> name) {
    InputDialog dialog = new InputDialog(
            shell, "Commit Message", "Please enter a commit message"
                    + name.map(n -> " for the diagram: " + n).orElse(StringUtils.EMPTY) + ".",
            StringUtils.EMPTY, EditorLauncherBase::isValidCommitMessage);
    dialog.setBlockOnOpen(true);
    if (dialog.open() != InputDialog.OK) {
        return;
    }
    String commitMessage = dialog.getValue();
    try {
        transformationManager.handleEditorMerge(commitMessage);
    } catch (CommitException e) {
        LOGGER.error("Failed to merge branch into master.", e);
        ErrorDialog.openError(shell, "Commit failed",
                "The requested commit failed. "
                        + "The changes stay in the temporary branch but will not appear on the master branch.",
                new Status(Status.ERROR, null, "Merging of branches failed.", e));
    }
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:21,代码来源:EditorLauncherBase.java

示例3: openAskInt

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
public static Integer openAskInt(String title, String message, int initial) {
    Shell shell = EditorUtils.getShell();
    String initialValue = "" + initial;
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText.length() == 0) {
                return "At least 1 char must be provided.";
            }
            try {
                Integer.parseInt(newText);
            } catch (Exception e) {
                return "A number is required.";
            }
            return null;
        }
    };
    InputDialog dialog = new InputDialog(shell, title, message, initialValue, validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return Integer.parseInt(dialog.getValue());
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:26,代码来源:DialogHelpers.java

示例4: queryNewResourceName

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * Return the new name to be given to the target resource.
 * 
 * @return java.lang.String
 * @param resource
 *            the resource to query status on
 */
protected String queryNewResourceName(final IResource resource) {
	final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
	final IPath prefix = resource.getFullPath().removeLastSegments(1);
	IInputValidator validator = new IInputValidator() {
		public String isValid(String string) {
			if (resource.getName().equals(string)) {
				return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
			}
			IStatus status = workspace.validateName(string, resource
					.getType());
			if (!status.isOK()) {
				return status.getMessage();
			}
			if (workspace.getRoot().exists(prefix.append(string))) {
				return IDEWorkbenchMessages.RenameResourceAction_nameExists;
			}
			return null;
		}
	};

	InputDialog dialog = new InputDialog(shellProvider.getShell(),
			IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
			IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage,
			resource.getName(), validator);
	dialog.setBlockOnOpen(true);
	int result = dialog.open();
	if (result == Window.OK)
		return dialog.getValue();
	return null;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:38,代码来源:RenameResourceAndCloseEditorAction.java

示例5: widgetSelected

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * Add a certificate specified by the user.
 * 
 * @param event
 *            selection event
 */
public void widgetSelected(SelectionEvent event) {
	FileDialog fileDialog = new FileDialog(Display.getCurrent().getActiveShell());
	fileDialog.open();
	if (!fileDialog.getFileName().equals("")) {
		String location = fileDialog.getFilterPath() + System.getProperty("file.separator")
			+ fileDialog.getFileName();

		InputDialog inputDialog = new InputDialog(Display.getCurrent().getActiveShell(),
			"Select certificate designation",
			"Please choose a designation for the previously selected certificate: ", "", null);

		inputDialog.setBlockOnOpen(true);
		if (inputDialog.open() != Window.OK) {
			return;
		}

		String alias = inputDialog.getValue();
		if (alias.equals("")) {
			alias = "unnamed:" + EcoreUtil.generateUUID();
		}

		try {
			KeyStoreManager.getInstance().addCertificate(alias, location);
		} catch (final ESCertificateException e) {
			setErrorMessage(e.getMessage());
		}

		try {
			setListElements(KeyStoreManager.getInstance().getCertificates().toArray());
		} catch (ESCertificateException e1) {
			setErrorMessage(e1.getMessage());
		}
	}
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:41,代码来源:CertificateSelectionDialog.java

示例6: openInputRequest

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
public static String openInputRequest(String title, String message, Shell shell, IInputValidator validator) {
    if (shell == null) {
        shell = EditorUtils.getShell();
    }
    String initialValue = "";
    InputDialog dialog = new InputDialog(shell, title, message, initialValue, validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return dialog.getValue();
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:13,代码来源:DialogHelpers.java

示例7: queryNewResourceName

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * Return the new name to be given to the target resource.
 *
 * @return java.lang.String
 * @param resource the resource to query status on
 *
 * Fix from platform: was not checking return from dialog.open
 */
@Override
protected String queryNewResourceName(final IResource resource) {
    final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
    final IPath prefix = resource.getFullPath().removeLastSegments(1);
    IInputValidator validator = new IInputValidator() {
        @Override
        public String isValid(String string) {
            if (resource.getName().equals(string)) {
                return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
            }
            IStatus status = workspace.validateName(string, resource.getType());
            if (!status.isOK()) {
                return status.getMessage();
            }
            if (workspace.getRoot().exists(prefix.append(string))) {
                return IDEWorkbenchMessages.RenameResourceAction_nameExists;
            }
            return null;
        }
    };

    InputDialog dialog = new InputDialog(shell, IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
            IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return dialog.getValue();
    } else {
        return null;
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:39,代码来源:PyRenameResourceAction.java

示例8: askInput

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * ask the user for some text input, and block until it has been provided
 * @param title
 * @param message
 * @return the users input, or null if cancelled
 */
public static String askInput(String title, String message)
{
	InputDialog dialog = new InputDialog(getShell(),title, message,null,null);
	dialog.setBlockOnOpen(true);
	dialog.open();
	String input = dialog.getValue();
	if (dialog.getReturnCode() == Window.CANCEL) input = null;
	return input;
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:16,代码来源:WorkBenchUtil.java

示例9: execute

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	/*
	 * No parameter try to get it from active navigator if any
	 */
	final IWorkbenchPage activePage = UIHelper.getActivePage();
	if (activePage != null) {
		final ISelection selection = activePage.getSelection(ToolboxExplorer.VIEW_ID);
		if (selection != null && selection instanceof IStructuredSelection) {
			// handler is set up to only allow single selection in
			// plugin.xml -> no need to handle multi selection
			final Spec spec = (Spec) ((IStructuredSelection) selection).getFirstElement();

			// name proposal
			String specName = spec.getName() + "_Copy";

			// dialog that prompts the user for the new spec name (no need
			// to join UI thread, this is the UI thread)
			final InputDialog dialog = new InputDialog(UIHelper.getShell(), "New specification name",
					"Please input the new name of the specification", specName, new SpecNameValidator());
			dialog.setBlockOnOpen(true);
			if (dialog.open() == Window.OK) {
				final WorkspaceSpecManager specManager = Activator.getSpecManager();
				
				// close open spec before it gets renamed
				reopenEditorAfterRename = false;
				if (specManager.isSpecLoaded(spec)) {
					UIHelper.runCommand(CloseSpecHandler.COMMAND_ID, new HashMap<String, String>());
					reopenEditorAfterRename = true;
				}
				
				// use confirmed rename -> rename
				final Job j = new ToolboxJob("Renaming spec...") {
					protected IStatus run(final IProgressMonitor monitor) {
						// do the actual rename
						specManager.renameSpec(spec, dialog.getValue(), monitor);
						
						// reopen editor again (has to happen in UI thread)
						UIHelper.runUIAsync(new Runnable() {
							/* (non-Javadoc)
							 * @see java.lang.Runnable#run()
							 */
							public void run() {
								if (reopenEditorAfterRename) {
									Map<String, String> parameters = new HashMap<String, String>();
									parameters.put(OpenSpecHandler.PARAM_SPEC, dialog.getValue());
									UIHelper.runCommand(OpenSpecHandler.COMMAND_ID, parameters);
								}
							}
						});
						return Status.OK_STATUS;
					}
				};
				j.schedule();
			}
		}
	}
	return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:59,代码来源:RenameSpecHandler.java

示例10: execute

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException
 {
     final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
     if (selection != null && selection instanceof IStructuredSelection)
     {
         // model file
         final Model model = (Model) ((IStructuredSelection) selection).getFirstElement();

         // a) fail if model is in use
if (model.isRunning()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename models",
			"Could not rename the model " + model.getName()
					+ ", because it is being model checked.");
	return null;
}
if (model.isSnapshot()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename model",
			"Could not rename the model " + model.getName()
					+ ", because it is a snapshot.");
	return null;
}

         // b) open dialog prompting for new model name
         final IInputValidator modelNameInputValidator = new ModelNameValidator(model.getSpec());
         final InputDialog dialog = new InputDialog(UIHelper.getShell(), "Rename model...",
                 "Please input the new name of the model", model.getName(), modelNameInputValidator);
         dialog.setBlockOnOpen(true);
         if(dialog.open() == Window.OK) {
         	// c) close model editor if open
             final IEditorPart editor = model.getAdapter(ModelEditor.class);
             if(editor != null) {
             	reopenModelEditorAfterRename = true;
             	UIHelper.getActivePage().closeEditor(editor, true);
             }
             
             final Job j = new ToolboxJob("Renaming model...") {
		/* (non-Javadoc)
		 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
		 */
		protected IStatus run(IProgressMonitor monitor) {
			// d) rename
			final String newModelName = dialog.getValue();
			model.rename(newModelName);

			// e) reopen (in UI thread)
            if (reopenModelEditorAfterRename) {
	            UIHelper.runUIAsync(new Runnable(){
					/* (non-Javadoc)
					 * @see java.lang.Runnable#run()
					 */
					public void run() {
						Map<String, String> parameters = new HashMap<String, String>();
						parameters.put(OpenModelHandler.PARAM_MODEL_NAME, newModelName);
						UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
					}
	            });
            }
			return Status.OK_STATUS;
		}
	};
	j.schedule();
         }
     }
     return null;
 }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:66,代码来源:RenameModelHandlerDelegate.java

示例11: execute

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final TLCSpec spec = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class);
	
	Model model = null;
	/*
	 * First try to get the model from the parameters. It is an optional
	 * parameter, so it may not have been set.
	 */
	final String paramModelName = (String) event.getParameter(PARAM_MODEL_NAME);
	if (paramModelName != null) {
		// The name is given which means the user clicked the main menu
		// instead of the spec explorer. Under the constraint that only ever
		// a single spec can be open, lookup the current spec to eventually
		// get the corresponding model.
		model = spec.getModel(paramModelName);
	} else {
		/*
		 * No parameter try to get it from active navigator if any
		 */
		final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
		if (selection != null && selection instanceof IStructuredSelection) {
			// model
			model = (Model) ((IStructuredSelection) selection).getFirstElement();
		}
	}

	if (model != null) {
		final InputDialog dialog = new InputDialog(UIHelper.getShellProvider().getShell(), "Clone model...",
				"Please input the new name of the model", spec.getModelNameSuggestion(model), new ModelNameValidator(spec));
		dialog.setBlockOnOpen(true);
		if (dialog.open() == Window.OK) {
			final String usersChosenName = dialog.getValue();
			if (model.copy(usersChosenName) == null) {
				throw new ExecutionException(
						"Failed to copy with name " + usersChosenName + " from model " + model.getName());
			}

			// Open the previously created model
			final Map<String, String> parameters = new HashMap<String, String>();
			parameters.put(OpenModelHandler.PARAM_MODEL_NAME, usersChosenName);
			UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
		}
	}
	return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:49,代码来源:CloneModelHandlerDelegate.java

示例12: queryNewResourceName

import org.eclipse.jface.dialogs.InputDialog; //导入方法依赖的package包/类
/**
 * Returns the new name to be given to the target resource.
 * 
 * @param container
 *            the container to query status on
 * @return the new name to be given to the target resource.
 */
private String queryNewResourceName( final File container )
{
	final IWorkspace workspace = ResourcesPlugin.getWorkspace( );

	IInputValidator validator = new IInputValidator( ) {

		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
		 */
		public String isValid( String string )
		{
			if ( string == null || string.length( ) <= 0 )
			{
				return Messages.getString( "NewFolderAction.emptyName" ); //$NON-NLS-1$
			}

			File newPath = new File( container, string );

			if ( newPath.exists( ) )
			{
				return Messages.getString( "NewFolderAction.nameExists" ); //$NON-NLS-1$
			}

			IStatus status = workspace.validateName( newPath.getName( ),
					IResource.FOLDER );

			if ( !status.isOK( ) )
			{
				return status.getMessage( );
			}
			return null;
		}
	};

	InputDialog dialog = new InputDialog( getShell( ),
			Messages.getString( "NewFolderAction.inputDialogTitle" ), //$NON-NLS-1$
			Messages.getString( "NewFolderAction.inputDialogMessage" ), //$NON-NLS-1$
			"", //$NON-NLS-1$
			validator );

	dialog.setBlockOnOpen( true );
	int result = dialog.open( );
	if ( result == Window.OK )
	{
		return dialog.getValue( );
	}
	return null;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:58,代码来源:NewFolderAction.java


注:本文中的org.eclipse.jface.dialogs.InputDialog.setBlockOnOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。