use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.
the class CubaFoldersPane method collapseItemInTree.
protected void collapseItemInTree(Tree tree, final String foldersCollapse) {
String s = userSettingService.loadSetting(foldersCollapse);
List<UUID> idFolders = strToIds(s);
// noinspection unchecked, RedundantCast
for (AbstractSearchFolder folder : (Collection<AbstractSearchFolder>) tree.getItemIds()) {
if (idFolders.contains(folder.getId())) {
tree.collapseItem(folder);
}
}
tree.addExpandListener(new Tree.ExpandListener() {
@Override
public void nodeExpand(Tree.ExpandEvent event) {
if (event.getItemId() instanceof AbstractSearchFolder) {
UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
String str = userSettingService.loadSetting(foldersCollapse);
userSettingService.saveSetting(foldersCollapse, removeIdInStr(str, uuid));
}
}
});
tree.addCollapseListener(new Tree.CollapseListener() {
@Override
public void nodeCollapse(Tree.CollapseEvent event) {
if (event.getItemId() instanceof AbstractSearchFolder) {
UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
String str = userSettingService.loadSetting(foldersCollapse);
userSettingService.saveSetting(foldersCollapse, addIdInStr(str, uuid));
}
}
});
}
use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.
the class CubaFoldersPane method createSearchFoldersPane.
protected Component createSearchFoldersPane() {
searchFoldersTree = new CubaTree();
searchFoldersTree.setCubaId("searchFoldersTree");
searchFoldersTree.setSelectable(true);
searchFoldersTree.setItemStyleGenerator(new FolderTreeStyleProvider());
searchFoldersTree.addShortcutListener(new ShortcutListener("applySearchFolder", ShortcutAction.KeyCode.ENTER, (int[]) null) {
@Override
public void handleAction(Object sender, Object target) {
if (target == searchFoldersTree) {
AbstractSearchFolder folder = (AbstractSearchFolder) searchFoldersTree.getValue();
if (folder != null) {
openFolder(folder);
}
}
}
});
List<SearchFolder> searchFolders = foldersService.loadSearchFolders();
searchFoldersRoot = messages.getMainMessage("folders.searchFoldersRoot");
searchFoldersTree.addItemClickListener(new FolderClickListener());
searchFoldersTree.addActionHandler(new SearchFolderActionsHandler());
if (!searchFolders.isEmpty()) {
fillTree(searchFoldersTree, searchFolders, isNeedRootSearchFolder() ? searchFoldersRoot : null);
}
for (Object itemId : searchFoldersTree.rootItemIds()) {
searchFoldersTree.expandItemsRecursively(itemId);
}
return searchFoldersTree;
}
use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.
the class FilterDelegateImpl method saveAsFolder.
protected void saveAsFolder(boolean isAppFolder) {
final AbstractSearchFolder folder;
if (isAppFolder)
folder = (metadata.create(AppFolder.class));
else
folder = (metadata.create(SearchFolder.class));
if (filterEntity.getCode() == null) {
String folderName = filterEntity != adHocFilter ? filterEntity.getName() : "";
folder.setName(folderName);
folder.setTabName(folderName);
} else {
String name = messages.getMainMessage(filterEntity.getCode());
folder.setName(name);
folder.setTabName(name);
}
String newXml = filterParser.getXml(conditions, Param.ValueProperty.VALUE);
folder.setFilterComponentId(filterEntity.getComponentId());
folder.setFilterXml(newXml);
if (!isAppFolder) {
if (uerCanEditGlobalFilter())
((SearchFolder) folder).setUser(filterEntity.getUser());
else
((SearchFolder) folder).setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
}
Presentations presentations;
if (applyTo != null && applyTo instanceof HasPresentations) {
final HasPresentations presentationsOwner = (HasPresentations) applyTo;
presentations = presentationsOwner.isUsePresentations() ? presentationsOwner.getPresentations() : null;
} else {
presentations = null;
}
Runnable commitHandler;
if (isAppFolder) {
commitHandler = () -> {
AbstractSearchFolder savedFolder = saveFolder(folder);
filterEntity.setFolder(savedFolder);
};
} else {
commitHandler = () -> {
AbstractSearchFolder savedFolder = saveFolder(folder);
filterEntity.setFolder(savedFolder);
};
}
filterHelper.openFolderEditWindow(isAppFolder, folder, presentations, commitHandler);
}
use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.
the class WebFoldersPane method setupIconGenerator.
protected void setupIconGenerator() {
WebConfig webConfig = beanLocator.get(Configuration.class).getConfig(WebConfig.class);
IconGenerator<AbstractSearchFolder> iconGenerator = !webConfig.getShowFolderIcons() ? NULL_ITEM_ICON_GENERATOR : iconProvider == null ? DEFAULT_ICON_GENERATOR : ICON_GENERATOR;
component.setIconGenerator(iconGenerator);
}
use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.
the class FoldersLinkHandlerProcessor method handle.
@Override
public void handle(ExternalLinkContext linkContext) {
String folderId = linkContext.getRequestParams().get("folder");
AbstractSearchFolder folder = loadFolder(UUID.fromString(folderId));
if (folder != null) {
folders.openFolder(folder);
} else {
log.warn("Folder not found: {}", folderId);
}
}
Aggregations