本文整理汇总了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;
}
示例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;
}
示例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;
}
}