Example #1
0
  private void ensureStylesInjected() {
    ThemeResources.INSTANCE.themeStyles().ensureInjected();
    CoreResources.INSTANCE.styles().ensureInjected();
    StudioResources.INSTANCE.styles().ensureInjected();
    ConsoleResources.INSTANCE.consoleStyles().ensureInjected();
    FileDialogResources.INSTANCE.styles().ensureInjected();
    ManipulatorResources.INSTANCE.manipulatorStyles().ensureInjected();
    PackagesCellTableResources.INSTANCE.cellTableStyle().ensureInjected();
    FilesListCellTableResources.INSTANCE.cellTableStyle().ensureInjected();
    ExportPlotResources.INSTANCE.styles().ensureInjected();
    CodeSearchResources.INSTANCE.styles().ensureInjected();

    ConsoleProgressDialog.ensureStylesInjected();
    SupportPopupMenu.ensureStylesInjected();
    SlideLabel.ensureStylesInjected();
    ThemedButton.ensureStylesInjected();
    ThemedPopupPanel.ensureStylesInjected();
    InstallPackageDialog.ensureStylesInjected();
    PublishPdfDialog.ensureStylesInjected();
    ApplicationEndedPopupPanel.ensureStylesInjected();
    ApplicationSerializationProgress.ensureStylesInjected();
    HistoryPane.ensureStylesInjected();
    Shelf.ensureStylesInjected();
    ImportFileSettingsDialog.ensureStylesInjected();
    ImportGoogleSpreadsheetDialog.ensureStylesInjected();
    FindReplaceBar.ensureStylesInjected();
    FontSizer.ensureStylesInjected();
    PreferencesDialogBaseResources.INSTANCE.styles().ensureInjected();
    PreferencesDialog.ensureStylesInjected();
    ProjectPreferencesDialogResources.INSTANCE.styles().ensureInjected();
    LinkColumn.ensureStylesInjected();
    CaptionWithHelp.ensureStylesInjected();
    CheckForUpdatesDialog.ensureStylesInjected();
    UnsavedChangesDialog.ensureStylesInjected();
    ChooseMirrorDialog.ensureStylesInjected();
    ResizeGripper.ensureStylesInjected();
    LineTableView.ensureStylesInjected();
    ChangelistTable.ensureStylesInjected();
    DiffFrame.ensureStylesInjected();
    ViewFilePanel.ensureStylesInjected();
    CodeBrowserEditingTargetWidget.ensureStylesInjected();
    ShowPublicKeyDialog.ensureStylesInjected();
    CreateKeyDialog.ensureStylesInjected();
    SshKeyWidget.ensureStylesInjected();
    IgnoreDialog.ensureStylesInjected();
    WizardResources.INSTANCE.styles().ensureInjected();
    NewProjectResources.INSTANCE.styles().ensureInjected();

    StyleInjector.inject("button::-moz-focus-inner {border:0}");
  }
  public CompileOutputBufferWithHighlight() {
    styles_ = ConsoleResources.INSTANCE.consoleStyles();

    output_ = new PreWidget();
    output_.setStylePrimaryName(styles_.output());
    output_.addStyleName("ace_text-layer");
    output_.addStyleName("ace_line");
    output_.addStyleName(styles_.paddedOutput());
    FontSizer.applyNormalFontSize(output_);

    scrollPanel_ = new BottomScrollPanel();
    scrollPanel_.setSize("100%", "100%");
    scrollPanel_.addStyleName("ace_editor");
    scrollPanel_.addStyleName("ace_scroller");
    scrollPanel_.setWidget(output_);

    initWidget(scrollPanel_);
  }
Example #3
0
  public HistoryTable(
      String commandClassName,
      String timestampClassName,
      String selectedClassName,
      TimestampMode timestampMode,
      final Commands commands) {
    super(
        new HistoryEntryItemCodec(
            commandClassName,
            timestampClassName,
            timestampMode,
            timestampMode == TimestampMode.ITEM),
        selectedClassName,
        true,
        true);

    searchResult_ = timestampMode == TimestampMode.ITEM;

    applyWidthConstraints();

    final Resources res = GWT.create(Resources.class);
    setStyleName(res.styles().historyTable());
    FontSizer.applyNormalFontSize(this);

    if (searchResult_) {
      addMouseDownHandler(
          new MouseDownHandler() {
            public void onMouseDown(MouseDownEvent event) {
              Element el = DOM.eventGetTarget((Event) event.getNativeEvent());
              if (el != null
                  && el.getTagName().equalsIgnoreCase("div")
                  && el.getClassName().equals(res.styles().disclosure())) {
                // disclosure click
                commands.historyShowContext().execute();
              }
            }
          });
    }
  }
Example #4
0
  @Override
  protected Widget createMainWidget() {
    context_ = new FindResultContext();

    FindOutputResources resources = GWT.create(FindOutputResources.class);
    resources.styles().ensureInjected();

    table_ =
        new FastSelectTable<FindResult, CodeNavigationTarget, Object>(
            new FindOutputCodec(resources), resources.styles().selectedRow(), true, false);
    FontSizer.applyNormalFontSize(table_);
    table_.addStyleName(resources.styles().findOutput());
    table_.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) return;

            if (dblClick_.checkForDoubleClick(event.getNativeEvent())) fireSelectionCommitted();
          }

          private final DoubleClickState dblClick_ = new DoubleClickState();
        });

    table_.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) fireSelectionCommitted();
            event.stopPropagation();
            event.preventDefault();
          }
        });

    scrollPanel_ = new ScrollPanel(table_);
    scrollPanel_.setSize("100%", "100%");
    return scrollPanel_;
  }
Example #5
0
  public int getCharacterWidth() {
    // create width checker label and add it to the root panel
    Label widthChecker = new Label();
    widthChecker.setStylePrimaryName(styles_.console());
    FontSizer.applyNormalFontSize(widthChecker);
    RootPanel.get().add(widthChecker, -1000, -1000);

    // put the text into the label, measure it, and remove it
    String text = new String("abcdefghijklmnopqrstuvwzyz0123456789");
    widthChecker.setText(text);
    int labelWidth = widthChecker.getOffsetWidth();
    RootPanel.get().remove(widthChecker);

    // compute the points per character
    int pointsPerCharacter = labelWidth / text.length();

    // compute client width
    int clientWidth = getElement().getClientWidth();
    int offsetWidth = getOffsetWidth();
    if (clientWidth == offsetWidth) {
      // if the two widths are the same then there are no scrollbars.
      // however, we know there will eventually be a scrollbar so we
      // should offset by an estimated amount
      // (is there a more accurate way to estimate this?)
      final int ESTIMATED_SCROLLBAR_WIDTH = 19;
      clientWidth -= ESTIMATED_SCROLLBAR_WIDTH;
    }

    // compute character width (add pad so characters aren't flush to right)
    final int RIGHT_CHARACTER_PAD = 2;
    int width = (clientWidth / pointsPerCharacter) - RIGHT_CHARACTER_PAD;

    // enforce a minimum width
    final int MINIMUM_WIDTH = 30;
    return Math.max(width, MINIMUM_WIDTH);
  }
Example #6
0
  public ShellWidget(AceEditor editor) {
    styles_ = ConsoleResources.INSTANCE.consoleStyles();

    SelectInputClickHandler secondaryInputHandler = new SelectInputClickHandler();

    output_ = new PreWidget();
    output_.setStylePrimaryName(styles_.output());
    output_.addClickHandler(secondaryInputHandler);

    pendingInput_ = new PreWidget();
    pendingInput_.setStyleName(styles_.output());
    pendingInput_.addClickHandler(secondaryInputHandler);

    prompt_ = new HTML();
    prompt_.setStylePrimaryName(styles_.prompt());
    prompt_.addStyleName(KEYWORD_CLASS_NAME);

    input_ = editor;
    input_.setShowLineNumbers(false);
    input_.setShowPrintMargin(false);
    if (!Desktop.isDesktop()) input_.setNewLineMode(NewLineMode.Unix);
    input_.setUseWrapMode(true);
    input_.setPadding(0);
    input_.autoHeight();
    final Widget inputWidget = input_.asWidget();
    input_.addClickHandler(secondaryInputHandler);
    inputWidget.addStyleName(styles_.input());
    input_.addCursorChangedHandler(
        new CursorChangedHandler() {
          public void onCursorChanged(CursorChangedEvent event) {
            Scheduler.get()
                .scheduleDeferred(
                    new ScheduledCommand() {
                      @Override
                      public void execute() {
                        input_.scrollToCursor(scrollPanel_, 8, 60);
                      }
                    });
          }
        });
    input_.addCapturingKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            // If the user hits Page-Up from inside the console input, we need
            // to simulate pageup because focus is not contained in the scroll
            // panel (it's in the hidden textarea that Ace uses under the
            // covers).

            int keyCode = event.getNativeKeyCode();
            switch (keyCode) {
              case KeyCodes.KEY_PAGEUP:
                event.stopPropagation();
                event.preventDefault();

                // Can't scroll any further up. Return before we change focus.
                if (scrollPanel_.getVerticalScrollPosition() == 0) return;

                scrollPanel_.focus();
                int newScrollTop =
                    scrollPanel_.getVerticalScrollPosition() - scrollPanel_.getOffsetHeight() + 40;
                scrollPanel_.setVerticalScrollPosition(Math.max(0, newScrollTop));
                break;
            }
          }
        });

    inputLine_ = new DockPanel();
    inputLine_.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
    inputLine_.setVerticalAlignment(DockPanel.ALIGN_TOP);
    inputLine_.add(prompt_, DockPanel.WEST);
    inputLine_.setCellWidth(prompt_, "1");
    inputLine_.add(input_.asWidget(), DockPanel.CENTER);
    inputLine_.setCellWidth(input_.asWidget(), "100%");
    inputLine_.setWidth("100%");

    verticalPanel_ = new VerticalPanel();
    verticalPanel_.setStylePrimaryName(styles_.console());
    verticalPanel_.addStyleName("ace_text-layer");
    verticalPanel_.addStyleName("ace_line");
    FontSizer.applyNormalFontSize(verticalPanel_);
    verticalPanel_.add(output_);
    verticalPanel_.add(pendingInput_);
    verticalPanel_.add(inputLine_);
    verticalPanel_.setWidth("100%");

    scrollPanel_ = new ClickableScrollPanel();
    scrollPanel_.setWidget(verticalPanel_);
    scrollPanel_.addStyleName("ace_editor");
    scrollPanel_.addStyleName("ace_scroller");
    scrollPanel_.addClickHandler(secondaryInputHandler);
    scrollPanel_.addKeyDownHandler(secondaryInputHandler);

    secondaryInputHandler.setInput(editor);

    scrollToBottomCommand_ =
        new TimeBufferedCommand(5) {
          @Override
          protected void performAction(boolean shouldSchedulePassive) {
            if (!DomUtils.selectionExists()) scrollPanel_.scrollToBottom();
          }
        };

    initWidget(scrollPanel_);

    addCopyHook(getElement());
  }
Example #7
0
  @Inject
  public WorkbenchScreen(
      EventBus eventBus,
      Session session,
      Provider<PaneManager> pPaneManager,
      final Edit.Shim edit,
      Commands commands,
      final Provider<MRUList> mruList,
      FontSizeManager fontSizeManager,
      OptionsLoader.Shim optionsLoader) {
    eventBus_ = eventBus;
    session_ = session;
    edit_ = edit;
    optionsLoader_ = optionsLoader;

    eventBus_.addHandler(ShowEditorEvent.TYPE, edit);
    eventBus_.addHandler(
        ChangeFontSizeEvent.TYPE,
        new ChangeFontSizeHandler() {
          public void onChangeFontSize(ChangeFontSizeEvent event) {
            FontSizer.setNormalFontSize(Document.get(), event.getFontSize());
            Scheduler.get()
                .scheduleDeferred(
                    new ScheduledCommand() {
                      public void execute() {
                        // Causes the console width to be remeasured
                        doOnPaneSizesChanged();
                      }
                    });
          }
        });
    FontSizer.setNormalFontSize(Document.get(), fontSizeManager.getSize());

    paneManager_ = pPaneManager.get();
    tabsPanel_ = paneManager_.getPanel();
    tabsPanel_.setSize("100%", "100%");
    tabsPanel_.addStyleDependentName("Workbench");

    // Prevent doOnPaneSizesChanged() from being called more than once
    // every N milliseconds. Note that the act of sending the client metrics
    // to the server also has its own buffer, so this one only needs to
    // minimize the expense of doing the calculation, not of sending data to
    // the server.
    paneSizesChangedCommand_ =
        new TimeBufferedCommand(200) {
          @Override
          protected void performAction(boolean shouldSchedulePassive) {
            assert !shouldSchedulePassive;
            doOnPaneSizesChanged();
          }
        };

    eventBus.addHandler(
        SessionInitEvent.TYPE,
        new SessionInitHandler() {
          public void onSessionInit(SessionInitEvent sie) {
            prefetch();
            mruList.get();
          }
        });

    eventBus.addHandler(
        LastSourceDocClosedEvent.TYPE,
        new LastSourceDocClosedHandler() {
          public void onLastSourceDocClosed(LastSourceDocClosedEvent event) {
            paneManager_
                .getSourceLogicalWindow()
                .onWindowStateChange(new WindowStateChangeEvent(WindowState.HIDE));
          }
        });

    eventBus.addHandler(
        WorkingDirChangedEvent.TYPE,
        new WorkingDirChangedHandler() {
          public void onWorkingDirChanged(WorkingDirChangedEvent event) {
            updateWorkingDirectory(event.getPath());
          }
        });

    ((PlotsTab) paneManager_.getTab(Tab.Plots))
        .addResizeHandler(
            new ResizeHandler() {
              public void onResize(ResizeEvent event) {
                onPaneSizesChanged();
              }
            });
    tabsPanel_.addSplitterResizedHandler(
        new SplitterResizedHandler() {
          public void onSplitterResized(SplitterResizedEvent event) {
            onPaneSizesChanged();
          }
        });

    // init widget
    initWidget(tabsPanel_);

    commandBinder.bind(commands, this);
  }