类org.eclipse.ui.ide.undo.WorkspaceUndoUtil源码实例Demo

下面列出了怎么用org.eclipse.ui.ide.undo.WorkspaceUndoUtil的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public boolean performFinish() {
  retrieveConfigurationValues();

  // todo set up
  IAdaptable uiInfoAdapter = WorkspaceUndoUtil.getUIInfoAdapter(getShell());
  CreateAppEngineWtpProject runnable =
      getAppEngineProjectCreationOperation(config, uiInfoAdapter);

  try {
    boolean fork = true;
    boolean cancelable = true;
    getContainer().run(fork, cancelable, runnable);

    // open most important file created by wizard in editor
    IFile file = runnable.getMostImportant();
    WorkbenchUtil.openInEditor(workbench, file);
    return true;
  } catch (InterruptedException | InvocationTargetException ex) {
    String message = Messages.getString("project.creation.failed"); //$NON-NLS-1$
    StatusUtil.setErrorStatus(this, message, ex);
    return false;
  }
}
 
源代码2 项目: gama   文件: RenameResourceAction.java
@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);
					}
				}
			}
		}
	};
}
 
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);
						}
					}
				}
			}
		}
	};
}
 
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);
						}
					}
				}
			}
		}
	};
}
 
 类所在包
 类方法
 同包方法