本文整理汇总了Java中org.eclipse.che.ide.resource.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于org.eclipse.che.ide.resource包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
resources[0] = resource;
when(appContext.getResources()).thenReturn(resources);
when(resource.getRelatedProject()).thenReturn(projectOptional);
when(projectOptional.get()).thenReturn(project);
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(Constants.LANGUAGE, singletonList("java"));
when(project.getAttributes()).thenReturn(attributes);
Path projectPath = Path.valueOf("/name");
when(project.getLocation()).thenReturn(projectPath);
}
示例2: render
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Override
public Element render(
final Node node, final String domID, final Tree.Joint joint, final int depth) {
// Initialize HTML elements.
final Element rootContainer = super.render(node, domID, joint, depth);
final Element nodeContainer = rootContainer.getFirstChildElement();
final Element checkBoxElement = new CheckBox().getElement();
final InputElement checkBoxInputElement =
(InputElement) checkBoxElement.getElementsByTagName("input").getItem(0);
final Path nodePath =
node instanceof ChangedFileNode
? Path.valueOf(node.getName())
: ((ChangedFolderNode) node).getPath();
setCheckBoxState(nodePath, checkBoxInputElement);
setCheckBoxClickHandler(nodePath, checkBoxElement, checkBoxInputElement.isChecked());
// Paste check-box element to node container.
nodeContainer.insertAfter(checkBoxElement, nodeContainer.getFirstChild());
return rootContainer;
}
示例3: trackEditor
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
/**
* Begins to track given editor to sync its content with opened files with the same {@link Path}.
*
* @param editor editor to sync content
*/
@Override
public void trackEditor(EditorPartPresenter editor) {
Path path = editor.getEditorInput().getFile().getLocation();
if (editorGroups.containsKey(path)) {
editorGroups.get(path).addEditor(editor);
} else {
EditorGroupSynchronization group = editorGroupSyncProvider.get();
editorGroups.put(path, group);
group.addEditor(editor);
}
}
示例4: addToIndex
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
private void addToIndex(final GitOutputConsole console) {
Resource[] resources = appContext.getResources();
Path[] paths = new Path[resources.length];
for (int i = 0; i < resources.length; i++) {
Path path = resources[i].getLocation().removeFirstSegments(1);
paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
}
service
.add(appContext.getRootProject().getLocation(), false, paths)
.then(
voidArg -> {
console.print(constant.addSuccess());
notificationManager.notify(constant.addSuccess());
})
.catchError(
error -> {
console.printError(constant.addFailed());
notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
});
}
示例5: intercept
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Override
public final void intercept(Resource resource) {
checkArgument(resource != null, "Null resource occurred");
if (resource.isFolder()) {
final Optional<Project> project = resource.getRelatedProject();
if (project.isPresent() && isJavaProject(project.get())) {
final Path resourcePath = resource.getLocation();
for (Path path : getPaths(project.get(), getAttribute())) {
if (path.equals(resourcePath)) {
resource.addMarker(new SourceFolderMarker(getContentRoot()));
return;
}
}
}
}
}
示例6: dispose
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void dispose(Path path, boolean withChildren) {
checkArgument(path != null, "Null path occurred");
final Path parent = path.segmentCount() == 1 ? Path.ROOT : path.parent();
Resource[] container = memoryCache.get(parent);
if (container != null) {
int index = -1;
for (int i = 0; i < container.length; i++) {
if (container[i].getName().equals(path.lastSegment())) {
index = i;
break;
}
}
if (index != -1) {
int size = container.length;
int numMoved = container.length - index - 1;
if (numMoved > 0) {
System.arraycopy(container, index + 1, container, index, numMoved);
}
container = copyOf(container, --size);
memoryCache.put(parent, container);
}
}
if (memoryCache.containsKey(path)) {
container = memoryCache.remove(path);
if (container != null && withChildren) {
for (Resource resource : container) {
if (resource instanceof Container) {
dispose(resource.getLocation(), true);
}
}
}
}
}
示例7: getResource
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Optional<Resource> getResource(Path path) {
checkArgument(path != null, "Null path occurred");
final Path parent = path.parent();
if (!memoryCache.containsKey(parent)) {
return absent();
}
final Resource[] container = memoryCache.get(parent);
if (container == null) {
return absent();
}
for (Resource resource : container) {
if (resource.getLocation().equals(path)) {
return Optional.of(resource);
}
}
return absent();
}
示例8: pasteSuccessively
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
private Promise<Void> pasteSuccessively(
Promise<Void> promise, Resource[] resources, int position, final Path destination) {
if (position == resources.length) {
return promise;
}
final Resource resource = resources[position];
final Promise<Void> derivedPromise;
if (move) {
derivedPromise =
promise.thenPromise(
ignored -> moveResource(resource, destination.append(resource.getName())));
} else {
derivedPromise =
promise.thenPromise(
ignored -> copyResource(resource, destination.append(resource.getName())));
}
return pasteSuccessively(derivedPromise, resources, ++position, destination);
}
示例9: handleCheckBoxState
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
private void handleCheckBoxState(Path path, boolean isChecked) {
if (isChecked) {
unselected.add(path);
} else {
unselected.remove(path);
}
if (delegate.getAllFiles().contains(path.toString())) {
delegate.onFileNodeCheckBoxValueChanged(path, !isChecked);
}
if (hasSelectedChildren(path) && !hasAllSelectedChildren(path)) {
indeterminate.add(path);
} else {
indeterminate.remove(path);
}
}
示例10: doFindResource
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
private Promise<Optional<Resource>> doFindResource(Path path) {
return ps.getTree(path.parent(), 1, true)
.thenPromise(
treeElement -> {
Resource resource = null;
for (TreeElement nodeElement : treeElement.getChildren()) {
ItemReference reference = nodeElement.getNode();
Resource tempResource = newResourceFrom(reference);
store.register(tempResource);
if (tempResource.isProject()) {
inspectProject(tempResource.asProject());
}
if (tempResource.getLocation().equals(path)) {
resource = tempResource;
eventBus.fireEvent(
new ResourceChangedEvent(new ResourceDeltaImpl(resource, UPDATED)));
}
}
return promises.resolve(Optional.fromNullable(resource));
})
.catchErrorPromise(error -> promises.resolve(absent()));
}
示例11: resolveFQN
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
/**
* Resolves fully qualified name based on base on start point container and end point resource.
*
* <p>Usually as start point there is a source directory and as end point there is a package
* fragment or java file.
*
* @param startPoint the start point container from which fqn should be resolved
* @param endPoint the end point resource to which fqn should be resolved
* @return the resolved fully qualified name
* @throws IllegalArgumentException in case if given arguments are invalid. Reason includes:
* <ul>
* <li>Null source folder occurred
* <li>Null resource occurred
* <li>Given base folder is not prefix of checked resource
* </ul>
*
* @since 4.4.0
*/
public static String resolveFQN(Container startPoint, Resource endPoint) {
checkArgument(startPoint != null, "Null source folder occurred");
checkArgument(endPoint != null, "Null resource occurred");
checkArgument(
startPoint.getLocation().isPrefixOf(endPoint.getLocation()),
"Given base folder is not prefix of checked resource");
Path path = endPoint.getLocation().removeFirstSegments(startPoint.getLocation().segmentCount());
if (isJavaFile(endPoint)) {
final String ext = ((File) endPoint).getExtension();
if (!isNullOrEmpty(ext)) {
final String name = endPoint.getName();
path =
path.removeLastSegments(1).append(name.substring(0, name.length() - ext.length() - 1));
}
}
return path.toString().replace('/', '.');
}
示例12: processDiagnostics
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
public void processDiagnostics(ExtendedPublishDiagnosticsParams diagnosticsMessage) {
EditorPartPresenter openedEditor =
editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getParams().getUri()));
// TODO add markers
if (openedEditor == null) {
return;
}
if (openedEditor instanceof TextEditor) {
TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
DiagnosticCollector collector = (DiagnosticCollector) annotationModel;
String languageServerId = diagnosticsMessage.getLanguageServerId();
collector.beginReporting(languageServerId);
try {
for (Diagnostic diagnostic : diagnosticsMessage.getParams().getDiagnostics()) {
collector.acceptDiagnostic(languageServerId, diagnostic);
}
} finally {
collector.endReporting(languageServerId);
}
}
}
}
示例13: JarFileNode
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Inject
public JarFileNode(
@Assisted JarEntry jarEntry,
@Assisted int libId,
@Assisted Path project,
@Assisted NodeSettings nodeSettings,
JavaResources javaResources,
NodesResources nodesResources,
JavaNavigationService service,
EditorAgent editorAgent,
EventBus eventBus) {
super(jarEntry, nodeSettings);
this.libId = libId;
this.project = project;
this.javaResources = javaResources;
this.nodesResources = nodesResources;
this.service = service;
this.editorAgent = editorAgent;
this.eventBus = eventBus;
getAttributes()
.put(
CUSTOM_BACKGROUND_FILL,
singletonList(Style.theme.projectExplorerReadonlyItemBackground()));
}
示例14: actionPerformed
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
Resource folder = getSelectedItem();
if (folder == null) {
return;
}
Path location = folder.getLocation();
if (location == null) {
return;
}
MutableProjectConfig mutableProjectConfig = new MutableProjectConfig();
mutableProjectConfig.setPath(location.toString());
mutableProjectConfig.setName(folder.getName());
projectConfigWizard.show(mutableProjectConfig);
}
示例15: searchShouldBeSuccessfullyFinished
import org.eclipse.che.ide.resource.Path; //导入依赖的package包/类
@Test
public void searchShouldBeSuccessfullyFinished() throws Exception {
when(view.getPathToSearch()).thenReturn("/search");
when(appContext.getWorkspaceRoot()).thenReturn(workspaceRoot);
when(workspaceRoot.getContainer(nullable(Path.class))).thenReturn(optionalContainerPromise);
when(searchContainer.search(nullable(QueryExpression.class))).thenReturn(searchResultPromise);
when(searchContainer.createSearchQueryExpression(
nullable(String.class), nullable(String.class)))
.thenReturn(queryExpression);
fullTextSearchPresenter.search(SEARCHED_TEXT);
verify(optionalContainerPromise).then(optionalContainerCaptor.capture());
optionalContainerCaptor.getValue().apply(Optional.of(searchContainer));
verify(searchResultPromise).then(searchResultCaptor.capture());
searchResultCaptor.getValue().apply(searchResult);
verify(view, never()).showErrorMessage(anyString());
verify(view).close();
verify(findResultPresenter)
.handleResponse(eq(searchResult), eq(queryExpression), eq(SEARCHED_TEXT));
}