Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

Introduction

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

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

From source file:org.bonitasoft.console.client.view.identity.RoleFinderPanel.java

License:Open Source License

private FlexTable buildContent() {
    FlexTable thePanel = new FlexTable();

    thePanel.setWidget(0, 0, myErrorMessageLabel);
    thePanel.getFlexCellFormatter().setStyleName(0, 0, CSSClassManager.VALIDATION_ERROR_MESSAGE);
    thePanel.getFlexCellFormatter().setColSpan(0, 0, 3);

    myInternalItemDataSource.setItemFilter(myItemFilter);
    RolesListWidget myUserList = new RolesListWidget(null, myInternalItemDataSource) {

        @Override/*from   w  ww  .ja v a2  s  .  c o  m*/
        protected void initView() {
            myMinimalSize = 10;
            myMaximalSize = 10;
            super.initView();
            if (myBottomNavBar.getWidgetCount() == 2) {
                myBottomNavBar.remove(1);
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @seeorg.bonitasoft.console.client.view.identity.UsersListWidget#
         * getContentRowTooltip()
         */
        @Override
        protected String getContentRowTooltip() {
            return "";
        }

        @Override
        public void notifyItemClicked(BonitaUUID anItem, ClickEvent anEvent) {
            // Modify item selection.
            if (anItem != null) {
                final Cell theCell = myInnerTable.getCellForEvent(anEvent);
                if (theCell != null) {
                    final int theCellIndex = theCell.getCellIndex();
                    if (theCellIndex != 0) {
                        if (mySelectionIsMultiple) {
                            if (myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.removeItemFromSelection(anItem);
                            } else {
                                myItemSelection.addItemToSelection(anItem);
                            }
                        } else {
                            if (!myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            } else {
                                myItemSelection.clearSelection();
                            }
                        }
                    } else {
                        // The check box has already inserted the item into the selection.
                        if (mySelectionIsMultiple) {
                            // Nothing to do here.
                        } else {
                            if (myItemSelection.getSize() > 1) {
                                // I have to solve the inconsistency here.
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            }
                        }
                    }
                }
            }
        }

        @Override
        protected FlowPanel buildTopNavBar() {
            final FlowPanel theResult = new FlowPanel();
            final Label theRefreshLink = new Label(constants.refresh());
            theRefreshLink.setStyleName(CSSClassManager.LINK_LABEL);
            theRefreshLink.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent aEvent) {
                    myBonitaDataSource.reload();
                }
            });
            theResult.add(theRefreshLink);
            return theResult;
        }

        @Override
        protected FlowPanel buildBottomNavBar() {
            final FlowPanel theResult = new FlowPanel();

            final CustomMenuBar theActionMenu = new CustomMenuBar();
            theActionMenu.addItem(constants.add(), new Command() {
                public void execute() {
                    setSelectedItems(myItemSelection);
                }

            });
            theActionMenu.addItem(constants.cancel(), new Command() {
                public void execute() {
                    cancel();
                }
            });

            theResult.add(theActionMenu);
            return theResult;
        }

    };
    thePanel.setWidget(2, 0, myUserList);
    thePanel.getFlexCellFormatter().setColSpan(2, 0, 3);

    return thePanel;
}

From source file:org.bonitasoft.console.client.view.identity.UserFinderPanel.java

License:Open Source License

private FlexTable buildContent() {
    FlexTable thePanel = new FlexTable();

    thePanel.setWidget(0, 0, myErrorMessageLabel);
    thePanel.getFlexCellFormatter().setStyleName(0, 0, CSSClassManager.VALIDATION_ERROR_MESSAGE);
    thePanel.getFlexCellFormatter().setColSpan(0, 0, 3);

    myInternalItemDataSource.setItemFilter(myUserFilter);
    UsersListWidget myUserList = new UsersListWidget(null, myInternalItemDataSource, null, null, null) {

        @Override/* w w w .ja v a  2s .c  o m*/
        protected void initView() {
            myMinimalSize = 10;
            myMaximalSize = 10;
            super.initView();
            if (myBottomNavBar.getWidgetCount() == 2) {
                myBottomNavBar.remove(1);
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @seeorg.bonitasoft.console.client.view.identity.UsersListWidget#
         * getContentRowTooltip()
         */
        @Override
        protected String getContentRowTooltip() {
            return "";
        }

        @Override
        public void notifyItemClicked(UserUUID anItem, ClickEvent anEvent) {
            // Modify item selection.
            if (anItem != null) {
                final Cell theCell = myInnerTable.getCellForEvent(anEvent);
                if (theCell != null) {
                    final int theCellIndex = theCell.getCellIndex();
                    if (theCellIndex != 0) {
                        if (mySelectionIsMultiple) {
                            if (myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.removeItemFromSelection(anItem);
                            } else {
                                myItemSelection.addItemToSelection(anItem);
                            }
                        } else {
                            if (!myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            } else {
                                myItemSelection.clearSelection();
                            }
                        }
                    } else {
                        // The check box has already inserted the item into the selection.
                        if (mySelectionIsMultiple) {
                            // Nothing to do here.
                        } else {
                            if (myItemSelection.getSize() > 1) {
                                // I have to solve the inconsistency here.
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            }
                        }
                    }
                }
            }
        }

        @Override
        protected FlowPanel buildTopNavBar() {
            final FlowPanel theResult = new FlowPanel();
            final Label theRefreshLink = new Label(constants.refresh());
            theRefreshLink.setStyleName(CSSClassManager.LINK_LABEL);
            theRefreshLink.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent aEvent) {
                    myBonitaDataSource.reload();
                }
            });
            theResult.add(theRefreshLink);
            return theResult;
        }

        @Override
        protected FlowPanel buildBottomNavBar() {
            final FlowPanel theResult = new FlowPanel();

            final CustomMenuBar theActionMenu = new CustomMenuBar();
            theActionMenu.addItem(constants.add(), new Command() {
                public void execute() {
                    setSelectedUsers(myItemSelection);
                }

            });
            theActionMenu.addItem(constants.cancel(), new Command() {
                public void execute() {
                    cancel();
                }
            });

            theResult.add(theActionMenu);
            return theResult;
        }

    };
    thePanel.setWidget(2, 0, myUserList);
    thePanel.getFlexCellFormatter().setColSpan(2, 0, 3);

    return thePanel;
}

From source file:org.bonitasoft.console.client.view.identity.UserInfoEditorPanel.java

License:Open Source License

protected FlexTable buildContent() {
    FlexTable thePanel = new FlexTable();
    thePanel.setWidget(0, 1, myErrorMessageLabel);
    thePanel.getFlexCellFormatter().setStyleName(0, 1, "identity_form_mandatory");
    thePanel.getFlexCellFormatter().setColSpan(0, 1, 2);

    thePanel.setWidget(1, 0, myUsernameLabel);
    thePanel.getFlexCellFormatter().setStyleName(1, 0, "bos_user_editor_identity_form_label");
    myUsernameTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(1, 1, myUsernameTextBox);
    thePanel.setWidget(1, 2, new Label(constants.mandatorySymbol()));

    thePanel.setWidget(2, 0, myPasswordLabel);
    thePanel.getFlexCellFormatter().setStyleName(2, 0, "bos_user_editor_identity_form_label");
    myPasswordTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(2, 1, myPasswordTextBox);
    thePanel.setWidget(2, 2, new Label(constants.mandatorySymbol()));

    thePanel.setWidget(3, 0, myPasswordConfirmLabel);
    thePanel.getFlexCellFormatter().setStyleName(3, 0, "bos_user_editor_identity_form_label");
    myPasswordConfirmTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(3, 1, myPasswordConfirmTextBox);
    thePanel.setWidget(3, 2, new Label(constants.mandatorySymbol()));

    thePanel.setWidget(4, 0, myFirstNameLabel);
    thePanel.getFlexCellFormatter().setStyleName(4, 0, "bos_user_editor_identity_form_label");
    myFirstNameTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(4, 1, myFirstNameTextBox);

    thePanel.setWidget(5, 0, myLastNameLabel);
    thePanel.getFlexCellFormatter().setStyleName(5, 0, "bos_user_editor_identity_form_label");
    myLastNameTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(5, 1, myLastNameTextBox);

    thePanel.setWidget(6, 0, myTitleLabel);
    thePanel.getFlexCellFormatter().setStyleName(6, 0, "bos_user_editor_identity_form_label");
    myTitleTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(6, 1, myTitleTextBox);

    thePanel.setWidget(7, 0, myJobTitleLabel);
    thePanel.getFlexCellFormatter().setStyleName(7, 0, "bos_user_editor_identity_form_label");
    myJobTitleTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(7, 1, myJobTitleTextBox);

    thePanel.setWidget(8, 0, myManagerLabel);
    thePanel.getFlexCellFormatter().setStyleName(8, 0, "bos_user_editor_identity_form_label");
    myJobTitleTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(8, 1, myManagerUserViewer);

    thePanel.setWidget(9, 0, myDelegateLabel);
    thePanel.getFlexCellFormatter().setStyleName(9, 0, "bos_user_editor_identity_form_label");
    myJobTitleTextBox.setStyleName("identity_form_input");
    thePanel.setWidget(9, 1, myDelegateUserViewer);

    return thePanel;
}

From source file:org.bonitasoft.console.client.view.identity.UserMetadataEditorPanel.java

License:Open Source License

public UserMetadataEditorPanel(UserMetadataDataSource aDataSource, BonitaUUID anItemUUID) {
    super();/*from   ww w  .  j a v a2 s  .  c  om*/
    myBonitaDataSource = aDataSource;
    if (anItemUUID != null) {
        myItem = myBonitaDataSource.getItem(anItemUUID);
    }
    FlowPanel myOuterPanel = new FlowPanel();
    FlexTable myRoleEditor = new FlexTable();

    if (myItem == null) {
        myItemNameTextBox.setValue("");
        myItemLabelTextBox.setValue("");
    } else {
        myItemNameTextBox.setValue(myItem.getName());
        myItemLabelTextBox.setValue(myItem.getLabel());
    }
    myRoleEditor.setWidget(0, 1, errorMessageLabel);
    myRoleEditor.getFlexCellFormatter().setStyleName(0, 1, "identity_form_mandatory");
    myRoleEditor.getFlexCellFormatter().setColSpan(0, 1, 2);

    myRoleEditor.setWidget(1, 0, roleNameLabel);
    myRoleEditor.getFlexCellFormatter().setStyleName(1, 0, "identity_form_label");
    myItemNameTextBox.setStyleName("identity_form_input");
    myRoleEditor.setWidget(1, 1, myItemNameTextBox);
    myRoleEditor.setWidget(1, 2, new Label(constants.mandatorySymbol()));

    myRoleEditor.setWidget(2, 0, roleLabelLabel);
    myRoleEditor.getFlexCellFormatter().setStyleName(2, 0, "identity_form_label");
    myItemLabelTextBox.setStyleName("identity_form_input");
    myRoleEditor.setWidget(2, 1, myItemLabelTextBox);
    myRoleEditor.setWidget(2, 2, new Label(constants.mandatorySymbol()));

    FlowPanel buttonPanel = new FlowPanel();
    saveButton.setStyleName("identity_form_button");
    buttonPanel.add(saveButton);
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (myItem == null) {
                create();
            } else {
                update();
            }
        }
    });
    cancelButton.setStyleName("identity_form_button");
    buttonPanel.add(cancelButton);
    buttonPanel.setStyleName("identity_form_button_group");
    myRoleEditor.setWidget(4, 0, buttonPanel);
    myRoleEditor.getFlexCellFormatter().setColSpan(4, 0, 3);
    myOuterPanel.add(myRoleEditor);
    initWidget(myOuterPanel);
}

From source file:org.bonitasoft.console.client.view.labels.LabelStyleSelectorWidget.java

License:Open Source License

/**
 * /*  w  w w  .j av  a 2 s.  co  m*/
 * Default constructor.
 * 
 * @param aLabelDataSource
 * @param aLabelModel
 */
public LabelStyleSelectorWidget(final LabelDataSource aLabelDataSource, final LabelModel aLabelModel) {
    super();
    myLabelDataSource = aLabelDataSource;
    myLabelModel = aLabelModel;
    myErrorMessage = new Label();
    myErrorMessage.setStylePrimaryName(CSSClassManager.VALIDATION_ERROR_MESSAGE);
    myCreateDialogBox = createDialogBox();
    FlexTable theOuterPanel = new FlexTable();
    Label theLabel;
    DecoratorPanel theContainer;
    theLabel = new Label(TITLE_LABEL_KEY);
    theOuterPanel.setWidget(0, 0, theLabel);
    theOuterPanel.getFlexCellFormatter().setColSpan(0, 0, 4);
    //

    if (editableCSSClassName.length != readonlyCSSClassName.length
            || editableCSSClassName.length != previewCSSClassName.length) {
        Window.alert("Invalid list of CSS style definitions in class LabelStyleSelectorWidget!");
    }

    int theRow = 1;
    int theCol = 0;
    for (int i = 0; i < editableCSSClassName.length; i++) {
        theContainer = new DecoratorPanel();
        theLabel = new Label(B_CHARACTER);
        theContainer.add(theLabel);
        theContainer.setStylePrimaryName(previewCSSClassName[i] + CONTAINER_CSS_SUFFIX);
        theLabel.setStyleName(previewCSSClassName[i]);
        theLabel.addClickHandler(new StyleClickHandler(aLabelModel, editableCSSClassName[i],
                previewCSSClassName[i], readonlyCSSClassName[i]));
        theOuterPanel.setWidget(theRow, theCol, theContainer);
        // Go to a new line every 4 choices.
        if (theCol == 3) {
            theRow++;
            theCol = 0;
        } else {
            theCol++;
        }
    }

    // Add a separator.
    theRow++;
    theOuterPanel.setHTML(theRow, 0, "<HR>");
    theOuterPanel.getFlexCellFormatter().setColSpan(theRow, 0, 4);

    // Add a menu.
    theRow++;
    Label theRenameLink = new Label(constants.renameLabel());
    theRenameLink.setStylePrimaryName(CSSClassManager.LINK_LABEL);
    theOuterPanel.setWidget(theRow, 0, theRenameLink);
    theOuterPanel.getFlexCellFormatter().setColSpan(theRow, 0, 4);

    theRenameLink.addClickHandler(new ClickHandler() {
        /*
         * (non-Javadoc)
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google .gwt.event.dom.client.ClickEvent)
         */
        public void onClick(final ClickEvent aClickEvent) {
            myCreateDialogBox.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                public void setPosition(int anOffsetWidth, int anOffsetHeight) {
                    int left = ((Window.getClientWidth() / 2) - (anOffsetWidth / 2));
                    int top = aClickEvent.getNativeEvent().getClientY() - (anOffsetHeight / 2);
                    myCreateDialogBox.setPopupPosition(left, top);
                }
            });
            myNewLabelName.setText(myLabelModel.getUUID().getValue());
            myNewLabelName.setFocus(true);
            LabelStyleSelectorWidget.this.hide();
        }
    });

    this.add(theOuterPanel);
    // Set the auto hide feature.
    setAutoHideEnabled(true);
}

From source file:org.bonitasoft.console.client.view.processes.ProcessFinderPanel.java

License:Open Source License

private FlexTable buildContent() {
    FlexTable thePanel = new FlexTable();

    thePanel.setWidget(0, 0, myErrorMessageLabel);
    thePanel.getFlexCellFormatter().setStyleName(0, 0, CSSClassManager.VALIDATION_ERROR_MESSAGE);
    thePanel.getFlexCellFormatter().setColSpan(0, 0, 3);

    final ProcessList myItemList = new ProcessList(null,
            (ProcessSelection) myItemFinderDataSource.getItemSelection(), myItemFinderDataSource) {

        @Override/*  w w w .ja  va2 s  . c  o  m*/
        protected void initView() {
            super.initView();
            if (myBottomNavBar.getWidgetCount() == 2) {
                myBottomNavBar.remove(1);
            }
        }

        @Override
        public void notifyItemClicked(BonitaProcessUUID anItem, ClickEvent anEvent) {
            // Modify item selection.
            if (anItem != null) {
                final Cell theCell = myInnerTable.getCellForEvent(anEvent);
                if (theCell != null) {
                    final int theCellIndex = theCell.getCellIndex();
                    if (theCellIndex != mySelectColumnIndex) {
                        if (mySelectionIsMultiple) {
                            if (myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.removeItemFromSelection(anItem);
                            } else {
                                myItemSelection.addItemToSelection(anItem);
                            }
                        } else {
                            if (!myItemSelection.getSelectedItems().contains(anItem)) {
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            } else {
                                myItemSelection.clearSelection();
                            }
                        }
                    } else {
                        // The check box has already inserted the item into the selection.
                        if (mySelectionIsMultiple) {
                            // Nothing to do here.
                        } else {
                            if (myItemSelection.getSize() > 1) {
                                // I have to solve the inconsistency here.
                                myItemSelection.clearSelection();
                                myItemSelection.addItemToSelection(anItem);
                            }
                        }
                    }
                }
            }
        }

        @Override
        protected FlowPanel buildTopNavBar() {
            final FlowPanel theResult = new FlowPanel();
            final Label theRefreshLink = new Label(constants.refresh());
            theRefreshLink.setStyleName(CSSClassManager.LINK_LABEL);
            theRefreshLink.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent aEvent) {
                    myBonitaDataSource.reload();
                }
            });
            theResult.add(theRefreshLink);
            return theResult;
        }

        @Override
        protected FlowPanel buildBottomNavBar() {
            final FlowPanel theResult = new FlowPanel();

            final CustomMenuBar theActionMenu = new CustomMenuBar();
            theActionMenu.addItem(constants.add(), new Command() {
                public void execute() {
                    setSelectedItems(myItemSelection);
                }

            });
            theActionMenu.addItem(constants.cancel(), new Command() {
                public void execute() {
                    cancel();
                }
            });

            theResult.add(theActionMenu);
            return theResult;
        }

    };
    thePanel.setWidget(2, 0, myItemList);
    thePanel.getFlexCellFormatter().setColSpan(2, 0, 3);

    return thePanel;
}

From source file:org.bonitasoft.console.client.view.UserSettingsEditionView.java

License:Open Source License

/**
 * @return/*w  w  w.j a v a  2 s  .  c om*/
 */
private UserInfoEditorPanel buildUserInfoPanel(UserUUID aUserUUID) {

    final UserInfoEditorPanel theUserInfoEditor = new UserInfoEditorPanel(myUserDataSource) {
        @Override
        protected FlexTable buildContent() {
            myDelegateUserViewer
                    .setEnabled((myUserProfile != null && myUserProfile.isAllowed(RuleType.DELEGEE_UPDATE)));
            myFirstNameTextBox.setEnabled(false);
            myJobTitleTextBox.setEnabled(false);
            myLastNameTextBox.setEnabled(false);
            myManagerUserViewer.setEnabled(false);
            myTitleTextBox.setEnabled(false);
            myUsernameTextBox.setEnabled(false);
            FlexTable theTable = super.buildContent();
            if (myUserProfile != null && myUserProfile.isAllowed(RuleType.PASSWORD_UPDATE)) {
                myPasswordConfirmTextBox.setEnabled(true);
                myPasswordTextBox.setEnabled(true);
                int theActionRow = theTable.getRowCount();
                theTable.setWidget(theActionRow, 0, mySaveUserProfileButton);
                theTable.getFlexCellFormatter().setColSpan(theActionRow, 0, 2);
                theTable.getFlexCellFormatter().setHorizontalAlignment(theActionRow, 0,
                        HasHorizontalAlignment.ALIGN_CENTER);
            } else {
                myPasswordConfirmTextBox.setEnabled(false);
                myPasswordTextBox.setEnabled(false);
                theTable.remove(mySaveUserProfileButton);
            }
            return theTable;
        }
    };

    theUserInfoEditor.update(aUserUUID);
    return theUserInfoEditor;
}

From source file:org.clevermore.monitor.client.servers.ServersWidget.java

License:Apache License

private void updateServersTable() {
    sp.clear();/* www  . j  a  v  a  2 s  .c  o  m*/
    FlexTable ft = new FlexTable();
    sp.add(ft);
    ft.getElement().setId("infoTable");
    ft.setCellPadding(0);
    ft.setCellSpacing(0);

    Collections.sort(servesList, new Comparator<ConnectedServer>() {

        @Override
        public int compare(ConnectedServer o1, ConnectedServer o2) {
            double o1p = 0, o2p = 0;
            if (o1.getStatus() && o2.getStatus()) {
                if (o1.getCpuUsage() > 80 || o2.getCpuUsage() > 80) {
                    // sort by CPU
                    o1p = o1.getCpuUsage();
                    o2p = o2.getCpuUsage();
                } else {
                    // sort by memory
                    o1p = o1.getMemoryUsage().getPercentage();
                    o2p = o2.getMemoryUsage().getPercentage();
                }
            } else if (o1.getStatus()) {
                o1p = o1.getMemoryUsage().getPercentage();
                o2p = 100;
            } else if (o2.getStatus()) {
                o1p = 100;
                o2p = o2.getMemoryUsage().getPercentage();
            }
            return (int) (o2p * 100d - o1p * 100d);
        }
    });

    int i = 0, j = 0;
    HTML t;
    ft.setText(i, j++, "Code, Name");
    ft.setText(i, j++, "Up Time");

    t = new HTML("Memory");
    t.setTitle("Latest memory status.");
    ft.setWidget(i, j++, t);

    t = new HTML("Max GC");
    t.setTitle("Max GC time in the last 24 hours.");
    ft.setWidget(i, j++, t);

    t = new HTML("Cpu");
    t.setTitle("Latest CPU load.");
    ft.setWidget(i, j++, t);

    t = new HTML("SYSL");
    t.setTitle("Linux system load.");
    ft.setWidget(i, j++, t);

    ft.getRowFormatter().getElement(i++).setId("th");

    int offline = 0;

    serversMap.clear();

    for (ConnectedServer cs : servesList) {
        serversMap.put(cs.getServerCode(), cs);

        j = 0;
        offline += cs.getStatus() ? 0 : 1;
        if (!toShow(cs.getName())) {
            continue;
        }
        if (cs.getStatus()) {
            final HTML name = new HTML("<a href=#>" + cs.getServerCode() + "," + cs.getName() + "</a>");
            name.getElement().setAttribute("code", "" + cs.getServerCode());
            name.setTitle(cs.getToolTip());
            name.addMouseOverHandler(handCursor);

            name.addClickHandler(getThreadDump);

            ft.setWidget(i, j++, name);
            ft.setText(i, j++, ClientStringFormatter.formatMilisecondsToHours(cs.getUpTime()));

            HTML usage = new HTML(ClientStringFormatter.formatMBytes(cs.getMemoryUsage().getUsed()) + " / "
                    + ClientStringFormatter.formatMBytes(cs.getMemoryUsage().getMax()) + " MB,  "
                    + ClientStringFormatter.formatMillisShort(cs.getMemoryUsage().getPercentage()) + "%");
            ft.setWidget(i, j++, usage);

            StringBuilder gcs = new StringBuilder();
            double gcMax = Double.MIN_VALUE;

            // Iterating over all available pools
            for (Double gch : cs.getGcHistories()) {
                gcs.append(ClientStringFormatter.formatMillisShort(gch)).append(", ");
                if (gch > gcMax) {
                    gcMax = gch;
                }
            }
            if (gcs.length() > 0) {
                gcs.setLength(gcs.length() - 2);
            }
            final HTML memory = new HTML(gcs.toString());
            memory.setTitle("Click to see GC history");
            memory.addMouseOverHandler(handCursor);
            memory.addClickHandler(getGCHistory);
            memory.getElement().setAttribute("code", "" + cs.getServerCode());

            ft.setWidget(i, j++, memory);
            if (gcMax > 3) {
                Style style = ft.getFlexCellFormatter().getElement(i, j - 1).getStyle();
                style.setBackgroundColor("#C00000");
                style.setFontWeight(FontWeight.BOLDER);
                style.setColor("white");
            }

            if (cs.getMemoryUsage().getPercentage() > 90) {
                ft.getRowFormatter().getElement(i).setId("memoryVeryHigh");
            }
            // else if (cs.getMemoryUsage().getPercentage() > 80) {
            // ft.getRowFormatter().getElement(i).setId("memoryHigh");
            // }

            HTML cpu = new HTML(cs.getCpuUsage() + "%");
            ft.setWidget(i, j++, cpu);
            if (cs.getCpuUsage() > 90d) {
                Style style = ft.getFlexCellFormatter().getElement(i, j - 1).getStyle();
                style.setBackgroundColor("#C00000");
                style.setFontWeight(FontWeight.BOLDER);
                style.setColor("white");
            }

            double sla = cs.getSystemLoadAverage();
            HTML sysl = new HTML(sla == -1 ? "N/A" : ClientStringFormatter.formatMillisShort(sla));
            sysl.setTitle("System Load Average");
            ft.setWidget(i, j++, sysl);
            i++;

        } else {
            if (showOffline) {
                final HTML name = new HTML("<a href=#>" + cs.getServerCode() + ", " + cs.getName() + "</a>");
                name.setTitle("JMX >> " + cs.getIp() + ":" + cs.getJmxPort());
                ft.setWidget(i, j++, name);
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "0.0%");
                ft.setText(i, j++, "0");
                ft.getRowFormatter().getElement(i++).setId("offline");
            }
        }
    }

    ft.getColumnFormatter().setWidth(0, "100px");

    if (databases != null && databases.size() > 0) {
        for (ConnectedDB cd : databases) {
            j = 0;
            HTML value = new HTML("<b>Database</b>:" + cd.getName() + " (" + cd.getService() + ")");
            value.setTitle(cd.toString());
            ft.setWidget(i, j, value);
            ft.getFlexCellFormatter().setColSpan(i, j, 2);
            ft.setText(i, 1, cd.getIp() + ":" + cd.getPort());
            ft.setText(i, 2, (cd.getStatus() ? "ONLINE" : "OFFLINE"));
            ft.setText(i, 3, "LastPing:" + cd.getLastPingTime() + "ms");
            ft.getFlexCellFormatter().setColSpan(i, 3, 2);
            if ((!cd.getStatus())) {
                ft.getRowFormatter().getElement(i).setId("offline");
            }
            i++;
        }
    }
    serversLabel.setText("Servers:" + servesList.size() + " (" + offline + ")");
}

From source file:org.drools.brms.client.packages.PackageSnapshotView.java

License:Apache License

/**
 * This opens the package viewer, showing the contents of that snapshot.
 *//*  ww w  .  j av a 2 s  .c  om*/
private void openPackageSnapshot(final String pkgName, final String snapshotName, final String uuid) {
    FlexTable viewLayout = new FlexTable();
    String msg = "<b>Viewing snapshot labelled: </b>" + snapshotName + " for package " + pkgName
            + ". This should not be edited.";
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(new HTML(msg));
    Image close = new ImageButton("images/close.gif");
    close.setTitle("Close this view");
    close.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            tab.remove(1);
            tab.selectTab(0);
        }
    });
    horiz.add(close);
    viewLayout.setWidget(0, 0, horiz);
    FlexCellFormatter formatter = viewLayout.getFlexCellFormatter();
    formatter.setStyleName(0, 0, "editable-Surface");

    viewLayout.setWidget(1, 0, new PackageManagerView(uuid, snapshotName));

    viewLayout.setWidth("100%");
    viewLayout.setHeight("100%");

    if (tab.getWidgetCount() > 1) {
        tab.remove(1);
    }
    tab.add(viewLayout, "<img src='images/package_snapshot_item.gif'> " + pkgName + " [" + snapshotName + "]",
            true);
    tab.selectTab(1);
}

From source file:org.drools.brms.client.ruleeditor.VersionViewer.java

License:Apache License

public VersionViewer(final MetaData head, String versionUUID, String headUUID, Command refresh) {
    super(false);

    this.versionUUID = versionUUID;
    this.headUUID = headUUID;
    this.refresh = refresh;

    setStyleName("version-Popup");

    LoadingPopup.showMessage("Loading version");

    RepositoryServiceFactory.getService().loadRuleAsset(versionUUID, new GenericCallback() {

        public void onSuccess(Object data) {

            RuleAsset asset = (RuleAsset) data;
            asset.isreadonly = true;/*  w  ww  . j a v a  2s  . co m*/
            asset.metaData.name = head.name;
            setText("Version number [" + asset.metaData.versionNumber + "] of [" + asset.metaData.name + "]");

            FlexTable layout = new FlexTable();
            FlexCellFormatter formatter = layout.getFlexCellFormatter();

            Button restore = new Button("Restore this version");
            restore.addClickListener(new ClickListener() {
                public void onClick(Widget w) {
                    restore(w);
                }

            });
            layout.setWidget(0, 0, restore);
            formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);

            Button close = new Button("Close");
            close.addClickListener(new ClickListener() {
                public void onClick(Widget w) {
                    hide();
                }
            });

            layout.setWidget(0, 1, close);

            formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);

            RuleViewer viewer = new RuleViewer(asset, true);

            viewer.setWidth("100%");
            layout.setWidget(1, 0, viewer);
            formatter.setColSpan(1, 1, 2);
            layout.setWidth("100%");
            layout.setPixelSize(800, 300);
            setWidget(layout);
        }
    });
}