• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WorkspaceUndoUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.ui.ide.undo.WorkspaceUndoUtil的典型用法代码示例。如果您正苦于以下问题:Java WorkspaceUndoUtil类的具体用法?Java WorkspaceUndoUtil怎么用?Java WorkspaceUndoUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WorkspaceUndoUtil类属于org.eclipse.ui.ide.undo包,在下文中一共展示了WorkspaceUndoUtil类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createNewFolder

import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; //导入依赖的package包/类
/**
 * Creates a new folder resource in the selected container and with the
 * selected name. Creates any missing resource containers along the path;
 * does nothing if the container resources already exist.
 * <p>
 * In normal usage, this method is invoked after the user has pressed Finish
 * on the wizard; the enablement of the Finish button implies that all
 * controls on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new folder once it has been successfully
 * created; subsequent invocations of this method will answer the same
 * folder resource without attempting to create it again.
 * </p>
 * <p>
 * This method should be called within a workspace modify operation since it
 * creates resources.
 * </p>
 * 
 * @return the created folder resource, or <code>null</code> if the folder
 *         was not created
 */
public IFolder createNewFolder(String containerName, String folderName, IProgressMonitor monitor) {
	// create the new folder and cache it if successful
	final IPath containerPath = new Path(containerName);
	IPath newFolderPath = containerPath.append(folderName);

	final IFolder newFolderHandle = createFolderHandle(newFolderPath);
		AbstractOperation op;
		op = new CreateFolderOperation(newFolderHandle, null, false, null, "New Folder");
		try {
			op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
		} catch (final ExecutionException e) {
			getContainer().getShell().getDisplay().syncExec(
					new Runnable() {
						public void run() {
							if (e.getCause() instanceof CoreException) {
								ErrorDialog.openError(getContainer().getShell(), "Creation Problems", null, ((CoreException) e.getCause()).getStatus());
							} else {
								MessageDialog.openError(getContainer().getShell(), "Creation problems", NLS.bind("Eclipse Internal error: {0}", e.getCause().getMessage()));
							}
						}
					});
		}
	return newFolderHandle;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:47,代码来源:TranslateBundleWizard.java


示例2: createOperation

import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; //导入依赖的package包/类
@Override
protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return monitor -> {
		final IResource[] resources = getActionResources().toArray(new IResource[getActionResources().size()]);
		// Rename is only valid for a single resource. This has already
		// been validated.
		if (resources.length == 1) {
			// check for overwrite
			final IWorkspaceRoot workspaceRoot = resources[0].getWorkspace().getRoot();
			final IResource newResource = workspaceRoot.findMember(newPath);
			boolean go = true;
			if (newResource != null) {
				go = checkOverwrite(WorkbenchHelper.getShell(), newResource);
			}
			if (go) {
				final MoveResourcesOperation op = new MoveResourcesOperation(resources[0], newPath,
						IDEWorkbenchMessages.RenameResourceAction_operationTitle);
				op.setModelProviderIds(getModelProviderIds());
				try {
					PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor,
							WorkspaceUndoUtil.getUIInfoAdapter(WorkbenchHelper.getShell()));
				} catch (final ExecutionException e) {
					if (e.getCause() instanceof CoreException) {
						errorStatus[0] = ((CoreException) e.getCause()).getStatus();
					} else {
						errorStatus[0] = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, getProblemsMessage(), e);
					}
				}
			}
		}
	};
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:33,代码来源:RenameResourceAction.java


示例3: createOperation

import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; //导入依赖的package包/类
protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) {
			IResource[] resources = (IResource[]) getActionResources()
					.toArray(new IResource[getActionResources().size()]);
			// Rename is only valid for a single resource. This has already
			// been validated.
			if (resources.length == 1) {
				// check for overwrite
				IWorkspaceRoot workspaceRoot = resources[0].getWorkspace()
						.getRoot();
				IResource newResource = workspaceRoot.findMember(newPath);
				boolean go = true;
				if (newResource != null) {
					go = checkOverwrite(shellProvider.getShell(), newResource);
				}
				if (go) {
					MoveResourcesOperation op = new MoveResourcesOperation(
							resources[0],
							newPath,
							IDEWorkbenchMessages.RenameResourceAction_operationTitle);
					op.setModelProviderIds(getModelProviderIds());
					try {
						PlatformUI
								.getWorkbench()
								.getOperationSupport()
								.getOperationHistory()
								.execute(
										op,
										monitor,
										WorkspaceUndoUtil
												.getUIInfoAdapter(shellProvider.getShell()));
					} catch (ExecutionException e) {
						if (e.getCause() instanceof CoreException) {
							errorStatus[0] = ((CoreException) e.getCause())
									.getStatus();
						} else {
							errorStatus[0] = new Status(IStatus.ERROR,
									PlatformUI.PLUGIN_ID,
									getProblemsMessage(), e);
						}
					}
				}
			}
		}
	};
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:48,代码来源:RenameResourceAndCloseEditorAction.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GraphQLTypeReference类代码示例发布时间:2022-05-21
下一篇:
Java AnnotationTypeDoc类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap