• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Label类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.haulmont.cuba.gui.components.Label的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Label类属于com.haulmont.cuba.gui.components包,在下文中一共展示了Label类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initPermissionColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumns(TreeTable<BasicPermissionTarget> screenPermissionsTree) {
    screenPermissionsTree.addGeneratedColumn("permissionVariant", entity -> {
        PermissionVariant permissionVariant = entity.getPermissionVariant();
        if (permissionVariant == PermissionVariant.NOTSET)
            return null;

        String labelValue = "<span class=\"role-permission-" + permissionVariant.getColor() + "\">" +
                messages.getMessage(permissionVariant) + "</span>";

        Label label = componentsFactory.createComponent(Label.class);
        label.setHtmlEnabled(true);
        label.setValue(labelValue);

        return label;
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:ScreenPermissionsFrameCompanion.java


示例2: initPermissionColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumns(TreeTable<BasicPermissionTarget> specificPermissionsTree) {
    specificPermissionsTree.addGeneratedColumn("permissionVariant", entity -> {
        PermissionVariant permissionVariant = entity.getPermissionVariant();
        if (permissionVariant == PermissionVariant.NOTSET)
            return null;

        Label label = componentsFactory.createComponent(Label.class);
        label.setHtmlEnabled(true);
        String labelValue = "<span class=\"role-permission-" + permissionVariant.getColor() + "\">" +
                messages.getMessage(permissionVariant) + "</span>";
        label.setValue(labelValue);

        return label;
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:SpecificPermissionsFrameCompanion.java


示例3: initPermissionColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumns(TreeTable screenPermissionsTree) {
    screenPermissionsTree.addGeneratedColumn("permissionVariant", new Table.ColumnGenerator<BasicPermissionTarget>() {
        @Override
        public Component generateCell(BasicPermissionTarget entity) {
            Label label = AppConfig.getFactory().createComponent(Label.class);
            JLabel jLabel = (JLabel) DesktopComponentsHelper.unwrap(label);

            StringBuilder builder = new StringBuilder();

            PermissionVariant permissionVariant = entity.getPermissionVariant();

            if (permissionVariant != PermissionVariant.NOTSET) {
                builder.append("<html>");
                builder.append("<font color=\"").append(permissionVariant.getColor()).append("\">")
                        .append(messages.getMessage(permissionVariant)).append("</font>");

                builder.append("</html>");
            }

            jLabel.setText(builder.toString());

            return label;
        }
    }, Label.class);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:ScreenPermissionsFrameCompanion.java


示例4: generateLabelByPermissionVariant

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
protected Label generateLabelByPermissionVariant(PermissionVariant permissionVariant) {
    Label label = AppConfig.getFactory().createComponent(Label.class);
    JLabel jLabel = (JLabel) DesktopComponentsHelper.unwrap(label);

    StringBuilder builder = new StringBuilder();

    if (permissionVariant != PermissionVariant.NOTSET) {
        builder.append("<html>");
        builder.append("<font color=\"").append(permissionVariant.getColor()).append("\">")
                .append(messages.getMessage(permissionVariant)).append("</font>");

        builder.append("</html>");
    }

    jLabel.setText(builder.toString());

    return label;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:EntityPermissionsFrameCompanion.java


示例5: initPermissionColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumns(TreeTable specificPermissionsTree) {
    specificPermissionsTree.addGeneratedColumn("permissionVariant", new Table.ColumnGenerator<BasicPermissionTarget>() {
        @Override
        public Component generateCell(BasicPermissionTarget entity) {
            Label label = AppConfig.getFactory().createComponent(Label.class);
            JLabel jLabel = (JLabel) DesktopComponentsHelper.unwrap(label);

            StringBuilder builder = new StringBuilder();

            PermissionVariant permissionVariant = entity.getPermissionVariant();

            if (permissionVariant != PermissionVariant.NOTSET) {
                builder.append("<html>");
                builder.append("<font color=\"").append(permissionVariant.getColor()).append("\">")
                        .append(messages.getMessage(permissionVariant)).append("</font>");

                builder.append("</html>");
            }

            jLabel.setText(builder.toString());

            return label;
        }
    }, Label.class);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:SpecificPermissionsFrameCompanion.java


示例6: initPermissionsColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionsColoredColumns(Table uiPermissionsTable) {
    uiPermissionsTable.addGeneratedColumn("permissionVariant", new Table.ColumnGenerator<UiPermissionTarget>() {
        @Override
        public Component generateCell(UiPermissionTarget entity) {
            Label label = AppConfig.getFactory().createComponent(Label.class);
            JLabel jLabel = (JLabel) DesktopComponentsHelper.unwrap(label);

            StringBuilder builder = new StringBuilder();

            UiPermissionVariant permissionVariant = entity.getPermissionVariant();

            if (permissionVariant != UiPermissionVariant.NOTSET) {
                builder.append("<html>");
                builder.append("<font color=\"").append(permissionVariant.getColor()).append("\">")
                        .append(messages.getMessage(permissionVariant)).append("</font>");

                builder.append("</html>");
            }

            jLabel.setText(builder.toString());

            return label;
        }
    }, Label.class);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:UiPermissionsFrameCompanion.java


示例7: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    // unbind
    label.setDatasource(null, null);
    assertNotNull(label.getValue());

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    label.addValueChangeListener(listener);

    user.setName("anotherName");
    assertEquals("testName", label.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:LabelDsTest.java


示例8: testUnsubscribeDsListener

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Test
public void testUnsubscribeDsListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    // unbind
    label.setDatasource(null, null);
    assertNotNull(label.getValue());

    Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    userDs.addItemPropertyChangeListener(propertyChangeListener);

    label.setValue("anotherName");
    assertEquals("testName", user.getName());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:LabelDsTest.java


示例9: testUnsubscribeSubscribeDsListener

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    label.setDatasource(null, null);
    label.setDatasource(userDs, "name");

    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(propertyChangeListener);

    label.setValue("anotherName");
    assertEquals(true, valueWasChanged[0]);
    assertEquals("anotherName", user.getName());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:LabelDsTest.java


示例10: initTable

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
private void initTable() {
    routeDs.addItem(new Route("00:11", "149 S 4th St", "202 S 14th St"));
    routeDs.addItem(new Route("00:32", "1192 Fremont St", "1252 Randol Ave"));
    routeDs.addItem(new Route("00:46", "760 Chapman St", "905 Morse St"));
    routeDs.addItem(new Route("01:03", "986 Silicon Dr", "1042 Newhall St"));
    routeDs.addItem(new Route("01:52", "1080 Portola Ave", "790 Locust St"));
    routeDs.addItem(new Route("02:27", "1098 Lexington St", "1313 Franklin St"));

    routesTable.addGeneratedColumn("direction", routes -> {
        Label dataTypeLabel = componentsFactory.createComponent(Label.class);
        dataTypeLabel.setValue("\u2192");
        dataTypeLabel.setStyleName("direction");
        return dataTypeLabel;
    });

    routesTable.setSettingsEnabled(false);
}
 
开发者ID:cuba-platform,项目名称:sample-dashboard,代码行数:18,代码来源:ExtAppMainWindow.java


示例11: checkComponents

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
private void checkComponents() {
    StringBuilder sb = new StringBuilder("Created components:\n");

    sb.append("label1 = ");
    Label label1 = (Label) getComponent("label1");
    sb.append(label1 == null ? null : (String) label1.getValue());

    sb.append(", label2 = ");
    Label label2 = (Label) getComponent("label2");
    sb.append(label2 == null ? null : (String) label2.getValue());

    info.setValue(sb.toString());
}
 
开发者ID:cuba-platform,项目名称:sampler,代码行数:14,代码来源:LazyAccordionFrame.java


示例12: initPermissionColoredColumn

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumn(final Table<MultiplePermissionTarget> propertyPermissionsTable) {
    propertyPermissionsTable.addGeneratedColumn("permissionsInfo", target -> {
        List<AttributeTarget> permissions = target.getPermissions();
        if (permissions.size() == 0)
            return null;

        Label label = AppConfig.getFactory().createComponent(Label.class);
        label.setHtmlEnabled(true);

        int i = 0;
        StringBuilder builder = new StringBuilder();
        Iterator<AttributeTarget> iterator = permissions.iterator();
        while (iterator.hasNext() && i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT) {
            AttributeTarget attributeTarget = iterator.next();
            AttributePermissionVariant permissionVariant = attributeTarget.getPermissionVariant();
            if (permissionVariant != AttributePermissionVariant.NOTSET) {
                if (i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT - 1) {
                    if (i > 0)
                        builder.append(", ");

                    builder.append("<span class=\"role-permission-").append(permissionVariant.getColor()).append("\">")
                            .append(attributeTarget.getId()).append("</span>");
                } else {
                    builder.append(", ...");
                }
                i++;
            }
        }
        label.setValue(builder.toString());

        return label;
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:35,代码来源:AttributePermissionsFrameCompanion.java


示例13: generateLabelByPermissionVariant

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
protected Label generateLabelByPermissionVariant(PermissionVariant permissionVariant) {
    if (permissionVariant == PermissionVariant.NOTSET)
        return null;

    String labelValue = "<span class=\"role-permission-" + permissionVariant.getColor() + "\">" +
            messages.getMessage(permissionVariant) + "</span>";

    Label label = componentsFactory.createComponent(Label.class);
    label.setHtmlEnabled(true);
    label.setValue(labelValue);

    return label;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:EntityPermissionsFrameCompanion.java


示例14: initPermissionsColoredColumns

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionsColoredColumns(Table<UiPermissionTarget> uiPermissionsTable) {
    uiPermissionsTable.addGeneratedColumn("permissionVariant", entity -> {
        UiPermissionVariant permissionVariant = entity.getPermissionVariant();
        if (permissionVariant == UiPermissionVariant.NOTSET)
            return null;

        Label label = componentsFactory.createComponent(Label.class);
        label.setHtmlEnabled(true);
        String labelValue = "<span style=\"role-permission-" + permissionVariant.getColor() + "\">" +
                messages.getMessage(permissionVariant) + "</span>";
        label.setValue(labelValue);
        return label;
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:16,代码来源:UiPermissionsFrameCompanion.java


示例15: initPermissionColoredColumn

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void initPermissionColoredColumn(final Table propertyPermissionsTable) {
    propertyPermissionsTable.addGeneratedColumn("permissionsInfo", new Table.ColumnGenerator<MultiplePermissionTarget>() {
        @Override
        public Component generateCell(MultiplePermissionTarget target) {
            Label label = AppConfig.getFactory().createComponent(Label.class);
            JLabel jLabel = (JLabel) DesktopComponentsHelper.unwrap(label);

            int i = 0;
            StringBuilder builder = new StringBuilder("<html>");
            Iterator<AttributeTarget> iterator = target.getPermissions().iterator();
            while (iterator.hasNext() && i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT) {
                AttributeTarget attributeTarget = iterator.next();
                AttributePermissionVariant permissionVariant = attributeTarget.getPermissionVariant();
                if (permissionVariant != AttributePermissionVariant.NOTSET) {
                    if (i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT - 1) {
                        if (i > 0)
                            builder.append(", ");

                        builder.append("<font color=\"").append(permissionVariant.getColor()).append("\">")
                                .append(attributeTarget.getId()).append("</font>");
                    } else {
                        builder.append(", ...");
                    }
                    i++;
                }
            }
            builder.append("</html>");
            jLabel.setText(builder.toString());

            return label;
        }
    }, Label.class);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:35,代码来源:AttributePermissionsFrameCompanion.java


示例16: decorate

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
public void decorate(Object component, Set<String> state) {
    JLabel label;
    if (component instanceof JLabel) {
        label = (JLabel) component;
    } else if (component instanceof Label) {
        label = (JLabel) DesktopComponentsHelper.unwrap((Component) component);
    } else {
        throw new RuntimeException("Component is not suitable: " + component);
    }

    Icon icon = App.getInstance().getResources().getIcon(iconName);
    label.setIcon(icon);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:15,代码来源:IconDecorator.java


示例17: createComponent

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Override
protected Component createComponent() {
    ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class);
    Label label = componentsFactory.createComponent(Label.class);
    label.setValue(condition.getOperationCaption());
    return label;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:DynamicAttributesOperationEditor.java


示例18: testValueChangeListener

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Test
public void testValueChangeListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    // listener after datasource
    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    label.addValueChangeListener(listener);

    user.setName("anotherName");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    label.removeValueChangeListener(listener);
    label.setDatasource(null, null);
    valueWasChanged[0] = false;
    label.setValue("testName");

    // datasource after listener
    label.addValueChangeListener(listener);
    label.setDatasource(userDs, "name");

    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:30,代码来源:LabelDsTest.java


示例19: testUnsubscribeSubscribeComponentListener

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    label.setDatasource(null, null);

    // datasource before listener
    label.setDatasource(userDs, "name");
    assertEquals("testName", label.getValue());

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    label.addValueChangeListener(listener);

    user.setName("anotherName");
    assertEquals(true, valueWasChanged[0]);
    assertEquals("anotherName", label.getValue());

    // reset state
    label.removeValueChangeListener(listener);
    label.setDatasource(null, null);
    valueWasChanged[0] = false;
    label.setValue("testName");

    // listener before datasource
    label.addValueChangeListener(listener);
    label.setDatasource(userDs, "name");
    assertEquals(true, valueWasChanged[0]);
    assertEquals("anotherName", label.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:36,代码来源:LabelDsTest.java


示例20: updateSummaryColumn

import com.haulmont.cuba.gui.components.Label; //导入依赖的package包/类
protected void updateSummaryColumn() {
    summaryBox.removeAll();
    CubaVerticalActionsLayout summaryLayout = (CubaVerticalActionsLayout) WebComponentsHelper.unwrap(summaryBox);
    CubaVerticalActionsLayout summaryCaptionVbox = new CubaVerticalActionsLayout();
    summaryCaptionVbox.setHeight("30px");
    summaryCaptionVbox.setWidth("100%");
    com.vaadin.ui.Label summaryCaption = new com.vaadin.ui.Label();
    summaryCaption.setContentMode(ContentMode.HTML);
    summaryCaption.setValue(getMessage("label.summaryCaption"));
    summaryCaption.setWidthUndefined();
    summaryCaptionVbox.addComponent(summaryCaption);
    summaryCaptionVbox.setComponentAlignment(summaryCaption, com.vaadin.ui.Alignment.MIDDLE_CENTER);
    summaryLayout.addComponent(summaryCaptionVbox);

    FactAndPlan[] summariesByWeeks = calculateSummariesByWeeks();
    FactAndPlan summaryForMonth = new FactAndPlan();
    for (int i = 1; i < summariesByWeeks.length; i++) {
        com.vaadin.ui.Label hourLabel = new com.vaadin.ui.Label();
        hourLabel.setContentMode(ContentMode.HTML);
        FactAndPlan summaryForTheWeek = summariesByWeeks[i];
        if (summaryForTheWeek == null) {
            summaryForTheWeek = new FactAndPlan();
        }
        if (summaryForTheWeek.isMatch()) {
            hourLabel.setValue(formatMessage("label.hoursSummary",
                    summaryForTheWeek.fact.getHours(), summaryForTheWeek.fact.getMinutes()));
        } else {
            hourLabel.setValue(formatMessage("label.hoursSummaryNotMatch",
                    summaryForTheWeek.fact.getHours(), summaryForTheWeek.fact.getMinutes(),
                    summaryForTheWeek.plan.getHours(), summaryForTheWeek.plan.getMinutes()));
            hourLabel.addStyleName("overtime");
        }
        hourLabel.setWidthUndefined();
        summaryLayout.addComponent(hourLabel);
        summaryLayout.setExpandRatio(hourLabel, 1);
        summaryLayout.setComponentAlignment(hourLabel, com.vaadin.ui.Alignment.MIDDLE_CENTER);

        summaryForMonth.fact.add(summaryForTheWeek.fact);
        summaryForMonth.plan.add(summaryForTheWeek.plan);
    }

    if (summaryForMonth.isMatch()) {
        monthSummary.setValue(formatMessage("label.monthSummaryFormat",
                summaryForMonth.fact.getHours(), summaryForMonth.fact.getMinutes()));
        monthSummary.setStyleName("month-summary");
    } else {
        monthSummary.setValue(formatMessage("label.monthSummaryFormatNotMatch",
                summaryForMonth.fact.getHours(), summaryForMonth.fact.getMinutes(),
                summaryForMonth.plan.getHours(), summaryForMonth.plan.getMinutes()));
        monthSummary.setStyleName("month-summary-overtime");
    }
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:53,代码来源:CalendarScreen.java



注:本文中的com.haulmont.cuba.gui.components.Label类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DatanodeLocalInfoProto类代码示例发布时间:2022-05-23
下一篇:
Java Toggle类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap