Skip to content

Commit

Permalink
#4672 Add context menus to table cells to copy values
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Dec 19, 2024
1 parent 62a212c commit 3eb4284
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void generateDocumentsReference(final ScanResult scanResult) {
.filter(Objects::nonNull)
.filter(docInfo ->
DocumentTypeGroup.SYSTEM != docInfo.group
&& DocumentTypeGroup.STRUCTURE != docInfo.group)
&& DocumentTypeGroup.STRUCTURE != docInfo.group)
.sequential()
.collect(Collectors.groupingBy(DocInfo::group))
.entrySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void testCreateTree() {
explorerTreeDao.addChild(c1, newTreePojo("C11"));

// Check create model.
explorerTreeDao.createModel(type -> null, 0, System.currentTimeMillis());
explorerTreeDao.createModel(0, System.currentTimeMillis());
}

private ExplorerTreeNode newTreePojo(final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ void testLargeTreePerformance() {
LOGGER.logDurationIfInfoEnabled(() -> {
// Check create model.
explorerTreeDao.createModel(
this::getIcon,
0,
System.currentTimeMillis());
}, "Create model");
Expand Down Expand Up @@ -215,28 +214,11 @@ private void addChildren(final ExplorerTreeNode parent, final int depth, final i
}
}

private ExplorerTreeNode newSystemNode() {
final ExplorerTreeNode explorerTreeNode = new ExplorerTreeNode();
explorerTreeNode.setName(ExplorerConstants.SYSTEM);
explorerTreeNode.setType(ExplorerConstants.SYSTEM_DOC_REF.getType());
explorerTreeNode.setUuid(ExplorerConstants.SYSTEM_DOC_REF.getUuid());
return explorerTreeNode;
}

private ExplorerTreeNode newTreeNode(final String name) {
final ExplorerTreeNode explorerTreeNode = new ExplorerTreeNode();
explorerTreeNode.setName(name);
explorerTreeNode.setType(TYPE_TEST);
explorerTreeNode.setUuid(UUID.randomUUID().toString());
return explorerTreeNode;
}

private SvgImage getIcon(final String type) {
return typeToIconMap.computeIfAbsent(type, k ->
explorerActionHandlers.stream()
.filter(handler -> handler.getDocumentType().getType().equals(k))
.map(handler -> handler.getDocumentType().getIcon())
.findFirst()
.orElse(SvgImage.OK));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class AnalyticsPlugin extends DocumentPlugin<AnalyticRuleDoc> {
AnalyticRuleDoc.DOCUMENT_TYPE,
"Analytic Rule",
SvgImage.DOCUMENT_ANALYTIC_RULE);
public static final ClientDocumentType ANALYTIC_DOCUMENT_TYPE = new ClientDocumentType(
DocumentTypeGroup.SEARCH,
"Analytics",
"Analytics",
SvgImage.DOCUMENT_SEARCHABLE);

private final Provider<AnalyticRulePresenter> editorProvider;
private final RestFactory restFactory;
Expand All @@ -68,6 +73,7 @@ public AnalyticsPlugin(final EventBus eventBus,
this.restFactory = restFactory;

ClientDocumentTypeRegistry.put(DOCUMENT_TYPE);
ClientDocumentTypeRegistry.put(ANALYTIC_DOCUMENT_TYPE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import stroom.svg.shared.SvgImage;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ClientDocumentTypeRegistry {
Expand All @@ -20,8 +22,12 @@ public static ClientDocumentType get(final String type) {
public static SvgImage getIcon(final String type) {
final ClientDocumentType documentType = MAP.get(type);
if (documentType == null) {
return null;
return SvgImage.DOCUMENT_SEARCHABLE;
}
return documentType.getIcon();
}

public static Collection<ClientDocumentType> getTypes() {
return MAP.values();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,10 @@ protected void onBind() {
final ExplorerNodePermissions permissions = documentPermissions.get(explorerNode);
final String type = event.getDocumentType();
if (permissions.hasCreatePermission(type)) {
documentTypeCache.fetch(documentTypes -> {
GwtNullSafe.consume(documentTypes.getDocumentType(type), documentType -> {
final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(type);
if (documentType != null) {
fireShowCreateDocumentDialogEvent(documentType, explorerNode);
});
}, explorerListener);
}
}
}, explorerListener);
}
Expand Down Expand Up @@ -1016,7 +1015,7 @@ private List<Item> createNewMenuItems(final ExplorerNode explorerNode,
return children;
}

private void fireShowCreateDocumentDialogEvent(final DocumentType documentType,
private void fireShowCreateDocumentDialogEvent(final ClientDocumentType documentType,
final ExplorerNode explorerNode) {
final Consumer<ExplorerNode> newDocumentConsumer = newDocNode -> {
final DocRef docRef = newDocNode.getDocRef();
Expand All @@ -1040,14 +1039,14 @@ private void fireShowCreateDocumentDialogEvent(final DocumentType documentType,
private IconMenuItem createIconMenuItemFromDocumentType(
final DocumentType documentType,
final ExplorerNode explorerNode) {

final ClientDocumentType clientDocumentType = ClientDocumentTypeRegistry.get(documentType.getType());
return new IconMenuItem.Builder()
.priority(1)
.icon(documentType.getIcon())
.text(documentType.getDisplayType())
.icon(clientDocumentType.getIcon())
.text(clientDocumentType.getDisplayType())
.command(() ->
fireShowCreateDocumentDialogEvent(documentType, explorerNode))
.action(KeyBinding.getCreateActionByType(documentType.getType()).orElse(null))
fireShowCreateDocumentDialogEvent(clientDocumentType, explorerNode))
.action(KeyBinding.getCreateActionByType(clientDocumentType.getType()).orElse(null))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package stroom.explorer.client.presenter;

import stroom.cell.tickbox.client.TickBoxCell;
import stroom.explorer.shared.DocumentType;
import stroom.document.client.ClientDocumentType;
import stroom.widget.util.client.SvgImageUtil;

import com.google.gwt.cell.client.AbstractCell;
Expand All @@ -11,7 +11,7 @@
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;

public class DocumentTypeCell extends AbstractCell<DocumentType> {
public class DocumentTypeCell extends AbstractCell<ClientDocumentType> {

private static Template template;

Expand Down Expand Up @@ -50,7 +50,7 @@ public DocumentTypeCell(final DocumentTypeSelectionModel selectionModel) {
// }

@Override
public void render(final Context context, final DocumentType item, final SafeHtmlBuilder sb) {
public void render(final Context context, final ClientDocumentType item, final SafeHtmlBuilder sb) {
if (item != null) {
final SafeHtml iconHtml = SvgImageUtil.toSafeHtml(item.getIcon(), "explorerCell-icon");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package stroom.explorer.client.presenter;

import stroom.cell.tickbox.shared.TickBoxState;
import stroom.explorer.shared.DocumentType;
import stroom.document.client.ClientDocumentType;

public interface DocumentTypeSelectionModel {
TickBoxState getState(DocumentType type);

TickBoxState getState(ClientDocumentType type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package stroom.explorer.client.presenter;

import stroom.docref.DocContentMatch;
import stroom.document.client.ClientDocumentType;
import stroom.document.client.ClientDocumentTypeRegistry;
import stroom.explorer.shared.FindInContentResult;
import stroom.widget.util.client.SafeHtmlUtil;
import stroom.widget.util.client.SvgImageUtil;
Expand Down Expand Up @@ -50,10 +52,12 @@ public void render(final Context context, final FindInContentResult value, final
final SafeHtmlBuilder sub = new SafeHtmlBuilder();

// Add icon
if (value.getIcon() != null) {
final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(
value.getDocContentMatch().getDocRef().getType());
if (documentType != null && documentType.getIcon() != null) {
main.append(SvgImageUtil.toSafeHtml(
match.getDocRef().getType(),
value.getIcon(),
documentType.getIcon(),
getCellClassName() + "-icon",
"svgIcon"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package stroom.explorer.client.presenter;

import stroom.docref.DocRef;
import stroom.document.client.ClientDocumentType;
import stroom.document.client.ClientDocumentTypeRegistry;
import stroom.explorer.shared.FindResult;
import stroom.widget.util.client.SafeHtmlUtil;
import stroom.widget.util.client.SvgImageUtil;
Expand Down Expand Up @@ -50,10 +52,11 @@ public void render(final Context context, final FindResult value, final SafeHtml
final SafeHtmlBuilder sub = new SafeHtmlBuilder();

// Add icon
if (value.getIcon() != null) {
final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(docRef.getType());
if (documentType != null && documentType.getIcon() != null) {
main.append(SvgImageUtil.toSafeHtml(
docRef.getType(),
value.getIcon(),
documentType.getIcon(),
getCellClassName() + "-icon",
"svgIcon"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package stroom.explorer.client.presenter;

import stroom.docref.DocRef;
import stroom.document.client.ClientDocumentType;
import stroom.document.client.ClientDocumentTypeRegistry;
import stroom.explorer.shared.FindResult;
import stroom.explorer.shared.FindResultWithPermissions;
import stroom.security.shared.DocumentUserPermissions;
Expand Down Expand Up @@ -58,10 +60,11 @@ public void render(final Context context, final FindResultWithPermissions v, fin
final SafeHtmlBuilder sub = new SafeHtmlBuilder();

// Add icon
if (value.getIcon() != null) {
final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(docRef.getType());
if (documentType != null && documentType.getIcon() != null) {
main.append(SvgImageUtil.toSafeHtml(
docRef.getType(),
value.getIcon(),
documentType.getIcon(),
getCellClassName() + "-icon",
"svgIcon"));
}
Expand Down
Loading

0 comments on commit 3eb4284

Please sign in to comment.