Esempio n. 1
0
  @Test
  public void html() {
    // Arrange
    CheckBox cb = new CheckBox("<h1>foo</h1>", true);
    // Pre-Assert
    assertEquals("<h1>foo</h1>", cb.getHTML());

    // Act
    cb.setHTML("<h1>test</h1>");

    // Assert
    assertEquals("<h1>test</h1>", cb.getHTML());
    assertEquals(1, cb.getElement().getChild(1).getChildCount());
    HeadingElement h1 = cb.getElement().getChild(1).getChild(0).cast();
    assertEquals("H1", h1.getTagName());
    assertEquals("test", h1.getInnerText());
  }
  @Override
  protected void onAttach() {
    super.onAttach();
    Element label = chkMineOnly.getElement().getElementsByTagName("label").getItem(0);
    label.getStyle().setTop(14, Unit.PX);

    canCreateStory = hasPermission(PermissionName.STORIES_CAN_CREATE_CONTENT.name());
    panelLoadStories.clear();
    if (!canCreateStory) {
      panelCreateStory.addStyleName("hide");
    }
  }
  public void testFocusWidgetDoubleClickEventSinkByAddingHandler() {
    verifyEventSinkOnAddHandler(new Anchor(), false);
    verifyEventSinkOnAddHandler(new Button(), false);

    CheckBox checkBox = new CheckBox();
    // Get the inputElem on which events are sunk
    Element e = (Element) checkBox.getElement().getFirstChildElement();
    verifyEventSinkOnAddHandler(checkBox, e, false);

    verifyEventSinkOnAddHandler(new ToggleButton(), false);
    verifyEventSinkOnAddHandler(new ListBox(), false);
    verifyEventSinkOnAddHandler(new RichTextArea(), false);
    verifyEventSinkOnAddHandler(new TextArea(), false);
    verifyEventSinkOnAddHandler(new PasswordTextBox(), false);
    verifyEventSinkOnAddHandler(new TextBox(), false);
    verifyEventSinkOnAddHandler(new SimpleRadioButton("foo"), false);
  }
Esempio n. 4
0
  @Inject
  public GeneralPreferencesPane(
      RemoteFileSystemContext fsContext,
      FileDialogs fileDialogs,
      UIPrefs prefs,
      Session session,
      final GlobalDisplay globalDisplay,
      WorkbenchContext context) {
    fsContext_ = fsContext;
    fileDialogs_ = fileDialogs;
    prefs_ = prefs;
    session_ = session;

    RVersionsInfo versionsInfo = context.getRVersionsInfo();

    if (Desktop.isDesktop()) {
      if (Desktop.getFrame().canChooseRVersion()) {
        rVersion_ =
            new TextBoxWithButton(
                "R version:",
                "Change...",
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    String ver = Desktop.getFrame().chooseRVersion();
                    if (!StringUtil.isNullOrEmpty(ver)) {
                      rVersion_.setText(ver);

                      globalDisplay.showMessage(
                          MessageDialog.INFO,
                          "Change R Version",
                          "You need to quit and re-open RStudio "
                              + "in order for this change to take effect.");
                    }
                  }
                });
        rVersion_.setWidth("100%");
        rVersion_.setText(Desktop.getFrame().getRVersion());
        spaced(rVersion_);
        add(rVersion_);
      }
    } else if (versionsInfo.isMultiVersion()) {
      rServerRVersion_ = new RVersionSelectWidget(versionsInfo.getAvailableRVersions());
      add(tight(rServerRVersion_));

      rememberRVersionForProjects_ = new CheckBox("Restore last used R version for projects");

      rememberRVersionForProjects_.setValue(true);
      Style style = rememberRVersionForProjects_.getElement().getStyle();
      style.setMarginTop(5, Unit.PX);
      style.setMarginBottom(12, Unit.PX);
      add(rememberRVersionForProjects_);
    }

    Label defaultLabel = new Label("Default working directory (when not in a project):");
    nudgeRight(defaultLabel);
    add(tight(defaultLabel));
    add(dirChooser_ = new DirectoryChooserTextBox(null, null, fileDialogs_, fsContext_));
    spaced(dirChooser_);
    nudgeRight(dirChooser_);
    textBoxWithChooser(dirChooser_);

    restoreLastProject_ = new CheckBox("Restore most recently opened project at startup");
    lessSpaced(restoreLastProject_);
    add(restoreLastProject_);

    add(
        checkboxPref(
            "Restore previously open source documents at startup",
            prefs_.restoreSourceDocuments()));

    add(loadRData_ = new CheckBox("Restore .RData into workspace at startup"));
    lessSpaced(loadRData_);

    saveWorkspace_ =
        new SelectWidget(
            "Save workspace to .RData on exit:", new String[] {"Always", "Never", "Ask"});
    spaced(saveWorkspace_);
    add(saveWorkspace_);

    alwaysSaveHistory_ = new CheckBox("Always save history (even when not saving .RData)");
    lessSpaced(alwaysSaveHistory_);
    add(alwaysSaveHistory_);

    removeHistoryDuplicates_ = new CheckBox("Remove duplicate entries in history");
    spaced(removeHistoryDuplicates_);
    add(removeHistoryDuplicates_);

    showLastDotValue_ = new CheckBox("Show .Last.value in environment listing");
    lessSpaced(showLastDotValue_);
    add(showLastDotValue_);

    rProfileOnResume_ = new CheckBox("Run Rprofile when resuming suspended session");
    spaced(rProfileOnResume_);
    if (!Desktop.isDesktop()) add(rProfileOnResume_);

    // The error handler features require source references; if this R
    // version doesn't support them, don't show these options.
    if (session_.getSessionInfo().getHaveSrcrefAttribute()) {
      add(
          checkboxPref(
              "Use debug error handler only when my code contains errors",
              prefs_.handleErrorsInUserCodeOnly()));
      CheckBox chkTracebacks =
          checkboxPref(
              "Automatically expand tracebacks in error inspector",
              prefs_.autoExpandErrorTracebacks());
      chkTracebacks.getElement().getStyle().setMarginBottom(15, Unit.PX);
      add(chkTracebacks);
    }

    // provide check for updates option in desktop mode when not
    // already globally disabled
    if (Desktop.isDesktop() && !session.getSessionInfo().getDisableCheckForUpdates()) {
      add(checkboxPref("Automatically notify me of updates to RStudio", prefs_.checkForUpdates()));
    }

    saveWorkspace_.setEnabled(false);
    loadRData_.setEnabled(false);
    dirChooser_.setEnabled(false);
    alwaysSaveHistory_.setEnabled(false);
    removeHistoryDuplicates_.setEnabled(false);
    rProfileOnResume_.setEnabled(false);
    showLastDotValue_.setEnabled(false);
    restoreLastProject_.setEnabled(false);
  }
Esempio n. 5
0
  public void sprayFileList(List<FileWrapper> list) {
    checkBoxList.clear();
    selectedFileSet.clear();
    flowPanel.clear();

    for (final FileWrapper fileWrapper : list) {
      final FlowPanel tempFlowPanel = new FlowPanel();
      flowPanel.add(tempFlowPanel);
      tempFlowPanel.getElement().getStyle().setProperty("margin", 50, Unit.PX);
      tempFlowPanel.getElement().getStyle().setProperty("textAlign", "center");
      tempFlowPanel.getElement().getStyle().setProperty("verticalAlign", "top");
      tempFlowPanel.getElement().getStyle().setProperty("display", "inline-block");
      tempFlowPanel.sinkEvents(Event.ONDBLCLICK);
      tempFlowPanel.sinkEvents(Event.ONCONTEXTMENU);

      final CheckBox chckbxFileName = new CheckBox(fileWrapper.getName());

      Image imgFileIcon;
      switch (fileWrapper.getKind()) {
        case DIR:
          imgFileIcon = new Image("/img/folder.png");
          tempFlowPanel.addHandler(
              new DoubleClickHandler() {
                public void onDoubleClick(DoubleClickEvent event) {
                  presenter.changeDirectory(fileWrapper.getPath());
                }
              },
              DoubleClickEvent.getType());
          tempFlowPanel.addHandler(
              new ContextMenuHandler() {
                public void onContextMenu(ContextMenuEvent event) {
                  event.preventDefault();
                  event.stopPropagation();
                  FileContextMenu fileContextMenu =
                      new FileContextMenu(
                          presenter,
                          ContextMenuType.DIRECTORY,
                          fileWrapper.getPath(),
                          selectedFileSet);
                  fileContextMenu.setPopupPosition(
                      event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                  fileContextMenu.show();
                  chckbxFileName.setValue(true, true);
                }
              },
              ContextMenuEvent.getType());
          break;

        default:
          imgFileIcon = new Image("/img/file.png");
          tempFlowPanel.addHandler(
              new DoubleClickHandler() {
                public void onDoubleClick(DoubleClickEvent event) {
                  presenter.downloadFiles(selectedFileSet);
                }
              },
              DoubleClickEvent.getType());
          tempFlowPanel.addHandler(
              new ContextMenuHandler() {
                public void onContextMenu(ContextMenuEvent event) {
                  event.preventDefault();
                  event.stopPropagation();
                  FileContextMenu fileContextMenu =
                      new FileContextMenu(
                          presenter,
                          ContextMenuType.OTHERS,
                          fileWrapper.getPath(),
                          selectedFileSet);
                  fileContextMenu.setPopupPosition(
                      event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                  fileContextMenu.show();
                  chckbxFileName.setValue(true, true);
                }
              },
              ContextMenuEvent.getType());
          break;
      }
      tempFlowPanel.add(imgFileIcon);
      imgFileIcon.setSize("128px", "128px");
      imgFileIcon.getElement().getStyle().setProperty("display", "block");

      checkBoxList.add(chckbxFileName);
      tempFlowPanel.add(chckbxFileName);
      chckbxFileName.addStyleName("iconName");
      chckbxFileName.getElement().getStyle().setProperty("display", "block");

      chckbxFileName.addClickHandler(clickHandlerStopPropagation);
      chckbxFileName.addValueChangeHandler(
          new ValueChangeHandler<Boolean>() {
            public void onValueChange(ValueChangeEvent<Boolean> event) {
              if (event.getValue()) {
                tempFlowPanel.getElement().getStyle().setBackgroundColor("lightblue");
                selectedFileSet.add(fileWrapper.getPath());
              } else {
                tempFlowPanel.getElement().getStyle().clearBackgroundColor();
                selectedFileSet.remove(fileWrapper.getPath());
              }

              if (!mntmDeleteFile.isEnabled() && selectedFileSet.size() > 0) {
                mntmDeleteFile.setEnabled(true);
              } else if (selectedFileSet.size() == 0) {
                mntmDeleteFile.setEnabled(false);
              }

              if (selectedFileSet.size() == 1
                  && !mntmDownloadFile.isEnabled()
                  && !mntmRenameFile.isEnabled()) {
                mntmDownloadFile.setEnabled(true);
                mntmRenameFile.setEnabled(true);
              } else if (selectedFileSet.size() != 1
                  && mntmDownloadFile.isEnabled()
                  && mntmRenameFile.isEnabled()) {
                mntmDownloadFile.setEnabled(false);
                mntmRenameFile.setEnabled(false);
              }
            }
          });

      imgFileIcon.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              event.stopPropagation();
              setAllCheckBoxFalse();
              chckbxFileName.setValue(true, true);
            }
          });
      imgFileIcon.addMouseOverHandler(
          new MouseOverHandler() {
            public void onMouseOver(MouseOverEvent event) {
              if (!chckbxFileName.getValue())
                tempFlowPanel.getElement().getStyle().setBackgroundColor("lightgray");
            }
          });
      imgFileIcon.addMouseOutHandler(
          new MouseOutHandler() {
            public void onMouseOut(MouseOutEvent event) {
              if (!chckbxFileName.getValue())
                tempFlowPanel.getElement().getStyle().clearBackgroundColor();
            }
          });
    }
  }