Example #1
0
 private void updateSelectedTab() {
   ICPropertyTab newTab = (ICPropertyTab) folder.getSelection()[0].getData();
   if (newTab != null && currentTab != newTab) {
     recentTabs.put(getClass(), newTab.getClass());
     if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
     currentTab = newTab;
     currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
   }
 }
Example #2
0
 @Override
 public void handleMessage(int code, Object data) {
   switch (code) {
       // First re-check visibility of all tabs.
       // While tab deletion can be made on the fly,
       // tabs adding will be made by re-creation
       // of all elements, to preserve their order
     case ICPropertyTab.MANAGEDBUILDSTATE:
       if (folder == null) {
         if (itabs == null || itabs.size() == 0) return;
         ICPropertyTab t = itabs.get(0).tab;
         if (!t.canBeVisible()) t.handleTabEvent(ICPropertyTab.VISIBLE, null);
         return;
       }
       boolean willAdd = false;
       TabItem[] ts = folder.getItems();
       int x = folder.getSelectionIndex();
       String currHeader = (x == -1) ? null : ts[x].getText();
       for (int i = 0; i < itabs.size(); i++) {
         InternalTab itab = itabs.get(i);
         TabItem ti = null;
         for (TabItem element2 : ts) {
           if (element2.isDisposed()) continue;
           if (element2.getData() == itab.tab) {
             ti = element2;
             break;
           }
         }
         if (itab.tab.canBeVisible()) {
           if (ti == null) {
             willAdd = true;
             break;
           }
         } else {
           if (ti != null) ti.dispose();
         }
       }
       // in case of new tab added,
       // we have to dispose and re-create all tabs
       if (willAdd) {
         for (int j = 0; j < ts.length; j++)
           if (ts[j] != null && !ts[j].isDisposed()) ts[j].dispose();
         TabItem ti = null;
         for (int i = 0; i < itabs.size(); i++) {
           InternalTab itab = itabs.get(i);
           if (itab.tab.canBeVisible()) {
             TabItem currTI = itab.createOn(folder);
             if (currHeader != null && currHeader.equals(itab.text)) ti = currTI;
           }
         }
         if (ti != null) folder.setSelection(ti);
       }
       break;
   }
 }
Example #3
0
  /**
   * @param element
   * @param parent
   * @return true if we should exit (no more loadings) false if we should continue extensions scan.
   * @throws BuildException
   */
  private boolean loadTab(IConfigurationElement element, Composite parent) {
    //	MBSCustomPageData currentPageData;
    // Check whether it's our tab
    if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME))) return false;

    ICPropertyTab page = null;
    try {
      page = (ICPropertyTab) element.createExecutableExtension(CLASS_NAME);
    } catch (CoreException e) {
      System.out.println(Messages.AbstractPage_14 + e.getLocalizedMessage());
      return false;
    }
    if (page == null) return false;

    String helpId = element.getAttribute(HELPID_NAME);
    if (helpId != null
        && helpId.length() > 0
        // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
        && page instanceof AbstractCPropertyTab) {
      ((AbstractCPropertyTab) page).setHelpContextId(helpId);
    }

    Image _img = getIcon(element);
    if (_img != null) page.handleTabEvent(ICPropertyTab.SET_ICON, _img);

    if (isSingle()) {
      // note that name, image and tooltip
      // are ignored for single page.
      page.createControls(parent, this);
      InternalTab itab = new InternalTab(parent, EMPTY_STR, null, page, null);
      itabs.add(itab);
      currentTab = page;
      return true; // don't load other tabs
    }
    String _name = element.getAttribute(TEXT_NAME);
    String _tip = element.getAttribute(TIP_NAME);

    Composite _comp = new Composite(folder, SWT.NONE);
    page.createControls(_comp, this);
    InternalTab itab = new InternalTab(_comp, _name, _img, page, _tip);
    itab.createOn(folder);
    itabs.add(itab);
    return false;
  }
Example #4
0
 public TabItem createOn(TabFolder f) {
   if (tab.canBeVisible()) {
     TabItem ti = new TabItem(f, SWT.NONE);
     ti.setText(text);
     if (tip != null) ti.setToolTipText(tip);
     if (image != null) ti.setImage(image);
     ti.setControl(comp);
     ti.setData(tab);
     return ti;
   }
   return null;
 }
Example #5
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);
  }