private Widget makeDropDownMenuButton(final String caption, final List<Widget> widgetList) {
   final ButtonGroup buttonGroup = new ButtonGroup();
   final Button dropdownButton = new Button(caption);
   dropdownButton.setDataToggle(Toggle.DROPDOWN);
   dropdownButton.setSize(ButtonSize.SMALL);
   final DropDownMenu dropDownMenu = new DropDownMenu();
   for (final Widget _item : widgetList) {
     dropDownMenu.add(_item);
   }
   buttonGroup.add(dropdownButton);
   buttonGroup.add(dropDownMenu);
   return buttonGroup;
 }
  @Before
  public void setup() {
    ApplicationPreferences.setUp(new HashMap<String, String>());

    // The BuildOptions widget is manipulated in the Presenter so we need some nasty mocking
    when(view.getBuildOptionsButton()).thenReturn(buildOptions);
    when(buildOptions.getWidget(eq(0))).thenReturn(buildOptionsButton1);
    when(buildOptions.getWidget(eq(1))).thenReturn(buildOptionsMenu);
    when(buildOptionsMenu.getWidget(eq(0))).thenReturn(buildOptionsMenuButton1);
    when(buildOptionsMenu.getWidget(eq(1))).thenReturn(buildOptionsMenuButton1);

    constructProjectScreenPresenter(
        new CallerMock<BuildService>(buildService),
        new CallerMock<AssetManagementService>(assetManagementServiceMock));

    // Mock ProjectScreenService
    final POM pom = new POM(new GAV("groupId", "artifactId", "version"));
    model = new ProjectScreenModel();
    model.setPOM(pom);
    when(projectScreenService.load(any(org.uberfire.backend.vfs.Path.class))).thenReturn(model);

    // Mock BuildService
    when(buildService.buildAndDeploy(any(Project.class))).thenReturn(new BuildResults());

    // Mock LockManager initialisation
    final Path path = mock(Path.class);
    final Metadata pomMetadata = mock(Metadata.class);
    model.setPOMMetaData(pomMetadata);
    when(pomMetadata.getPath()).thenReturn(path);
    final Metadata kmoduleMetadata = mock(Metadata.class);
    model.setKModuleMetaData(kmoduleMetadata);
    when(kmoduleMetadata.getPath()).thenReturn(path);
    final Metadata importsMetadata = mock(Metadata.class);
    model.setProjectImportsMetaData(importsMetadata);
    when(importsMetadata.getPath()).thenReturn(path);

    // Mock ProjectContext
    final Repository repository = mock(Repository.class);
    when(context.getActiveRepository()).thenReturn(repository);
    when(repository.getAlias()).thenReturn("repository");
    when(repository.getCurrentBranch()).thenReturn("master");

    final Project project = mock(Project.class);
    when(project.getProjectName()).thenReturn("project");

    when(context.getActiveProject()).thenReturn(project);

    // Trigger initialisation of view. Unfortunately this is the only way to initialise a Project in
    // the Presenter
    context.onProjectContextChanged(
        new ProjectContextChangeEvent(mock(OrganizationalUnit.class), repository, project));

    verify(view, times(1)).showBusyIndicator(eq(CommonConstants.INSTANCE.Loading()));
    verify(view, times(1)).hideBusyIndicator();
  }
 @Override
 public void addLabel(VersionRecord versionRecord, boolean isSelected, int versionIndex) {
   VersionMenuItemLabel widget =
       new VersionMenuItemLabel(
           versionRecord,
           versionIndex,
           isSelected,
           new Callback<VersionRecord>() {
             @Override
             public void callback(VersionRecord result) {
               presenter.onVersionRecordSelected(result);
             }
           });
   widget.setWidth("400px");
   menuItems.add(widget);
 }
 @Override
 public void addViewAllLabel(final int index, final Command command) {
   menuItems.add(new ViewAllLabel(index, command));
 }
 @Override
 public void clear() {
   menuItems.clear();
 }
Esempio n. 6
0
 public void addItem(final String url) {
   content.add(makeListItem(url));
 }
Esempio n. 7
0
 public void clear() {
   content.clear();
 }
Esempio n. 8
0
  public void initButtonGroup() {

    // // Button Groups List to contain all button groups//
    buttonGroupList = new ArrayList<ButtonGroup>();

    // Button Groups to encapsulate drop down buttons and menus
    exchangeButtonGroup = new ButtonGroup();
    ruleTypeButtonGroup = new ButtonGroup();
    triggerButtonGroup = new ButtonGroup();
    actionButtonGroup = new ButtonGroup();

    // Drop down buttons
    exchangeDropDownButton = new Button("Choose Exchange");
    ruleTypeDropDownButton = new Button("Rule Type");
    triggerDropDownButton = new Button("Choose Condition");
    actionDropDownButton = new Button("Choose Action");

    // Drop down menus
    exchangeDropdownMenu = new DropDownMenu();
    ruleTypeDropdownMenu = new DropDownMenu();
    triggerDropdownMenu = new DropDownMenu();
    actionDropdownMenu = new DropDownMenu();

    exchangeDropDownButton.setType(ButtonType.INFO);
    exchangeDropDownButton.setToggle(Toggle.DROPDOWN);
    ruleTypeDropDownButton.setType(ButtonType.INFO);
    ruleTypeDropDownButton.setToggle(Toggle.DROPDOWN);
    triggerDropDownButton.setType(ButtonType.INFO);
    triggerDropDownButton.setToggle(Toggle.DROPDOWN);
    actionDropDownButton.setType(ButtonType.INFO);
    actionDropDownButton.setToggle(Toggle.DROPDOWN);

    // exchanges drop down list items //
    final ListItem exlistItem1 = new ListItem();
    final ListItem exlistItem2 = new ListItem();
    // Rule type drop down list items //
    final ListItem rtlistItem1 = new ListItem();
    final ListItem rtlistItem2 = new ListItem();
    final ListItem rtlistItem3 = new ListItem();
    // trigger type list items
    final ListItem trglistItem1 = new ListItem();
    final ListItem trglistItem2 = new ListItem();
    final ListItem trglistItem3 = new ListItem();
    // Action list items
    final ListItem actionlistItem1 = new ListItem();
    final ListItem actionlistItem2 = new ListItem();
    final ListItem actionlistItem3 = new ListItem();

    // encapsulate list items into drop down menus
    exchangeDropdownMenu.add(exlistItem1);
    exchangeDropdownMenu.add(exlistItem2);

    ruleTypeDropdownMenu.add(rtlistItem1);
    ruleTypeDropdownMenu.add(rtlistItem2);
    ruleTypeDropdownMenu.add(rtlistItem3);

    triggerDropdownMenu.add(trglistItem1);
    triggerDropdownMenu.add(trglistItem2);
    triggerDropdownMenu.add(trglistItem3);

    actionDropdownMenu.add(actionlistItem1);
    actionDropdownMenu.add(actionlistItem2);
    actionDropdownMenu.add(actionlistItem3);

    exchangeButtonGroup.add(exchangeDropDownButton);
    exchangeButtonGroup.add(exchangeDropdownMenu);

    // init exchange list items //
    exlistItem1.setText("MtGox");
    exlistItem1.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            ruleTypeButtonGroup.add(ruleTypeDropDownButton);
            ruleTypeButtonGroup.add(ruleTypeDropdownMenu);
            exchangeDropDownButton.setText(exlistItem1.getText());
          }
        });

    exlistItem2.setText("Bitstamp");
    exlistItem2.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            ruleTypeButtonGroup.add(ruleTypeDropDownButton);
            ruleTypeButtonGroup.add(ruleTypeDropdownMenu);
            exchangeDropDownButton.setText(exlistItem2.getText());
          }
        });

    // init rule type list items //
    rtlistItem1.setText("Price Trigger");
    rtlistItem1.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            ruleTypeDropDownButton.setText(rtlistItem1.getText());

            triggerButtonGroup.add(triggerDropDownButton);
            triggerButtonGroup.add(triggerDropdownMenu);
            triggerDropDownButton.setText("Choose Condition");
            trglistItem1.setText("Price Drops Below");
            trglistItem2.setText("Price Rises Above");
            triggerDropdownMenu.add(trglistItem2);
            triggerDropdownMenu.remove(trglistItem3);
            trglistItem3.setText("");
          }
        });

    rtlistItem2.setText("Price Range Trigger");
    rtlistItem2.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            ruleTypeDropDownButton.setText(rtlistItem2.getText());

            triggerButtonGroup.add(triggerDropDownButton);
            triggerButtonGroup.add(triggerDropdownMenu);
            triggerDropDownButton.setText("Choose Condition");
            trglistItem1.setText("Price is between");
            triggerDropdownMenu.remove(trglistItem2);
            triggerDropdownMenu.remove(trglistItem3);
            trglistItem2.setText("");
            trglistItem3.setText("");
          }
        });

    rtlistItem3.setText("Trend Change Trigger");
    rtlistItem3.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            ruleTypeDropDownButton.setText(rtlistItem3.getText());

            triggerButtonGroup.add(triggerDropDownButton);
            triggerButtonGroup.add(triggerDropdownMenu);
            triggerDropDownButton.setText("Choose Condition");
            trglistItem1.setText("Price begins to Drop");
            trglistItem2.setText("Price begins to Rise");
            triggerDropdownMenu.add(trglistItem2);
            triggerDropdownMenu.remove(trglistItem3);
            trglistItem3.setText("");
          }
        });

    // init exchange list items (depending on rule type - so no initial text)
    trglistItem1.setText("");
    trglistItem1.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            actionButtonGroup.add(actionDropDownButton);
            actionButtonGroup.add(actionDropdownMenu);
            triggerDropDownButton.setText(trglistItem1.getText());
          }
        });

    trglistItem2.setText("");
    trglistItem2.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            if (!trglistItem2.getText().equals("")) {
              triggerDropDownButton.setText(trglistItem2.getText());
              actionButtonGroup.add(actionDropDownButton);
              actionButtonGroup.add(actionDropdownMenu);
            }
          }
        });

    trglistItem3.setText("");
    trglistItem3.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            if (!trglistItem3.getText().equals("")) {
              triggerDropDownButton.setText(trglistItem3.getText());
              actionButtonGroup.add(actionDropDownButton);
              actionButtonGroup.add(actionDropdownMenu);
            }
          }
        });

    // init action list items //
    actionlistItem1.setText("Buy");
    actionlistItem1.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            actionDropDownButton.setText(actionlistItem1.getText());
          }
        });

    actionlistItem2.setText("Sell");
    actionlistItem2.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            actionDropDownButton.setText(actionlistItem2.getText());
          }
        });

    actionlistItem3.setText("Alert Me");
    actionlistItem3.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {

            actionDropDownButton.setText(actionlistItem3.getText());
          }
        });

    buttonGroupList.add(exchangeButtonGroup);
    buttonGroupList.add(ruleTypeButtonGroup);
    buttonGroupList.add(triggerButtonGroup);
    buttonGroupList.add(actionButtonGroup);
  }