use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class BaseBreadcrumbNavigatorTest method testLoadContentFileAndFolder.
@Test
public void testLoadContentFileAndFolder() {
final BreadcrumbNavigator navigator = spy(new BreadcrumbNavigator(activeOptions, hiddenTypeDef, user));
final FolderItem item = new FolderItem(path, "item1", FolderItemType.FILE);
final List<FolderItem> content = new ArrayList<FolderItem>() {
{
add(new FolderItem(mock(Path.class), "File1", FolderItemType.FILE));
add(new FolderItem(mock(Path.class), "Folder1", FolderItemType.FOLDER));
}
};
final List<FolderItem> segments = new ArrayList<FolderItem>();
final FolderListing listing = new FolderListing(item, content, segments);
navigator.loadContent(listing);
verify(navigator).setupBreadcrumb(listing);
verify(navigator).setupUpFolder(listing);
verify(navigator).setupContent(listing);
verify(navigator).showNavigatorPanel();
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class BaseBreadcrumbNavigatorTest method testLoadContentOnlyFolder.
@Test
public void testLoadContentOnlyFolder() {
final BreadcrumbNavigator navigator = spy(new BreadcrumbNavigator(activeOptions, hiddenTypeDef, user));
final FolderItem item = new FolderItem(path, "item1", FolderItemType.FILE);
final List<FolderItem> content = new ArrayList<FolderItem>() {
{
add(new FolderItem(mock(Path.class), "Folder1", FolderItemType.FOLDER));
}
};
final List<FolderItem> segments = new ArrayList<FolderItem>();
final FolderListing listing = new FolderListing(item, content, segments);
navigator.loadContent(listing);
verify(navigator).setupBreadcrumb(listing);
verify(navigator).setupUpFolder(listing);
verify(navigator).setupContent(listing);
verify(navigator).showNavigatorPanel();
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class BreadcrumbNavigator method setupBreadcrumb.
// Package protected for unit-testing
void setupBreadcrumb(final FolderListing content) {
final NavigatorBreadcrumbs navigatorBreadcrumbs = new NavigatorBreadcrumbs(NavigatorBreadcrumbs.Mode.SECOND_LEVEL);
navigatorBreadcrumbs.build(content.getSegments(), content.getItem(), new ParameterizedCommand<FolderItem>() {
@Override
public void execute(final FolderItem item) {
presenter.onActiveFolderItemSelected(item);
}
});
final Panel panel = new Panel();
final PanelBody panelBody = new PanelBody();
panelBody.getElement().getStyle().setPaddingLeft(10, Style.Unit.PX);
panelBody.getElement().getStyle().setPaddingRight(10, Style.Unit.PX);
panelBody.add(navigatorBreadcrumbs);
panel.add(panelBody);
container.add(panel);
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolver method setSiblings.
private void setSiblings(final Content content) {
if (content.getFolderListing().getSegments().size() > 1) {
final ListIterator<FolderItem> li = content.getFolderListing().getSegments().listIterator(content.getFolderListing().getSegments().size());
while (li.hasPrevious()) {
final FolderItem currentItem = li.previous();
final List<FolderItem> result = new ArrayList<>();
result.add(currentItem);
if (currentItem.getItem() instanceof Package) {
result.addAll(getSegmentSiblings((Package) currentItem.getItem()));
} else if (currentItem.getItem() instanceof Path) {
result.addAll(getSegmentSiblings((Path) currentItem.getItem()));
}
content.getSiblings().put(currentItem, result);
}
}
if (content.getSelectedItem() != null && content.getSelectedItem().getType().equals(FolderItemType.FOLDER) && !content.getSiblings().containsKey(content.getSelectedItem())) {
final List<FolderItem> result = new ArrayList<>();
result.add(content.getSelectedItem());
if (content.getSelectedItem().getItem() instanceof Package) {
result.addAll(getSegmentSiblings((Package) content.getSelectedItem().getItem()));
} else if (content.getSelectedItem().getItem() instanceof Path) {
result.addAll(getSegmentSiblings((Path) content.getSelectedItem().getItem()));
}
content.getSiblings().put(content.getSelectedItem(), result);
}
if (content.getFolderListing().getItem().getType().equals(FolderItemType.FOLDER) && !content.getSiblings().containsKey(content.getFolderListing().getItem())) {
final List<FolderItem> result = new ArrayList<>();
result.add(content.getFolderListing().getItem());
if (content.getFolderListing().getItem().getItem() instanceof Package) {
result.addAll(getSegmentSiblings((Package) content.getFolderListing().getItem().getItem()));
} else if (content.getFolderListing().getItem().getItem() instanceof Path) {
result.addAll(getSegmentSiblings((Path) content.getFolderListing().getItem().getItem()));
}
if (!result.isEmpty()) {
content.getSiblings().put(content.getFolderListing().getItem(), result);
}
}
// Sort sibling lists before returning to client
for (Map.Entry<FolderItem, List<FolderItem>> e : content.getSiblings().entrySet()) {
Collections.sort(e.getValue(), Sorters.ITEM_SORTER);
}
}
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;
}
Aggregations