public void testFlatSectionAroundNestedSectionLayoutDecorator() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new SeparatorLayoutDecorator(
            new SeparatorLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Baz());

    Composite composite = (Composite) metawidget.getChildren()[0];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Foo", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    TabFolder innerTabFolder = (TabFolder) metawidget.getChildren()[1];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite innerPanel = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Abc:", ((Label) innerPanel.getChildren()[0]).getText());
    assertTrue(innerPanel.getChildren()[1] instanceof Text);
    assertEquals(2, innerPanel.getChildren().length);

    composite = (Composite) metawidget.getChildren()[2];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Baz", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    assertEquals("Def:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Button);
    assertEquals((metawidget.getChildren()[4].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals(5, metawidget.getChildren().length);
  }
  private void turnToPage(SelectionEvent event) {
    final TabItem item = (TabItem) event.item;
    TabFolder folder = item.getParent();

    SearchPageDescriptor descriptor =
        (SearchPageDescriptor) item.getData("descriptor"); // $NON-NLS-1$

    if (item.getControl() == null) {
      item.setControl(createPageControl(folder, descriptor));
    }

    Control oldControl = folder.getItem(fCurrentIndex).getControl();
    Point oldSize = oldControl.getSize();
    Control newControl = item.getControl();
    Point newSize = newControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    resizeDialogIfNeeded(oldSize, newSize);

    ISearchPage oldPage = fCurrentPage;
    if (oldPage != null) {
      oldPage.setVisible(false);
    }

    fCurrentPage = descriptor.getPage();
    fDialogSettings.put(STORE_PREVIOUS_PAGE, descriptor.getId());
    fCurrentIndex = folder.getSelectionIndex();

    setPerformActionEnabled(fCurrentPage != null);
    if (fCurrentPage != null) {
      fCurrentPage.setVisible(true);
      Control pageControl = fCurrentPage.getControl();
      if (pageControl instanceof Composite) ((Composite) pageControl).layout(false, true);
    }
    fReplaceButton.setVisible(fCurrentPage instanceof IReplacePage);
    notifyPageChanged();
  }
Exemple #3
0
  private void changeCurrentlyDisplayedExecutionRecord(ExecutionHistoryRecord newExecutionRecord) {
    if (newExecutionRecord.out.rows.isEmpty()) {
      // We do not want to erase the old content, but we want to give feedback that the command was
      // executed.
      return;
    }
    boolean needRefresh = currentlySelectedExecutionRecord == null;
    currentlySelectedExecutionRecord = newExecutionRecord;

    if (!needRefresh) {
      int percentage = 100 / (terminalDataLayer.getColumnCount() + 1);
      terminalDataLayer.setColumnWidthPercentageByPosition(0, percentage * 2);
      for (int i = 1; i < terminalDataLayer.getColumnCount(); i++) {
        terminalDataLayer.setColumnWidthPercentageByPosition(i, percentage);
      }
    }
    terminalGrid
        .refresh(); // FIXME: This somewhat works to display the columns the first time a command is
                    // run. Especially if the output contains few rows and does not require a scroll
                    // bar

    int selectedTab = 0;
    tabularErrorTable.clearAll();
    int numberOfErrLines = 0;
    //    if(currentlySelectedExecutionRecord.err!=null){
    //      numberOfErrLines=currentlySelectedExecutionRecord.err.rows.size();
    //      if(numberOfErrLines>0){
    //        selectedTab=1;
    //      }
    //    }
    TabFolder tabPane = (TabFolder) terminalGrid.getParent();
    tabPane.getItem(1).setText("err " + numberOfErrLines + " lines");
    tabularErrorTable.setItemCount(numberOfErrLines);

    tabularLogTable.clearAll();
    int numberOfLogLines = 0;
    //    if(currentlySelectedExecutionRecord.log!=null){
    //      numberOfLogLines=currentlySelectedExecutionRecord.log.rows.size();
    //    }
    tabPane.getItem(2).setText("log-" + numberOfLogLines);
    tabularLogTable.setItemCount(numberOfLogLines);

    tabPane.setSelection(selectedTab);
    commandLineTxt.setFocus();
  }
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @since 1.3
  */
 public Rectangle getBounds() {
   checkWidget();
   Rectangle result = new Rectangle(0, 0, 0, 0);
   int index = parent.indexOf(this);
   if (index != -1) {
     int selectionIndex = parent.getSelectionIndex();
     boolean selected = index == selectionIndex;
     Rectangle padding = parent.getItemPadding(selected);
     String text = getText();
     if (text != null) {
       Point extent = Graphics.stringExtent(parent.getFont(), text);
       result.width = extent.x;
       result.height = extent.y;
     }
     Image image = getImage();
     if (image != null) {
       Rectangle imageSize = image.getBounds();
       result.width += imageSize.width + IMAGE_TEXT_SPACING;
       result.height = Math.max(result.height, imageSize.height);
     }
     result.width += 2 * ITEM_BORDER + padding.width;
     result.height += ITEM_BORDER + padding.height;
     if (selected) {
       result.height += SELECTED_ITEM_BORDER;
     }
     if (selectionIndex != -1) {
       if (index + 1 == selectionIndex || index - 1 == selectionIndex) {
         result.width -= ITEM_BORDER;
       }
     }
     if (isBarTop()) {
       if (index != selectionIndex) {
         result.y += SELECTED_ITEM_BORDER;
       }
     } else {
       result.y = parent.getBounds().height - 2 * parent.getBorderWidth() - result.height;
       if (index != selectionIndex) {
         result.y -= SELECTED_ITEM_BORDER;
       }
     }
     if (index > 0) {
       TabItem leftItem = parent.getItem(index - 1);
       Rectangle leftItemBounds = leftItem.getBounds();
       result.x = leftItemBounds.x + leftItemBounds.width + TABS_SPACING;
       if (index == selectionIndex || index - 1 == selectionIndex) {
         result.x -= TABS_SPACING;
       }
     }
   }
   return result;
 }
  /**
   * Opens the specified tab of preferences dialog
   *
   * @param tabIndex
   */
  public void openTab(int tabIndex) {
    // widgets are created on demand
    createShell();
    loadPreferences();
    tabFolder.setSelection(tabIndex);

    // select ports text by default if ports tab is opened
    // this is needed for PortsFetcher that uses this tab as its preferences
    if (tabFolder.getItem(tabIndex) == portsTabItem) {
      portsText.forceFocus();
    }

    super.open();
  }
Exemple #6
0
 protected void adjustJARSigningTabVisibility() {
   IDialogSettings settings = getDialogSettings();
   if (useJARFormat()) {
     if (fTabFolder.getItemCount() < 3) {
       createJARSigningTab(fTabFolder);
       fJARSiginingTab.initialize(settings);
     }
   } else {
     if (fTabFolder.getItemCount() >= 3) {
       fJARSiginingTab.saveSettings(settings);
       fTabFolder.getItem(2).dispose();
     }
   }
 }
Exemple #7
0
  @Override
  public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (visible) {
      handleResize(true);
      displayedConfig = true;
      if (excludeFromBuildCheck != null && resd != null)
        excludeFromBuildCheck.setSelection(resd.isExcluded());
      populateConfigurations();
    }

    if (itabs.size() < 1) return;

    if (currentTab == null && folder.getItemCount() > 0) {
      Object ob = folder.getItem(0).getData();
      currentTab = (ICPropertyTab) ob;
    }
    if (currentTab != null)
      currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null);
  }
Exemple #8
0
 /**
  * Returns a parent composite for a field editor.
  *
  * <p>This value must not be cached since a new parent may be created each time this method
  * called. Thus this method must be called each time a field editor is constructed.
  *
  * @return a parent
  */
 protected Composite getFieldEditorParent() {
   if (folder == null || folder.getItemCount() == 0) {
     return super.getFieldEditorParent();
   }
   return (Composite) folder.getItem(folder.getItemCount() - 1).getControl();
 }
  /**
   * Creates all the tabs in the detail pane to display the information for a given node.
   *
   * @param composite
   * @param node
   */
  public static void createTabs(Composite composite, INode node) {

    List<IDetailTab> tabs = getTabs(node);

    if (tabs == null || tabs.size() == 0) {
      // no detail found..

      Label label = new Label(composite, SWT.FILL);
      label.setText(
          Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + node.getLabelText());
      label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

      return;
    }

    // create tabs
    TabFolder tabFolder = new TabFolder(composite, SWT.NULL);

    // only init tabs when the tab becomes active
    tabFolder.addSelectionListener(
        new SelectionListener() {

          public void widgetDefaultSelected(SelectionEvent e) {

            // noop
          }

          public void widgetSelected(SelectionEvent e) {

            TabItem tabItem = (TabItem) e.item;
            IDetailTab tab = (IDetailTab) tabItem.getData();
            if (tab != null) {

              // create composite on tab and fill it..
              Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
              tabItem.setControl(detailComposite);
              detailComposite.setLayout(new FillLayout());
              tab.fillComposite(detailComposite);
              detailComposite.layout();

              // store tab name, so we can reselect when other node is
              // chosen
              DetailTabManager.setActiveTabName(tabItem.getText());
            }
          }
        });

    // add tabs to folder
    int tabIndex = 0;
    for (IDetailTab detailTab : tabs) {

      // create tab
      TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
      tabItem.setText(detailTab.getLabelText());
      tabItem.setToolTipText(detailTab.getLabelToolTipText());

      // store tab so we can fill later
      tabItem.setData(detailTab);

      // reselect same tab as was previous selected
      if (tabItem.getText() != null && _activeTabName != null) {
        if (tabItem.getText().equals(_activeTabName)) {
          tabFolder.setSelection(tabIndex);
        }
      }

      tabIndex++;
    }

    // load data for active tab, default to first one if none is selected
    tabIndex = tabFolder.getSelectionIndex();
    if (tabIndex == -1) {
      tabIndex = 0;
    }

    TabItem tabItem = tabFolder.getItem(tabIndex);
    if (tabItem != null) {
      Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
      tabItem.setControl(detailComposite);
      detailComposite.setLayout(new FillLayout());
      IDetailTab tab = (IDetailTab) tabItem.getData();
      tab.fillComposite(detailComposite);
      detailComposite.layout();
    }

    tabFolder.layout();
  }
  public void testNestedTabs() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new TabFolderLayoutDecorator(
            new TabFolderLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Bar());

    assertEquals("Abc:", ((Label) metawidget.getChildren()[0]).getText());
    assertTrue(metawidget.getChildren()[1] instanceof Text);

    TabFolder outerTabFolder = (TabFolder) metawidget.getChildren()[2];
    assertEquals("Foo", outerTabFolder.getItem(0).getText());
    Composite outerPanel = (Composite) outerTabFolder.getChildren()[0];
    assertEquals(4, outerPanel.getChildren().length);

    TabFolder innerTabFolder = (TabFolder) outerPanel.getChildren()[0];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite barComposite = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Def:", ((Label) barComposite.getChildren()[0]).getText());
    assertTrue(barComposite.getChildren()[1] instanceof Button);
    assertEquals((barComposite.getChildren()[1].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals("Ghi:", ((Label) barComposite.getChildren()[2]).getText());
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.MULTI), SWT.MULTI);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.BORDER), SWT.BORDER);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.V_SCROLL), SWT.V_SCROLL);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.WRAP), SWT.WRAP);

    assertEquals(4, barComposite.getChildren().length);

    assertEquals("Baz", innerTabFolder.getItem(1).getText());
    Composite bazComposite = (Composite) innerTabFolder.getChildren()[1];
    assertEquals("Jkl:", ((Label) bazComposite.getChildren()[0]).getText());
    assertTrue(bazComposite.getChildren()[1] instanceof Text);
    assertEquals(2, bazComposite.getChildren().length);

    assertEquals("Mno:", ((Label) outerPanel.getChildren()[1]).getText());
    assertTrue(outerPanel.getChildren()[2] instanceof Button);
    assertEquals((outerPanel.getChildren()[2].getStyle() & SWT.CHECK), SWT.CHECK);

    innerTabFolder = (TabFolder) outerPanel.getChildren()[3];
    assertEquals("Moo", innerTabFolder.getItem(0).getText());
    Composite mooComposite = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Pqr:", ((Label) mooComposite.getChildren()[0]).getText());
    assertTrue(mooComposite.getChildren()[1] instanceof Text);
    assertEquals(2, mooComposite.getChildren().length);

    assertEquals("Stu:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Text);
    assertEquals(5, metawidget.getChildren().length);

    // Test components within nested tabs still accessible by name

    assertEquals(metawidget.getChildren()[1], metawidget.getControl("abc"));
    assertEquals(barComposite.getChildren()[1], metawidget.getControl("def"));
    assertEquals(barComposite.getChildren()[3], metawidget.getControl("ghi"));
    assertEquals(bazComposite.getChildren()[1], metawidget.getControl("jkl"));
    assertEquals(outerPanel.getChildren()[2], metawidget.getControl("mno"));
    assertEquals(mooComposite.getChildren()[1], metawidget.getControl("pqr"));
    assertEquals(metawidget.getChildren()[4], metawidget.getControl("stu"));
  }