Search in sources :

Example 11 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolver method getSegmentSiblings.

private List<FolderItem> getSegmentSiblings(final Package pkg) {
    final List<FolderItem> result = new ArrayList<>();
    final Package parentPkg = moduleService.resolveParentPackage(pkg);
    if (parentPkg == null) {
        return emptyList();
    }
    final Set<Package> siblings = moduleService.resolvePackages(parentPkg);
    if (siblings != null && !siblings.isEmpty()) {
        for (final Package sibling : siblings) {
            if (!sibling.equals(pkg)) {
                result.add(explorerServiceHelper.toFolderItem(sibling));
            }
        }
    }
    return result;
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package)

Example 12 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class ProjectScreenTestBase method getAssetInfo.

protected AssetInfo getAssetInfo(final String assetPathString, final FolderItemType itemType, final String itemName) {
    final Path assetPath = mock(Path.class);
    doReturn(assetPathString).when(assetPath).toURI();
    final FolderItem asset = mock(FolderItem.class);
    doReturn(itemType).when(asset).getType();
    doReturn(itemName).when(asset).getFileName();
    doReturn(assetPath).when(asset).getItem();
    return new AssetInfo(asset, new Date(), new Date());
}
Also used : Path(org.uberfire.backend.vfs.Path) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) AssetInfo(org.kie.workbench.common.screens.library.api.AssetInfo) Date(java.util.Date)

Example 13 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class ExplorerServiceHelperTest method getPathSegmentsTest.

@Test
public void getPathSegmentsTest() {
    doAnswer(invocationOnMock -> {
        final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
        return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
    }).when(helper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
    Path path = PathFactory.newPath("myproject", "default://master@myproject/src/main/java/org/myproject");
    final List<FolderItem> pathSegments = helper.getPathSegments(path);
    assertEquals(5, pathSegments.size());
    assertEquals("/", pathSegments.get(0).getFileName());
    assertEquals("src", pathSegments.get(1).getFileName());
    assertEquals("main", pathSegments.get(2).getFileName());
    assertEquals("java", pathSegments.get(3).getFileName());
    assertEquals("org", pathSegments.get(4).getFileName());
}
Also used : Path(org.uberfire.backend.vfs.Path) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) Test(org.junit.Test)

Example 14 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverTest method getSegmentSiblingsRootTest.

@Test
public void getSegmentSiblingsRootTest() {
    doAnswer(invocationOnMock -> {
        final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
        return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
    }).when(explorerServiceHelper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
    Path path = PathFactory.newPath("/", "default://master@myproject/");
    final List<FolderItem> siblings = resolver.getSegmentSiblings(path);
    assertEquals(1, siblings.size());
    assertEquals("/", siblings.get(0).getFileName());
}
Also used : Path(org.uberfire.backend.vfs.Path) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) Test(org.junit.Test)

Example 15 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverTest method getSegmentSiblingsTest.

@Test
public void getSegmentSiblingsTest() {
    doAnswer(invocationOnMock -> {
        final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
        return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
    }).when(explorerServiceHelper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
    Path path = PathFactory.newPath("src", "default://master@myproject/src");
    final List<org.uberfire.java.nio.file.Path> mockedSiblings = new ArrayList<>();
    mockedSiblings.add(Paths.convert(path));
    mockedSiblings.add(Paths.convert(PathFactory.newPath("src", "default://master@myproject/pom.xml")));
    doReturn(mockedSiblings).when(resolver).getDirectoryIterator(any(org.uberfire.java.nio.file.Path.class));
    final List<FolderItem> siblings = resolver.getSegmentSiblings(path);
    assertEquals(2, siblings.size());
    assertEquals("src", siblings.get(0).getFileName());
    assertEquals("pom.xml", siblings.get(1).getFileName());
}
Also used : Path(org.uberfire.backend.vfs.Path) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)31 ArrayList (java.util.ArrayList)15 Path (org.uberfire.backend.vfs.Path)14 Test (org.junit.Test)13 Package (org.guvnor.common.services.project.model.Package)8 FolderListing (org.kie.workbench.common.screens.explorer.model.FolderListing)8 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 List (java.util.List)4 Set (java.util.Set)3 Inject (javax.inject.Inject)3 Module (org.guvnor.common.services.project.model.Module)3 FolderItemType (org.kie.workbench.common.screens.explorer.model.FolderItemType)3 ClientResourceType (org.uberfire.client.workbench.type.ClientResourceType)3 Window (com.google.gwt.user.client.Window)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 PostConstruct (javax.annotation.PostConstruct)2 Event (javax.enterprise.event.Event)2