Example usage for com.vaadin.server ThemeResource ThemeResource

List of usage examples for com.vaadin.server ThemeResource ThemeResource

Introduction

In this page you can find the example usage for com.vaadin.server ThemeResource ThemeResource.

Prototype

public ThemeResource(String resourceId) 

Source Link

Document

Creates a resource.

Usage

From source file:org.ow2.sirocco.cloudmanager.MyUI.java

License:Open Source License

@Override
protected void init(final VaadinRequest request) {
    this.userName = request.getUserPrincipal().getName();
    this.identityContext.setUserName(this.userName);

    this.getPage().setTitle("Sirocco Dashboard");
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*w  w  w .  j ava 2 s.  c o m*/
    this.setContent(layout);

    // Top header *********************
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(true);
    header.setWidth("100%");
    header.setHeight("70px");
    header.setStyleName("topHeader");

    // logo
    Image image = new Image(null, new ThemeResource("img/sirocco_small_logo.png"));
    header.addComponent(image);

    // spacer
    Label spacer = new Label();
    spacer.setWidth("100%");
    header.addComponent(spacer);
    header.setExpandRatio(spacer, 1.0f);

    HorizontalLayout rightButtons = new HorizontalLayout();
    rightButtons.setStyleName("topHeader");
    rightButtons.setSpacing(true);

    this.userName = request.getUserPrincipal().getName();
    User user = null;
    try {
        user = this.userManager.getUserByUsername(this.userName);
    } catch (CloudProviderException e) {
        e.printStackTrace();
    }

    Label label = new Label("Tenant:");
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);
    final ComboBox tenantSelect = new ComboBox();
    tenantSelect.setTextInputAllowed(false);
    tenantSelect.setNullSelectionAllowed(false);
    for (Tenant tenant : user.getTenants()) {
        tenantSelect.addItem(tenant.getName());
    }
    tenantSelect.setValue(user.getTenants().iterator().next().getName());
    tenantSelect.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            Notification.show("Switching to tenant " + tenantSelect.getValue());

        }
    });
    tenantSelect.setImmediate(true);
    rightButtons.addComponent(tenantSelect);

    this.tenantId = user.getTenants().iterator().next().getUuid();
    this.identityContext.setTenantId(this.tenantId);

    // logged user name

    label = new Label("Logged in as: " + this.userName);
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);

    // sign out button
    Button button = new Button("Sign Out");
    // button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            MyUI.this.logout();
        }
    });
    rightButtons.addComponent(button);

    header.addComponent(rightButtons);
    layout.addComponent(header);

    // Split view
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setFirstComponent(this.createLeftMenu());

    this.inventoryContainer = new VerticalLayout();
    this.inventoryContainer.setSizeFull();

    this.inventoryContainer.addComponent(this.machineView);

    splitPanel.setSecondComponent(this.inventoryContainer);
    splitPanel.setSplitPosition(15);

    layout.addComponent(splitPanel);
    layout.setExpandRatio(splitPanel, 1.0f);

    this.listenToNotifications();

}

From source file:org.ow2.sirocco.cloudmanager.MyUI.java

License:Open Source License

Tree createLeftMenu() {
    final Tree resourceTree = new Tree("Root");
    resourceTree.setStyleName("myTree");
    resourceTree.setImmediate(true);/*from ww  w. j  av  a  2 s.co m*/
    resourceTree.setSizeFull();
    resourceTree.addItem(MyUI.PROVIDERS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.PROVIDERS_MENU_ITEM_ID, new ThemeResource("img/cloud.png"));
    resourceTree.setChildrenAllowed(MyUI.PROVIDERS_MENU_ITEM_ID, false);

    // resourceTree.addItem(MyUI.COMPUTE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.INSTANCES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.INSTANCES_MENU_ITEM_ID, new ThemeResource("img/server.png"));
    resourceTree.setChildrenAllowed(MyUI.INSTANCES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.INSTANCES_MENU_ITEM_ID, MyUI.COMPUTE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.IMAGES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.IMAGES_MENU_ITEM_ID, new ThemeResource("img/image.png"));
    resourceTree.setItemCaption(MyUI.IMAGES_MENU_ITEM_ID, "  Images");
    resourceTree.setChildrenAllowed(MyUI.IMAGES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.IMAGES_MENU_ITEM_ID, MyUI.COMPUTE_MENU_ITEM_ID);

    // resourceTree.addItem(MyUI.STORAGE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.VOLUMES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.VOLUMES_MENU_ITEM_ID, new ThemeResource("img/disk.png"));
    resourceTree.setItemCaption(MyUI.VOLUMES_MENU_ITEM_ID, "  Volumes");
    resourceTree.setChildrenAllowed(MyUI.VOLUMES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.VOLUMES_MENU_ITEM_ID, MyUI.STORAGE_MENU_ITEM_ID);

    // resourceTree.addItem(MyUI.NETWORKING_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.NETWORKS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.NETWORKS_MENU_ITEM_ID, new ThemeResource("img/network.png"));
    resourceTree.setChildrenAllowed(MyUI.NETWORKS_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.NETWORKS_MENU_ITEM_ID, MyUI.NETWORKING_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.ADDRESSES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.ADDRESSES_MENU_ITEM_ID, new ThemeResource("img/ip-icon.png"));
    resourceTree.setChildrenAllowed(MyUI.ADDRESSES_MENU_ITEM_ID, false);

    resourceTree.addItem(MyUI.SECURITY_GROUP_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.SECURITY_GROUP_MENU_ITEM_ID, new ThemeResource("img/secgroup.png"));
    resourceTree.setChildrenAllowed(MyUI.SECURITY_GROUP_MENU_ITEM_ID, false);

    // resourceTree.addItem(MyUI.SECURITY_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.KEYPAIRS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.KEYPAIRS_MENU_ITEM_ID, new ThemeResource("img/key.png"));
    resourceTree.setChildrenAllowed(MyUI.KEYPAIRS_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.KEYPAIRS_MENU_ITEM_ID, MyUI.SECURITY_MENU_ITEM_ID);

    // resourceTree.expandItemsRecursively(MyUI.COMPUTE_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.STORAGE_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.NETWORKING_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.SECURITY_MENU_ITEM_ID);

    resourceTree.select(MyUI.INSTANCES_MENU_ITEM_ID);

    resourceTree.addValueChangeListener(new ValueChangeListener() {
        Object previous = null;

        @Override
        public void valueChange(final ValueChangeEvent event) {
            if (resourceTree.getValue() != null) {
                if (resourceTree.hasChildren(resourceTree.getValue())) {
                    resourceTree.setValue(this.previous);
                } else {
                    this.previous = resourceTree.getValue();
                    switch ((String) resourceTree.getValue()) {
                    case PROVIDERS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.providerView);
                        break;
                    case INSTANCES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.machineView);
                        break;
                    case IMAGES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.machineImageView);
                        break;
                    case VOLUMES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.volumeView);
                        break;
                    case NETWORKS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.networkView);
                        break;
                    case ADDRESSES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.addressView);
                        break;
                    case SECURITY_GROUP_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.secGroupView);
                        break;
                    case KEYPAIRS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.keyPairView);
                        break;
                    }
                }
            }
        }
    });
    return resourceTree;
}

From source file:org.ow2.sirocco.cloudmanager.NetworkView.java

License:Open Source License

public NetworkView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);//w  ww  .  j  a  va 2s .com
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Create Network...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (NetworkView.this.networkCreationWizard.init(NetworkView.this)) {
                UI.getCurrent().addWindow(NetworkView.this.networkCreationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.deleteNetworkButton = new Button("Delete");
    this.deleteNetworkButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteNetworkButton.setEnabled(false);
    this.deleteNetworkButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedNetworkIds = (Set<?>) NetworkView.this.networkTable.getValue();
            String name = NetworkView.this.networks.getItem(selectedNetworkIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Network",
                    "Are you sure you want to delete network " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedNetworkIds) {
                                    try {
                                        NetworkView.this.networkManager.deleteNetwork(id.toString());
                                    } catch (CloudProviderException e) {
                                        e.printStackTrace();
                                    }
                                }
                                NetworkView.this.valueChange(null);
                            }
                        }
                    });
            NetworkView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteNetworkButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            NetworkView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.networkTable = this.createNetworkTable());
    this.setExpandRatio(this.networkTable, 1.0f);

}

From source file:org.ow2.sirocco.cloudmanager.SecurityGroupView.java

License:Open Source License

public SecurityGroupView() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();// w w w  .  jav a 2s .  c o  m

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Create SecurityGroup...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (SecurityGroupView.this.securityGroupCreationWizard.init(SecurityGroupView.this)) {
                UI.getCurrent().addWindow(SecurityGroupView.this.securityGroupCreationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.deleteSecurityGroupButton = new Button("Delete");
    this.deleteSecurityGroupButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteSecurityGroupButton.setEnabled(false);
    this.deleteSecurityGroupButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedSecurityGroupIds = (Set<?>) SecurityGroupView.this.securityGroupTable
                    .getValue();
            String name = SecurityGroupView.this.securityGroups
                    .getItem(selectedSecurityGroupIds.iterator().next()).getBean().getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete SecurityGroup",
                    "Are you sure you want to delete securityGroup " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedSecurityGroupIds) {
                                    try {
                                        SecurityGroupView.this.networkManager
                                                .deleteSecurityGroup(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Cannot delete security group "
                                                + SecurityGroupView.this.securityGroups.getItem(id).getBean()
                                                        .getName(),
                                                e);
                                    }
                                }
                                SecurityGroupView.this.valueChange(null);
                            }
                        }
                    });
            SecurityGroupView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteSecurityGroupButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            SecurityGroupView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.securityGroupTable = this.createSecurityGroupTable());
    verticalLayout.setExpandRatio(this.securityGroupTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new SecurityGroupDetailView(this));
    this.setSplitPosition(60.0f);

}

From source file:org.ow2.sirocco.cloudmanager.util.CountrySelector.java

License:Open Source License

private static IndexedContainer getISO3166Container() {
    if (CountrySelector.iso3166Container == null) {
        CountrySelector.iso3166Container = new IndexedContainer();
        CountrySelector.iso3166Container.addContainerProperty(CountrySelector.iso3166_PROPERTY_NAME,
                String.class, null);
        CountrySelector.iso3166Container.addContainerProperty(CountrySelector.iso3166_PROPERTY_SHORT,
                String.class, null);
        CountrySelector.iso3166Container.addContainerProperty(CountrySelector.iso3166_PROPERTY_FLAG,
                Resource.class, null);
        for (int i = 0; i < CountrySelector.iso3166.length; i++) {
            String name = CountrySelector.iso3166[i++];
            String id = CountrySelector.iso3166[i];
            Item item = CountrySelector.iso3166Container.addItem(id);
            item.getItemProperty(CountrySelector.iso3166_PROPERTY_NAME).setValue(name);
            item.getItemProperty(CountrySelector.iso3166_PROPERTY_SHORT).setValue(id);
            item.getItemProperty(CountrySelector.iso3166_PROPERTY_FLAG)
                    .setValue(new ThemeResource("img/flags/" + id.toLowerCase() + ".gif"));
        }/*from   w ww  .j a v  a  2s.c  om*/
        CountrySelector.iso3166Container.sort(new Object[] { CountrySelector.iso3166_PROPERTY_NAME },
                new boolean[] { true });

    }
    return CountrySelector.iso3166Container;
}

From source file:org.ow2.sirocco.cloudmanager.VolumeView.java

License:Open Source License

public VolumeView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);//from  ww w . j av  a  2s  .  c  o m
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Create Volume...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (VolumeView.this.volumeCreationWizard.init(VolumeView.this)) {
                UI.getCurrent().addWindow(VolumeView.this.volumeCreationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.attachVolumeButton = new Button("Attach");
    this.attachVolumeButton.setEnabled(false);
    this.attachVolumeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            final String volumeId = (String) selectedVolumeIds.iterator().next();
            List<VolumeAttachDialog.MachineChoice> choices = new ArrayList<>();
            Volume volume;
            try {
                volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                List<Machine> machines = VolumeView.this.machineManager.getMachines().getItems();
                for (Machine machine : machines) {
                    if (machine.getCloudProviderAccount().getId() == volume.getCloudProviderAccount().getId()
                            && machine.getLocation().getId() == volume.getLocation().getId()) {
                        MachineChoice machineChoice = new MachineChoice();
                        machineChoice.id = machine.getUuid();
                        machineChoice.name = machine.getName();
                        choices.add(machineChoice);
                    }
                }

            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Internal error", e);
            }

            VolumeAttachDialog volumeAttachDialog = new VolumeAttachDialog(choices,
                    new VolumeAttachDialog.DialogCallback() {

                        @Override
                        public void response(final String machineId, final String location) {
                            try {
                                Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                                MachineVolume volumeAttachment = new MachineVolume();
                                volumeAttachment.setInitialLocation(location);
                                volumeAttachment.setVolume(volume);
                                VolumeView.this.machineManager.addVolumeToMachine(machineId, volumeAttachment);
                            } catch (CloudProviderException e) {
                                Util.diplayErrorMessageBox("Volume attach failure", e);
                            }
                        }
                    });
            UI.getCurrent().addWindow(volumeAttachDialog);
        }
    });
    actionButtonHeader.addComponent(this.attachVolumeButton);

    this.detachVolumeButton = new Button("Detach");
    this.detachVolumeButton.setEnabled(false);
    this.detachVolumeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            String volumeId = (String) selectedVolumeIds.iterator().next();
            try {
                Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                MachineVolume volumeAttachment = volume.getAttachments().get(0);
                VolumeView.this.machineManager.removeVolumeFromMachine(volumeAttachment.getOwner().getUuid(),
                        volumeAttachment.getUuid());
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Volume detach failure", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.detachVolumeButton);

    this.deleteVolumeButton = new Button("Delete");
    this.deleteVolumeButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteVolumeButton.setEnabled(false);
    this.deleteVolumeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            String name = VolumeView.this.volumes.getItem(selectedVolumeIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Volume",
                    "Are you sure you want to delete volume " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedVolumeIds) {
                                    try {
                                        VolumeView.this.volumeManager.deleteVolume(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Volume delete failure", e);
                                    }
                                }
                                VolumeView.this.valueChange(null);
                            }
                        }
                    });
            VolumeView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteVolumeButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            VolumeView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.volumeTable = this.createVolumeTable());
    this.setExpandRatio(this.volumeTable, 1.0f);
}

From source file:org.plukh.fluffymeow.ui.Header.java

License:Open Source License

@Inject
public Header(HeaderUserComponent loginComponent, LocaleChooserComponent localeChooser) {
    log.trace("Creating Header...");

    this.loginComponent = loginComponent;
    this.localeChooser = localeChooser;

    setWidth("100%");
    setMargin(true);/*from   w  w  w  .j  a va  2s.c  o m*/
    setSpacing(true);

    Resource resource = new ThemeResource("logo.png");
    logoImage = new Image(null, resource);
    logoImage.addStyleName("pointer");
    logoImage.addClickListener(this::onLogoImageClick);

    addComponent(logoImage);
    addComponent(loginComponent);
    addComponent(localeChooser);

    setExpandRatio(loginComponent, 1.0f);
    setComponentAlignment(loginComponent, Alignment.BOTTOM_LEFT);
    setComponentAlignment(localeChooser, Alignment.BOTTOM_RIGHT);

    log.debug("Header created");
}

From source file:org.plukh.fluffymeow.ui.i18n.LocaleChooserComponent.java

License:Open Source License

@Inject
public LocaleChooserComponent() {
    log.trace("Creating LocaleChooserComponent...");
    setSizeUndefined();// w w w  .j a v  a  2  s .c om

    HorizontalLayout layout = new HorizontalLayout();

    flags = new ArrayList<>();

    languages.forEach(language -> {
        Resource flagResource = new ThemeResource(language.getFlagFile());
        Image flag = new Image(null, flagResource);
        flag.addStyleName("pointer");
        flag.addClickListener(event -> onLanguageChange(language.getLocale()));
        flag.setData(language.getMessage());

        log.debug("Created flag for locale " + language.getLocale());

        flags.add(flag);
        layout.addComponent(flag);
    });

    setCompositionRoot(layout);

    log.debug("LocaleChooserComponent created");
}

From source file:org.ripla.web.demo.widgets.views.ButtonWidgetsView.java

License:Open Source License

public ButtonWidgetsView() {
    super();/*from ww w  . j  a  v  a 2s.c  o  m*/

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.button"); //$NON-NLS-1$

    lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.button"))); //$NON-NLS-1$
    final Button lButton = new Button(lMessages.getMessage("widgets.view.button.label.save")); //$NON-NLS-1$
    lButton.setDescription(lMessages.getMessage("widgets.view.button.descr.normal")); //$NON-NLS-1$
    lButton.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.normal"))); //$NON-NLS-1$
    lLayout.addComponent(lButton);

    lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.label.image"))); //$NON-NLS-1$
    final Button lButton2 = new Button(lMessages.getMessage("widgets.view.button.label.save")); //$NON-NLS-1$
    lButton2.setIcon(new ThemeResource("../runo/icons/16/ok.png")); //$NON-NLS-1$
    lButton2.setDescription(lMessages.getMessage("widgets.view.button.label.image")); //$NON-NLS-1$
    lButton2.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.image"))); //$NON-NLS-1$
    lLayout.addComponent(lButton2);

    lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.disable"))); //$NON-NLS-1$
    lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.disable"))); //$NON-NLS-1$
    final Button lButton3 = new Button(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$
    lButton3.setDisableOnClick(true);
    lButton3.setDescription(lMessages.getMessage("widgets.view.button.descr.disable")); //$NON-NLS-1$
    lButton3.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            try {
                Thread.sleep(3000);
            } catch (final InterruptedException exc) {
            }
            Notification.show(lMessages.getMessage("widgets.view.button.feedback.disable"),
                    Notification.Type.TRAY_NOTIFICATION);
            inEvent.getButton().setEnabled(true);
        }
    });
    lLayout.addComponent(lButton3);

    lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.link"))); //$NON-NLS-1$
    final Button lButton4 = new Button(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$
    lButton4.setStyleName(BaseTheme.BUTTON_LINK);
    lButton4.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.link"))); //$NON-NLS-1$
    lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.link"))); //$NON-NLS-1$
    lLayout.addComponent(lButton4);

    lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.check"))); //$NON-NLS-1$
    lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.check"))); //$NON-NLS-1$
    final CheckBox lCheckbox = new CheckBox(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$
    lCheckbox.setImmediate(true);
    lCheckbox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final ValueChangeEvent inEvent) {
            Notification.show(lMessages.getMessage("widgets.view.button.feedback.check"),
                    Notification.Type.TRAY_NOTIFICATION);

        }
    });
    lLayout.addComponent(lCheckbox);
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.PerspectiveStackRenderer.java

License:Open Source License

private void initializedPerspectiveSwticherPanel(MPerspectiveStack perspectiveStack) {
    if (perspectiveSwitcherPanel != null)
        return;/*ww  w.  j  a  v  a  2s. c  o  m*/
    //initialize perspective switcher panel
    perspectiveStackForSwitcher = perspectiveStack;
    boolean iconsOnly = perspectiveStackForSwitcher.getTags().contains(Tags.ICONS_ONLY);

    perspectiveSwitcherPanel = new HorizontalLayout();
    perspectiveSwitcherPanel.setStyleName("perspectivepanel");
    perspectiveSwitcherPanel.setSizeUndefined();

    Button openPerspectiveButton = new Button("Open");
    openPerspectiveButton.addStyleName("vaaclipsebutton");
    openPerspectiveButton.addStyleName("icononly");
    openPerspectiveButton.setIcon(new ThemeResource("../vaaclipse_default_theme/img/open_perspective.png"));
    perspectiveSwitcherPanel.addComponent(openPerspectiveButton);

    openPerspectiveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            openOpenPerspectiveWindow();

            //change focus
            Component parent = event.getButton().getParent();
            while (parent != null) {
                if (parent instanceof Component.Focusable) {
                    ((Component.Focusable) parent).focus();
                    break;
                } else {
                    parent = parent.getParent();
                }
            }
        }
    });

    //add separator between openPerspectiveButton and perspective's buttons
    Label separator = new Label();
    separator.setSizeUndefined();
    separator.addStyleName("horizontalseparator");
    separator.setHeight("100%");
    perspectiveSwitcherPanel.addComponent(separator);

    //add buttons to perspective switch panel   
    for (final MPerspective perspective : perspectiveStackForSwitcher.getChildren()) {
        Component button = createPerspectiveButton(perspective);
        if (button != null)
            perspectiveSwitcherPanel.addComponent(button);
    }
}