本文整理汇总了Java中org.eclipse.core.internal.resources.Workspace类的典型用法代码示例。如果您正苦于以下问题:Java Workspace类的具体用法?Java Workspace怎么用?Java Workspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Workspace类属于org.eclipse.core.internal.resources包,在下文中一共展示了Workspace类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAdapter
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
ILocationDescriptor res = null;
if (adaptableObject instanceof IMarker) {
final IMarker marker = (IMarker)adaptableObject;
final MarkerManager manager = ((Workspace)ResourcesPlugin.getWorkspace()).getMarkerManager();
try {
final String markerType = marker.getType();
for (IMarkerToLocationDescriptor adapter : ADAPTERS) {
if (manager.isSubtype(markerType, ADAPTER_TYPE.get(adapter))) {
res = adapter.getAdapter(marker);
if (res != null) {
break;
}
}
}
} catch (CoreException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e
.getMessage(), e));
}
}
return res;
}
示例2: UMLFileTreeNode
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* constructor.
*
* @param workspace
* @param path
* @param parentElement
* @param fragment
* @param adapterFactoryContentProvider
*/
public UMLFileTreeNode(IPath pPath, Workspace workspace, EObject obj, Object parentElement, boolean isFragmented,
AdapterFactoryContentProvider propSourceProvider) {
// super(path, workspace);
super(parentElement);
path = pPath;
eobject = obj;
parent = parentElement;
fragment = isFragmented;
propertySourceProvider = propSourceProvider;
if (eobject != null) {
if(!eobject.eResource().isTrackingModification()){
eobject.eResource().setTrackingModification(true);
}
}
// String fragment = EcoreUtil.getURI(eobject).fragment();
// Object object = UMLCacheManager.getInstance().get(UMLCacheManager.RESOURCE_URI_CACHE, fragment);
//
// if (object == null){
// String uriStr = EcoreUtil.getURI(eobject).toString();
// UMLCacheManager.getInstance().put(UMLCacheManager.RESOURCE_URI_CACHE, fragment, uriStr);
// }
}
示例3: postHook
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
public void postHook(IWorkbenchPage page) {
try {
URI newFile = (new File(this.newFilename)).toURI().normalize();
URI workspaceFile = ResourcesPlugin.getWorkspace().getRoot().getLocationURI().normalize();
if (newFile.toString().toLowerCase().startsWith(workspaceFile.toString().toLowerCase())) {
String path = newFile.toString().substring(workspaceFile.toString().length());
path = path.replaceAll("%20", " "); //$NON-NLS-1$ //$NON-NLS-2$
IFile file = (IFile) ((Workspace) ResourcesPlugin.getWorkspace()).newResource(new Path(path), IResource.FILE);
file.getParent().refreshLocal(1, null);
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
if (desc == null)
desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor("xml.xml"); //$NON-NLS-1$
page.openEditor(new FileEditorInput(file), desc.getId());
}
} catch (Exception ex) {
// hide any errors.
}
}
示例4: scheduleBuildIfNecessary
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
* iterable of projects is empty.
*
* @param toUpdate
* an iterable of projects to build.
*/
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder()))
.filter(config -> Iterables.contains(toUpdate, config.getProject()))
.toArray(IBuildConfiguration.class);
if (!Arrays2.isEmpty(projectsToReBuild)) {
new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
}
}
}
示例5: register
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* registers the given {@link IMarkerToLocationDescriptor} for the given marker type.
*
* @param adapter
* the {@link IMarkerToLocationDescriptor}
* @param markerType
* the marker type
*/
public static void register(IMarkerToLocationDescriptor adapter, String markerType) {
ADAPTER_TYPE.put(adapter, markerType);
final MarkerManager manager = ((Workspace)ResourcesPlugin.getWorkspace()).getMarkerManager();
int i = 0;
for (IMarkerToLocationDescriptor registeredAdapter : ADAPTERS) {
if (manager.isSubtype(markerType, ADAPTER_TYPE.get(registeredAdapter))) {
break;
}
i++;
}
ADAPTERS.add(i, adapter);
}
示例6: createFile
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
private static File createFile(IPath workspaceRelativeAbsPathOfFile, String contents) throws CoreException {
// TODO: Convert to ResouceUtils.createFile
Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
File file = (File) workspace.newResource(workspaceRelativeAbsPathOfFile, IResource.FILE);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(contents.getBytes());
file.create(byteArrayInputStream, false, null);
JobsUtilities.waitForIdle();
return file;
}
示例7: syncBuild
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* Synchronous run of a builder with the given name on the given project.
*
* @param project
* @param kind
* See {@link IncrementalProjectBuilder} for the available types.
* @param builderName
* @param args
* @param monitor
* @return A status indicating if the build succeeded or failed
*/
public static IStatus syncBuild(IProject project, int kind, String builderName, Map args, IProgressMonitor monitor)
{
try
{
IWorkspace workspace = ResourcesPlugin.getWorkspace();
BuildManager buildManager = ((Workspace) workspace).getBuildManager();
return buildManager.build(new BuildConfiguration(project), kind, builderName, args, monitor);
}
catch (IllegalStateException e)
{
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, "Error while getting the Workspace", e); //$NON-NLS-1$
}
}
示例8: doBuild
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* Like the super implementation, except the build is not triggered if
* both toBeDeleted and toBeUpdated are empty. {@inheritDoc}
*/
@SuppressWarnings("nls")
@Override
protected void doBuild(final ToBeBuilt toBeBuilt, final IProgressMonitor monitor, final BuildType type) throws CoreException {
if (toBeBuilt.getToBeDeleted().size() != 0 || toBeBuilt.getToBeUpdated().size() != 0) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Starting " + type.name() + " build:" + "\ndeleted(" + toBeBuilt.getToBeDeleted().size() + ")=" + toBeBuilt.getToBeDeleted().toString()
+ "\nupdated(" + toBeBuilt.getToBeUpdated().size() + ")=" + toBeBuilt.getToBeUpdated().toString());
}
SubMonitor progress = SubMonitor.convert(monitor, 1 + 1 + 1); // build + participant + rebuild
ResourceSet resourceSet = getResourceSetProvider().get(getProject());
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
if (resourceSet instanceof ResourceSetImpl) {
((ResourceSetImpl) resourceSet).setURIResourceMap(Maps.<URI, Resource> newHashMap());
}
BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData);
ImmutableList<Delta> deltas = builderState.update(buildData, progress.newChild(1));
if (participant != null) {
final BuildContext buildContext = new BuildContext(this, resourceSet, deltas, type);
// remember the current workspace tree
final ElementTree oldTree = ((Workspace) ResourcesPlugin.getWorkspace()).getElementTree();
oldTree.immutable();
participant.build(buildContext, progress.newChild(1));
if (buildContext.isRebuildRequired() && rebuilds++ <= 2) {
final ElementTree newTree = ((Workspace) ResourcesPlugin.getWorkspace()).getElementTree();
newTree.immutable();
final ResourceDelta generatedDelta = ResourceDeltaFactory.computeDelta((Workspace) ResourcesPlugin.getWorkspace(), oldTree, newTree, getProject().getFullPath(), -1);
// rebuild the generated delta
ResourcesPlugin.getWorkspace().checkpoint(false);
incrementalBuild(generatedDelta, progress.newChild(1));
}
} else {
progress.worked(2);
}
resourceSet.getResources().clear();
resourceSet.eAdapters().clear();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Build done.");
}
} else if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Ignoring empty " + type.name() + " build.");
}
}
示例9: saveServerConfigurations
import org.eclipse.core.internal.resources.Workspace; //导入依赖的package包/类
/**
* Save state of server configurations
*/
public void saveServerConfigurations()
{
new DelayedSnapshotJob(((Workspace) ResourcesPlugin.getWorkspace()).getSaveManager()).schedule();
}