Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant.

Prototype

public static SafeHtml fromSafeConstant(String s) 

Source Link

Document

Returns a SafeHtml constructed from a safe string, i.e., without escaping the string.

Usage

From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.products.ProjectAdminTasksEditView.java

License:Open Source License

private void addPersonCellToComponentsTable() {
    if (personColumn != null) {
        componentsTable.removeColumn(personColumn);
    }/*w  w w.j a  v  a  2  s .  c  om*/

    personColumn = addColumn(new SelectionCell(users) {

        @Override
        public void render(Context context, String value, SafeHtmlBuilder sb) {
            super.render(context, value, sb);
        }
    }, new GetValue<Component, String>() {
        @Override
        public String getValue(Component object) {
            TaskUserProfile value = componentsEditor.getEditors()
                    .get(componentsEditor.getList().indexOf(object)).initialOwnerEditor.getValue();
            if (value == null) {
                return null;
            }
            return value.getRealname();
        }
    });
    personColumn.setFieldUpdater(new FieldUpdater<Component, String>() {
        @Override
        public void update(int index, Component object, String value) {
            boolean foundUser = false;
            for (TaskUserProfile user : presenter.getUsers()) {
                if (user.getRealname().equals(value)) {
                    componentsEditor.getEditors().get(index).initialOwnerEditor.setValue(user);
                    foundUser = true;
                    break;
                }
            }
            if (!foundUser) {
                componentsEditor.getEditors().get(index).initialOwnerEditor.setValue(null);
            }
        }
    });

    componentsTable.insertColumn(PERSON_COLUMN_INDEX, personColumn,
            SafeHtmlUtils.fromSafeConstant("<h4>" + tasksMessages.owner() + "</h4>"));
    componentsTable.setColumnWidth(personColumn, 210, Unit.PX);

}

From source file:com.thinqq.qsports.client.wireframe.QSportsWireFrameImpl.java

License:Open Source License

public QSportsWireFrameImpl(ClientFactory clientFactory) {
    this.clientFactory = clientFactory;
    style.ensureInjected();//from w w w . ja  v a2s.  co m
    initWidget(binder.createAndBindUi(this));
    addHandlers();
    HTML tweetContent = new HTML(
            "<a class=\"twitter-timeline\"  href=\"https://twitter.com/CricketQSports/cricketq\"  data-widget-id=\"368013046121115648\">Tweets from @CricketQSports/cricketq</a> "
                    + "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>");
    //addTeams();
    tweet.add(tweetContent);
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("http://platform.twitter.com/widgets.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);

    // TO TEST

    SafeHtml homeImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-home.png'/>");
    SafeHtml addMatchImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-batsman.png'/>");

    SafeHtml peopleImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-people.png'/>");
    //       MenuBar home = new MenuBar(true);
    Command homeCommand = new Command() {

        @Override
        public void execute() {
            Window.alert("fire the view request event to show the home view");

        }
    };

    Command peopleCommand = new Command() {

        @Override
        public void execute() {
            // TODO Navigate to people tab.

        }
    };
    MenuBar addMatch = new MenuBar(true);

    testMenu.addItem(homeImage, homeCommand);
    testMenu.addItem(addMatchImage, addMatch);
    testMenu.addItem(peopleImage, peopleCommand);

    SafeHtml createMatchText = SafeHtmlUtils.fromSafeConstant("New Match");
    SafeHtml createTeamText = SafeHtmlUtils.fromSafeConstant("New Team");
    createMatch = new MenuItem(createMatchText);
    createMatch = new MenuItem(createMatchText);
    createMatch.addStyleName("fancybox");
    createTeam = new MenuItem(createTeamText);
    addMatch.addItem(createMatch);
    addMatch.addItem(createTeam);

    createTeam.setCommand(new Command() {

        @Override
        public void execute() {
            Genie.getEventmanager().fireEvent(new CreateNewTeamEvent());

        }
    });

    createMatch.setCommand(new Command() {

        @Override
        public void execute() {
            Genie.getEventmanager().fireEvent(new CreateNewMatchEvent());

        }
    });
}

From source file:com.vaadin.client.renderers.HtmlRenderer.java

License:Apache License

@Override
public void render(RendererCellReference cell, String htmlString) {
    cell.getElement().setInnerSafeHtml(SafeHtmlUtils.fromSafeConstant(htmlString));
}

From source file:de.datenhahn.vaadin.rendererpackage.client.ClickableHtmlRenderer.java

License:Apache License

@Override
public void render(RendererCellReference cell, String html, FocusPanel panel) {
    ((HTML) panel.getWidget()).setHTML(SafeHtmlUtils.fromSafeConstant(html));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.progressbar.Css3ProgressBarAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, Double value, ProgressBarAppearanceOptions options) {
    value = value == null ? 0 : value;/*from ww w. jav  a2 s . c  o m*/

    String text = options.getProgressText();

    if (text != null) {
        int v = (int) Math.round(value * 100);
        text = Format.substitute(text, v);
    }

    SafeHtml txt;
    if (text == null) {
        txt = SafeHtmlUtils.fromSafeConstant("&#160;");
    } else {
        txt = SafeHtmlUtils.fromString(text);
    }

    SafeStyles widthStyles = SafeStylesUtils.fromTrustedNameAndValue("width", options.getWidth() + "px");

    final SafeStyles progressBarStyles;
    if (value <= 0) {
        progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("visibility", "hidden");
    } else {
        progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("width", value * 100 + "%");
    }

    sb.append(template.render(txt, styles, null, progressBarStyles, null, widthStyles));

}

From source file:eu.europeana.uim.gui.cp.client.europeanawidgets.ImportResourcesWidget.java

License:EUPL

/**
 * Add the columns to the table./*from   w  w w .  j av  a2  s.  c  o  m*/
 */
private void initTableColumns(final SelectionModel<SugarCRMRecordDTO> selectionModel,
        ListHandler<SugarCRMRecordDTO> sortHandler) {

    // Checkbox column. This table will uses a checkbox column for
    // selection.
    // Alternatively, you can call cellTable.setSelectionEnabled(true) to
    // enable
    // mouse selection.
    Column<SugarCRMRecordDTO, Boolean> checkColumn = new Column<SugarCRMRecordDTO, Boolean>(
            new CheckboxCell(true, false)) {
        @Override
        public Boolean getValue(SugarCRMRecordDTO object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
        }
    };
    cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    cellTable.setColumnWidth(checkColumn, 40, Unit.PX);

    // IsImported column
    Column<SugarCRMRecordDTO, String> isImportedColumn = new Column<SugarCRMRecordDTO, String>(
            new ImageCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getImportedIMG();
        }
    };
    isImportedColumn.setSortable(true);

    sortHandler.setComparator(isImportedColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getImportedIMG().compareTo(o2.getImportedIMG());
        }
    });
    cellTable.addColumn(isImportedColumn, EuropeanaClientConstants.UIMSTATELABEL);
    isImportedColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(isImportedColumn, 7, Unit.PCT);

    // Collection Name Column
    Column<SugarCRMRecordDTO, Anchor> collectionColumn = new Column<SugarCRMRecordDTO, Anchor>(
            new AnchorCell()) {
        @Override
        public Anchor getValue(SugarCRMRecordDTO object) {

            Anchor hyper = new Anchor();
            hyper.setName(object.getName());
            hyper.setText(object.getName());
            hyper.setHref(sugarLocation + object.getId());
            hyper.setTarget("TOP");

            return hyper;
        }
    };
    collectionColumn.setSortable(true);

    sortHandler.setComparator(collectionColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    cellTable.addColumn(collectionColumn, EuropeanaClientConstants.DSNAMESEARCHLABEL);
    collectionColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, Anchor>() {
        public void update(int index, SugarCRMRecordDTO object, Anchor value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(collectionColumn, 40, Unit.PCT);

    // Organization Name Column
    Column<SugarCRMRecordDTO, String> organizationColumn = new Column<SugarCRMRecordDTO, String>(
            new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getOrganization_name();
        }
    };

    collectionColumn.setSortable(true);

    sortHandler.setComparator(organizationColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getOrganization_name().compareTo(o2.getOrganization_name());
        }
    });

    cellTable.addColumn(organizationColumn, EuropeanaClientConstants.ORGANIZATIONSEARCHLABEL);
    organizationColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(organizationColumn, 20, Unit.PCT);

    // Country Column

    Column<SugarCRMRecordDTO, String> countryColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getCountry_c();
        }
    };
    countryColumn.setSortable(true);

    sortHandler.setComparator(countryColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getCountry_c().compareTo(o2.getCountry_c());
        }
    });
    cellTable.addColumn(countryColumn, EuropeanaClientConstants.COUNTRYSEARCHLABEL);
    countryColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(countryColumn, 5, Unit.PCT);

    // Status Column
    Column<SugarCRMRecordDTO, String> statusColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getStatus();
        }
    };
    statusColumn.setSortable(true);

    sortHandler.setComparator(statusColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getStatus().compareTo(o2.getStatus());
        }
    });
    cellTable.addColumn(statusColumn, EuropeanaClientConstants.STATUSSEARCHLABEL);
    statusColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(statusColumn, 20, Unit.PCT);

    // Amount Column

    Column<SugarCRMRecordDTO, String> amountColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getIngested_total_c();
        }
    };
    amountColumn.setSortable(true);

    sortHandler.setComparator(amountColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getIngested_total_c().compareTo(o2.getIngested_total_c());
        }
    });
    cellTable.addColumn(amountColumn, EuropeanaClientConstants.AMOUNTSEARCHLABEL);
    amountColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(amountColumn, 20, Unit.PCT);

    // Ingestion Date Column
    Column<SugarCRMRecordDTO, String> ingestionDateColumn = new Column<SugarCRMRecordDTO, String>(
            new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getExpected_ingestion_date();
        }
    };
    ingestionDateColumn.setSortable(true);

    sortHandler.setComparator(ingestionDateColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {
            return o1.getExpected_ingestion_date().compareTo(o2.getExpected_ingestion_date());
        }
    });
    cellTable.addColumn(ingestionDateColumn, EuropeanaClientConstants.INGESTDATESEARCHLABEL);
    ingestionDateColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(ingestionDateColumn, 20, Unit.PCT);

    // User Column

    Column<SugarCRMRecordDTO, String> userColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) {
        @Override
        public String getValue(SugarCRMRecordDTO object) {
            return object.getAssigned_user_name();
        }
    };
    userColumn.setSortable(true);

    sortHandler.setComparator(userColumn, new Comparator<SugarCRMRecordDTO>() {
        public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) {

            return o1.getAssigned_user_name().compareTo(o2.getAssigned_user_name());
        }
    });

    cellTable.addColumn(userColumn, EuropeanaClientConstants.USERSEARCHLABEL);
    userColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() {
        public void update(int index, SugarCRMRecordDTO object, String value) {

            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(userColumn, 20, Unit.PCT);

}

From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java

License:Apache License

private void addCheckedColumn() {
    Column<ItemDto, Boolean> checkedColumn = new Column<ItemDto, Boolean>(new CheckboxCell()) {
        @Override//from   w  w w  .j av a2 s  .c  o m
        public Boolean getValue(ItemDto object) {
            return object.isChecked();
        }
    };
    checkedColumn.setFieldUpdater(new FieldUpdater<ItemDto, Boolean>() {

        @Override
        public void update(int index, ItemDto object, Boolean value) {
            presenter.check(object, value);
        }
    });

    cellTable.addColumn(checkedColumn, SafeHtmlUtils.fromSafeConstant("Checked"));
}

From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java

License:Apache License

private void addEditColumn() {
    Column<ItemDto, ItemDto> deleteColumn = new Column<ItemDto, ItemDto>(new ActionCell<ItemDto>(
            SafeHtmlUtils.fromSafeConstant("<i class='icon-edit'></i>"), new Delegate<ItemDto>() {
                @Override/*ww  w .ja  v a  2  s.  com*/
                public void execute(final ItemDto item) {
                    presenter.edit(item);
                }
            })) {
        @Override
        public ItemDto getValue(ItemDto object) {
            return object;
        }
    };
    cellTable.addColumn(deleteColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
}

From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java

License:Apache License

private void addDeleteColumn() {
    Column<ItemDto, ItemDto> deleteColumn = new Column<ItemDto, ItemDto>(new ActionCell<ItemDto>(
            SafeHtmlUtils.fromSafeConstant("<i class='icon-remove'></i>"), new Delegate<ItemDto>() {
                @Override/*  w  w w .  j  a  va2  s  .c o m*/
                public void execute(final ItemDto item) {
                    presenter.delete(item);
                    reset();
                }
            })) {
        @Override
        public ItemDto getValue(ItemDto object) {
            return object;
        }
    };
    cellTable.addColumn(deleteColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
}

From source file:eu.zeigermann.gwt.demo.client.list.DefaultShoppingListView.java

License:Apache License

private void addEditColumn() {
    Delegate<ShoppingList> delegate = new Delegate<ShoppingList>() {
        @Override/*from  ww  w . j  av a 2s  .  c  o m*/
        public void execute(final ShoppingList list) {
            presenter.edit(list);
        }
    };
    ActionCell<ShoppingList> actionCell = new ActionCell<ShoppingList>(
            SafeHtmlUtils.fromSafeConstant("<i class='icon-edit'></i>"), delegate);
    Column<ShoppingList, ShoppingList> deleteColumn = new Column<ShoppingList, ShoppingList>(actionCell) {
        @Override
        public ShoppingList getValue(ShoppingList object) {
            return object;
        }

    };
    cellTable.addColumn(deleteColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
}