Example usage for com.vaadin.ui GridLayout setMargin

List of usage examples for com.vaadin.ui GridLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setMargin.

Prototype

@Override
    public void setMargin(MarginInfo marginInfo) 

Source Link

Usage

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

public FHIRChart() {
    session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes();
    setCaption("TriCare Portal");
    //final VerticalComponentGroup vert = new VerticalComponentGroup();
    GridLayout layout = new GridLayout(3, 2);
    layout.setMargin(true);
    layout.setWidth("80%");
    layout.setHeight("100%");

    Panel problemListPanel = getProblemList();
    Panel medicationPanel = getMedications();
    Panel encountersPanel = getEncounters();
    Panel allergiesPanel = getAllergies();
    Panel testsPanel = getTests();
    Panel carePanel = getCarePlan();

    layout.addComponent(problemListPanel, 0, 0);
    layout.setComponentAlignment(problemListPanel, Alignment.TOP_LEFT);
    layout.addComponent(medicationPanel, 1, 0);
    layout.setComponentAlignment(medicationPanel, Alignment.TOP_LEFT);
    layout.addComponent(encountersPanel, 2, 0);
    layout.setComponentAlignment(encountersPanel, Alignment.TOP_LEFT);
    layout.addComponent(allergiesPanel, 0, 1);
    layout.setComponentAlignment(allergiesPanel, Alignment.TOP_LEFT);
    layout.addComponent(testsPanel, 1, 1);
    layout.setComponentAlignment(testsPanel, Alignment.TOP_LEFT);
    layout.addComponent(carePanel, 2, 1);
    layout.setComponentAlignment(carePanel, Alignment.TOP_LEFT);

    //vert.addComponent(layout);

    setContent(new CssLayout(layout));

}

From source file:gov.va.ehtac.myappsonfhir.ui.FitnessWellness.java

private GridLayout getChartLayout() {
    getChartData(-6);/* www .j ava2  s. c om*/
    Button b1 = new Button("See More");
    Button b2 = new Button("See More");
    Button b3 = new Button("See More");
    Button b4 = new Button("See More");

    b1.setImmediate(true);
    b2.setImmediate(true);
    b3.setImmediate(true);
    b4.setImmediate(true);

    b1.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b3.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b4.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    GridLayout grid = new GridLayout(2, 2);
    grid.setMargin(true);
    grid.setWidth("100%");

    Panel p1 = new Panel("Heart Rate Activity");
    p1.setHeight("100px");
    VerticalComponentGroup v = new VerticalComponentGroup();
    //v.addComponent(hChart.getChart());
    v.addComponent(hChart.getChart());
    v.addComponent(b1);
    grid.addComponent(v, 0, 0);

    Panel p2 = new Panel("Distance - Miles");
    p2.setHeight("100px");
    VerticalComponentGroup v2 = new VerticalComponentGroup();
    //v2.addComponent(dChart.getChart());
    v2.addComponent(dChart.getChart(results));
    v2.addComponent(b2);
    grid.addComponent(v2, 1, 0);

    Panel p3 = new Panel("Calories Burned");
    p3.setHeight("100px");
    VerticalComponentGroup v3 = new VerticalComponentGroup();
    //v3.addComponent(cChart.getChart());
    v3.addComponent(cChart.getChart(results));
    v3.addComponent(b3);
    grid.addComponent(v3, 0, 1);

    Panel p4 = new Panel("Steps Taken");
    p4.setHeight("100px");
    VerticalComponentGroup v4 = new VerticalComponentGroup();
    //v4.addComponent(sChart.getChart());
    v4.addComponent(sChart.getChart(results));
    v4.addComponent(b4);
    grid.addComponent(v4, 1, 1);
    return grid;
}

From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java

public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker,
        final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes,
        final NodeType nodeType) {
    super("Add New Node");
    setModal(true);/*from  ww w .  jav a 2 s .c o m*/

    setWidth(650, Unit.PIXELS);
    setHeight(450, Unit.PIXELS);

    GridLayout content = new GridLayout(1, 3);
    content.setSizeFull();
    content.setMargin(true);
    content.setSpacing(true);

    HorizontalLayout topContent = new HorizontalLayout();
    topContent.setSpacing(true);

    content.addComponent(topContent);
    topContent.addComponent(new Label("Nodes:"));

    final ComboBox hadoopNodes = new ComboBox();
    hadoopNodes.setId("HadoopNodesCb");
    hadoopNodes.setImmediate(true);
    hadoopNodes.setTextInputAllowed(false);
    hadoopNodes.setNullSelectionAllowed(false);
    hadoopNodes.setRequired(true);
    hadoopNodes.setWidth(200, Unit.PIXELS);
    for (EnvironmentContainerHost node : nodes) {
        hadoopNodes.addItem(node);
        hadoopNodes.setItemCaption(node, node.getHostname());
    }

    if (nodes.size() == 0) {
        return;
    }
    hadoopNodes.setValue(nodes.iterator().next());

    topContent.addComponent(hadoopNodes);

    final Button addNodeBtn = new Button("Add");
    addNodeBtn.setId("AddSelectedNode");
    topContent.addComponent(addNodeBtn);

    final Button ok = new Button("Ok");

    addNodeBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addNodeBtn.setEnabled(false);
            ok.setEnabled(false);
            showProgress();
            EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue();
            final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(),
                    containerHost.getHostname(), nodeType);
            executorService.execute(new Runnable() {
                public void run() {
                    while (track) {
                        TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY,
                                trackID);
                        if (po != null) {
                            setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n"
                                    + po.getLog());
                            if (po.getState() != OperationState.RUNNING) {
                                hideProgress();
                                ok.setEnabled(true);
                                break;
                            }
                        } else {
                            setOutput("Product operation not found. Check logs");
                            break;
                        }
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException ex) {
                            break;
                        }
                    }
                }
            });
        }
    });

    outputTxtArea = new TextArea("Operation output");
    outputTxtArea.setId("outputTxtArea");
    outputTxtArea.setRows(13);
    outputTxtArea.setColumns(43);
    outputTxtArea.setImmediate(true);
    outputTxtArea.setWordwrap(true);

    content.addComponent(outputTxtArea);

    indicator = new Label();
    indicator.setId("indicator");
    indicator.setIcon(new ThemeResource("img/spinner.gif"));
    indicator.setContentMode(ContentMode.HTML);
    indicator.setHeight(11, Unit.PIXELS);
    indicator.setWidth(50, Unit.PIXELS);
    indicator.setVisible(false);

    ok.setId("btnOk");
    ok.setStyleName("default");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            //close window
            track = false;
            close();
        }
    });

    HorizontalLayout bottomContent = new HorizontalLayout();
    bottomContent.addComponent(indicator);
    bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT);
    bottomContent.addComponent(ok);

    content.addComponent(bottomContent);
    content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT);

    setContent(content);
}

From source file:io.subutai.plugin.accumulo.ui.wizard.VerificationStep.java

public VerificationStep(final Accumulo accumulo, final Hadoop hadoop, final ExecutorService executorService,
        final Tracker tracker, EnvironmentManager environmentManager, final Wizard wizard) {

    setSizeFull();/*from www .j a v a  2 s  . c o  m*/

    GridLayout grid = new GridLayout(1, 5);
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setSizeFull();

    Label confirmationLbl = new Label("<strong>Please verify the installation settings "
            + "(you may change them by clicking on Back button)</strong><br/>");
    confirmationLbl.setContentMode(ContentMode.HTML);

    ConfigView cfgView = new ConfigView("Installation configuration");
    cfgView.addStringCfg("Cluster Name", wizard.getConfig().getClusterName());
    cfgView.addStringCfg("Instance name", wizard.getConfig().getInstanceName());
    cfgView.addStringCfg("Password", wizard.getConfig().getPassword());
    cfgView.addStringCfg("Hadoop cluster", wizard.getConfig().getHadoopClusterName());
    cfgView.addStringCfg("Zookeeper cluster", wizard.getConfig().getZookeeperClusterName());

    if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) {
        try {
            Environment hadoopEnvironment = environmentManager.loadEnvironment(
                    hadoop.getCluster(wizard.getConfig().getHadoopClusterName()).getEnvironmentId());
            EnvironmentContainerHost master = hadoopEnvironment
                    .getContainerHostById(wizard.getConfig().getMasterNode());
            EnvironmentContainerHost gc = hadoopEnvironment
                    .getContainerHostById(wizard.getConfig().getGcNode());
            EnvironmentContainerHost monitor = hadoopEnvironment
                    .getContainerHostById(wizard.getConfig().getMonitor());
            Set<EnvironmentContainerHost> tracers = hadoopEnvironment
                    .getContainerHostsByIds(wizard.getConfig().getTracers());
            Set<EnvironmentContainerHost> slaves = hadoopEnvironment
                    .getContainerHostsByIds(wizard.getConfig().getSlaves());

            cfgView.addStringCfg("Master node", master.getHostname());
            cfgView.addStringCfg("GC node", gc.getHostname());
            cfgView.addStringCfg("Monitor node", monitor.getHostname());
            for (EnvironmentContainerHost containerHost : tracers) {
                cfgView.addStringCfg("Tracers", containerHost.getHostname());
            }
            for (EnvironmentContainerHost containerHost : slaves) {
                cfgView.addStringCfg("Slaves", containerHost.getHostname());
            }
        } catch (EnvironmentNotFoundException | ContainerHostNotFoundException e) {
            LOGGER.error("Error applying operations on environment/container", e);
        }
    } else {
        cfgView.addStringCfg("Number of Hadoop slaves",
                wizard.getHadoopClusterConfig().getCountOfSlaveNodes() + "");
        cfgView.addStringCfg("Hadoop replication factor",
                wizard.getHadoopClusterConfig().getReplicationFactor() + "");
        cfgView.addStringCfg("Hadoop domain name", wizard.getHadoopClusterConfig().getDomainName() + "");
        cfgView.addStringCfg("Number of tracers", wizard.getConfig().getNumberOfTracers() + "");
        cfgView.addStringCfg("Number of slaves", wizard.getConfig().getNumberOfSlaves() + "");
    }

    Button install = new Button("Install");
    install.setId("installBtn");
    install.addStyleName("default");
    install.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UUID trackID;
            if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) {
                trackID = accumulo.installCluster(wizard.getConfig());
            } else {
                trackID = accumulo.installCluster(wizard.getConfig());
            }
            ProgressWindow window = new ProgressWindow(executorService, tracker, trackID,
                    AccumuloClusterConfig.PRODUCT_KEY);
            window.getWindow().addCloseListener(new Window.CloseListener() {
                @Override
                public void windowClose(Window.CloseEvent closeEvent) {
                    wizard.init();
                }
            });
            getUI().addWindow(window.getWindow());
        }
    });

    Button back = new Button("Back");
    back.setId("verBack");
    back.addStyleName("default");
    back.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            wizard.back();
        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addComponent(back);
    buttons.addComponent(install);

    grid.addComponent(confirmationLbl, 0, 0);

    grid.addComponent(cfgView.getCfgTable(), 0, 1, 0, 3);

    grid.addComponent(buttons, 0, 4);

    setContent(grid);
}

From source file:io.subutai.plugin.accumulo.ui.wizard.WelcomeStep.java

public WelcomeStep(final Wizard wizard) {

    setSizeFull();/*from  w  w w .ja  v  a 2  s  . c o m*/

    GridLayout grid = new GridLayout(10, 6);
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setSizeFull();

    Label welcomeMsg = new Label("<center><h2>Welcome to Accumulo Installation Wizard!</h2>");
    welcomeMsg.setContentMode(ContentMode.HTML);
    grid.addComponent(welcomeMsg, 3, 1, 6, 2);

    Label logoImg = new Label();
    // Image as a file resource
    logoImg.setIcon(new FileResource(FileUtil.getFile(AccumuloPortalModule.MODULE_IMAGE, this)));
    logoImg.setContentMode(ContentMode.HTML);
    logoImg.setHeight(56, Unit.PIXELS);
    logoImg.setWidth(220, Unit.PIXELS);
    grid.addComponent(logoImg, 1, 3, 2, 5);

    Button startOverHadoopNZK = new Button("Start over Hadoop & ZK installation");
    startOverHadoopNZK.setId("startOverHadoopNZK");
    startOverHadoopNZK.addStyleName("default");
    grid.addComponent(startOverHadoopNZK, 4, 4, 4, 4);
    grid.setComponentAlignment(startOverHadoopNZK, Alignment.BOTTOM_RIGHT);

    startOverHadoopNZK.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            wizard.init();
            wizard.getConfig().setSetupType(SetupType.OVER_HADOOP_N_ZK);
            wizard.next();
        }
    });

    setContent(grid);
}

From source file:life.qbic.components.qOfferManager.java

License:Open Source License

private void init() {

    DBManager.setCredentials();//w  w w. ja  v  a2s.co  m
    DBManager.getDatabaseInstance();
    db = Database.Instance;
    managerTabs = new TabSheet();

    /*    System.out.println(ft.format(dNow) + "  INFO  Offer Manager accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());*/

    managerTabs.addStyleName(ValoTheme.TABSHEET_FRAMED);
    managerTabs.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);

    final GridLayout gridLayout = new GridLayout(6, 6);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);

    try {

        managerTabs.addTab(createOfferGeneratorTab(), "Offer Generator");
        managerTabs.addTab(createOfferManagerTab(), "Offer Manager");
        managerTabs.addTab(createPackageManagerTab(), "Package Manager");

        managerTabs.setSelectedTab(1); // show the offer manager first, since this will probably be mostly in use

        // TODO: make this more elegant
        // if one changes the tab e.g. from the offer manager to the package manager, creates a new package and goes
        // back to the offer manager tab, the package won't be updated -> workaround:
        // since the selected offer in the offer manager grid won't requery the database for the information needed, we
        // deselect the current offer (if any has been selected), so the user has to select the offer again -> information
        // for the database is queried again and e.g. the newly created packages are shown properly)
        managerTabs.addSelectedTabChangeListener((TabSheet.SelectedTabChangeListener) event -> {
            OfferManagerTab.getOfferManagerGrid().deselectAll();
            OfferManagerTab.getDetailsLayout().removeAllComponents();
        });

    } catch (SQLException e1) {
        e1.printStackTrace();
    }

    try {
        gridLayout.addComponent(managerTabs, 0, 1, 5, 1);
    } catch (OverlapsException | OutOfBoundsException e) {
        e.printStackTrace();
    }

    gridLayout.setSizeFull();
    setCompositionRoot(gridLayout);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();//from   w ww .  j  a v  a 2 s  .  c o  m

    VerticalLayout header = new VerticalLayout();
    header.setSizeFull();

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

    GridLayout addCoordinatorLayout = new GridLayout(2, 4);
    addCoordinatorLayout.setSpacing(true);
    addCoordinatorLayout.setMargin(true);
    addCoordinatorLayout.setSizeFull();

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

    buttons.setMargin(true);
    buttons.setSpacing(true);
    buttons.setSizeFull();

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

    GridLayout delCoordinatorLayout = new GridLayout(2, 2);
    delCoordinatorLayout.setSpacing(true);
    delCoordinatorLayout.setMargin(true);
    delCoordinatorLayout.setSizeFull();

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);//  www  . j a va2s.c om
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

GridLayout getPreviewLayout(String caption) {
    GridLayout grid = new GridLayout(3, 1) {
        @Override/*from  w w w .jav a2  s  .c  om*/
        public void addComponent(Component c) {
            super.addComponent(c);
            setComponentAlignment(c, "center middle");
            if (c.getStyleName() != "") {
                ((AbstractComponent) c).setDescription(
                        c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")");
            } else {
                ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()");
            }
        }
    };
    grid.setWidth("100%");
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setCaption(caption);
    grid.setStyleName("preview-grid");
    return grid;
}

From source file:org.agocontrol.site.viewlet.bus.BusesFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields.getFieldDescriptors(Bus.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<Bus>(entityManager, true, true, false, Bus.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "busId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/* w  w w.  java  2s. c om*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Bus bus = new Bus();
            bus.setCreated(new Date());
            bus.setModified(bus.getCreated());
            bus.setInventorySynchronized(new Date(0L));
            bus.setConnectionStatus(BusConnectionStatus.Disconnected);
            bus.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final BusFlowlet busView = getViewSheet().forward(BusFlowlet.class);
            busView.edit(bus, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Bus entity = container.getEntity(grid.getSelectedItemId());
            final BusFlowlet busView = getViewSheet().forward(BusFlowlet.class);
            busView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}