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


Java IDEWorkbenchMessages.RenameResourceAction_nameExists方法代码示例

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


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

示例1: queryNewResourceName

import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; //导入方法依赖的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: queryNewResourceName

import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; //导入方法依赖的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

示例3: queryNewResourceName

import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; //导入方法依赖的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


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