Search in sources :

Example 6 with SafeUri

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

the class CaseManagementShapeDefFactory method newActivityShape.

@SuppressWarnings("unchecked")
private Shape newActivityShape(final Object instance, final ShapeDef shapeDef) {
    final BPMNViewDefinition bpmnDefinition = (BPMNViewDefinition) instance;
    final CaseManagementActivityShapeDef cmShapeDef = (CaseManagementActivityShapeDef) shapeDef;
    final double width = cmShapeDef.getWidth(bpmnDefinition);
    final double height = cmShapeDef.getHeight(bpmnDefinition);
    final ActivityView view = cmShapeViewFactory.newActivityView(width, height);
    final SafeUri iconUri = cmShapeDef.getIconUri(instance.getClass());
    final PictureShapeView iconView = basicShapeViewFactory.pictureFromUri(iconUri, 15d, 15d);
    return new ActivityShape(cmShapeDef, iconView, view);
}
Also used : CaseManagementActivityShapeDef(org.kie.workbench.common.stunner.cm.client.shape.def.CaseManagementActivityShapeDef) ActivityView(org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView) SafeUri(com.google.gwt.safehtml.shared.SafeUri) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) ActivityShape(org.kie.workbench.common.stunner.cm.client.shape.ActivityShape) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView)

Example 7 with SafeUri

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

the class UnsupportedDialog method show.

public static void show() {
    Template template = GWT.create(Template.class);
    SafeUri downloadUri = UriUtils.fromSafeConstant("https://www.google.com/chrome/browser/desktop/?hl=" + LocaleInfo.getCurrentLocale().getLocaleName());
    SafeHtml message = template.message(I18N.CONSTANTS.offlineNotSupported(), downloadUri, I18N.CONSTANTS.downloadGoogleChrome());
    MessageBox.alert(I18N.CONSTANTS.offlineNotSupportedTitle(), message.asString(), null);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeUri(com.google.gwt.safehtml.shared.SafeUri)

Example 8 with SafeUri

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

the class ShapeViewFactory method picture.

public PictureShapeView picture(final Object source, final double width, final double height) {
    checkNotNull("source", source);
    final SafeUri uri = pictureProvidersManager.getUri(source);
    return new PictureShapeView(uri.asString(), width, height);
}
Also used : SafeUri(com.google.gwt.safehtml.shared.SafeUri)

Example 9 with SafeUri

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

the class DiagramNavigatorItemImplTest method checkSizeIsSetBeforeUriWhenShowing.

@Test
public void checkSizeIsSetBeforeUriWhenShowing() {
    final InOrder inOrder = inOrder(view, view);
    final SafeUri uri = mock(SafeUri.class);
    final DiagramRepresentation diagramRepresentation = mock(DiagramRepresentation.class);
    when(diagramRepresentation.getDefinitionSetId()).thenReturn("defId");
    when(shapeManager.getThumbnail(eq("defId"))).thenReturn(uri);
    when(diagramRepresentation.getThumbImageData()).thenReturn(null);
    diagramNavigatorItem.show(diagramRepresentation, 100, 200, () -> {
    });
    inOrder.verify(view).setItemPxSize(eq(100), eq(200));
    inOrder.verify(view).setThumbUri(eq(uri));
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) InOrder(org.mockito.InOrder) SafeUri(com.google.gwt.safehtml.shared.SafeUri) Test(org.junit.Test)

Example 10 with SafeUri

use of com.google.gwt.safehtml.shared.SafeUri in project blogwt by billy1380.

the class HeaderPart method setupNavBarPages.

private void setupNavBarPages() {
    String titleInNavBar = PropertyController.get().stringProperty(PropertyHelper.TITLE_IN_NAVBAR);
    boolean removedHome = false;
    if (titleInNavBar == null || titleInNavBar.contains(PropertyHelper.TITLE_VALUE)) {
        elName.setInnerText(PropertyController.get().title());
    } else if (titleInNavBar.equals(PropertyHelper.NONE_VALUE)) {
        btnHome.removeFromParent();
        removedHome = true;
    } else {
        elName.removeFromParent();
    }
    boolean foundBrandPage = false, addedBlog = false;
    List<Page> pages;
    SafeUri href;
    Map<Long, Page> possibleParents = new HashMap<Long, Page>();
    if ((pages = PageController.get().getHeaderPages()) != null) {
        for (Page page : pages) {
            if (page.priority != null && page.priority.floatValue() == 0.0f && !removedHome) {
                btnHome.setHref(PageTypeHelper.slugToHref(page.slug));
                foundBrandPage = true;
            } else {
                if (page.priority != null && page.priority.floatValue() > 2 && (foundBrandPage || removedHome) && !addedBlog) {
                    href = PageTypeHelper.asHref(PageType.PostsPageType);
                    addItem(elNavLeft, SafeHtmlUtils.fromSafeConstant("Blog"), href);
                    addedBlog = true;
                }
                Element el;
                if (page.parent == null) {
                    href = PageTypeHelper.slugToHref(page.slug);
                    if (possibleParents.get(page.id) == null) {
                        addItem(elNavLeft, SafeHtmlUtils.fromString(page.title), href);
                        possibleParents.put(page.id, page);
                    } else {
                        possibleParents.put(page.id, page);
                        swapTitle(PageTypeHelper.slugToTargetHistoryToken("pageid_" + page.id), HeaderTemplates.INSTANCE.openableTitle(page.title), href);
                    }
                } else {
                    Page parent;
                    if ((parent = possibleParents.get(page.parent.id)) != null) {
                        el = getOpenable(PageTypeHelper.slugToTargetHistoryToken(parent.slug));
                        if (el == null) {
                            el = getOpenable(PageTypeHelper.slugToTargetHistoryToken("pageid_" + parent.id));
                        }
                        if (el == null) {
                            el = getItem(PageTypeHelper.slugToTargetHistoryToken(parent.slug));
                            if (el != null) {
                                el = convertItemToOpenable(PageTypeHelper.slugToTargetHistoryToken(parent.slug), HeaderTemplates.INSTANCE.openableTitle(parent.title));
                            }
                        }
                    } else {
                        String dummySlug = "pageid_" + page.parent.id;
                        el = addOpenable(elNavLeft, HeaderTemplates.INSTANCE.openableTitle(dummySlug), PageTypeHelper.slugToHref(dummySlug));
                        possibleParents.put(page.parent.id, page.parent);
                    }
                    if (el != null) {
                        href = PageTypeHelper.slugToHref(page.slug);
                        addItem(el.getFirstChildElement().getNextSiblingElement(), SafeHtmlUtils.fromString(page.title), href);
                    }
                }
            }
        }
    }
    if (foundBrandPage || removedHome) {
        if (!addedBlog) {
            href = PageTypeHelper.asHref(PageType.PostsPageType);
            addItem(elNavLeft, SafeHtmlUtils.fromSafeConstant("Blog"), href);
        }
    } else {
        btnHome.setHref(PageTypeHelper.asHref(PageType.PostsPageType));
    }
    ensureItems().put(PageType.AllPostsPageType.asTargetHistoryToken(), elPosts);
    ensureItems().put(PageType.PagesPageType.asTargetHistoryToken(), elPages);
    ensureItems().put(PageType.PropertiesPageType.asTargetHistoryToken(), elProperties);
    ensureItems().put(PageType.UsersPageType.asTargetHistoryToken(), elUsers);
    ensureItems().put(PageType.RolesPageType.asTargetHistoryToken(), elRoles);
    ensureItems().put(PageType.PermissionsPageType.asTargetHistoryToken(), elPermissions);
    ensureItems().put(PageType.ResourcesPageType.asTargetHistoryToken(), elResources);
    ensureItems().put(PageType.MetaNotificationsPageType.asTargetHistoryToken(), elMetaNotifications);
    elAdmin.removeFromParent();
    elAccount.removeFromParent();
}
Also used : HashMap(java.util.HashMap) Element(com.google.gwt.dom.client.Element) AnchorElement(com.google.gwt.dom.client.AnchorElement) ImageElement(com.google.gwt.dom.client.ImageElement) SafeUri(com.google.gwt.safehtml.shared.SafeUri) Page(com.willshex.blogwt.shared.api.datatype.Page)

Aggregations

SafeUri (com.google.gwt.safehtml.shared.SafeUri)12 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 GWT (com.google.gwt.core.client.GWT)1 AnchorElement (com.google.gwt.dom.client.AnchorElement)1 Element (com.google.gwt.dom.client.Element)1 ImageElement (com.google.gwt.dom.client.ImageElement)1 PropertyController (com.willshex.blogwt.client.controller.PropertyController)1 Page (com.willshex.blogwt.shared.api.datatype.Page)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)1 ActivityShape (org.kie.workbench.common.stunner.cm.client.shape.ActivityShape)1 CaseManagementActivityShapeDef (org.kie.workbench.common.stunner.cm.client.shape.def.CaseManagementActivityShapeDef)1 ActivityView (org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView)1 DiagramRepresentation (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation)1 PictureShapeView (org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView)1 InOrder (org.mockito.InOrder)1