Search in sources :

Example 66 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project kie-wb-common by kiegroup.

the class AbstractVerticalMergableGridWidget method makeTableCellElement.

// Build a TableCellElement
@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {
    TableCellElement tce = null;
    // Column to handle rendering
    DynamicColumn<T> column = columns.get(iCol);
    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {
        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(resources.cellTableCell());
        tce.addClassName(resources.cellTableColumn(column.getModelColumn()));
        div.setClassName(resources.cellTableCellDiv());
        divText.addClassName(resources.cellTableTextDiv());
        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);
        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);
        // Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(resources.cellTableCellOtherwise());
        } else {
            tce.removeClassName(resources.cellTableCellOtherwise());
        }
        if (cellData instanceof CellValue.GroupedCellValue) {
            CellValue.GroupedCellValue gcv = (CellValue.GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(resources.cellTableCellMultipleValues());
            }
        } else {
            tce.removeClassName(resources.cellTableCellMultipleValues());
        }
        if (cellData.isSelected()) {
            tce.addClassName(resources.cellTableCellSelected());
        } else {
            tce.removeClassName(resources.cellTableCellSelected());
        }
        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());
        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);
        // Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(Constants.INSTANCE.groupCells());
            divGroup.addClassName(resources.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }
    }
    return tce;
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) TableCellElement(com.google.gwt.dom.client.TableCellElement) TableSectionElement(com.google.gwt.dom.client.TableSectionElement) DivElement(com.google.gwt.dom.client.DivElement) TableRowElement(com.google.gwt.dom.client.TableRowElement) Element(com.google.gwt.dom.client.Element) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) DivElement(com.google.gwt.dom.client.DivElement) GWT(com.google.gwt.core.client.GWT) Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 67 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project activityinfo by bedatadriven.

the class AdminColumnRenderer method render.

private Object render(SiteDTO model) {
    StringBuilder qtip = new StringBuilder();
    SafeHtmlBuilder summary = new SafeHtmlBuilder();
    // we use this set to keep track of names that we've added
    // to the summary to avoid duplication that is common between
    // territories, zones de sante, provinces and districts, etc
    seen.clear();
    int summaryLines = 0;
    for (AdminLevelDTO level : levels) {
        AdminEntityDTO entity = model.getAdminEntity(level.getId());
        if (entity != null) {
            String name = entity.getName();
            if (qtip.length() > 0) {
                qtip.append("<br>");
            }
            qtip.append(level.getName()).append(": ").append(name);
            if (summaryLines < 3 && !seen.contains(name)) {
                if (summaryLines > 0) {
                    summary.appendHtmlConstant("<br/>");
                }
                summary.appendEscaped(name);
                seen.add(name);
                summaryLines++;
            }
        }
    }
    // return summary.toSafeHtml().asString();
    return ColumnTemplates.INSTANCE.adminCell(qtip.toString(), summary.toSafeHtml()).asString();
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 68 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project pentaho-platform by pentaho.

the class SchedulesPanel method createUI.

private void createUI(boolean isAdmin, final boolean isScheduler) {
    table.getElement().setId("schedule-table");
    table.setStylePrimaryName("pentaho-table");
    table.setWidth("100%", true);
    // BISERVER-9331 Column sort indicators should be to the right of header text in the Manage Schedules table.
    if (table.getHeaderBuilder() instanceof AbstractHeaderOrFooterBuilder) {
        ((AbstractHeaderOrFooterBuilder<JsJob>) table.getHeaderBuilder()).setSortIconStartOfLine(false);
    }
    final MultiSelectionModel<JsJob> selectionModel = new MultiSelectionModel<JsJob>(new ProvidesKey<JsJob>() {

        public Object getKey(JsJob item) {
            return item.getJobId();
        }
    });
    table.setSelectionModel(selectionModel);
    Label noDataLabel = new Label(Messages.getString("noSchedules"));
    noDataLabel.setStyleName("noDataForScheduleTable");
    table.setEmptyTableWidget(noDataLabel);
    TextColumn<JsJob> idColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            return job.getJobId();
        }
    };
    idColumn.setSortable(true);
    TextColumn<JsJob> nameColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            return job.getJobName();
        }
    };
    nameColumn.setSortable(true);
    HtmlColumn<JsJob> resourceColumn = new HtmlColumn<JsJob>() {

        @Override
        public String getStringValue(JsJob job) {
            String name = job.getFullResourceName().split("\\.")[0];
            return name.replaceAll("/", "/<wbr/>");
        }
    };
    resourceColumn.setSortable(true);
    HtmlColumn<JsJob> outputPathColumn = new HtmlColumn<JsJob>(new ClickableSafeHtmlCell()) {

        @Override
        public String getStringValue(JsJob jsJob) {
            try {
                String outputPath = jsJob.getOutputPath();
                if (StringUtils.isEmpty(outputPath)) {
                    return BLANK_VALUE;
                }
                outputPath = new SafeHtmlBuilder().appendEscaped(outputPath).toSafeHtml().asString();
                return MessageFormat.format("<span class='workspace-resource-link' title='{0}'>{0}</span>", outputPath);
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    outputPathColumn.setFieldUpdater(new FieldUpdater<JsJob, SafeHtml>() {

        @Override
        public void update(final int index, final JsJob jsJob, final SafeHtml value) {
            if (value != null && !BLANK_VALUE.equals(value.asString())) {
                final Command errorCallback = new Command() {

                    @Override
                    public void execute() {
                        showValidateOutputLocationError();
                    }
                };
                final Command successCallback = new Command() {

                    @Override
                    public void execute() {
                        openOutputLocation(jsJob.getOutputPath());
                    }
                };
                OutputLocationUtils.validateOutputLocation(jsJob.getOutputPath(), successCallback, errorCallback);
            }
        }
    });
    outputPathColumn.setSortable(true);
    TextColumn<JsJob> scheduleColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            try {
                return job.getJobTrigger().getDescription();
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    scheduleColumn.setSortable(true);
    TextColumn<JsJob> userNameColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            try {
                return job.getUserName();
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    userNameColumn.setSortable(true);
    TextColumn<JsJob> stateColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            try {
                // BISERVER-9965
                final String jobState = "COMPLETE".equalsIgnoreCase(job.getState()) ? "FINISHED" : job.getState();
                // not css text-transform because tooltip will use pure text from the cell
                return jobState.substring(0, 1).toUpperCase() + jobState.substring(1).toLowerCase();
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    stateColumn.setSortable(true);
    TextColumn<JsJob> nextFireColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            try {
                Date date = job.getNextRun();
                if (date == null) {
                    return BLANK_VALUE;
                }
                DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM);
                return format.format(date);
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    nextFireColumn.setSortable(true);
    TextColumn<JsJob> lastFireColumn = new TextColumn<JsJob>() {

        public String getValue(JsJob job) {
            try {
                Date date = job.getLastRun();
                if (date == null) {
                    return BLANK_VALUE;
                }
                DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM);
                return format.format(date);
            } catch (Throwable t) {
                return BLANK_VALUE;
            }
        }
    };
    lastFireColumn.setSortable(true);
    // table.addColumn(idColumn, "ID");
    table.addColumn(nameColumn, Messages.getString("scheduleName"));
    table.addColumn(scheduleColumn, Messages.getString("recurrence"));
    table.addColumn(resourceColumn, Messages.getString("sourceFile"));
    table.addColumn(outputPathColumn, Messages.getString("outputPath"));
    table.addColumn(lastFireColumn, Messages.getString("lastFire"));
    table.addColumn(nextFireColumn, Messages.getString("nextFire"));
    if (isAdmin) {
        table.addColumn(userNameColumn, Messages.getString("user"));
    }
    table.addColumn(stateColumn, Messages.getString("state"));
    table.addColumnStyleName(0, "backgroundContentHeaderTableCell");
    table.addColumnStyleName(1, "backgroundContentHeaderTableCell");
    table.addColumnStyleName(2, "backgroundContentHeaderTableCell");
    table.addColumnStyleName(3, "backgroundContentHeaderTableCell");
    table.addColumnStyleName(4, "backgroundContentHeaderTableCell");
    table.addColumnStyleName(5, "backgroundContentHeaderTableCell");
    if (isAdmin) {
        table.addColumnStyleName(6, "backgroundContentHeaderTableCell");
    }
    table.addColumnStyleName(isAdmin ? 7 : 6, "backgroundContentHeaderTableCell");
    table.setColumnWidth(nameColumn, 160, Unit.PX);
    table.setColumnWidth(resourceColumn, 200, Unit.PX);
    table.setColumnWidth(outputPathColumn, 180, Unit.PX);
    table.setColumnWidth(scheduleColumn, 170, Unit.PX);
    table.setColumnWidth(lastFireColumn, 120, Unit.PX);
    table.setColumnWidth(nextFireColumn, 120, Unit.PX);
    if (isAdmin) {
        table.setColumnWidth(userNameColumn, 100, Unit.PX);
    }
    table.setColumnWidth(stateColumn, 90, Unit.PX);
    dataProvider.addDataDisplay(table);
    List<JsJob> list = dataProvider.getList();
    ListHandler<JsJob> columnSortHandler = new ListHandler<JsJob>(list);
    columnSortHandler.setComparator(idColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                return (o2 != null) ? o1.getJobId().compareTo(o2.getJobId()) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(nameColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                return (o2 != null) ? o1.getJobName().compareTo(o2.getJobName()) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(resourceColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                String r1 = o1.getShortResourceName();
                String r2 = null;
                if (o2 != null) {
                    r2 = o2.getShortResourceName();
                }
                return (o2 != null) ? r1.compareTo(r2) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(outputPathColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                String r1 = o1.getOutputPath();
                String r2 = null;
                if (o2 != null) {
                    r2 = o2.getOutputPath();
                }
                return (o2 != null) ? r1.compareTo(r2) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(scheduleColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            String s1 = o1.getJobTrigger().getDescription();
            String s2 = o2.getJobTrigger().getDescription();
            return s1.compareTo(s2);
        }
    });
    columnSortHandler.setComparator(userNameColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                return (o2 != null) ? o1.getUserName().compareTo(o2.getUserName()) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(stateColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 != null) {
                return (o2 != null) ? o1.getState().compareTo(o2.getState()) : 1;
            }
            return -1;
        }
    });
    columnSortHandler.setComparator(nextFireColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 == null || o1.getNextRun() == null) {
                return -1;
            }
            if (o2 == null || o2.getNextRun() == null) {
                return 1;
            }
            if (o1.getNextRun() == o2.getNextRun()) {
                return 0;
            }
            return o1.getNextRun().compareTo(o2.getNextRun());
        }
    });
    columnSortHandler.setComparator(lastFireColumn, new Comparator<JsJob>() {

        public int compare(JsJob o1, JsJob o2) {
            if (o1 == o2) {
                return 0;
            }
            if (o1 == null || o1.getLastRun() == null) {
                return -1;
            }
            if (o2 == null || o2.getLastRun() == null) {
                return 1;
            }
            if (o1.getLastRun() == o2.getLastRun()) {
                return 0;
            }
            return o1.getLastRun().compareTo(o2.getLastRun());
        }
    });
    table.addColumnSortHandler(columnSortHandler);
    table.getColumnSortList().push(idColumn);
    table.getColumnSortList().push(resourceColumn);
    table.getColumnSortList().push(outputPathColumn);
    table.getColumnSortList().push(nameColumn);
    table.getSelectionModel().addSelectionChangeHandler(new Handler() {

        public void onSelectionChange(SelectionChangeEvent event) {
            Set<JsJob> selectedJobs = getSelectedJobs();
            if (!selectedJobs.isEmpty()) {
                final JsJob job = selectedJobs.toArray(new JsJob[0])[0];
                updateJobScheduleButtonStyle(job.getState());
                controlScheduleButton.setEnabled(isScheduler);
                editButton.setEnabled(isScheduler);
                controlScheduleButton.setEnabled(isScheduler);
                scheduleRemoveButton.setEnabled(isScheduler);
                triggerNowButton.setEnabled(isScheduler);
            } else {
                editButton.setEnabled(false);
                controlScheduleButton.setEnabled(false);
                scheduleRemoveButton.setEnabled(false);
                triggerNowButton.setEnabled(false);
            }
        }
    });
    // BISERVER-9965
    table.addCellPreviewHandler(new CellPreviewEvent.Handler<JsJob>() {

        @Override
        public void onCellPreview(CellPreviewEvent<JsJob> event) {
            if ("mouseover".equals(event.getNativeEvent().getType())) {
                final TableCellElement cell = table.getRowElement(event.getIndex()).getCells().getItem(event.getColumn());
                cell.setTitle(cell.getInnerText());
            }
        }
    });
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true) {

        @Override
        public void setPageStart(int index) {
            if (getDisplay() != null) {
                Range range = getDisplay().getVisibleRange();
                int pageSize = range.getLength();
                index = Math.max(0, index);
                if (index != range.getStart()) {
                    getDisplay().setVisibleRange(index, pageSize);
                }
            }
        }
    };
    pager.setDisplay(table);
    VerticalPanel tableAndPager = new VerticalPanel();
    tableAndPager.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    Toolbar bar = new Toolbar();
    bar.addSpacer(10);
    bar.add(Toolbar.GLUE);
    // Add control scheduler button
    if (isAdmin) {
        final ToolbarButton controlSchedulerButton = new ToolbarButton(ImageUtil.getThemeableImage(ICON_SMALL_STYLE, "icon-start-scheduler"));
        controlSchedulerButton.setCommand(new Command() {

            public void execute() {
                toggleSchedulerOnOff(controlSchedulerButton, isScheduler);
            }
        });
        updateControlSchedulerButtonState(controlSchedulerButton, isScheduler);
        bar.add(controlSchedulerButton);
        bar.addSpacer(20);
    }
    // Add filter button
    filterButton.setCommand(new Command() {

        public void execute() {
            if (filterDialog == null) {
                filterDialog = new FilterDialog(allJobs, filterDialogCallback);
            } else {
                filterDialog.initUI(allJobs);
            }
            filterDialog.center();
        }
    });
    filterButton.setToolTip(Messages.getString("filterSchedules"));
    if (isAdmin) {
        bar.add(filterButton);
    }
    // Add remove filters button
    filterRemoveButton.setCommand(new Command() {

        public void execute() {
            filterDialog = null;
            filters.clear();
            filterAndShowData();
            filterRemoveButton.setEnabled(false);
            filterButton.setImage(ImageUtil.getThemeableImage(ICON_SMALL_STYLE, "icon-filter-add"));
        }
    });
    filterRemoveButton.setToolTip(Messages.getString("removeFilters"));
    filterRemoveButton.setEnabled(!filters.isEmpty());
    if (isAdmin) {
        bar.add(filterRemoveButton);
    }
    // Add refresh button
    ToolbarButton refresh = new ToolbarButton(ImageUtil.getThemeableImage(ICON_SMALL_STYLE, "icon-refresh"));
    refresh.setToolTip(Messages.getString("refreshTooltip"));
    refresh.setCommand(new Command() {

        public void execute() {
            RefreshSchedulesCommand cmd = new RefreshSchedulesCommand();
            cmd.execute();
        }
    });
    bar.add(refresh);
    bar.addSpacer(20);
    // Add execute now button
    triggerNowButton.setToolTip(Messages.getString("executeNow"));
    triggerNowButton.setCommand(new Command() {

        public void execute() {
            Set<JsJob> selectedJobs = getSelectedJobs();
            if (!selectedJobs.isEmpty()) {
                triggerExecuteNow(selectedJobs);
            }
        }
    });
    triggerNowButton.setEnabled(false);
    bar.add(triggerNowButton);
    // Add control schedule button
    controlScheduleButton.setCommand(new Command() {

        public void execute() {
            Set<JsJob> selectedJobs = getSelectedJobs();
            if (!selectedJobs.isEmpty()) {
                final JsJob job = selectedJobs.toArray(new JsJob[0])[0];
                boolean isRunning = JOB_STATE_NORMAL.equalsIgnoreCase(job.getState());
                final String action = isRunning ? "pauseJob" : "resumeJob";
                controlJobs(selectedJobs, action, RequestBuilder.POST, false);
            }
        }
    });
    controlScheduleButton.setEnabled(false);
    bar.add(controlScheduleButton);
    bar.addSpacer(20);
    // Add edit button
    editButton.setCommand(new Command() {

        public void execute() {
            Set<JsJob> selectedJobs = getSelectedJobs();
            if (!selectedJobs.isEmpty()) {
                final JsJob editJob = selectedJobs.toArray(new JsJob[0])[0];
                canAccessJobRequest(editJob, new RequestCallback() {

                    public void onError(Request request, Throwable exception) {
                        promptForScheduleResourceError(Collections.singleton(editJob));
                    }

                    public void onResponseReceived(Request request, Response response) {
                        boolean canEditJob = "true".equalsIgnoreCase(response.getText());
                        if (!canEditJob) {
                            promptForScheduleResourceError(Collections.singleton(editJob));
                            return;
                        }
                        editJob(editJob);
                    }
                });
            }
        }
    });
    editButton.setEnabled(false);
    editButton.setToolTip(Messages.getString("editTooltip"));
    bar.add(editButton);
    // Add remove button
    scheduleRemoveButton.setCommand(new Command() {

        public void execute() {
            final Set<JsJob> selectedJobs = getSelectedJobs();
            int selectionSize = selectedJobs.size();
            if (selectionSize > 0) {
                final PromptDialogBox prompt = new PromptDialogBox(Messages.getString("warning"), Messages.getString("yes"), Messages.getString("no"), false, true);
                final String promptContent = Messages.getString("deleteConfirmSchedles", "" + selectionSize);
                prompt.setContent(new Label(promptContent));
                prompt.setCallback(new IDialogCallback() {

                    public void okPressed() {
                        controlJobs(selectedJobs, "removeJob", RequestBuilder.DELETE, true);
                        prompt.hide();
                    }

                    public void cancelPressed() {
                        prompt.hide();
                    }
                });
                prompt.center();
            }
        }
    });
    scheduleRemoveButton.setToolTip(Messages.getString("remove"));
    scheduleRemoveButton.setEnabled(false);
    bar.add(scheduleRemoveButton);
    tableAndPager.add(bar);
    tableAndPager.add(table);
    tableAndPager.add(pager);
    // Add it to the root panel.
    setWidget(tableAndPager);
}
Also used : RefreshSchedulesCommand(org.pentaho.mantle.client.commands.RefreshSchedulesCommand) Set(java.util.Set) HashSet(java.util.HashSet) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(com.google.gwt.user.client.ui.Label) JSONString(com.google.gwt.json.client.JSONString) HtmlColumn(org.pentaho.mantle.client.ui.column.HtmlColumn) ToolbarButton(org.pentaho.gwt.widgets.client.toolbar.ToolbarButton) AbstractHeaderOrFooterBuilder(com.google.gwt.user.cellview.client.AbstractHeaderOrFooterBuilder) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Toolbar(org.pentaho.gwt.widgets.client.toolbar.Toolbar) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Request(com.google.gwt.http.client.Request) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Handler(com.google.gwt.view.client.SelectionChangeEvent.Handler) SimplePager(com.google.gwt.user.cellview.client.SimplePager) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Range(com.google.gwt.view.client.Range) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) Date(java.util.Date) CellPreviewEvent(com.google.gwt.view.client.CellPreviewEvent) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Response(com.google.gwt.http.client.Response) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) RequestCallback(com.google.gwt.http.client.RequestCallback) Command(com.google.gwt.user.client.Command) RefreshSchedulesCommand(org.pentaho.mantle.client.commands.RefreshSchedulesCommand) JSONObject(com.google.gwt.json.client.JSONObject) TableCellElement(com.google.gwt.dom.client.TableCellElement) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 69 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.

the class CompletionItemBasedCompletionProposal method getDisplayString.

@Override
public String getDisplayString() {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    String label = completionItem.getLabel();
    int pos = 0;
    for (Match highlight : highlights) {
        if (highlight.getStart() == highlight.getEnd()) {
            continue;
        }
        if (pos < highlight.getStart()) {
            appendPlain(builder, label.substring(pos, highlight.getStart()));
        }
        appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd()));
        pos = highlight.getEnd();
    }
    if (pos < label.length()) {
        appendPlain(builder, label.substring(pos));
    }
    if (completionItem.getDetail() != null) {
        appendDetail(builder, completionItem.getDetail());
    }
    return builder.toSafeHtml().asString();
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Match(org.eclipse.che.plugin.languageserver.ide.filters.Match)

Example 70 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.

the class RemoteViewImpl method initRepositoriesTable.

/**
     * Initialize the columns of the grid.
     *
     * @param ideResources
     */
private void initRepositoriesTable(org.eclipse.che.ide.Resources ideResources) {
    repositories = new CellTable<>(15, ideResources);
    Column<Remote, String> nameColumn = new Column<Remote, String>(new TextCell()) {

        @Override
        public String getValue(Remote remote) {
            return remote.getName();
        }

        @Override
        public void render(Cell.Context context, Remote remote, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-remotes-remotes-cellTable-" + context.getIndex() + "\">");
            super.render(context, remote, sb);
        }
    };
    Column<Remote, String> urlColumn = new Column<Remote, String>(new TextCell()) {

        @Override
        public String getValue(Remote remote) {
            return remote.getUrl();
        }
    };
    repositories.addColumn(nameColumn, locale.remoteGridNameField());
    repositories.setColumnWidth(nameColumn, "20%");
    repositories.addColumn(urlColumn, locale.remoteGridLocationField());
    repositories.setColumnWidth(urlColumn, "80%");
    final SingleSelectionModel<Remote> selectionModel = new SingleSelectionModel<Remote>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            selectedObject = selectionModel.getSelectedObject();
            delegate.onRemoteSelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) Remote(org.eclipse.che.api.git.shared.Remote) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Column(com.google.gwt.user.cellview.client.Column)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)143 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)26 Test (org.junit.Test)18 Column (com.google.gwt.user.cellview.client.Column)17 Cell (com.google.gwt.cell.client.Cell)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)12 Context (com.google.gwt.cell.client.Cell.Context)7 MenuItem (com.google.gwt.user.client.ui.MenuItem)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Command (com.google.gwt.user.client.Command)6 ArrayList (java.util.ArrayList)6 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)5 GWT (com.google.gwt.core.client.GWT)5 Element (com.google.gwt.dom.client.Element)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 TextCell (com.google.gwt.cell.client.TextCell)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 ImageResource (com.google.gwt.resources.client.ImageResource)4 Map (java.util.Map)4