/** * Navigation Buttons to browse other pages * * @param layout * @return a table containing navigation buttons */ private FlexTable NavigationButtons(VerticalPanel layout) { FlexTable navigatorLayout = new FlexTable(); FlexCellFormatter formatterNavigator = navigatorLayout.getFlexCellFormatter(); navigatorLayout.setWidth("60%"); Button businessGoalButton = new Button(messages.businessGoalButtonLabel()); Button associateAssetsAndGoalsButton = new Button(messages.associateAssetsAndGoalsButtonLabel()); businessGoalButton.setWidth("180px"); associateAssetsAndGoalsButton.setWidth("180px"); navigatorLayout.setWidget(0, 0, businessGoalButton); navigatorLayout.setWidget(0, 1, associateAssetsAndGoalsButton); formatterNavigator.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); formatterNavigator.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT); businessGoalButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { updateBusinessGoalInformation(null); History.newItem( AssetsAndGoalsPilot.generateNavigationId(AssetsAndGoalsPilot.PageId.start)); } }); associateAssetsAndGoalsButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { updateBusinessGoalInformation(new AssociateAssetsNavigation()); } }); return navigatorLayout; }
/** * Add a new row to the sub goals table * * @param integer * @param subGoalsTable the flex table for the sub-goals */ private void addRowToTable( String info, String keyInfo, Integer priority, final FlexTable table, boolean isAsset) { // get the current number of rows so we know where to add the new text box int currentNumberOfRows = table.getRowCount(); // Create and add the textbox and supporting links for the mechanics of the UI final ScrollBarTextBox userInput = new ScrollBarTextBox(); userInput.setWidth("100%"); SquareHyperlink removeLink = new SquareHyperlink(messages.remove()); userInput.setName(String.valueOf(currentNumberOfRows)); userInput.setKey(keyInfo); // For tracking db id userInput.setText(info); userInput.setPriority(priority); table.setWidget(currentNumberOfRows, 0, userInput); table.setWidget(currentNumberOfRows, 1, removeLink); FlexCellFormatter formatter = table.getFlexCellFormatter(); formatter.setHorizontalAlignment(currentNumberOfRows, 0, HasHorizontalAlignment.ALIGN_LEFT); formatter.setHorizontalAlignment(currentNumberOfRows, 1, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setWidth(currentNumberOfRows, 1, "10%"); if (isAsset) { this.addAssetToTable(userInput, removeLink); } else { this.addGoalToTable(userInput, removeLink); } }
/** Configures a flex table and corresponding titles to add to the overall layout. */ private VerticalPanel addToPanel( String sectionText, final FlexTable table, final boolean isAsset) { VerticalPanel layout = new VerticalPanel(); layout.setWidth("60%"); layout.setStyleName("asset-step-layout"); layout.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); table.setWidth("100%"); FlexCellFormatter formatter = table.getFlexCellFormatter(); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); // Adding the section headings for the table Label sectionLabel = new Label(sectionText); sectionLabel.setStyleName("square-title"); table.setWidget(0, 0, sectionLabel); if (table.getRowCount() == 0) { this.addRowToTable("", null, -1, table, isAsset); // initially blank } Button newRowButton = null; if (isAsset) { newRowButton = new Button(messages.addAssetButton()); } else { newRowButton = new Button(messages.addSecuritySubGoal()); } newRowButton.setWidth("180px"); newRowButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { addRowToTable("", null, new Integer(-1), table, isAsset); } }); layout.add(table); layout.add(newRowButton); return layout; }
public IdentifyAssetsAndGoalsSubGoalsPane(State stateInfo) { super(stateInfo); VerticalPanel layout = new VerticalPanel(); layout.setWidth("100%"); layout.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); layout.setSpacing(5); // Get up to date data first thing this.updateBusinessGoalInformation(new SubGoalsTableInitializer()); this.updateBusinessGoalInformation(new AssetTableInitializer()); // Then add the data to our flex tables this.subGoalsTable = new FlexTable(); layout.add(addToPanel(messages.securitySubGoalsLabel(), this.subGoalsTable, false)); // And do the same thing for the assets this.assetsTable = new FlexTable(); layout.add(addToPanel(messages.assetsLabel(), this.assetsTable, true)); layout.add(NavigationButtons(layout)); this.getContent().clear(); this.getContent().add(layout); }