Skip to content

Commit

Permalink
WIP #19
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed May 24, 2021
1 parent 5d6631b commit 155b158
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;

import com.google.gwt.dom.client.Style;
import org.fusesource.restygwt.client.MethodCallback;
import org.roda.core.data.v2.index.sublist.Sublist;

Expand Down Expand Up @@ -471,8 +472,13 @@ private void addColumn(ColumnStatus viewerColumn, Column<ViewerRow, ?> displayCo
viewerColumn.getCustomDescription(), "column-description-block");
SafeHtmlBuilder spanDescription = CommonClientUtils.constructSpan(viewerColumn.getCustomDescription(),
viewerColumn.getCustomDescription(), "column-description-block column-description");
addColumn(displayColumn, CommonClientUtils.wrapOnDiv(Arrays.asList(spanTitle, spanDescription)), true,
TextAlign.LEFT, 10);
if (viewerColumn.getCustomName().equals("actor_id")) {
addColumn(displayColumn, CommonClientUtils.wrapOnDiv(Arrays.asList(spanTitle, spanDescription)), true,
TextAlign.LEFT, 20);
} else {
addColumn(displayColumn, CommonClientUtils.wrapOnDiv(Arrays.asList(spanTitle, spanDescription)), true,
TextAlign.LEFT, 10);
}
} else {
SafeHtmlBuilder spanTitle = CommonClientUtils.constructSpan(viewerColumn.getCustomName(),
viewerColumn.getCustomDescription(), "column-description-block");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE file at the root of the source
* tree and available online at
*
* https://github.com/keeps/dbptk-ui
*/
package com.databasepreservation.common.client.common.lists.cells;

import com.google.gwt.cell.client.TextInputCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

/**
* @author Miguel Guimarães <mguimaraes@keep.pt>
*/
public class EditableNumberCell extends TextInputCell {
private static Template template;
private String placeholder;

interface Template extends SafeHtmlTemplates {
// {0}, {1} relate to value, placeholder
@Template("<input type=\"number\" min=\"0\" value=\"{0}\" tabindex=\"-1\" placeholder=\"{1}\" class=\"gwt-TextBox form-textbox\"></input>")
SafeHtml input(String value, String placeholder);
}

public EditableNumberCell() {
EditableNumberCell.template = GWT.create(Template.class);
this.placeholder = "";
}

public EditableNumberCell(String placeholder) {
EditableNumberCell.template = GWT.create(Template.class);
this.placeholder = placeholder;
}

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value == null || value.isEmpty()) {
sb.append(template.input("", placeholder));
} else {
sb.append(template.input(value, placeholder));
}
}

@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event,
ValueUpdater<String> valueUpdater) {
if (value == null) {
value = "";
}

InputElement input = getInputElement(parent);
Element target = event.getEventTarget().cast();
if (!input.isOrHasChild(target)) {
return;
}

String eventType = event.getType();
if (BrowserEvents.FOCUS.equals(eventType)) {
input.select();
}

super.onBrowserEvent(context, parent, value, event, valueUpdater);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ protected void addColumn(Column<T, ?> column, SafeHtml headerHTML, boolean nowra

protected void addColumn(Column<T, ?> column, SafeHtml headerHTML, boolean nowrap, TextAlign textAlign,
double fixedSize) {
addColumn(column, headerHTML, nowrap, textAlign);
display.setColumnWidth(column, fixedSize, Style.Unit.EM);
addColumn(column, headerHTML, nowrap, textAlign);
}

protected void addColumn(Column<T, ?> column, String headerText, boolean nowrap, TextAlign textAlign) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.databasepreservation.common.client.common.fields.MetadataField;
import com.databasepreservation.common.client.common.lists.cells.ActionsCell;
import com.databasepreservation.common.client.common.lists.cells.DisableableCheckboxCell;
import com.databasepreservation.common.client.common.lists.cells.EditableNumberCell;
import com.databasepreservation.common.client.common.lists.cells.RequiredEditableCell;
import com.databasepreservation.common.client.common.lists.cells.TextAreaInputCell;
import com.databasepreservation.common.client.common.lists.cells.helper.CheckboxData;
Expand Down Expand Up @@ -55,13 +56,15 @@
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.CompositeCell;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.cell.client.SafeHtmlCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
Expand Down Expand Up @@ -254,6 +257,12 @@ public SafeHtml getValue(ColumnStatus column) {
}),
new BasicTablePanel.ColumnInfo<>(messages.basicTableHeaderLabel(), 15, getLabelColumn()),
new BasicTablePanel.ColumnInfo<>(messages.basicTableHeaderDescription(), 0, getDescriptionColumn()),
new BasicTablePanel.ColumnInfo<>("Set width (EM)", 10, new Column<ColumnStatus, String>(new EditableNumberCell()) {
@Override
public String getValue(ColumnStatus object) {
return "";
}
}),
new BasicTablePanel.ColumnInfo<>(SafeHtmlUtils.fromSafeConstant(FontAwesomeIconManager
.getTagWithStyleName(FontAwesomeIconManager.COG, messages.basicTableHeaderOptions(), FA_FW)), false, 3,
getOptionsColumn()),
Expand Down Expand Up @@ -570,8 +579,8 @@ public void onSuccess(Boolean value) {
.updateDetailsTemplate(clobColumnOptionPanel.getDetailsTemplate());
collectionStatus.getTableStatusByTableId(tableId).getColumnById(columnStatus.getId())
.updateDetailsShowContent(((ClobColumnOptionsPanel) clobColumnOptionPanel).showContentInDetails());
collectionStatus.getTableStatusByTableId(tableId).getColumnById(columnStatus.getId())
.getSearchStatus().getList().setShowContent(((ClobColumnOptionsPanel) clobColumnOptionPanel).showContentInList());
collectionStatus.getTableStatusByTableId(tableId).getColumnById(columnStatus.getId()).getSearchStatus()
.getList().setShowContent(((ClobColumnOptionsPanel) clobColumnOptionPanel).showContentInList());
collectionStatus.getTableStatusByTableId(tableId).getColumnById(columnStatus.getId())
.setApplicationType(((ClobColumnOptionsPanel) clobColumnOptionPanel).getApplicationType());
saveChanges(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ColumnStatus implements Serializable, Comparable<ColumnStatus> {
private String nullable;
private ViewerType.dbTypes type;
private int columnIndex;
private int width;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean externalLob;
private String applicationType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public class FontAwesomeIconManager {
public static final String DATA_TRANSFORMATION = "project-diagram";
public static final String SLIDERS = "sliders-h";
public static final String HANDS_HELP = "hand-holding-heart";
public static final String PAINT_BRUSH = "paint-brush";
public static final String WIDTH = "arrows-alt-h";

public static String getTag(String icon) {
return "<i class=\"fa fa-" + icon + "\"></i>";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/config/i18n/client/ClientMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,8 @@ public interface ClientMessages extends Messages {

String columnManagementPageDescription();

String columnManagementPageTableHeader();

String columnManagementPageCancelEventDialog();

String columnManagementPageToastDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ columnManagementLabelForSeparatorHint=html markup can be used as a separator (e.
columnManagementLabelForTemplateDetail=Template that will be rendered in the record panel.
columnManagementLabelForTemplateExport=Template that will be used when table or row are exported
columnManagementLabelForQuantityList=Quantity of records that will show in the table panel.
columnManagementPageTableHeader=Edit column width
#############################################################################
# Column Management Panel - Binary #
#############################################################################
Expand All @@ -1139,4 +1140,3 @@ resourceNotAvailableTableHiddenDescription=Please contact the administrator abou
# Configuration Errors #
#############################################################################
configErrorTextForMissingProperty=Missing property {0} in configuration property files.
configErrorTextForMissingProperty=Missing property {0} in configuration property files.

0 comments on commit 155b158

Please sign in to comment.