Example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing.

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:edu.colorado.csdms.wmt.client.ui.panel.RadioButtonPanel.java

License:Open Source License

/**
 * Makes a new {@link RadioButtonPanel} with default labels.
 *//*from   w ww . ja  v  a  2 s  .c o m*/
public RadioButtonPanel() {

    panelLabel = new Label("Name:");
    leftButton = new RadioButton("RadioButtonPanel", "True");
    rightButton = new RadioButton("RadioButtonPanel", "False");
    rightButton.setValue(true);

    HorizontalPanel contents = new HorizontalPanel();
    contents.setSpacing(5); // px
    contents.add(panelLabel);
    contents.add(leftButton);
    contents.add(rightButton);

    initWidget(contents);
}

From source file:edu.ucdenver.bios.glimmpseweb.client.shared.CancelDialogBox.java

License:Open Source License

public Widget cancelDialogBox() {
    DialogBox dialogBox = new DialogBox();
    dialogBox.setGlassEnabled(true);//from w w w.j  ava  2s .c o m
    dialogBox.setAnimationEnabled(true);
    HTML query = new HTML(GlimmpseWeb.constants.cancelDialogBoxQuery());
    Button saveButton = new Button("Save", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });
    Button discardChangesButton = new Button("Discard Changes", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });
    Button continueButton = new Button("Continue", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });

    saveButton.setStyleName(STYLE_BUTTON);
    discardChangesButton.setStyleName(STYLE_BUTTON);
    continueButton.setStyleName(STYLE_BUTTON);
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.add(saveButton);
    horizontalPanel.add(discardChangesButton);
    horizontalPanel.add(continueButton);
    horizontalPanel.setSpacing(10);

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.add(query);
    verticalPanel.add(horizontalPanel);

    dialogBox.setText("Cancel Dialog Box");
    dialogBox.add(verticalPanel);
    dialogBox.show();

    return dialogBox;
}

From source file:edu.ucsb.eucalyptus.admin.client.ClusterInfoTable.java

License:Open Source License

public ClusterInfoTable(String sessionId) {
    this.sessionId = sessionId;
    this.setStyleName("euca-config-component");
    this.setSpacing(2);
    this.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    //      this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    Label clustersHeader = new Label("Clusters:");
    clustersHeader.setStyleName("euca-section-header");
    this.add(clustersHeader);
    this.noClusterLabel.setText("No clusters registered");
    this.noClusterLabel.setStyleName("euca-greeting-disabled");
    HorizontalPanel grid_and_hint = new HorizontalPanel();
    grid_and_hint.add(this.grid);
    grid_and_hint.add(this.hint);
    this.hint.setWidth("100");
    this.add(grid_and_hint);
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(2);
    hpanel.add(add_button);/*from  www.  j  av  a  2  s . co m*/
    hpanel.add(new Button("Save cluster configuration", new SaveCallback(this)));
    hpanel.add(this.statusLabel);
    //      this.statusLabel.setWidth ("250");
    this.statusLabel.setText("");
    this.statusLabel.setStyleName("euca-greeting-pending");
    this.add(hpanel);
    rebuildTable();
    EucalyptusWebBackend.App.getInstance().getClusterList(this.sessionId, new GetClusterListCallback(this));
    EucalyptusWebBackend.App.getInstance().getSystemConfig(this.sessionId, new GetSystemConfigCallback(this));
    EucalyptusWebBackend.App.getInstance().getStorageList(this.sessionId, new GetStorageListCallback(this));
}

From source file:edu.ucsb.eucalyptus.admin.client.ClusterInfoTable.java

License:Open Source License

private Grid addClusterEntry(int row, ClusterInfoWeb clusterInfo, final StorageInfoWeb storageInfo) {
    final ArrayList<String> storageParams = storageInfo.getStorageParams();
    numStorageParams = storageParams.size() / 4;
    Grid g = new Grid(8 + numStorageParams, 2);
    g.setStyleName("euca-table");
    if (row > 0) {
        g.setStyleName("euca-nonfirst-cluster-entry");
    }//from  ww  w  .j a va2s  . c  o  m
    g.setCellPadding(4);

    int i = 0; // row 1
    g.setWidget(i, 0, new HTML("<b>Name:</b>"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final HorizontalPanel namePanel = new HorizontalPanel();
    namePanel.setSpacing(0);

    if (clusterInfo.isCommitted()) {
        namePanel.add(new Label(clusterInfo.getName()));
    } else {
        final TextBox nb = new TextBox();
        nb.addChangeListener(new ChangeCallback(this, row));
        nb.setVisibleLength(12);
        nb.setText(clusterInfo.getName());
        nb.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
        namePanel.add(nb);
    }
    namePanel.add(new Button("Deregister Cluster", new DeleteCallback(this, row)));
    g.setWidget(i, 1, namePanel);

    i++; // next row
    g.setWidget(i, 1, new Label("Cluster Controller"));

    i++; // next row
    g.setWidget(i, 0, new Label("Host:"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox hb = new TextBox();
    hb.addChangeListener(new ChangeCallback(this, row));
    hb.setVisibleLength(20);
    hb.setText(clusterInfo.getHost());
    hb.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
    g.setWidget(i, 1, hb);

    i++; // next row
    /*      g.setWidget( i, 0, new Label( "Port:" ) );
          g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
          final TextBox pb = new TextBox();
          pb.addChangeListener (new ChangeCallback (this, row));
          pb.setVisibleLength( 5 );
          pb.setText( "" + clusterInfo.getPort() );
          pb.addFocusListener (new FocusHandler (this.hint, this.warningMessage));
          g.setWidget( i, 1, pb );*/

    final TextBox reservedAddressesBox = new TextBox(); // declare here, set up after the checkbox later

    final CheckBox dynamicAddressesCheckbox = new CheckBox();
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    g.setWidget(i, 0, dynamicAddressesCheckbox);
    if (systemConfig.isDoDynamicPublicAddresses()) {
        dynamicAddressesCheckbox.setChecked(true);
        reservedAddressesBox.setEnabled(false);
    } else {
        dynamicAddressesCheckbox.setChecked(false);
        reservedAddressesBox.setEnabled(true);
    }
    dynamicAddressesCheckbox.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (((CheckBox) sender).isChecked()) {
                reservedAddressesBox.setEnabled(false);
                systemConfig.setDoDynamicPublicAddresses(true);
            } else {
                reservedAddressesBox.setEnabled(true);
                systemConfig.setDoDynamicPublicAddresses(false);
            }
        }
    });
    g.setWidget(i, 1, new Label("Dynamic public IP address assignment"));

    i++; // next row
    g.setWidget(i, 0, new Label("Reserve for assignment"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    reservedAddressesBox.addChangeListener(new ChangeCallback(this, row));
    reservedAddressesBox.setVisibleLength(5);
    reservedAddressesBox.setText("" + systemConfig.getSystemReservedPublicAddresses());
    final HorizontalPanel reservedAddressesPanel = new HorizontalPanel();
    reservedAddressesPanel.setSpacing(4);
    reservedAddressesPanel.add(reservedAddressesBox);
    reservedAddressesPanel.add(new HTML("public IP addresses"));
    reservedAddressesBox.setText("" + systemConfig.getSystemReservedPublicAddresses());
    g.setWidget(i, 1, reservedAddressesPanel);

    i++; // next row
    g.setWidget(i, 0, new Label("Maximum of"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox publicAddressesBox = new TextBox();
    publicAddressesBox.addChangeListener(new ChangeCallback(this, row));
    publicAddressesBox.setVisibleLength(5);
    publicAddressesBox.setText("" + systemConfig.getMaxUserPublicAddresses());
    final HorizontalPanel publicAddressesPanel = new HorizontalPanel();
    publicAddressesPanel.setSpacing(4);
    publicAddressesPanel.add(publicAddressesBox);
    publicAddressesPanel.add(new HTML("public IP addresses per user"));
    g.setWidget(i, 1, publicAddressesPanel);

    i++;
    g.setWidget(i, 0, new Label("Use VLAN tags"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox minVlanBox = new TextBox();
    minVlanBox.addChangeListener(new ChangeCallback(this, row));
    minVlanBox.setVisibleLength(4);
    minVlanBox.setText(String.valueOf(clusterInfo.getMinVlans()));
    final TextBox maxVlanBox = new TextBox();
    maxVlanBox.addChangeListener(new ChangeCallback(this, row));
    maxVlanBox.setVisibleLength(4);
    maxVlanBox.setText(String.valueOf(clusterInfo.getMaxVlans()));
    final HorizontalPanel vlanPanel = new HorizontalPanel();
    vlanPanel.setSpacing(4);
    vlanPanel.add(minVlanBox);
    vlanPanel.add(new HTML("through"));
    vlanPanel.add(maxVlanBox);
    g.setWidget(i, 1, vlanPanel);

    i++; // next row
    g.setWidget(i, 1, new Label("Storage Controller"));

    for (int paramidx = 0; paramidx < numStorageParams; ++paramidx) {
        i++; // next row
        if ("KEYVALUE".equals(storageParams.get(4 * paramidx))) {
            g.setWidget(i, 0, new Label(storageParams.get(4 * paramidx + 1) + ": "));
            g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            final TextBox propTextBox = new TextBox();
            propTextBox.addChangeListener(new ChangeCallback(this, row));
            propTextBox.setVisibleLength(30);
            propTextBox.setText(storageParams.get(4 * paramidx + 2));
            propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
            g.setWidget(i, 1, propTextBox);
        } else if ("PASSWORD".equals(storageParams.get(4 * paramidx))) {
            g.setWidget(i, 0, new Label(storageParams.get(4 * paramidx + 1) + ": "));
            g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            final TextBox propTextBox = new PasswordTextBox();
            propTextBox.addChangeListener(new ChangeCallback(this, row));
            propTextBox.setVisibleLength(30);
            propTextBox.setText(storageParams.get(4 * paramidx + 2));
            propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
            g.setWidget(i, 1, propTextBox);
        } else if ("BOOLEAN".equals(storageParams.get(4 * paramidx))) {

            final int index = paramidx;
            final CheckBox propCheckbox = new CheckBox();
            g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            g.setWidget(i, 0, propCheckbox);
            if (Boolean.parseBoolean(storageParams.get(4 * index + 2))) {
                propCheckbox.setChecked(true);
            } else {
                propCheckbox.setChecked(false);
            }
            propCheckbox.addClickListener(new ClickListener() {
                public void onClick(Widget sender) {
                    if (((CheckBox) sender).isChecked()) {
                        storageParams.set(4 * index + 2, String.valueOf(true));
                    } else {
                        storageParams.set(4 * index + 2, String.valueOf(false));
                    }
                }
            });
            g.setWidget(i, 1, new Label(storageParams.get(paramidx * 4 + 1)));
        }
    }

    return g;
}

From source file:edu.ucsb.eucalyptus.admin.client.DownloadsTable.java

License:Open Source License

public DownloadsTable(String sessionId, String theUrl, String theHumanUrl, String theName, int maxEntries) {
    this.sessionId = sessionId;
    this.setStyleName("euca-config-component");
    this.theUrl = theUrl;
    this.theHumanUrl = theHumanUrl;
    this.theName = theName;
    this.maxEntries = maxEntries;
    this.setSpacing(10);
    //this.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    //this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    this.DownloadsHeader.setText(this.theName);
    this.DownloadsHeader.setStyleName("euca-section-header");
    this.add(DownloadsHeader);
    this.add(this.grid);
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(5);
    hpanel.add(this.statusLabel);
    //        this.statusLabel.setWidth("600");
    this.statusLabel.setText("Contacting " + this.theName + " server");
    this.statusLabel.setStyleName("euca-greeting-pending");
    this.add(hpanel);

    EucalyptusWebBackend.App.getInstance().getDownloads(this.sessionId, this.theUrl, new GetCallback(this));

}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

public void displayLoginPage(String greeting) {
    History.newItem("login");
    label_box.setText(greeting);/*from  w ww.j a va 2 s.  c  o  m*/
    label_box.setStyleName("euca-greeting-normal");
    final TextBox login_box = new TextBox();
    login_box.setFocus(true); // this box gets focus first
    final PasswordTextBox pass_box = new PasswordTextBox();

    ClickListener LoginButtonListener = new ClickListener() {
        public void onClick(Widget sender) {
            /* perform checks */
            if (login_box.getText().length() < 1) {
                displayLoginErrorPage("Username is empty!");
                return;
            }
            if (pass_box.getText().length() < 1) {
                displayLoginErrorPage("Password is empty!");
                return;
            }

            label_box.setText("Contacting the server...");
            label_box.setStyleName("euca-greeting-pending");
            EucalyptusWebBackend.App.getInstance().getNewSessionID(login_box.getText(),
                    GWTUtils.md5(pass_box.getText()), new AsyncCallback() {
                        public void onSuccess(Object result) {
                            sessionId = (String) result;
                            long expiresMs = System.currentTimeMillis() + (7 * 24 * 60 * 60 * 1000); /* week */
                            Date expires = new Date(expiresMs);
                            if (check_box.isChecked()) {
                                Cookies.setCookie(cookie_name, sessionId, expires);
                            } else {
                                /* this cookie should expire at the end of the session */
                                /* TODO: does this work right in all browsers? */
                                Cookies.setCookie(cookie_name, sessionId, new Date(0));
                            }
                            attemptLogin();
                        }

                        public void onFailure(Throwable caught) {
                            displayLoginErrorPage((String) caught.getMessage());
                        }
                    });
        }
    };

    ClickListener RecoverButtonListener = new ClickListener() {
        public void onClick(Widget sender) {
            displayInitiatePasswordRecoveryPage();
        }
    };

    Button submit_button = new Button(MSG.signInButton(), LoginButtonListener);
    Hyperlink signup_button = new Hyperlink(MSG.applyButton(), "apply");
    signup_button.addClickListener(AddUserButtonListener);
    Hyperlink recover_button = new Hyperlink(MSG.recoverButton(), "recover");
    recover_button.addClickListener(RecoverButtonListener);
    remember_label.setStyleName("euca-remember-text");

    /* enable login by pressing Enter */
    EucalyptusKeyboardListener sl = new EucalyptusKeyboardListener(submit_button);
    submit_button.addKeyboardListener(sl);
    login_box.addKeyboardListener(sl);
    pass_box.addKeyboardListener(sl);

    Grid g = new Grid(4, 2);
    g.setCellSpacing(4);
    g.setWidget(0, 0, new Label(MSG.usernameField() + ":"));
    g.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    g.setWidget(1, 0, new Label(MSG.passwordField() + ":"));
    g.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    g.setWidget(0, 1, login_box);
    g.setWidget(1, 1, pass_box);
    g.setWidget(2, 0, check_box);
    g.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    g.setWidget(2, 1, remember_label);
    g.setWidget(3, 1, submit_button);
    VerticalPanel panel = new VerticalPanel();
    panel.add(g);
    panel.setStyleName("euca-login-panel");
    panel.setCellHorizontalAlignment(g, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(g, HasVerticalAlignment.ALIGN_MIDDLE);

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(2);
    if (enable_signups) {
        hpanel.add(signup_button);
        hpanel.add(new HTML("&nbsp;" + MSG.forAccount() + "&nbsp;&nbsp;|&nbsp;&nbsp;"));
    }
    hpanel.add(recover_button);
    hpanel.add(new HTML("&nbsp;" + MSG.thePassword()));

    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(15);
    vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    if (logo != null) {
        vpanel.add(logo);
    }
    if (version != null) {
        Label version_label = new Label("Version " + version);
        version_label.setStyleName("euca-small-text");
        vpanel.add(version_label);
    }
    vpanel.add(label_box);
    vpanel.add(panel);
    if (server_ready.booleanValue()) {
        vpanel.add(hpanel);
    }

    VerticalPanel wrapper = new VerticalPanel();
    wrapper.add(vpanel);
    wrapper.setSize("100%", "100%");
    wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER);
    wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE);

    RootPanel.get().clear();
    RootPanel.get().add(wrapper);
}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

private Button displayDialog(String greeting, String message, Button firstButton) {
    if (message == null || message.equalsIgnoreCase("")) {
        message = "Server is not accessible!"; // TODO: any other reasons why message would be empty?
    }/*from   w w w.  j a  va 2s  .c  om*/
    label_box.setText(greeting);
    label_box.setStyleName("euca-greeting-normal");
    Label m = new Label(message);
    m.setWidth("300");

    VerticalPanel panel = new VerticalPanel();
    panel.add(m);
    panel.setStyleName("euca-login-panel");
    panel.setCellHorizontalAlignment(m, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(m, HasVerticalAlignment.ALIGN_MIDDLE);
    Button ok_button = new Button("Ok", DefaultPageButtonListener);

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(10);
    if (firstButton != null) {
        hpanel.add(firstButton);
    }
    hpanel.add(ok_button);

    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(15);
    vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    if (logo != null) {
        vpanel.add(logo);
    }
    vpanel.add(label_box);
    vpanel.add(panel);
    vpanel.add(hpanel);

    VerticalPanel wrapper = new VerticalPanel();
    wrapper.add(vpanel);
    wrapper.setSize("100%", "100%");
    wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER);
    wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE);

    RootPanel.get().clear();
    RootPanel.get().add(wrapper);

    return ok_button;
}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

public void displayBarAndTabs(String message) {
    /* top bar */
    displayStatusPage("Drawing the tabs...");

    HorizontalPanel top_bar = new HorizontalPanel();
    top_bar.getElement().setClassName("euca-top-bar");

    HorizontalPanel name_panel = new HorizontalPanel();
    name_panel.getElement().setClassName("euca-top-bar-left");
    name_panel.setSpacing(5);
    name_panel.add(new HTML(Theme.draw_header()));
    top_bar.add(name_panel);/*from  w w  w  . j av a 2s  . co  m*/

    top_bar.setCellHorizontalAlignment(name_panel, HorizontalPanel.ALIGN_LEFT);
    top_bar.setCellVerticalAlignment(name_panel, HorizontalPanel.ALIGN_TOP); // michael left this as MIDDLE

    HorizontalPanel upanel = new HorizontalPanel();
    upanel.getElement().setClassName("euca-top-bar-right");
    Label user_name = new HTML(
            "Logged in as <b>" + loggedInUser.getUserName() + "</b>&nbsp;&nbsp;|&nbsp;&nbsp;");
    Hyperlink logout_button = new Hyperlink("Logout", "logout");
    logout_button.addClickListener(LogoutButtonListener);
    upanel.add(user_name);
    upanel.add(logout_button);
    top_bar.add(upanel);
    top_bar.setCellHorizontalAlignment(upanel, HorizontalPanel.ALIGN_RIGHT);
    top_bar.setCellVerticalAlignment(upanel, HorizontalPanel.ALIGN_TOP);

    final HorizontalPanel messageBox = new HorizontalPanel();
    messageBox.setStyleName("euca-message-bar");
    messageBox.setSpacing(3);
    messageBox.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    messageBox.add(statusMessage);
    statusMessage.setStyleName("euca-small-text");

    final VerticalPanel wrapper = new VerticalPanel();
    wrapper.setStyleName("euca-tab-contents");
    //        wrapper.setSize("100%", "80%");
    //        wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        wrapper.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    // set up tab layout so that *TabIndex variables are set in the beginning
    int nTabs = 0;
    allTabs = new TabBar();

    allTabs.addTab("Credentials");
    credsTabIndex = nTabs++;
    allTabs.addTab("Images");
    imgTabIndex = nTabs++;
    /////allTabs.addTab ("Instances"); instTabIndex = nTabs++;
    if (loggedInUser.isAdministrator() != null && loggedInUser.isAdministrator().booleanValue()) {
        allTabs.addTab("Users");
        usrTabIndex = nTabs++;
        allTabs.addTab("Configuration");
        confTabIndex = nTabs++;
        allTabs.addTab("Extras");
        downTabIndex = nTabs++;
        if (extensions != null && extensions.contains("store")) {
            allTabs.addTab("Store");
            storeTabIndex = nTabs++;
        }
    }
    // can happen if admin user re-logs in as regular without reloading
    if (currentTabIndex > (nTabs - 1)) {
        currentTabIndex = 0;
    }
    allTabs.addTabListener(new TabListener() {
        public void onTabSelected(SourcesTabEvents sender, int tabIndex) {
            String error = "This tab is not implemented yet, sorry!";
            statusMessage.setText("");
            wrapper.clear();
            currentTabIndex = tabIndex;
            if (tabIndex == credsTabIndex) {
                displayCredentialsTab(wrapper);
            } else if (tabIndex == imgTabIndex) {
                displayImagesTab(wrapper);
            } else if (tabIndex == usrTabIndex) {
                displayUsersTab(wrapper);
            } else if (tabIndex == confTabIndex) {
                displayConfTab(wrapper);
            } else if (tabIndex == downTabIndex) {
                displayDownloadsTab(wrapper);
            } else if (tabIndex == storeTabIndex) {
                displayStoreTab(wrapper);
            } else {
                displayErrorPage("Invalid tab!");
            }
        }

        public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
            return true; /* here we could do checking for clicks on disabled tabs */
        }
    });

    RootPanel.get().clear();
    RootPanel.get().add(top_bar);
    RootPanel.get().add(allTabs);
    RootPanel.get().add(messageBox);
    RootPanel.get().add(wrapper);
    allTabs.selectTab(currentTabIndex);
}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

public void actuallyDisplayCredentialsTab(VerticalPanel parent) {
    History.newItem("credentials");

    VerticalPanel credspanel = new VerticalPanel();
    credspanel.setSpacing(5);//from   w w w  . j  av  a 2  s.c  om
    parent.add(credspanel);
    credspanel.getElement().setClassName("euca-tab-with-text");

    VerticalPanel ppanel = new VerticalPanel();
    ppanel.add(new HTML("<h3>User account Information</h3>"));

    Grid userGrid = new Grid(3, 2);
    userGrid.setText(0, 0, "Login:");
    userGrid.setHTML(0, 1, "<b>" + loggedInUser.getUserName() + "</b>");
    userGrid.setText(1, 0, "Name:");
    userGrid.setHTML(1, 1, "<b>" + loggedInUser.getRealName() + "</b>");
    userGrid.setText(2, 0, "Email:");
    userGrid.setHTML(2, 1, "<b>" + loggedInUser.getEmail() + "</b>");
    ppanel.add(userGrid);
    ppanel.add(new HTML("<p>" + user_account_text + "</p>"));
    ppanel.setStyleName("euca-text");
    ppanel.addStyleName("content");

    Button passwordButton = new Button("Change Password", new ClickListener() {
        public void onClick(Widget sender) {
            displayPasswordChangePage(false);
        }
    });
    Button editButton = new Button("Edit Account Information", new ClickListener() {
        public void onClick(Widget sender) {
            displayUserRecordPage(RootPanel.get(), loggedInUser);
        }
    });
    ppanel.setSpacing(0);
    ppanel.add(editButton);
    ppanel.add(passwordButton);

    VerticalPanel cpanel = new VerticalPanel();
    cpanel.add(new HTML(certificate_download_text));
    cpanel.setStyleName("euca-text");
    cpanel.addStyleName("content");
    Button certButton = new Button("Download Credentials", new ClickListener() {
        public void onClick(Widget sender) {
            Window.open(GWT.getModuleBaseURL() + "getX509?user=" + loggedInUser.getUserName() + "&keyValue="
                    + loggedInUser.getUserName() + "&code=" + loggedInUser.getToken(), "_self", "");
        }
    });

    VerticalPanel rpanel = new VerticalPanel();
    rpanel.setSpacing(0);
    HTML credentials_html = new HTML(rest_credentials_text);
    credentials_html.setStyleName("content");
    rpanel.add(credentials_html);
    Grid g0 = new Grid(2, 2);
    g0.setWidget(0, 0, new HTML("<b><font size=\"2\">Query ID:</font></b>"));
    final HTML queryId = new HTML("<font color=#666666 size=\"2\">" + loggedInUser.getQueryId() + "</font>");
    queryId.setVisible(false);
    g0.setWidget(0, 1, queryId);
    g0.setWidget(1, 0, new HTML("<b><font size=\"2\">Secret Key:</font></b>"));
    final HTML secretKey = new HTML(
            "<font color=#666666 size=\"2\">" + loggedInUser.getSecretKey() + "</font>");
    secretKey.setVisible(false);
    g0.setWidget(1, 1, secretKey);
    rpanel.add(g0);
    rpanel.setStyleName("euca-text");
    final Button secretButton = new Button("Show keys");
    secretButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (secretKey.isVisible()) {
                secretKey.setVisible(false);
                queryId.setVisible(false);
                secretButton.setText("Show keys");
            } else {
                secretKey.setVisible(true);
                queryId.setVisible(true);
                secretButton.setText("Hide keys");
            }
        }
    });

    int gridRows = 3;
    if (loggedInUser.isAdministrator() != null && loggedInUser.isAdministrator() && show_cloud_registration) {
        gridRows++;
    }
    credspanel.add(ppanel);

    credspanel.add(cpanel);
    credspanel.add(certButton);
    credspanel.add(rpanel);
    credspanel.add(secretButton);

    //        final Grid g = new Grid( gridRows, 2 );
    //        g.getColumnFormatter().setWidth(0, "400");
    //        g.getColumnFormatter().setWidth(1, "200");
    //        g.setCellSpacing( 30 );
    //
    //        g.setWidget( 0, 0, ppanel ); g.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    //       // g.setWidget( 0, 1, ppanel2); g.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
    //
    //        g.setWidget( 1, 0, cpanel ); g.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    //        g.setWidget( 1, 1, certButton ); g.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
    //
    //        g.setWidget( 2, 0, rpanel ); g.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
    //      g.setWidget( 2, 1, secretButton ); g.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);

    if (loggedInUser.isAdministrator() != null && loggedInUser.isAdministrator() && show_cloud_registration) {
        VerticalPanel cloud_panel = new VerticalPanel();
        cloud_panel.setSpacing(0);
        cloud_panel.add(new HTML(cloud_registration_text));
        Grid g1 = new Grid(2, 2);
        g1.setWidget(0, 0, new HTML("<b><font size=\"2\">Cloud URL:</font></b>"));
        final HTML cloudUrl = new HTML("<font color=#666666 size=\"2\">https://"
                + cloudInfo.getInternalHostPort() + cloudInfo.getServicePath() + "</font>");
        g1.setWidget(0, 1, cloudUrl);
        g1.setWidget(1, 0, new HTML("<b><font size=\"2\">Cloud ID:</font></b>"));
        final HTML cloudId = new HTML("<font color=#666666 size=\"2\">" + cloudInfo.getCloudId() + "</font>");
        g1.setWidget(1, 1, cloudId);
        cloud_panel.add(g1);
        cloud_panel.setStyleName("euca-text");
        final Button cloudButton = new Button("Register");
        cloudButton.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                new RightscaleDialog().center();
            }
        });
        //         g.setWidget (3, 0, cloud_panel );
        //         g.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
        credspanel.add(cloud_panel);
        VerticalPanel vp = new VerticalPanel();
        vp.setSpacing(0);
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(0);
        hp.add(cloudButton);
        hp.add(new HTML("with"));
        Image logo = new Image("themes/share/rightscale-logo-blue.gif");
        logo.setStyleName("euca-inline-image");
        hp.add(logo);
        vp.add(hp);
        //         g.setWidget( 3, 1, vp );
        //         g.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
        credspanel.add(vp);
    }

    //credspanel.add(g);
}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

public void displayUsersList(final List usersList, final VerticalPanel parent) {
    String sortSymbol = "&darr;"; // HTML down arrow
    if (sortUsersLastFirst) {
        sortSymbol = "&uarr;"; // HTML up arrow
    }//from  ww w .  jav a  2 s  .  c o  m
    parent.clear();
    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(5);
    parent.add(new HTML("<h3>Users</h3>"));
    parent.add(vpanel);
    int nusers = usersList.size();
    if (nusers > 0) {
        Anchor sort_button = new Anchor(sortSymbol, true);
        sort_button.setStyleName("euca-small-text");
        sort_button.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                sortUsersLastFirst = !sortUsersLastFirst;
                displayUsersList(usersList, parent);
            }
        });

        final Grid g = new Grid(nusers + 1, 6);
        g.setStyleName("euca-table");
        g.setCellPadding(6);
        g.setWidget(0, 0, sort_button);
        g.setWidget(0, 1, new Label("Username"));
        g.setWidget(0, 2, new Label("Email"));
        g.setWidget(0, 3, new Label("Name"));
        g.setWidget(0, 4, new Label("Status"));
        g.setWidget(0, 5, new Label("Actions"));
        g.getRowFormatter().setStyleName(0, "euca-table-heading-row");

        for (int i = 0; i < nusers; i++) {
            int userIndex = i;
            if (sortUsersLastFirst) {
                userIndex = nusers - i - 1;
            }
            final UserInfoWeb u = (UserInfoWeb) usersList.get(userIndex);
            int row = i + 1;
            if ((row % 2) == 1) {
                g.getRowFormatter().setStyleName(row, "euca-table-odd-row");
            } else {
                g.getRowFormatter().setStyleName(row, "euca-table-even-row");
            }
            Label indexLabel = new Label(Integer.toString(userIndex));
            indexLabel.setStyleName("euca-small-text");
            g.setWidget(row, 0, indexLabel);
            Label userLabel = new Label(u.getUserName());
            g.setWidget(row, 1, userLabel);
            Label emailLabel = new Label(u.getEmail());
            g.setWidget(row, 2, emailLabel);
            Label nameLabel = new Label(u.getRealName());
            g.setWidget(row, 3, nameLabel);
            String status;
            if (u.isApproved() == null || !u.isApproved().booleanValue()) {
                status = "unapproved";
            } else if (u.isEnabled() == null || !u.isEnabled().booleanValue()) {
                status = "disabled";
            } else if (u.isConfirmed() == null || !u.isConfirmed().booleanValue()) {
                status = "unconfirmed";
            } else {
                status = "active";
            }
            if (u.isAdministrator() != null && u.isAdministrator().booleanValue()) {
                status += " & admin";
            }
            g.setWidget(row, 4, new Label(status));

            // actions
            HorizontalPanel ops = new HorizontalPanel();
            ops.setSpacing(3);

            Label editLabel = new Label("Edit");
            editLabel.addClickListener(new EditCallback(this, u));
            editLabel.setStyleName("euca-action-link");
            ops.add(editLabel);

            // admin can't be disabled or deleted (that breaks things)
            if (u.isAdministrator() == null || !u.isAdministrator().booleanValue()) {
                HTML act_button = userActionButtonNoReload("Disable", u, parent);
                if (u.isApproved() == null || !u.isApproved().booleanValue()) {
                    act_button = userActionButtonNoReload("Approve", u, parent);
                } else if (u.isEnabled() == null || !u.isEnabled().booleanValue()) {
                    act_button = userActionButtonNoReload("Enable", u, parent);
                }
                ops.add(act_button);

                Anchor del_button = new Anchor("Delete");
                del_button.setStyleName("euca-action-link");
                del_button.addClickListener(new ClickListener() {
                    public void onClick(Widget sender) {
                        displayConfirmDeletePageNoReload(u.getUserName(), parent);
                    }
                });
                ops.add(del_button);
            }

            g.setWidget(row, 5, ops);

            // view
            HorizontalPanel views = new HorizontalPanel();
            views.setSpacing(3);
            HTML inst_button = userActionButton("Instances", u);
            views.add(inst_button);
            HTML img_button = userActionButton("Images", u);
            views.add(img_button);
            //g.setWidget(row, 5, views); TODO: implement 'views'
        }
        vpanel.add(g);
    } else {
        vpanel.add(new Label("No users found"));
    }
    vpanel.add(new Button("Add user", AddUserButtonListener));
}