use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ClassifierTest method successfullyFindResourceTypeByFolderItemTest.
@Test
public void successfullyFindResourceTypeByFolderItemTest() {
final FolderItem folderItem = mock(FolderItem.class);
final Path path = mock(Path.class);
doReturn(path).when(folderItem).getItem();
doReturn(true).when(clientResourceType).accept(path);
final ClientResourceType resourceType = classifier.findResourceType(folderItem);
assertNotNull(resourceType);
assertEquals(clientResourceType, resourceType);
}
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 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 ExplorerServiceHelper method store.
public void store(final WorkspaceProject project, final Module selectedModule, final FolderListing folderListing, final Package selectedPackage, final ActiveOptions options) {
final org.uberfire.java.nio.file.Path userNavPath = userServices.buildPath("explorer", "user.nav");
final org.uberfire.java.nio.file.Path lastUserNavPath = userServices.buildPath("explorer", "last.user.nav");
final Module _selectedModule = selectedModule;
final FolderItem _selectedItem = folderListing.getItem();
final org.guvnor.common.services.project.model.Package _selectedPackage;
if (selectedPackage != null) {
_selectedPackage = selectedPackage;
} else if (folderListing.getItem().getItem() instanceof Package) {
_selectedPackage = (Package) folderListing.getItem().getItem();
} else {
_selectedPackage = null;
}
this.executorService.execute(new DescriptiveRunnable() {
@Override
public String getDescription() {
return "Serialize Navigation State";
}
@Override
public void run() {
try {
store(userNavPath, lastUserNavPath, project, _selectedModule, _selectedPackage, _selectedItem, options);
} catch (final Exception e) {
LOGGER.error("Can't serialize user's state navigation", e);
}
}
});
}
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);
}
}
Aggregations