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


Java WorkspaceUndoUtil类代码示例

本文整理汇总了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;未经允许,请勿转载。