Package org.rstudio.studio.client.workbench.views.history.view

Examples of org.rstudio.studio.client.workbench.views.history.view.Shelf


  
   public FindReplaceBar(boolean showReplace, final boolean defaultForward)
   {
      defaultForward_ = defaultForward;
     
      Shelf shelf = new Shelf(true);
      shelf.setWidth("100%");

      VerticalPanel panel = new VerticalPanel();
      ElementIds.assignElementId(panel.getElement(),
                                 ElementIds.FIND_REPLACE_BAR);
     
      HorizontalPanel findReplacePanel = new HorizontalPanel();
      findReplacePanel.addStyleName(RES.styles().findPanel());
      findReplacePanel.add(txtFind_ = new FindTextBox("Find"));
      txtFind_.setIconVisible(true);
     
      Commands cmds = RStudioGinjector.INSTANCE.getCommands();
      findReplacePanel.add(btnFindNext_ = new SmallButton(cmds.findNext()));
      findReplacePanel.add(btnFindPrev_ = new SmallButton(cmds.findPrevious()));
     
      findReplacePanel.add(txtReplace_ = new FindTextBox("Replace"));
      txtReplace_.addStyleName(RES.styles().replaceTextBox());
      findReplacePanel.add(btnReplace_ = new SmallButton(cmds.replaceAndFind()));
      findReplacePanel.add(btnReplaceAll_ = new SmallButton("All"));
     
      panel.add(findReplacePanel);
     
      HorizontalPanel optionsPanel = new HorizontalPanel();
      optionsPanel.addStyleName(RES.styles().optionsPanel());
       
      optionsPanel.add(chkInSelection_ = new CheckBox());
      Label inSelectionLabel = new CheckboxLabel(chkInSelection_,
                                                 "In selection").getLabel();
      inSelectionLabel.addStyleName(RES.styles().checkboxLabel());
      optionsPanel.add(inSelectionLabel);
     
      optionsPanel.add(chkCaseSensitive_ = new CheckBox());
      Label matchCaseLabel =
                  new CheckboxLabel(chkCaseSensitive_, "Match case").getLabel();
      matchCaseLabel.addStyleName(RES.styles().checkboxLabel());
      optionsPanel.add(matchCaseLabel);
     
      optionsPanel.add(chkWholeWord_ = new CheckBox());
      Label wholeWordLabel =
             new CheckboxLabel(chkWholeWord_, "Whole word").getLabel();
      wholeWordLabel.addStyleName(RES.styles().checkboxLabel());
      optionsPanel.add(wholeWordLabel);
     
      optionsPanel.add(chkRegEx_ = new CheckBox());
      Label regexLabel = new CheckboxLabel(chkRegEx_, "Regex").getLabel();
      regexLabel.addStyleName(RES.styles().checkboxLabel());
     
      optionsPanel.add(regexLabel);
     
      optionsPanel.add(chkWrapSearch_ = new CheckBox());
      Label wrapSearchLabel = new CheckboxLabel(chkWrapSearch_,
                                                "Wrap").getLabel();
      wrapSearchLabel.addStyleName(RES.styles().checkboxLabel());  
      optionsPanel.add(wrapSearchLabel);
     
     
      panel.add(optionsPanel);
     
      shelf.addLeftWidget(panel);
     
      // fixup tab indexes of controls
      txtFind_.setTabIndex(100);
      txtReplace_.setTabIndex(101);
      chkInSelection_.setTabIndex(102);
      chkCaseSensitive_.setTabIndex(103);
      chkWholeWord_.setTabIndex(104);
      chkRegEx_.setTabIndex(105);
      chkWrapSearch_.setTabIndex(106);
     
      // remove SmallButton instances from tab order since (a) they aren't
      // capable of showing a focused state; and (b) enter is already a
      // keyboard shortcut for both find and replace
      btnFindNext_.setTabIndex(-1);
      btnFindPrev_.setTabIndex(-1);
      btnReplace_.setTabIndex(-1);
      btnReplaceAll_.setTabIndex(-1);
    
      shelf.setRightVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
      shelf.addRightWidget(btnClose_ = new Button());
      btnClose_.setStyleName(RES.styles().closeButton());
      btnClose_.addStyleName(ThemeStyles.INSTANCE.closeTabButton());
      btnClose_.getElement().appendChild(
            new Image(ThemeResources.INSTANCE.closeTab()).getElement());

      txtFind_.addKeyDownHandler(new KeyDownHandler()
      {
         public void onKeyDown(KeyDownEvent event)
         {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
            {
               event.preventDefault();
               event.stopPropagation();
               if (defaultForward_)
                  btnFindNext_.click();
               else
                  btnFindPrev_.click();
               focusFindField(false);
            }
         }
      });

      txtReplace_.addKeyDownHandler(new KeyDownHandler()
      {
         public void onKeyDown(KeyDownEvent event)
         {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
            {
               event.preventDefault();
               event.stopPropagation();
               btnReplace_.click();
               WindowEx.get().focus();
               txtReplace_.focus();
            }
         }
      });

      shelf.addKeyDownHandler(new KeyDownHandler()
      {
         public void onKeyDown(KeyDownEvent event)
         {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE
                && !event.isAnyModifierKeyDown())
View Full Code Here

TOP

Related Classes of org.rstudio.studio.client.workbench.views.history.view.Shelf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.