Example usage for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel

List of usage examples for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel

Introduction

In this page you can find the example usage for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel.

Prototype

public SingleSelectionModel() 

Source Link

Document

Constructs a SingleSelectionModel without a key provider.

Usage

From source file:eu.riscoss.client.rdr.ContactCell.java

License:Apache License

public void onModuleLoad() {

    RiscossJsonClient.listEntities(new JsonCallback() {
        @Override/*from  w  ww . j av  a2  s  . com*/
        public void onFailure(Method method, Throwable exception) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(Method method, JSONValue response) {
            listEntities = new ArrayList<>();
            for (int i = 0; i < response.isArray().size(); ++i) {
                if (!response.isArray().get(i).isObject().get("name").isString().stringValue().equals("-"))
                    listEntities.add(response.isArray().get(i).isObject());
            }

            cellList = new CellTable<JSONObject>(15, (Resources) GWT.create(TableResources.class));
            cellList.setStyleName("list");
            cellList.setPageSize(30);
            cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
            cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);

            final SingleSelectionModel<JSONObject> selectionModel = new SingleSelectionModel<JSONObject>();
            cellList.setSelectionModel(selectionModel);
            selectionModel.addSelectionChangeHandler(new Handler() {
                @Override
                public void onSelectionChange(SelectionChangeEvent arg0) {
                    ppg.setSelectedEntity(
                            selectionModel.getSelectedObject().get("name").isString().stringValue());
                }
            });

            Column<JSONObject, String> t = new Column<JSONObject, String>(new TextCell()) {
                @Override
                public String getValue(JSONObject arg0) {
                    return arg0.get("name").isString().stringValue();
                }
            };

            Column<JSONObject, String> t2 = new Column<JSONObject, String>(new TextCell()) {
                @Override
                public String getValue(JSONObject arg0) {
                    return arg0.get("layer").isString().stringValue();
                }
            };

            cellList.addColumn(t, "Entity");
            cellList.addColumn(t2, "Layer");
            cellList.setWidth("100%");

            if (listEntities.size() > 0)
                cellList.setRowData(0, listEntities);
            else {
                listEntities.add(new JSONObject());
                cellList.setRowData(0, listEntities);
                listEntities.remove(0);
            }
            cellList.setStyleName("table");

            dataProvider = new ListDataProvider<JSONObject>();
            dataProvider.addDataDisplay(cellList);

            for (int i = 0; i < listEntities.size(); i++) {
                dataProvider.getList().add(listEntities.get(i));
            }

            pager = new SimplePager();
            pager.setDisplay(cellList);

            ppg = new EntityDataBox();

            dock.setWidth("100%");
            dock.add(cellList, DockPanel.CENTER);
            dock.add(ppg.asWidget(), DockPanel.EAST);
            dock.setCellWidth(ppg.asWidget(), "60%");

            mainView.setStyleName("mainViewLayer");
            //mainView.setWidth("100%");
            leftPanel.setStyleName("leftPanelLayer");
            leftPanel.setWidth("400px");
            //leftPanel.setHeight("100%");
            rightPanel.setStyleName("rightPanelLayer");
            page.setWidth("100%");

            Label title = new Label("Risk Data Repository");
            title.setStyleName("title");
            page.add(title);

            leftPanel.add(cellList);
            leftPanel.add(pager);
            rightPanel.add(ppg);
            rightPanel.setWidth("90%");
            mainView.add(leftPanel);
            mainView.add(rightPanel);

            page.add(mainView);

            RootPanel.get().add(page);
        }
    });

}

From source file:gov.nist.appvet.gwt.client.gui.AppVetPanel.java

License:Open Source License

public AppVetPanel(Unit unit, final ConfigInfoGwt configInfo, List<AppInfoGwt> initialApps) {
    super(Unit.PX);

    Window.addResizeHandler(new ResizeHandler() {
        Timer resizeTimer = new Timer() {

            @Override/*from w w  w.  j a va 2 s.c om*/
            public void run() {
                resizeComponents();
            }

        };

        @Override
        public void onResize(ResizeEvent event) {
            resizeTimer.cancel();
            resizeTimer.schedule(250);
        }

    });

    userInfo = configInfo.getUserInfo();
    userName = userInfo.getUserName();
    allApps = initialApps;

    sinkEvents(Event.ONCLICK);
    sessionId = configInfo.getSessionId();
    sessionExpirationLong = configInfo.getSessionExpirationLong();
    MAX_SESSION_IDLE_DURATION = configInfo.getMaxIdleTime();
    POLLING_INTERVAL = configInfo.getUpdatesDelay();

    setSize("100%", "");
    setStyleName("mainDockPanel");
    SERVLET_URL = configInfo.getAppVetServletUrl();
    HOST_URL = configInfo.getAppVetHostUrl();
    appSelectionModel = new SingleSelectionModel<AppInfoGwt>();
    appSelectionModel.addSelectionChangeHandler(new AppListHandler(this, configInfo));
    if (configInfo.getAvailableToolNames() == null) {
        log.severe("Available tools is null");
    }
    availableToolNames = configInfo.getAvailableToolNames();
    availableToolIDs = configInfo.getAvailableToolIDs();
    availableToolTypes = configInfo.getAvailableToolTypes();

    final VerticalPanel northAppVetPanel = new VerticalPanel();
    northAppVetPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    northAppVetPanel.setStyleName("northAppVetPanel");
    northAppVetPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    addNorth(northAppVetPanel, 125.0);
    northAppVetPanel.setSize("100%", "");

    final HorizontalPanel horizontalPanel_5 = new HorizontalPanel();
    horizontalPanel_5.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_5.setStyleName("appVetHeaderPanel");
    northAppVetPanel.add(horizontalPanel_5);
    northAppVetPanel.setCellVerticalAlignment(horizontalPanel_5, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_5.setWidth("100%");
    northAppVetPanel.setCellWidth(horizontalPanel_5, "100%");

    final InlineHTML nlnhtmlNewInlinehtml_1 = new InlineHTML(
            "<img border=\"0\" width=\"192px\" src=\"images/appvet_logo.png\" alt=\"appvet\" />");
    nlnhtmlNewInlinehtml_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    nlnhtmlNewInlinehtml_1.setStyleName("");
    horizontalPanel_5.add(nlnhtmlNewInlinehtml_1);
    horizontalPanel_5.setCellWidth(nlnhtmlNewInlinehtml_1, "33%");
    horizontalPanel_5.setCellVerticalAlignment(nlnhtmlNewInlinehtml_1, HasVerticalAlignment.ALIGN_MIDDLE);

    final HorizontalPanel horizontalPanel_6 = new HorizontalPanel();
    horizontalPanel_6.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_6.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_5.add(horizontalPanel_6);
    horizontalPanel_6.setWidth("");
    horizontalPanel_5.setCellWidth(horizontalPanel_6, "34%");
    horizontalPanel_5.setCellHorizontalAlignment(horizontalPanel_6, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_5.setCellVerticalAlignment(horizontalPanel_6, HasVerticalAlignment.ALIGN_MIDDLE);

    searchTextBox = new TextBox();
    searchTextBox.setText("Search");
    searchTextBox.setStyleName("searchTextBox");
    searchTextBox.setTitle("Search by app ID, name, release kit, etc.");
    searchTextBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            searchTextBox.setText("");
        }

    });

    searchTextBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event_) {
            final boolean enterPressed = KeyCodes.KEY_ENTER == event_.getNativeEvent().getKeyCode();
            final String searchString = searchTextBox.getText();

            if (enterPressed) {
                final int numFound = search();
                if (numFound > 0) {
                    appsLabel.setText("Search Results for \"" + searchString + "\"");
                }
            }
        }

    });

    searchTextBox.setSize("300px", "22px");

    horizontalPanel_6.add(searchTextBox);
    horizontalPanel_6.setCellVerticalAlignment(searchTextBox, HasVerticalAlignment.ALIGN_MIDDLE);

    final PushButton searchButton = new PushButton("Search");
    searchButton.setTitle("Search by app ID, name, release kit, etc.");
    searchButton.getUpFace().setHTML("");
    searchButton.setSize("18px", "18px");
    searchButton.setHTML("<img width=\"18px\" src=\"images/icon-search.png\" alt=\"search\" />");
    searchButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final String searchString = searchTextBox.getText();
            final int numFound = search();
            if (numFound > 0) {
                appsLabel.setText("Search Results for \"" + searchString + "\"");
            }
        }

    });

    horizontalPanel_6.add(searchButton);
    horizontalPanel_6.setCellHorizontalAlignment(searchButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_6.setCellVerticalAlignment(searchButton, HasVerticalAlignment.ALIGN_MIDDLE);

    Image image = new Image("images/nist-gray.png");
    horizontalPanel_5.add(image);
    horizontalPanel_5.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_RIGHT);
    horizontalPanel_5.setCellWidth(image, "33%");

    final HorizontalPanel horizontalPanel_3 = new HorizontalPanel();
    northAppVetPanel.add(horizontalPanel_3);
    northAppVetPanel.setCellHorizontalAlignment(horizontalPanel_3, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_3.setWidth("100%");
    northAppVetPanel.setCellWidth(horizontalPanel_3, "100%");
    final MenuBar appVetMenuBar = new MenuBar(false);
    horizontalPanel_3.add(appVetMenuBar);

    appVetMenuBar.setStyleName("appVetMenuBar");
    appVetMenuBar.setAutoOpen(true);
    appVetMenuBar.setWidth("250px");
    appVetMenuBar.setAnimationEnabled(false);
    final MenuBar userMenuBar = new MenuBar(true);
    accountMenuItem = new MenuItem(userInfo.getNameWithLastNameInitial(), true, userMenuBar);
    accountMenuItem.setStyleName("AccountMenuItem");

    final MenuItem accountSettingsMenuItem = new MenuItem("Account Settings", false, new Command() {
        @Override
        public void execute() {
            updateUserInfo();
        }
    });

    userMenuBar.addItem(accountSettingsMenuItem);

    final MenuItem myAppsMenuItem = new MenuItem("My Apps", false, new Command() {

        @Override
        public void execute() {
            searchTextBox.setText(userInfo.getUserName());
            final int numFound = search();
            if (numFound > 0) {
                appsLabel.setText("My Apps");
            }
        }

    });
    userMenuBar.addItem(myAppsMenuItem);

    final MenuItemSeparator separator = new MenuItemSeparator();
    userMenuBar.addSeparator(separator);
    final MenuItem logoutMenuItem = new MenuItem("Logout", false, new Command() {

        @Override
        public void execute() {
            appVetServiceAsync.removeSession(sessionId, new AsyncCallback<Boolean>() {

                @Override
                public void onFailure(Throwable caught) {
                    AppVetPanel.showMessageDialog("AppVet Error", "App list retrieval error", true);
                    errorDialogBox.closeButton.setFocus(true);
                    errorDialogBox.closeButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            killDialogBox(errorDialogBox);
                        }

                    });
                }

                @Override
                public void onSuccess(Boolean result) {
                    if (result == false) {
                        AppVetPanel.showMessageDialog("AppVet Error", "Could not remove session", true);
                        errorDialogBox.closeButton.setFocus(true);
                        errorDialogBox.closeButton.addClickHandler(new ClickHandler() {

                            @Override
                            public void onClick(ClickEvent event) {
                                killDialogBox(errorDialogBox);
                            }

                        });
                    } else {
                        pollingTimer.cancel();
                        final LoginPanel loginPanel = new LoginPanel(Unit.PX);
                        final RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
                        rootLayoutPanel.clear();
                        rootLayoutPanel.add(loginPanel);

                        System.gc();
                    }
                }

            });
        }

    });

    userMenuBar.addItem(logoutMenuItem);
    appVetMenuBar.addItem(accountMenuItem);

    final MenuBar helpMenuBar = new MenuBar(true);
    final MenuItem helpMenuItem = new MenuItem("Help", true, helpMenuBar);
    final MenuItem aboutMenuItem = new MenuItem("About", false, new Command() {

        @Override
        public void execute() {
            aboutDialogBox = new AboutDialogBox(configInfo.getAppVetVersion());
            aboutDialogBox.setText("About");
            aboutDialogBox.center();
            aboutDialogBox.closeButton.setFocus(true);
            aboutDialogBox.closeButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(aboutDialogBox);
                }

            });
        }

    });

    final MenuItem documentationMenuItem = new MenuItem("Documentation", false, new Command() {

        @Override
        public void execute() {
            Window.open("http://csrc.nist.gov/projects/appvet/", "_blank", null);
        }

    });
    helpMenuBar.addItem(documentationMenuItem);

    appVetMenuBar.addItem(helpMenuItem);
    helpMenuBar.addItem(aboutMenuItem);

    horizontalPanel_3.add(statusMessageLabel);
    horizontalPanel_3.setCellVerticalAlignment(statusMessageLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_3.setCellHorizontalAlignment(statusMessageLabel, HasHorizontalAlignment.ALIGN_RIGHT);
    horizontalPanel_3.setCellWidth(statusMessageLabel, "100%");

    statusMessageLabel.setStyleName("devModeIndicator");
    statusMessageLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    statusMessageLabel.setSize("420px", "18");

    final MenuBar adminMenuBar = new MenuBar(true);
    final MenuItem adminMenuItem = new MenuItem("Admin", true, adminMenuBar);

    final MenuItem mntmAppVetLog = new MenuItem("AppVet Log", false, new Command() {

        @Override
        public void execute() {
            final String dateString = "?nocache" + new Date().getTime();
            final String url = SERVLET_URL + dateString + "&command=GET_APPVET_LOG&sessionid=" + sessionId;
            Window.open(url, "_blank", "");
        }

    });

    adminMenuBar.addItem(mntmAppVetLog);

    final MenuItem usersMenuItem = new MenuItem("Users", false, new Command() {

        @Override
        public void execute() {
            usersDialogBox = new UsersDialogBox();
            usersDialogBox.setText("Users");
            usersDialogBox.center();
            usersDialogBox.doneButton.setFocus(true);
            usersDialogBox.doneButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(usersDialogBox);
                }

            });
        }

    });

    adminMenuBar.addItem(usersMenuItem);

    if (userInfo.getRole().equals("ADMIN")) {
        appVetMenuBar.addItem(adminMenuItem);
    }

    // Remove first element containing the lastUpdate timestamp
    AppInfoGwt timeStampObject = null;
    if (initialApps != null && initialApps.size() > 0) {
        timeStampObject = initialApps.remove(0);
        lastAppsListUpdate = timeStampObject.getLastAppUpdate();
    }

    final HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_2.setStyleName("footerPanel");
    addSouth(horizontalPanel_2, 35.0);
    horizontalPanel_2.setSize("100%", "");

    //      final Label lastUpdatedLabel = new Label("Last updated: "
    //            + configInfo.getLastUpdated());
    //      lastUpdatedLabel
    //      .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    //      lastUpdatedLabel.setStyleName("lastUpdated");
    //      horizontalPanel_2.add(lastUpdatedLabel);
    //      lastUpdatedLabel.setWidth("200px");
    //      horizontalPanel_2.setCellWidth(lastUpdatedLabel, "100%");
    //      horizontalPanel_2.setCellVerticalAlignment(lastUpdatedLabel,
    //            HasVerticalAlignment.ALIGN_MIDDLE);

    final HorizontalSplitPanel centerAppVetSplitPanel = new HorizontalSplitPanel();
    centerAppVetSplitPanel.setSplitPosition("64%");
    centerAppVetSplitPanel.setSize("", "");

    final SimplePanel leftCenterPanel = new SimplePanel();
    centerAppVetSplitPanel.setLeftWidget(leftCenterPanel);
    leftCenterPanel.setSize("", "95%");

    final DockPanel dockPanel_1 = new DockPanel();
    dockPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    leftCenterPanel.setWidget(dockPanel_1);
    dockPanel_1.setSize("100%", "");
    rightCenterPanel = new SimplePanel();
    centerAppVetSplitPanel.setRightWidget(rightCenterPanel);
    rightCenterPanel.setSize("", "630px");

    final VerticalPanel appInfoVerticalPanel = new VerticalPanel();
    appInfoVerticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    rightCenterPanel.setWidget(appInfoVerticalPanel);
    appInfoVerticalPanel.setSize("99%", "");

    final HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setStyleName("iconPanel");
    appInfoVerticalPanel.add(horizontalPanel_1);
    appInfoVerticalPanel.setCellWidth(horizontalPanel_1, "100%");
    horizontalPanel_1.setSize("", "");

    appInfoIcon = new Image("");
    appInfoIcon.setVisible(false);
    appInfoIcon.setAltText("");
    horizontalPanel_1.add(appInfoIcon);
    horizontalPanel_1.setCellVerticalAlignment(appInfoIcon, HasVerticalAlignment.ALIGN_MIDDLE);
    appInfoIcon.setSize("70px", "70px");

    final VerticalPanel verticalPanel = new VerticalPanel();
    horizontalPanel_1.add(verticalPanel);
    appInfoName = new HTML("", true);
    appInfoName.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    verticalPanel.add(appInfoName);
    appInfoName.setStyleName("appInfoName");
    appInfoName.setWidth("");
    horizontalPanel_1.setCellVerticalAlignment(appInfoName, HasVerticalAlignment.ALIGN_MIDDLE);
    appInfoVersion = new HTML("", true);
    appInfoVersion.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    appInfoVersion.setStyleName("appInfoVersion");
    verticalPanel.add(appInfoVersion);
    appsListButtonPanel = new HorizontalPanel();
    appsListButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    dockPanel_1.add(appsListButtonPanel, DockPanel.NORTH);
    dockPanel_1.setCellHorizontalAlignment(appsListButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    dockPanel_1.setCellWidth(appsListButtonPanel, "100%");
    dockPanel_1.setCellVerticalAlignment(appsListButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    appsListButtonPanel.setStyleName("appListButtonPanel");
    appsListButtonPanel.setSize("100%", "");

    appsLabel = new InlineLabel("Apps");
    appsLabel.setStyleName("AppsLabel");
    appsListButtonPanel.add(appsLabel);
    appsListButtonPanel.setCellWidth(appsLabel, "50%");
    appsListButtonPanel.setCellVerticalAlignment(appsLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    appsLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    appsLabel.setWidth("60px");

    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setStyleName("appFunctionButtonPanel");
    appsListButtonPanel.add(horizontalPanel);
    appsListButtonPanel.setCellWidth(horizontalPanel, "50%");
    appsListButtonPanel.setCellVerticalAlignment(horizontalPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    appsListButtonPanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_RIGHT);
    horizontalPanel.setWidth("");

    final PushButton submitButton = new PushButton("Submit");
    submitButton.setTitle("Submit App");
    submitButton.setHTML("<img width=\"18px\" src=\"images/icon-submit.png\" alt=\"Submit\" />");
    submitButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            appUploadDialogBox = new AppUploadDialogBox(sessionId, SERVLET_URL);
            appUploadDialogBox.setText("Submit App");
            appUploadDialogBox.center();
            appUploadDialogBox.cancelButton.setFocus(true);
            appUploadDialogBox.cancelButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(appUploadDialogBox);
                }

            });

            appUploadDialogBox.uploadAppForm.addFormHandler(new AppUploadFormHandler(appUploadDialogBox));
        }
    });

    final PushButton viewAllButton = new PushButton("View All");
    viewAllButton.setTitle("View All");
    viewAllButton.setHTML("<img width=\"18px\" src=\"images/icon-view-all.png\" alt=\"view-all\" />");
    viewAllButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            searchMode = false;
            setAllApps();
        }

    });

    horizontalPanel.add(viewAllButton);
    horizontalPanel.setCellHorizontalAlignment(viewAllButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel.setCellVerticalAlignment(viewAllButton, HasVerticalAlignment.ALIGN_MIDDLE);
    viewAllButton.setSize("18px", "18px");
    horizontalPanel.add(submitButton);
    horizontalPanel.setCellVerticalAlignment(submitButton, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setCellHorizontalAlignment(submitButton, HasHorizontalAlignment.ALIGN_CENTER);
    submitButton.setSize("18px", "18px");
    downloadButton = new PushButton("Download");
    downloadButton.setTitle("Download Reports");
    downloadButton.setHTML("<img width=\"18px\" src=\"images/icon-download.png\" alt=\"Download\" />");
    horizontalPanel.add(downloadButton);
    downloadButton.setEnabled(true);
    downloadButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final AppInfoGwt selected = appSelectionModel.getSelectedObject();
            if (selected == null) {
                showMessageDialog("AppVet Error", "No app is selected", true);
            } else {

                final String appId = selected.appId;
                final String dateString = "?nocache" + new Date().getTime();
                final String url = SERVLET_URL + dateString + "&command=DOWNLOAD_REPORTS&appid=" + appId
                        + "&sessionid=" + sessionId;
                Window.open(url, "_self", "");

                //               downloadDialog = new DownloadDialogBox(sessionId, selected);
                //               downloadDialog.setText("Download reports");
                //               downloadDialog.center();
                //               downloadDialog.cancelButton.setFocus(true);
                //               downloadDialog.cancelButton
                //               .addClickHandler(new ClickHandler() {
                //                  @Override
                //                  public void onClick(ClickEvent event) {
                //                     killDialogBox(downloadDialog);
                //                  }
                //               });
                //               downloadDialog.downloadButton
                //               .addClickHandler(new ClickHandler() {
                //                  @Override
                //                  public void onClick(ClickEvent event) {
                //                     if (downloadDialog.selected_apk_radio_button
                //                           .isChecked()) {
                //                        final AppInfoGwt selected = appSelectionModel
                //                              .getSelectedObject();
                //                        final String appId = selected.appId;
                //                        final String apk = selected.appName;
                //                        final String dateString = "?nocache"
                //                              + new Date().getTime();
                //                        final String url = SERVLET_URL
                //                              + dateString
                //                              + "&command=DOWNLOAD_APP&appid="
                //                              + appId + "&sessionid="
                //                              + sessionId + "&appname=" + apk
                //                              + ".apk";
                //                        Window.open(url, "_self", "");
                //                        killDialogBox(downloadDialog);
                //                     } else if (downloadDialog.selected_report_radio_button
                //                           .isChecked()) {
                //                        final AppInfoGwt selected = appSelectionModel
                //                              .getSelectedObject();
                //                        final String appId = selected.appId;
                //                        final String dateString = "?nocache"
                //                              + new Date().getTime();
                //                        final String url = SERVLET_URL
                //                              + dateString
                //                              + "&command=DOWNLOAD_REPORTS&appid="
                //                              + appId + "&sessionid="
                //                              + sessionId;
                //                        Window.open(url, "_self", "");
                //                        killDialogBox(downloadDialog);
                //                     }
                //                  }
                //               });
            }
        }
    });

    horizontalPanel.setCellHorizontalAlignment(downloadButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel.setCellVerticalAlignment(downloadButton, HasVerticalAlignment.ALIGN_MIDDLE);
    appsListButtonPanel.setCellHorizontalAlignment(downloadButton, HasHorizontalAlignment.ALIGN_CENTER);
    downloadButton.setSize("18px", "18px");
    addReportButton = new PushButton("Add Report");
    horizontalPanel.add(addReportButton);
    horizontalPanel.setCellVerticalAlignment(addReportButton, HasVerticalAlignment.ALIGN_MIDDLE);
    addReportButton.setTitle("Override Report");
    addReportButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final AppInfoGwt selected = appSelectionModel.getSelectedObject();
            if (selected == null) {
                showMessageDialog("AppVet Error", "No app is selected", true);
            } else {
                reportUploadDialogBox = new ReportUploadDialogBox(userName, sessionId, selected.appId,
                        SERVLET_URL, availableToolNames, availableToolIDs);
                reportUploadDialogBox.setText("Override Report");
                reportUploadDialogBox.center();
                reportUploadDialogBox.cancelButton.setFocus(true);
                reportUploadDialogBox.cancelButton.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent event) {
                        killDialogBox(reportUploadDialogBox);
                    }

                });
                reportUploadDialogBox.uploadReportForm.addFormHandler(
                        new ReportUploadFormHandler(reportUploadDialogBox, userName, selected.appId));
            }
        }
    });

    addReportButton.setSize("18px", "18px");
    addReportButton.setHTML("<img width=\"18px\" src=\"images/icon-submit-report.png\" alt=\"Add Report\" />");
    deleteButton = new PushButton("Delete");
    horizontalPanel.add(deleteButton);
    horizontalPanel.setCellVerticalAlignment(deleteButton, HasVerticalAlignment.ALIGN_MIDDLE);
    deleteButton.setHTML("<img width=\"18px\" src=\"images/icon-delete.png\" alt=\"delete\" />");
    deleteButton.setTitle("Delete App");
    deleteButton.setVisible(true);
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final AppInfoGwt selected = appSelectionModel.getSelectedObject();
            deleteConfirmDialogBox = new DeleteAppConfirmDialogBox(selected.appId, selected.appName);
            deleteConfirmDialogBox.setText("Confirm Delete");
            deleteConfirmDialogBox.center();
            deleteConfirmDialogBox.cancelButton.setFocus(true);
            deleteConfirmDialogBox.cancelButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(deleteConfirmDialogBox);
                    return;
                }

            });
            deleteConfirmDialogBox.okButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(deleteConfirmDialogBox);
                    if (selected != null) {
                        deleteApp(selected.appId, userName);
                    }
                }

            });
        }
    });
    deleteButton.setSize("18px", "18px");
    logButton = new PushButton("Log");
    horizontalPanel.add(logButton);
    horizontalPanel.setCellVerticalAlignment(logButton, HasVerticalAlignment.ALIGN_MIDDLE);
    logButton.setTitle("View Log");
    logButton.setHTML("<img width=\"18px\" src=\"images/icon-log.png\" alt=\"log\" />");
    logButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final AppInfoGwt selected = appSelectionModel.getSelectedObject();
            if (selected != null) {
                final String appId = selected.appId;
                final String dateString = "?nocache" + new Date().getTime();
                final String url = SERVLET_URL + dateString + "&command=GET_APP_LOG&appid=" + appId
                        + "&sessionid=" + sessionId;
                Window.open(url, "_blank", "");
            }
        }

    });
    logButton.setSize("18px", "18px");

    appsListTable = new AppsListPagingDataGrid<AppInfoGwt>();
    appsListTable.dataGrid.setStyleName("dataGrid");
    dockPanel_1.add(appsListTable, DockPanel.CENTER);
    dockPanel_1.setCellHorizontalAlignment(appsListTable, HasHorizontalAlignment.ALIGN_CENTER);
    dockPanel_1.setCellVerticalAlignment(appsListTable, HasVerticalAlignment.ALIGN_MIDDLE);
    appsListTable.setAppVetHostUrl(HOST_URL);
    appsListTable.dataGrid.setSize("99%", "");
    appsListTable.setDataList(initialApps);
    appsListTable.setSize("", "");
    appsListTable.dataGrid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    appsListTable.dataGrid.setSelectionModel(appSelectionModel);
    addReportButton.setVisible(true);
    logButton.setVisible(true);

    //      final Label lblNewLabel_1 = new Label("*See log for system errors");
    //      lblNewLabel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    //      appInfoVerticalPanel.add(lblNewLabel_1);
    //      lblNewLabel_1.setWidth("200px");
    //      appInfoVerticalPanel.setCellWidth(lblNewLabel_1, "100%");
    toolResultsHtml = new HTML("", true);
    appInfoVerticalPanel.add(toolResultsHtml);
    appInfoVerticalPanel.setCellWidth(toolResultsHtml, "100%");
    toolResultsHtml.setWidth("100%");
    toolResultsHtml.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    toolResultsHtml.setStyleName("toolResultsHtml");

    add(centerAppVetSplitPanel);

    /*
    // Add logo in bottom-right corner 
    final InlineHTML nlnhtmlNewInlinehtml = new InlineHTML(
    "<a href=\"http://www.example.com\"><img border=\"0\" width=\"75px\"  src=\"exampleImage.png\" alt=\"example\" /></a>"
    ); nlnhtmlNewInlinehtml
    .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    nlnhtmlNewInlinehtml.setStyleName("mainTaLogo");
    horizontalPanel_2.add(nlnhtmlNewInlinehtml);
    nlnhtmlNewInlinehtml.setWidth("");
    horizontalPanel_2.setCellHorizontalAlignment(nlnhtmlNewInlinehtml,
    HasHorizontalAlignment.ALIGN_RIGHT);
    horizontalPanel_2.setCellVerticalAlignment(nlnhtmlNewInlinehtml,
    HasVerticalAlignment.ALIGN_MIDDLE);
     */
    if ((initialApps != null) && (initialApps.size() > 0)) {
        appSelectionModel.setSelected(initialApps.get(0), true);
    } else {
        logButton.setEnabled(false);
        addReportButton.setEnabled(false);
        deleteButton.setEnabled(false);
        downloadButton.setEnabled(false);
    }
    pollServer(userName);
    scheduleResize();
}

From source file:gov.nist.appvet.gwt.client.gui.dialog.UsersDialogBox.java

License:Open Source License

public UsersDialogBox() {
    super(false, true);
    setSize("", "450px");
    setAnimationEnabled(false);//w ww . j ava 2s.  c o  m
    usersSelectionModel = new SingleSelectionModel<UserInfoGwt>();
    usersSelectionModel.addSelectionChangeHandler(new UserListHandler(this));

    final DockPanel dockPanel = new DockPanel();
    dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    setWidget(dockPanel);
    dockPanel.setSize("", "417px");

    final VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setStyleName("usersCenterPanel");
    dockPanel.add(verticalPanel, DockPanel.CENTER);
    dockPanel.setCellVerticalAlignment(verticalPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    dockPanel.setCellHorizontalAlignment(verticalPanel, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setSize("", "416px");

    final HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setStyleName("usersHorizPanel");
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(horizontalPanel_1);
    verticalPanel.setCellVerticalAlignment(horizontalPanel_1, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellHorizontalAlignment(horizontalPanel_1, HasHorizontalAlignment.ALIGN_CENTER);

    searchTextBox = new TextBox();
    searchTextBox.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                searchMode = true;
                search();
            }
        }

    });
    horizontalPanel_1.add(searchTextBox);
    horizontalPanel_1.setCellVerticalAlignment(searchTextBox, HasVerticalAlignment.ALIGN_MIDDLE);
    searchTextBox.setSize("260px", "18px");
    final PushButton searchButton = new PushButton("Search");
    searchButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

        }
    });
    searchButton.setHTML("<img width=\"18px\" src=\"images/icon-search.png\" alt=\"search\" />");
    searchButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            searchMode = true;
            search();
        }

    });
    horizontalPanel_1.add(searchButton);
    horizontalPanel_1.setCellVerticalAlignment(searchButton, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setCellHorizontalAlignment(searchButton, HasHorizontalAlignment.ALIGN_CENTER);
    searchButton.setSize("18px", "18px");
    final PushButton viewAllButton = new PushButton("View All");
    viewAllButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            searchMode = false;
            getAllUsers(allUsers);
        }

    });
    viewAllButton.setHTML("<img width=\"18px\" src=\"images/icon-view-all.png\" alt=\"view-all\" />");
    horizontalPanel_1.add(viewAllButton);
    horizontalPanel_1.setCellHorizontalAlignment(viewAllButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_1.setCellVerticalAlignment(viewAllButton, HasVerticalAlignment.ALIGN_MIDDLE);
    viewAllButton.setSize("18px", "18px");

    final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.EM);
    dockLayoutPanel.setStyleName("usersDockPanel");
    verticalPanel.add(dockLayoutPanel);
    verticalPanel.setCellVerticalAlignment(dockLayoutPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellHorizontalAlignment(dockLayoutPanel, HasHorizontalAlignment.ALIGN_CENTER);
    dockLayoutPanel.setSize("", "380px");
    usersListTable = new UsersListPagingDataGrid<UserInfoGwt>();
    usersListTable.dataGrid.setSize("342px", "342px");
    usersListTable.dataGrid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    usersListTable.dataGrid.setSelectionModel(usersSelectionModel);
    dockLayoutPanel.add(usersListTable);
    usersListTable.setWidth("");

    final HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_2.setStyleName("buttonPanel");
    verticalPanel.add(horizontalPanel_2);

    verticalPanel.setCellVerticalAlignment(horizontalPanel_2, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellHorizontalAlignment(horizontalPanel_2, HasHorizontalAlignment.ALIGN_CENTER);
    addButton = new PushButton("Add");
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            editUser(true);
        }

    });
    addButton.setHTML("Add");
    horizontalPanel_2.add(addButton);
    horizontalPanel_2.setCellHorizontalAlignment(addButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_2.setCellVerticalAlignment(addButton, HasVerticalAlignment.ALIGN_MIDDLE);
    addButton.setSize("70px", "18px");

    final PushButton editButton = new PushButton("Edit");
    editButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            editUser(false);
        }

    });

    final PushButton pshbtnNewButton = new PushButton("Delete");
    pshbtnNewButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final UserInfoGwt selected = usersSelectionModel.getSelectedObject();
            final DeleteUserConfirmDialogBox deleteConfirmDialogBox = new DeleteUserConfirmDialogBox(
                    selected.getUserName());
            deleteConfirmDialogBox.setText("Confirm Delete");
            deleteConfirmDialogBox.center();
            deleteConfirmDialogBox.cancelButton.setFocus(true);
            deleteConfirmDialogBox.cancelButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(deleteConfirmDialogBox);
                    return;
                }

            });
            deleteConfirmDialogBox.okButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    killDialogBox(deleteConfirmDialogBox);
                    if (selected != null) {
                        deleteUser(user.getUserName());
                    }
                }

            });
        }
    });
    pshbtnNewButton.setHTML("Delete");
    horizontalPanel_2.add(pshbtnNewButton);
    horizontalPanel_2.setCellVerticalAlignment(pshbtnNewButton, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_2.setCellHorizontalAlignment(pshbtnNewButton, HasHorizontalAlignment.ALIGN_CENTER);
    pshbtnNewButton.setSize("70px", "18px");
    editButton.setHTML("Edit");
    horizontalPanel_2.add(editButton);
    horizontalPanel_2.setCellHorizontalAlignment(editButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_2.setCellVerticalAlignment(editButton, HasVerticalAlignment.ALIGN_MIDDLE);
    editButton.setSize("70px", "18px");
    doneButton = new PushButton("Done");
    doneButton.setHTML("Done");
    horizontalPanel_2.add(doneButton);
    horizontalPanel_2.setCellHorizontalAlignment(doneButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel_2.setCellVerticalAlignment(doneButton, HasVerticalAlignment.ALIGN_MIDDLE);
    doneButton.setSize("70px", "18px");
    getUsersList();
}

From source file:gwtquery.plugins.droppable.client.permissionmanagersample.MemberTreeViewModel.java

License:Apache License

public <T> NodeInfo<?> getNodeInfo(T value) {

    if (value == null) {
        // permission tree node
        DragAndDropNodeInfo<Permission> permissionNodeInfo = new DragAndDropNodeInfo<Permission>(
                permissionDataProvider, permissionCell);

        // setup drop operation
        DroppableOptions options = permissionNodeInfo.getDroppableOptions();
        options.setDroppableHoverClass(Resource.INSTANCE.css().droppableHover());
        // use a DroppableFunction here. We can also add a DropHandler in the tree
        // itself
        options.setOnDrop(new DroppableFunction() {

            public void f(DragAndDropContext context) {
                MemberInfo droppedMember = context.getDraggableData();
                Permission dropPermission = context.getDroppableData();

                MemberDatabase.get().permissionChange(droppedMember, dropPermission);

            }/*from   w  w  w. j a  v a2  s .  c om*/
        });
        // permission cell are not draggable
        permissionNodeInfo.setCellDroppableOnly();
        return permissionNodeInfo;

    } else if (value instanceof Permission) {
        // member tree node
        Permission p = (Permission) value;

        ListDataProvider<MemberInfo> dataProvider = MemberDatabase.get().getDataProvider(p);

        DragAndDropNodeInfo<MemberInfo> memberNodeInfo = new DragAndDropNodeInfo<MemberInfo>(dataProvider,
                memberCell, new SingleSelectionModel<MemberInfo>(), null);

        // setup the drag operation
        PermissionManagerSample.configureDragOperation(memberNodeInfo.getDraggableOptions());
        // member cell are only draggable
        memberNodeInfo.setCellDraggableOnly();

        return memberNodeInfo;
    }

    String type = value.getClass().getName();
    throw new IllegalArgumentException("Unsupported object type: " + type);
}

From source file:gwtquery.plugins.droppable.client.permissionmanagersample2.MemberTreeViewModel.java

License:Apache License

private DragAndDropNodeInfo<MemberInfo> createNodeInfoForMembers(
        ListDataProvider<MemberInfo> listDataProvider) {
    DragAndDropNodeInfo<MemberInfo> memberNodeInfo = new DragAndDropNodeInfo<MemberInfo>(listDataProvider,
            memberCell, new SingleSelectionModel<MemberInfo>(), null);

    // setup the drag operation
    PermissionManagerSample2.configureDragOperation(memberNodeInfo.getDraggableOptions());

    memberNodeInfo.getDroppableOptions().setTolerance(DroppableTolerance.INTERSECT);

    return memberNodeInfo;
}

From source file:n3phele.client.view.AccountHyperlinkView.java

License:Open Source License

public AccountHyperlinkView(String uri) {
    super(new MenuItem(N3phele.n3pheleResource.accountIcon(), "Account", null),
            new MenuItem(N3phele.n3pheleResource.accountAddIcon(), "Account Edit", "account:" + uri));

    if (resource == null)
        resource = GWT.create(DataGridResource.class);

    // TABLE//  www.  j  av a 2 s .c  o  m
    table = new FlexTable();
    table.setCellPadding(10);
    errorsOnPage = new ValidInputIndicatorWidget(
            "check for missing or invalid parameters marked with this icon", false);
    setTableData();
    table.getFlexCellFormatter().setRowSpan(0, 1, 2);
    table.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    table.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    table.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    table.getColumnFormatter().setWidth(0, "220px");
    table.getColumnFormatter().setWidth(1, "290px");
    table.setCellPadding(1);
    table.setCellSpacing(1);

    // DATAGRID
    dataGrid = new DataGrid<ActivityData>(15, resource);
    dataGrid.setSize("495px", "100px");

    TextColumn<ActivityData> nameColumn = new TextColumn<ActivityData>() {
        @Override
        public String getValue(ActivityData item) {
            String result = "";
            if (item != null) {
                result += item.getName();
            }
            return result;
        }
    };
    dataGrid.addColumn(nameColumn, "Name");
    dataGrid.setColumnWidth(nameColumn, "130px");

    // TODO: Working on Activity column

    Column<ActivityData, String> activityColumn = new Column<ActivityData, String>(new ClickableTextCell()) {
        @Override
        public String getValue(ActivityData item) {

            return item.getNameTop();
        }

    };
    activityColumn.setFieldUpdater(new FieldUpdater<ActivityData, String>() {
        @Override
        public void update(int index, ActivityData obj, String value) {
            presenter.onSelect(obj);

        }
    });

    activityColumn.setCellStyleNames(N3phele.n3pheleResource.css().clickableTextCellEffect());
    dataGrid.addColumn(activityColumn, "Activity");
    dataGrid.setColumnWidth(activityColumn, "100px");

    TextColumn<ActivityData> ageColumn = new TextColumn<ActivityData>() {
        @Override
        public String getValue(ActivityData item) {
            return item.getAge();
        }
    };
    dataGrid.addColumn(ageColumn, "Age");
    dataGrid.setColumnWidth(ageColumn, "80px");

    TextColumn<ActivityData> priceColumn = new TextColumn<ActivityData>() {
        @Override
        public String getValue(ActivityData item) {
            return item.getCost();
        }
    };
    dataGrid.addColumn(priceColumn, "Total Cost");
    dataGrid.setColumnWidth(priceColumn, "75px");

    // Add a selection model to handle user selection.
    final SingleSelectionModel<ActivityData> selectionModel = new SingleSelectionModel<ActivityData>();
    dataGrid.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            selectionModel.getSelectedObject();
        }
    });

    Column<ActivityData, ActivityData> cancelColumn = new Column<ActivityData, ActivityData>(
            new CancelButtonCell<ActivityData>(new Delegate<ActivityData>() {
                @Override
                public void execute(ActivityData value) {
                    if (value != null) {
                        dataGrid.getSelectionModel().setSelected(value, false);
                        getDialog(value).show();
                    }
                }
            }, "delete virtual machine")) {
        @Override
        public ActivityData getValue(ActivityData object) {
            return object;
        }
    };
    cancelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    dataGrid.addColumn(cancelColumn);
    dataGrid.setColumnWidth(cancelColumn, "50px");

    // CALL onModuleLoad()
    chartPanel = get();
    chartPanel.add(table);
    chartPanel.add(new SectionPanel("History"));
    chartPanel.add(historyTable);
    chartPanel.add(new SectionPanel("Active Machines"));
    chartPanel.add(vsTable);
    chartPanel = get();
    setChartTableData();
    onModuleLoad();
}

From source file:n3phele.client.view.AccountListView.java

License:Open Source License

public AccountListView() {
    super(new MenuItem(N3phele.n3pheleResource.accountIcon(), "Accounts", null),
            new MenuItem(N3phele.n3pheleResource.accountAddIcon(), "create a new account", "account:null"));

    if (resource == null)
        resource = GWT.create(ClickableCellTableResource.class);

    cellTable = new CellTable<Account>(15, resource);
    cellTable.setSize("455px", "");

    TextColumn<Account> nameColumn = new TextColumn<Account>() {
        @Override/*from  www . j  a va2s.c o m*/
        public String getValue(Account item) {
            String result = "";
            if (item != null)
                return item.getName();
            return result;
        }
    };
    cellTable.addColumn(nameColumn, "Name");

    TextColumn<Account> descriptionColumn = new TextColumn<Account>() {
        @Override
        public String getValue(Account item) {
            String result = "";
            if (item != null)
                return item.getDescription();
            return result;
        }
    };
    cellTable.addColumn(descriptionColumn, "Description");

    TextColumn<Account> cloudColumn = new TextColumn<Account>() {
        @Override
        public String getValue(Account item) {
            String result = "";
            if (item != null) {
                result = item.getCloudName();
                //               String s= item.getCloud();
                //               if(cloudMap.containsKey(s))
                //                  return cloudMap.get(s);
                //               else
                //                  return s;
            }
            return result;
        }
    };
    cellTable.addColumn(cloudColumn, "Cloud");
    // Add a selection model to handle user selection.
    final SingleSelectionModel<Account> selectionModel = new SingleSelectionModel<Account>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Account selected = selectionModel.getSelectedObject();
            if (selected != null) {
                if (accountListActivity != null) {
                    accountListActivity.onSelect(selected);
                }
            }
        }
    });

    Column<Account, Account> cancelColumn = new Column<Account, Account>(
            new CancelButtonCell<Account>(new Delegate<Account>() {

                @Override
                public void execute(Account value) {
                    if (value != null) {
                        cellTable.getSelectionModel().setSelected(value, false);
                        getDialog(value).show();
                    }
                }
            }, "delete Account")) {
        @Override
        public Account getValue(Account object) {
            return object;
        }
    };
    cellTable.addColumn(cancelColumn);
    cellTable.setColumnWidth(cancelColumn, "26px");

    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    this.add(cellTable);

}

From source file:n3phele.client.view.ActivityListView.java

License:Open Source License

public ActivityListView() {
    super(new MenuItem(N3phele.n3pheleResource.activityIcon(), "Activity History", null));

    HorizontalPanel heading = new HorizontalPanel();
    heading.setWidth("500px");
    heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    add(heading);/*from ww w.j a v  a2 s . c  o  m*/

    heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    heading.add(simplePager);
    heading.setCellHorizontalAlignment(simplePager, HorizontalPanel.ALIGN_CENTER);

    this.cellTable = new ActivityStatusList();
    this.cellTable.setWidth("100%");
    TextColumn<Progress> narrative = new TextColumn<Progress>() {

        @Override
        public String getValue(Progress progress) {
            String result = "";
            List<Narrative> narrative = progress.getNarratives();
            if (narrative != null && narrative.size() > 0) {
                result = narrative.get(narrative.size() - 1).getText();
            }

            return result;
        }
    };
    this.cellTable.addColumn(narrative);
    this.cellTable.setColumnWidth(narrative, "55%");
    Column<Progress, Progress> cancelColumn = new Column<Progress, Progress>(
            new CancelButtonCell<Progress>(new Delegate<Progress>() {

                @Override
                public void execute(Progress value) {
                    if (value != null) {
                        cellTable.getSelectionModel().setSelected(value, false);
                        getDialog(value).show();
                    }
                }
            }, "cancel activity")) {
        @Override
        public Progress getValue(Progress object) {
            String status = object.getStatus();
            if (status == null || status.equalsIgnoreCase("COMPLETE") || status.equalsIgnoreCase("FAILED")
                    || status.equalsIgnoreCase("CANCELLED")) {
                return null;
            }
            return object;
        }
    };
    cellTable.addColumn(cancelColumn);
    cellTable.setColumnWidth(cancelColumn, "26px");
    //cellTable.setSize("455px", "");
    this.add(cellTable);
    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    final SingleSelectionModel<Progress> selectionModel = new SingleSelectionModel<Progress>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Progress selected = selectionModel.getSelectedObject();
            if (selected != null) {
                if (presenter != null) {
                    presenter.onSelect(selected);
                    // selectionModel.setSelected(selected, false);
                }

            }
        }
    });

    /*
     * Add Table paging
     */
    simplePager.setDisplay(cellTable);
    simplePager.setPageSize(PAGESIZE);
    cellTable.addRangeChangeHandler(new RangeChangeEvent.Handler() {

        /* (non-Javadoc)
         * @see com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange(com.google.gwt.view.client.RangeChangeEvent)
         */
        @Override
        public void onRangeChange(RangeChangeEvent event) {
            Range range = cellTable.getVisibleRange();
            int start = range.getStart();

            //            if(data == null || (data.size() < start) ){
            GWT.log("Fetch " + start);
            presenter.refresh(start);
            //            } else {
            //               if(length+start > data.size())
            //                  length = data.size()-start;
            //               GWT.log("data available start="+start);
            //               grid.setRowData(start, chunk(data.subList(start, start+length)));
            //            }
        }

    });
    this.add(cellTable);

}

From source file:n3phele.client.view.RecentActivityView.java

License:Open Source License

public RecentActivityView() {
    super();/* w  w  w . ja v  a2 s.c o  m*/
    //setSize("100%", "100%");
    this.cellTable = new ActivityStatusList();
    this.setWidget(this.cellTable);
    this.setHeading("Recent activities");
    final SingleSelectionModel<Progress> selectionModel = new SingleSelectionModel<Progress>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Progress selected = selectionModel.getSelectedObject();
            if (selected != null) {
                if (presenter != null) {
                    presenter.onSelect(selected);
                    selectionModel.setSelected(selected, false);
                }
            }
        }
    });

}

From source file:n3phele.client.view.RepoListView.java

License:Open Source License

public RepoListView() {
    super(new MenuItem(N3phele.n3pheleResource.repositoryIcon(), "File Repositories", null), new MenuItem(
            N3phele.n3pheleResource.repositoryAddIcon(), "create a new repository", "repository:"));

    if (resource == null)
        resource = GWT.create(ClickableCellTableResource.class);

    cellTable = new CellTable<Repository>(15, resource);

    cellTable.setSize("455px", "");
    //this.scrollPanel.add(this.cellTable);
    TextColumn<Repository> nameColumn = new TextColumn<Repository>() {
        @Override/*from w ww . j  a  v a 2  s  .c om*/
        public String getValue(Repository item) {
            String result = "";
            if (item != null)
                return item.getName();
            return result;
        }
    };
    cellTable.addColumn(nameColumn, "Name");

    TextColumn<Repository> descriptionColumn = new TextColumn<Repository>() {
        @Override
        public String getValue(Repository item) {
            String result = "";
            if (item != null)
                return item.getDescription();
            return result;
        }
    };
    cellTable.addColumn(descriptionColumn, "Description");

    // Add a selection model to handle user selection.
    final SingleSelectionModel<Repository> selectionModel = new SingleSelectionModel<Repository>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Repository selected = selectionModel.getSelectedObject();
            if (selected != null) {
                if (repositoryListActivity != null) {
                    repositoryListActivity.onSelect(selected);
                }
            }
        }
    });
    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    this.add(cellTable);

    Column<Repository, Repository> cancelColumn = new Column<Repository, Repository>(
            new CancelButtonCell<Repository>(new Delegate<Repository>() {

                @Override
                public void execute(Repository value) {
                    if (value != null) {
                        cellTable.getSelectionModel().setSelected(value, false);
                        getDialog(value).show();
                    }
                }
            }, "remove repository")) {
        @Override
        public Repository getValue(Repository object) {
            return object;
        }
    };
    cellTable.addColumn(cancelColumn);
    cellTable.setColumnWidth(cancelColumn, "26px");
}