Search in sources :

Example 1 with ButtonCell

use of com.google.gwt.cell.client.ButtonCell in project che by eclipse.

the class SshKeyManagerViewImpl method initSshKeyTable.

/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
    keys = new CellTable<>(20, res);
    Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return object.getName();
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-title-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    hostColumn.setSortable(true);
    Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return "View";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">");
            if (object != null && object.getPublicKey() != null) {
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {

        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onViewClicked(object);
        }
    });
    Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return "Delete";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    // Creates handler on button clicked
    deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {

        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onDeleteClicked(object);
        }
    });
    keys.addColumn(hostColumn, "Title");
    keys.addColumn(publicKeyColumn, "Public Key");
    keys.addColumn(deleteKeyColumn, "Delete");
    keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
    keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
    keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);
    // don't show loading indicator
    keys.setLoadingIndicator(null);
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) Column(com.google.gwt.user.cellview.client.Column) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ButtonCell(com.google.gwt.cell.client.ButtonCell) TextCell(com.google.gwt.cell.client.TextCell)

Example 2 with ButtonCell

use of com.google.gwt.cell.client.ButtonCell in project che by eclipse.

the class SshKeyManagerViewImpl method initSshKeyTable.

/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return object.getName();
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-host-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    hostColumn.setSortable(true);
    Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return "View";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">");
            if (object != null && object.getPublicKey() != null) {
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {

        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onViewClicked(object);
        }
    });
    Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {

        @Override
        public String getValue(SshPairDto object) {
            return "Delete";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    // Creates handler on button clicked
    deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {

        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onDeleteClicked(object);
        }
    });
    keys.addColumn(hostColumn, "Host");
    keys.addColumn(publicKeyColumn, "Public Key");
    keys.addColumn(deleteKeyColumn, "Delete");
    keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
    keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
    keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);
    // don't show loading indicator
    keys.setLoadingIndicator(null);
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) Column(com.google.gwt.user.cellview.client.Column) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ButtonCell(com.google.gwt.cell.client.ButtonCell) TextCell(com.google.gwt.cell.client.TextCell)

Aggregations

ButtonCell (com.google.gwt.cell.client.ButtonCell)2 Context (com.google.gwt.cell.client.Cell.Context)2 TextCell (com.google.gwt.cell.client.TextCell)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 Column (com.google.gwt.user.cellview.client.Column)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2