-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the copy of all the cells in histories
- Loading branch information
Showing
10 changed files
with
208 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...gui/src/main/java/com/logicaldoc/gui/common/client/widgets/grid/CopyCellClickHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.logicaldoc.gui.common.client.widgets.grid; | ||
|
||
import com.logicaldoc.gui.common.client.util.LD; | ||
import com.smartgwt.client.widgets.grid.ListGrid; | ||
import com.smartgwt.client.widgets.grid.ListGridField; | ||
import com.smartgwt.client.widgets.grid.events.CellClickEvent; | ||
import com.smartgwt.client.widgets.grid.events.CellClickHandler; | ||
|
||
/** | ||
* A click handler useful to give users the option to look and copy into the clipboard the content of a grid cell | ||
* | ||
* @author Marco Meschieri - LogicalDOC | ||
* @since 9.0.1 | ||
*/ | ||
public class CopyCellClickHandler implements CellClickHandler { | ||
@Override | ||
public void onCellClick(CellClickEvent click) { | ||
ListGrid grid=(ListGrid)click.getSource(); | ||
ListGridField field = grid.getField(click.getColNum()); | ||
String title = field.getTitle(); | ||
String value = grid.getDefaultFormattedFieldValue(click.getRecord(), field); | ||
|
||
// In case the value contains HTML formatting, fallback to the original content | ||
if (value != null && (value.contains("<div") || value.contains("<p") || value.contains("<img") | ||
|| value.contains("<b>"))) | ||
value = click.getRecord().getAttribute(grid.getFieldName(click.getColNum())); | ||
|
||
LD.askForValue(title, title, value, v -> { | ||
// Nothing to do | ||
}); | ||
click.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...main/java/com/logicaldoc/gui/frontend/client/settings/searchindex/SearchHistoryPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.logicaldoc.gui.frontend.client.settings.searchindex; | ||
|
||
import com.logicaldoc.gui.common.client.Session; | ||
import com.logicaldoc.gui.common.client.data.UserHistoryDS; | ||
import com.logicaldoc.gui.common.client.i18n.I18N; | ||
import com.logicaldoc.gui.common.client.util.GridUtil; | ||
import com.logicaldoc.gui.common.client.util.ItemFactory; | ||
import com.logicaldoc.gui.common.client.widgets.grid.ColoredListGridField; | ||
import com.logicaldoc.gui.common.client.widgets.grid.CopyCellClickHandler; | ||
import com.logicaldoc.gui.common.client.widgets.grid.DateListGridField; | ||
import com.logicaldoc.gui.common.client.widgets.grid.DateListGridField.DateCellFormatter; | ||
import com.logicaldoc.gui.common.client.widgets.grid.RefreshableListGrid; | ||
import com.logicaldoc.gui.common.client.widgets.grid.UserListGridField; | ||
import com.smartgwt.client.types.Alignment; | ||
import com.smartgwt.client.widgets.form.fields.SpinnerItem; | ||
import com.smartgwt.client.widgets.grid.ListGridField; | ||
import com.smartgwt.client.widgets.layout.Layout; | ||
import com.smartgwt.client.widgets.layout.VLayout; | ||
import com.smartgwt.client.widgets.toolbar.ToolStrip; | ||
import com.smartgwt.client.widgets.toolbar.ToolStripButton; | ||
|
||
/** | ||
* Shows search history | ||
* | ||
* @author Marco Meschieri - LogicalDOC | ||
* @since 9.0.1 | ||
*/ | ||
public class SearchHistoryPanel extends VLayout { | ||
|
||
private static final String USERID = "userId"; | ||
|
||
private SpinnerItem maxItem; | ||
|
||
@Override | ||
protected void onDraw() { | ||
setWidth100(); | ||
setHeight100(); | ||
initGUI(); | ||
} | ||
|
||
private void initGUI() { | ||
ColoredListGridField id = new ColoredListGridField("id"); | ||
id.setHidden(true); | ||
|
||
ListGridField date = new DateListGridField("date", "date", DateCellFormatter.FORMAT_LONG); | ||
|
||
ColoredListGridField comment = new ColoredListGridField("comment", I18N.message("search")); | ||
comment.setWidth("*"); | ||
comment.setCellFormatter((value, rcd, rowNum, colNum) -> { | ||
if (value == null) | ||
return null; | ||
String val = value.toString().replace("FulltextSearch[", "").replace(",expression=", ",<b>expression=") | ||
.replace(",userId=", "</b>,userId=").replace(",fields=", ",<b>fields=") | ||
.replace(",page=", "</b>,page="); | ||
if (val.endsWith("]")) | ||
val = val.substring(0, val.length() - 1); | ||
return val; | ||
}); | ||
|
||
ListGridField userId = new ListGridField(USERID, I18N.message("userid"), 100); | ||
userId.setCanFilter(true); | ||
userId.setHidden(true); | ||
|
||
ListGridField userField = new UserListGridField("user", USERID, "user"); | ||
userField.setCanFilter(true); | ||
userField.setAlign(Alignment.CENTER); | ||
|
||
final RefreshableListGrid list = new RefreshableListGrid(); | ||
list.setEmptyMessage(I18N.message("notitemstoshow")); | ||
list.setCanFreezeFields(true); | ||
list.setAutoFetchData(true); | ||
list.setDataSource(new UserHistoryDS(Session.get().getTenantId(), null, "event.user.search", "Fulltext", | ||
Session.get().getConfigAsInt("gui.maxhistories"))); | ||
list.setFields(id, date, userId, userField, comment); | ||
list.addCellClickHandler(new CopyCellClickHandler()); | ||
|
||
ToolStrip buttons = new ToolStrip(); | ||
buttons.setWidth100(); | ||
|
||
maxItem = ItemFactory.newSpinnerItem("max", "display", Session.get().getConfigAsInt("gui.maxhistories"), 1, | ||
(Integer) null); | ||
maxItem.setWidth(70); | ||
maxItem.setStep(20); | ||
maxItem.setSaveOnEnter(true); | ||
maxItem.setImplicitSave(true); | ||
maxItem.setHint(I18N.message("elements")); | ||
maxItem.addChangedHandler(evnt -> refresh(list)); | ||
|
||
ToolStripButton refresh = new ToolStripButton(I18N.message("refresh")); | ||
refresh.addClickHandler(evnt -> refresh(list)); | ||
|
||
buttons.addButton(refresh); | ||
buttons.addFormItem(maxItem); | ||
buttons.addSeparator(); | ||
|
||
ToolStripButton export = new ToolStripButton(I18N.message("export")); | ||
buttons.addButton(export); | ||
export.addClickHandler(evnt -> GridUtil.exportCSV(list, true)); | ||
|
||
ToolStripButton print = new ToolStripButton(I18N.message("print")); | ||
buttons.addButton(print); | ||
print.addClickHandler(evnt -> GridUtil.print(list)); | ||
|
||
buttons.addSeparator(); | ||
|
||
Layout container = new VLayout(); | ||
container.setMembersMargin(3); | ||
container.addMember(buttons); | ||
container.addMember(list); | ||
addMember(container); | ||
} | ||
|
||
private void refresh(RefreshableListGrid list) { | ||
list.refresh(new UserHistoryDS(Session.get().getTenantId(), null, "event.user.search", "Fulltext", | ||
Integer.parseInt(maxItem.getValueAsString()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters