java中注解 onopen_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

​點讚 3

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,

示例2: promptForCommitInsideDisplayThread

​點讚 3

import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類

private static void promptForCommitInsideDisplayThread(Shell shell, Optional 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,

示例3: openAskInt

​點讚 3

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,

示例4: queryNewResourceName

​點讚 2

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,

示例5: widgetSelected

​點讚 2

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,

示例6: openInputRequest

​點讚 2

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,

示例7: queryNewResourceName

​點讚 2

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,

示例8: askInput

​點讚 2

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,

示例9: execute

​點讚 2

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());

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 parameters = new HashMap();

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,

示例10: execute

​點讚 2

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 parameters = new HashMap();

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,

示例11: execute

​點讚 2

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 parameters = new HashMap();

parameters.put(OpenModelHandler.PARAM_MODEL_NAME, usersChosenName);

UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);

}

}

return null;

}

開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:49,

示例12: queryNewResourceName

​點讚 2

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,

注:本文中的org.eclipse.jface.dialogs.InputDialog.setBlockOnOpen方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值