Example usage for com.vaadin.ui Label addStyleName

List of usage examples for com.vaadin.ui Label addStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.peergreen.example.webconsole.extensions.SimpleExtension.java

License:Open Source License

@PostConstruct
public void init() {
    Label hello = new Label("Hello world !");
    hello.addStyleName("h1");
    addComponent(hello);/*from w  w w.  j a v a  2 s  . com*/
    Label guide = new Label(String.format("This is a simple extension added by the bundle <b>%s</b> "
            + "to the scope <b>%s</b>.<br />If you want to contribute to this scope, write an extension class "
            + "annotated by @ExtensionPoint(\"com.peergreen.example.webconsole.scope.ScopeExample.tab\")",
            bundleContext.getBundle().getSymbolicName(), "Example"), ContentMode.HTML);
    addComponent(guide);
    setExpandRatio(guide, 1.5f);
}

From source file:com.peergreen.webconsole.core.exception.ExceptionView.java

License:Open Source License

public ExceptionView(Exception ex) {

    setSizeFull();//  ww w . j  a v a  2 s  .  c  o  m
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    addComponent(top);
    final Label title = new Label("Oops ! A problem occurred when drawing this view");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setMargin(new MarginInfo(true, true, false, true));
    row.setSpacing(true);
    addComponent(row);
    setExpandRatio(row, 1.5f);

    Table t = new Table();
    t.setCaption("Stack trace");
    t.addContainerProperty("<p style=\"display:none\">Stack</p>", String.class, null);
    t.setWidth("100%");
    t.setImmediate(true);
    t.addStyleName("plain");
    t.addStyleName("borderless");
    t.setSortEnabled(false);
    t.setImmediate(true);
    t.setSizeFull();

    int i = 1;
    t.addItem(new Object[] { ex.toString() }, i++);
    for (StackTraceElement element : ex.getStackTrace()) {
        t.addItem(new Object[] { element.toString() }, i++);
    }
    CssLayout panel = new CssLayout();
    panel.addStyleName("layout-panel");
    panel.setSizeFull();

    panel.addComponent(t);

    row.addComponent(panel);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Init UI/*  ww  w.  jav  a2 s .c o m*/
 *
 * @param request vaadin request
 */
@Override
protected void init(VaadinRequest request) {
    setLocale(Locale.US);
    getPage().setTitle("Welcome to " + consoleName);
    setContent(root);
    root.addStyleName("root");
    root.setSizeFull();

    Label bg = new Label();
    bg.setSizeUndefined();
    bg.addStyleName("login-bg");
    root.addComponent(bg);

    Boolean isLogged = (Boolean) getSession().getAttribute("is.logged");
    if (!enableSecurity || (isLogged != null && isLogged)) {
        securityManager = (ISecurityManager) getSession().getAttribute("security.manager");
        if (securityManager == null) {
            Subject defaultSubject = new Subject();
            defaultSubject.getPrincipals().add(new UserPrincipal(ANONYMOUS_USER));
            RoleGroup group = new RoleGroup();
            if (defaultRoles != null) {
                for (String role : defaultRoles) {
                    group.addMember(new RolePrincipal(role));
                }
            }
            defaultSubject.getPrincipals().add(group);
            defaultSubject.setReadOnly();
            securityManager = new SecurityManager(defaultSubject);
            getSession().setAttribute("security.manager", securityManager);
            getSession().getService().addSessionDestroyListener(new SessionDestroyListener() {
                @Override
                public void sessionDestroy(SessionDestroyEvent sessionDestroyEvent) {
                    sessionDestroyEvent.getSession().getSession().removeAttribute("security.manager");
                }
            });
        }
        buildMainView();
    } else {
        //            Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
        //            if (userCookie != null) {
        //                String token = userCookie.getValue();
        //                // get user by token and show main view
        //            }
        buildLoginView(false);
    }
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view//from w  ww.  j  a v a 2 s.  com
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build Welcome progress indicator view
 */// www. j  a v  a  2 s  . c  o m
private void buildProgressIndicatorView() {

    final CssLayout progressPanel = new CssLayout();
    progressPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    progressPanel.addComponent(labels);

    Label welcome = new Label("Welcome " + ((securityManager == null) ? "" : securityManager.getUserName()));
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    Float scopesViewsBound = (float) scopes.size();
    final Float stopValue = new Float(1.0);

    if (scopesFactories.isEmpty()) {
        progressIndicator.setValue(stopValue);
    } else {
        progressIndicator.setValue(scopesViewsBound / nbScopesToBind);
    }

    if (stopValue.equals(progressIndicator.getValue())) {
        showMainContent();
    } else {
        // We are still waiting for scopes we have requested their creation, wait a while.
        TimeOutThread timeOutThread = new TimeOutThread();
        timeOutThread.start();
        progressIndicator.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                if (stopValue.equals(event.getProperty().getValue())) {
                    showMainContent();
                }
            }
        });
    }

    HorizontalLayout progressBarPanel = new HorizontalLayout();
    progressBarPanel.setWidth(MAX_WIDTH);
    progressBarPanel.setMargin(true);
    progressBarPanel.addComponent(progressIndicator);
    progressBarPanel.setComponentAlignment(progressIndicator, Alignment.MIDDLE_CENTER);
    progressPanel.addComponent(progressBarPanel);

    progressIndicatorLayout.addComponent(progressPanel);
    progressIndicatorLayout.setComponentAlignment(progressPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.scope.home.HomeScope.java

License:Open Source License

public HomeScope() {
    setSizeFull();//from   www  .  j  a v a 2  s  .c  o m
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    addComponent(top);
    Label title = new Label("Welcome to Peergreen Administration Console");
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row1 = new HorizontalLayout();
    row1.setSizeFull();
    row1.setMargin(new MarginInfo(true, true, true, true));
    row1.setSpacing(true);
    row1.addStyleName("row");
    addComponent(row1);
    setExpandRatio(row1, 4);

    HorizontalLayout row2 = new HorizontalLayout();
    row2.setSizeFull();
    row2.setMargin(new MarginInfo(true, true, true, true));
    row2.setSpacing(true);
    row2.addStyleName("row");
    addComponent(row2);
    setExpandRatio(row2, 4);

    topLeftFrame = new FrameView();
    row1.addComponent(topLeftFrame);

    topRightFrame = new FrameView();
    row1.addComponent(topRightFrame);

    bottomLeftFrame = new FrameView();
    row2.addComponent(bottomLeftFrame);

    bottomRightFrame = new FrameView();
    row2.addComponent(bottomRightFrame);
}

From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleTab.java

License:Open Source License

private void init() {

    setMargin(true);/*from w w  w .j a  v  a 2s  . c om*/
    setSpacing(true);

    // ----------------------------------------------------
    // Title
    // ----------------------------------------------------

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setMargin(true);

    Label title = new Label(format("Bundle %d: %s (%s)", bundle.getBundleId(),
            getHeader(bundle, Constants.BUNDLE_NAME), bundle.getVersion()));
    title.addStyleName("h1");
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    addComponent(header);

    // ----------------------------------------------------
    // Action(s) Bar
    // ----------------------------------------------------

    HorizontalLayout actions = new HorizontalLayout();
    if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) {
        Button changeState = new Button();
        changeState.addClickListener(new StartBundleClickListener(bundle, notifierService));
        //changeState.addStyleName("no-padding");
        changeState.setCaption("Start");
        changeState.setIcon(new ClassResource(getClass(), "/images/32x32/go-next.png"));
        actions.addComponent(changeState);
    }
    if (BundleHelper.isState(bundle, Bundle.ACTIVE)) {
        Button changeState = new Button();
        changeState.addClickListener(new StopBundleClickListener(bundle, notifierService));
        //changeState.addStyleName("no-padding");
        changeState.setCaption("Stop");
        changeState.setIcon(new ClassResource(getClass(), "/images/32x32/media-record.png"));
        actions.addComponent(changeState);
    }

    // Update
    Button update = new Button();
    update.addClickListener(new UpdateBundleClickListener(bundle, notifierService));
    //update.addStyleName("no-padding");
    update.setCaption("Update");
    update.setIcon(new ClassResource(getClass(), "/images/32x32/view-refresh.png"));
    actions.addComponent(update);

    // Trash
    Button trash = new Button();
    trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService));
    //trash.addStyleName("no-padding");
    trash.setCaption("Remove");
    trash.setIcon(new ClassResource(getClass(), "/images/32x32/user-trash-full.png"));
    actions.addComponent(trash);
    addComponent(actions);
    setComponentAlignment(actions, Alignment.MIDDLE_RIGHT);

    // ----------------------------------------------------
    // Standard Section
    // ----------------------------------------------------

    Table table = new Table();
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setWidth("100%");

    Section mainSection = new Section("Standard", table);
    addComponent(mainSection);

    table.addContainerProperty("label", Label.class, null);
    table.addContainerProperty("value", Label.class, null);

    table.addItem(new Object[] { label("Bundle ID"), label(String.valueOf(bundle.getBundleId())) },
            "bundle.id");
    for (Map.Entry<String, String> entry : HEADERS.entrySet()) {
        String value = getHeader(bundle, entry.getKey());
        if (value != null) {
            table.addItem(new Object[] { label(entry.getValue()), label(value) }, entry.getKey());
        }
    }
    table.addItem(new Object[] { label("Location"), label(bundle.getLocation()) }, "bundle.location");
    Date date = new Date(bundle.getLastModified());
    table.addItem(new Object[] { label("Last Modified"), label(date.toString()) }, "last.modified");

    // ----------------------------------------------------
    // Packages Section
    // ----------------------------------------------------

    FilteredPackageTable exported = new FilteredPackageTable("Exported");

    FilteredPackageTable imported = new FilteredPackageTable("Imported");

    GridLayout packages = new GridLayout(2, 1);
    packages.addComponent(exported);
    packages.addComponent(imported);
    packages.setSpacing(true);
    packages.setWidth("100%");

    Section packagesSection = new Section("Packages", packages);
    addComponent(packagesSection);

    BundleWiring wiring = bundle.adapt(BundleWiring.class);
    if (wiring != null) {
        for (BundleCapability capability : wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) {
            String name = (String) capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
            Version version = (Version) capability.getAttributes()
                    .get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            exported.addPackage(format("%s (%s)", name, version));
        }
        for (BundleRequirement requirement : wiring.getRequirements(PackageNamespace.PACKAGE_NAMESPACE)) {
            String filter = requirement.getDirectives().get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE);
            imported.addPackage(filter);
        }
    }

    // ----------------------------------------------------
    // Services Section
    // ----------------------------------------------------

    FilteredServiceTable registered = new FilteredServiceTable("Registered");

    FilteredServiceTable used = new FilteredServiceTable("Used Services");

    VerticalLayout services = new VerticalLayout(registered, used);
    services.setSpacing(true);
    services.setWidth("100%");

    ServiceReference<?>[] registeredServices = bundle.getRegisteredServices();
    if (registeredServices != null) {
        for (ServiceReference<?> reference : registeredServices) {
            registered.addService(reference);
        }
    }

    ServiceReference<?>[] inUseServices = bundle.getServicesInUse();
    if (inUseServices != null) {
        for (ServiceReference<?> reference : inUseServices) {
            used.addService(reference);
        }
    }

    if (!registered.isEmpty() || !used.isEmpty()) {
        Section servicesSection = new Section("Services", services);
        addComponent(servicesSection);
    }

    // ----------------------------------------------------
    // Raw Manifest Section
    // ----------------------------------------------------

    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".monospaced-font {font-family: monospace !important; }");

    Table manifest = new Table();
    manifest.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    manifest.setWidth("100%");
    manifest.addStyleName("monospaced-font");
    manifest.setPageLength(15);
    manifest.addContainerProperty("name", String.class, null);
    manifest.addContainerProperty("value", String.class, null);

    Dictionary<String, String> headers = bundle.getHeaders();
    for (String key : Collections.list(headers.keys())) {
        manifest.addItem(new Object[] { key, headers.get(key) }, null);
    }

    Section manifestSection = new Section("Manifest", manifest);
    addComponent(manifestSection);

}

From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleView.java

License:Open Source License

@PostConstruct
public void createView() {
    setMargin(true);/*  ww w  .  j  av a  2s.  c  om*/
    setSpacing(true);

    /*
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".no-padding {padding: 0em 0em 0em 0em !important; }");
    */

    HorizontalLayout header = new HorizontalLayout();
    //        header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    Label title = new Label("OSGi Bundles");
    title.addStyleName("h1");
    //        title.setSizeUndefined();
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    final TextField filter = new TextField();
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            data.removeAllContainerFilters();
            String trimmed = event.getText().trim();
            Container.Filter or = new Or(new SimpleStringFilter(BUNDLE_ID_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(BUNDLE_NAME_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(BUNDLE_SYMBOLICNAME_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(VERSION_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(PRETTY_STATE_COLUMN, trimmed, true, false));

            data.addContainerFilter(or);
        }
    });

    filter.setInputPrompt("Filter");
    filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            filter.setValue("");
            data.removeAllContainerFilters();
        }
    });
    header.addComponent(filter);
    header.setExpandRatio(filter, 1);
    header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);

    // Store the header in the vertical layout (this)
    addComponent(header);

    addComponent(tabSheet);

    table = new Table();
    table.setContainerDataSource(data);
    table.setSizeFull();
    table.setSortContainerPropertyId(BUNDLE_ID_COLUMN);
    table.setSortAscending(true);
    table.setImmediate(true);
    table.setColumnHeader(BUNDLE_ID_COLUMN, "Bundle ID");
    table.setColumnHeader(PRETTY_NAME_COLUMN, "Bundle Name");
    table.setColumnHeader(VERSION_COLUMN, "Version");
    table.setColumnHeader(PRETTY_STATE_COLUMN, "State");
    table.setColumnHeader("actions", "Actions");

    table.setColumnWidth(BUNDLE_ID_COLUMN, 100);

    table.setColumnAlignment(BUNDLE_ID_COLUMN, Table.Align.CENTER);
    table.setColumnAlignment(PRETTY_STATE_COLUMN, Table.Align.CENTER);
    table.setColumnAlignment(VERSION_COLUMN, Table.Align.CENTER);

    table.addGeneratedColumn("actions", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {
            HorizontalLayout layout = new HorizontalLayout();
            BeanItem<BundleItem> item = (BeanItem<BundleItem>) source.getContainerDataSource().getItem(itemId);
            Bundle bundle = item.getBean().getBundle();
            if (BundleHelper.isState(bundle, Bundle.INSTALLED)
                    || BundleHelper.isState(bundle, Bundle.RESOLVED)) {
                Button changeState = new Button();
                changeState.addClickListener(new StartBundleClickListener(bundle, notifierService));
                //changeState.addStyleName("no-padding");
                changeState.setCaption("Start");
                //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/go-next.png"));
                if (!securityManager.isUserInRole("admin")) {
                    changeState.setDisableOnClick(true);
                }
                layout.addComponent(changeState);
            }
            if (BundleHelper.isState(bundle, Bundle.ACTIVE)) {
                Button changeState = new Button();
                changeState.addClickListener(new StopBundleClickListener(bundle, notifierService));
                //changeState.addStyleName("no-padding");
                changeState.setCaption("Stop");
                if (!securityManager.isUserInRole("admin")) {
                    changeState.setDisableOnClick(true);
                }
                //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/media-record.png"));
                layout.addComponent(changeState);
            }

            // Update
            Button update = new Button();
            update.addClickListener(new UpdateBundleClickListener(bundle, notifierService));
            //update.addStyleName("no-padding");
            update.setCaption("Update");
            if (!securityManager.isUserInRole("admin")) {
                update.setDisableOnClick(true);
            }
            //update.setIcon(new ClassResource(BundleViewer.class, "/images/view-refresh.png"));
            layout.addComponent(update);

            // Trash
            Button trash = new Button();
            trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService));
            //trash.addStyleName("no-padding");
            trash.setCaption("Delete");
            if (!securityManager.isUserInRole("admin")) {
                trash.setDisableOnClick(true);
            }
            //trash.setIcon(new ClassResource(BundleViewer.class, "/images/user-trash-full.png"));
            layout.addComponent(trash);

            return layout;
        }
    });

    table.setVisibleColumns(BUNDLE_ID_COLUMN, PRETTY_NAME_COLUMN, VERSION_COLUMN, PRETTY_STATE_COLUMN,
            "actions");

    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(final ItemClickEvent event) {
            if (event.isDoubleClick()) {
                BeanItem<BundleItem> item = (BeanItem<BundleItem>) table.getContainerDataSource()
                        .getItem(event.getItemId());
                Bundle bundle = item.getBean().getBundle();
                showBundle(bundle);
            }
        }
    });

    createBundleTracker();

    tabSheet.setSizeFull();
    selectedTabListener = new SelectedTabListener(uiContext.getViewNavigator());
    selectedTabListener.addLocation(table, uiContext.getViewNavigator().getLocation(this.getClass().getName()));
    tabSheet.addSelectedTabChangeListener(selectedTabListener);
    tabSheet.addTab(table, "Bundles", new ClassResource(BundleView.class, "/images/22x22/user-home.png"));
    setExpandRatio(tabSheet, 1.5f);

    tabSheet.setCloseHandler(new TabSheet.CloseHandler() {
        @Override
        public void onTabClose(TabSheet tabsheet, Component tabContent) {
            for (Map.Entry<Long, Component> tab : openTabs.entrySet()) {
                if (tabContent.equals(tab.getValue())) {
                    openTabs.remove(tab.getKey());
                }
            }
            tabsheet.removeComponent(tabContent);
            selectedTabListener.removeLocation(tabContent);
        }
    });
}

From source file:com.peergreen.webconsole.scope.system.internal.service.ServiceViewer.java

License:Open Source License

private void initHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);//from ww  w  . jav a 2s  .  co  m
    header.setMargin(true);

    Label title = new Label("OSGi Services");
    title.addStyleName("h1");
    title.setSizeUndefined();
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    final TextField filter = new TextField();
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            data.removeAllContainerFilters();
            String trimmed = event.getText().trim();
            Container.Filter or = new Or(new SimpleStringFilter(SERVICE_ID_COLUMN, trimmed, true, false),
                    new InterfacesFilter(trimmed), new BundleFilter(trimmed),
                    new ServicePropertiesFilter(trimmed));

            data.addContainerFilter(or);
        }
    });

    filter.setInputPrompt("Filter");
    filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            filter.setValue("");
            data.removeAllContainerFilters();
        }
    });
    header.addComponent(filter);
    header.setExpandRatio(filter, 1);
    header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);

    // Store the header in the vertical layout (this)
    addComponent(header);
}

From source file:com.peergreen.webconsole.scope.system.internal.shell.ShellConsoleView.java

License:Open Source License

private void initHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);//  w w  w . ja v  a  2  s. c o m
    header.setMargin(true);

    Label title = new Label("Shell Console");
    title.addStyleName("h1");
    title.setSizeUndefined();
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    // Store the header in the vertical layout (this)
    addComponent(header);
}