Пример #1
0
 TabItem findItem(String value, TabItem[] items) {
   for (int i = 0; i < items.length; i++) {
     TabItem item = items[i];
     if (item.getText().equals(value)) return item;
   }
   return null;
 }
  /**
   * Creates an instance of a ControlExample embedded inside the supplied parent Composite.
   *
   * @param parent the container of the example
   */
  public ControlExample(Composite parent) {
    initResources();
    tabFolder = new TabFolder(parent, SWT.NONE);
    tabs = createTabs();
    for (Tab tab : tabs) {
      TabItem item = new TabItem(tabFolder, SWT.NONE);
      item.setText(tab.getTabText());
      item.setControl(tab.createTabFolderPage(tabFolder));
      item.setData(tab);
    }

    /* Workaround: if the tab folder is wider than the screen,
     * Mac platforms clip instead of somehow scrolling the tab items.
     * We try to recover some width by using shorter tab names. */
    Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = parent.getMonitor().getClientArea();
    boolean isMac = SWT.getPlatform().equals("cocoa");
    if (size.x > monitorArea.width && isMac) {
      TabItem[] tabItems = tabFolder.getItems();
      for (int i = 0; i < tabItems.length; i++) {
        tabItems[i].setText(tabs[i].getShortTabText());
      }
    }
    startup = false;
  }
  private void createComposite(
      int style,
      Project project,
      ESModelElementIdToEObjectMapping<ESModelElementId> idToEObjectMapping,
      boolean showRootNodes) {
    setLayout(new GridLayout());
    folder = new TabFolder(this, style);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(folder);

    tabComposite = new Composite(folder, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(tabComposite);

    tabTreeViewer = new TreeViewer(tabComposite, SWT.H_SCROLL | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tabTreeViewer.getControl());

    contentProvider = new SCMContentProvider(idToEObjectMapping);
    contentProvider.setShowRootNodes(showRootNodes);
    SCMLabelProvider detailedLabelProvider = new SCMLabelProvider(project);
    detailedLabelProvider.setChangePackageVisualizationHelper(
        new ChangePackageVisualizationHelper(idToEObjectMapping));
    tabTreeViewer.setContentProvider(contentProvider);
    tabTreeViewer.setLabelProvider(detailedLabelProvider);
    tabTreeViewer.expandToLevel(1);

    TabItem opTab = new TabItem(folder, style);
    opTab.setText("Operations");
    opTab.setControl(tabComposite);
  }
 private void createSchemaGui(final TabFolder tabFolder, final SchemaTree schemaTreeModel) {
   final TabItem dbStructureTabItem = new TabItem(tabFolder, SWT.NULL);
   dbStructureTabItem.setText("Database Structure");
   final Tree tree = new Tree(tabFolder, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
   tree.setHeaderVisible(true);
   tree.setLinesVisible(true);
   tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   // create the jface wrapper
   final TreeViewer treeViewer = new TreeViewer(tree);
   final String[] schemaColumnNames = new String[] {"Name", "Object", "Type", "Schema"};
   final int[] schemaColumnWidths = new int[] {200, 100, 150, 800};
   final int[] schemaColumnAlignments = new int[] {SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT};
   for (int i = 0; i < schemaColumnNames.length; i++) {
     final TreeColumn treeColumn = new TreeColumn(tree, schemaColumnAlignments[i]);
     treeColumn.setText(schemaColumnNames[i]);
     treeColumn.pack();
     treeColumn.setWidth(schemaColumnWidths[i]);
   }
   final SchemaContentProvider schemaContentProvider = new SchemaContentProvider();
   treeViewer.setContentProvider(schemaContentProvider);
   treeViewer.setLabelProvider(new SchemaLabelProvider());
   treeViewer.setInput(schemaTreeModel.getRoot());
   // Add table viewer to database structure tab item
   dbStructureTabItem.setControl(tree);
 }
 public static void labelTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("A Label"); // Text on the tab
   tab.setToolTipText("A simple label");
   Label label = new Label(folder, SWT.CENTER);
   label.setText("Label text");
   tab.setControl(label);
 }
 private TabItem createPartTab(IPresentablePart part, int tabIndex) {
   TabItem tabItem = new TabItem(tabFolder, SWT.NONE, tabIndex);
   tabItem.setData(TAB_DATA, part);
   part.addPropertyListener(childPropertyChangeListener);
   tabItem.addDisposeListener(tabDisposeListener);
   initTab(tabItem, part);
   return tabItem;
 }
Пример #7
0
 void removeControl(Control control) {
   super.removeControl(control);
   int count = getItemCount();
   for (int i = 0; i < count; i++) {
     TabItem item = items[i];
     if (item.control == control) item.setControl(null);
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.skins.StackPresentation#removePart(org.eclipse.ui.internal.skins.IPresentablePart)
   */
  public void removePart(IPresentablePart oldPart) {
    TabItem item = getTab(oldPart);
    if (item == null) {
      return;
    }
    oldPart.setVisible(false);

    item.dispose();
  }
  /**
   * Initializes a tab for the given part. Sets the text, icon, tool tip, etc. This will also be
   * called whenever a relevant property changes in the part to reflect those changes in the tab.
   * Subclasses may override to change the appearance of tabs for a particular part.
   *
   * @param tabItem tab for the part
   * @param part the part being displayed
   */
  protected void initTab(TabItem tabItem, IPresentablePart part) {
    tabItem.setText(part.getName());
    tabItem.setToolTipText(part.getTitleToolTip());

    Image tabImage = part.getTitleImage();
    if (tabImage != tabItem.getImage()) {
      tabItem.setImage(tabImage);
    }
  }
 public static void scribbleTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Scribble");
   tab.setToolTipText("Simple graphics: drawing");
   final Canvas canvas = new Canvas(folder, SWT.NONE);
   ScribbleMouseListener sml = new ScribbleMouseListener();
   canvas.addMouseListener(sml);
   canvas.addMouseMoveListener(sml);
   tab.setControl(canvas);
 }
Пример #11
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;
   }
 }
Пример #12
0
 void releaseChildren(boolean destroy) {
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       TabItem item = items[i];
       if (item != null && !item.isDisposed()) {
         item.release(false);
       }
     }
     items = null;
   }
   super.releaseChildren(destroy);
 }
Пример #13
0
 /**
  * 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;
 }
Пример #14
0
 void reskinChildren(int flags) {
   if (items != null) {
     long /*int*/ list = OS.gtk_container_get_children(handle);
     if (list != 0) {
       int count = OS.g_list_length(list);
       OS.g_list_free(list);
       for (int i = 0; i < count; i++) {
         TabItem item = items[i];
         if (item != null) item.reskin(flags);
       }
     }
   }
   super.reskinChildren(flags);
 }
 @Override
 protected Control createCustomArea(Composite parent) {
   if (pvMap == null || pvMap.size() == 0) return super.createCustomArea(parent);
   parent.setLayout(new FillLayout());
   TabFolder tabFolder = new TabFolder(parent, SWT.None);
   for (Entry<String, IPV> entry : pvMap.entrySet()) {
     TabItem tabItem = new TabItem(tabFolder, SWT.None);
     tabItem.setText(entry.getKey());
     Text text = new Text(tabFolder, SWT.MULTI | SWT.READ_ONLY);
     text.setText(getPVInfo(entry.getValue()));
     tabItem.setControl(text);
   }
   return tabFolder;
 }
Пример #16
0
 /**
  * Returns the tab item at the given point in the receiver or null if no such item exists. The
  * point is in the coordinate system of the receiver.
  *
  * @param point the point used to locate the item
  * @return the tab item at the given point, or null if the point is not in a tab item
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the point is null
  *     </ul>
  *
  * @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 3.4
  */
 public TabItem getItem(Point point) {
   checkWidget();
   if (point == null) error(SWT.ERROR_NULL_ARGUMENT);
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) return null;
   int itemCount = OS.g_list_length(list);
   OS.g_list_free(list);
   for (int i = 0; i < itemCount; i++) {
     TabItem item = items[i];
     Rectangle rect = item.getBounds();
     if (rect.contains(point)) return item;
   }
   return null;
 }
  /**
   * Create the animator area, where the animation is played and controlled.
   *
   * @param parent The composite parent.
   * @return The created composite.
   */
  private AnimationRenderer createAnimationRenderer(TabFolder parent) {
    final Composite content = new Composite(parent, SWT.NONE);
    content.setLayout(new GridLayout(1, false));
    content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Composite renderer = new Composite(content, SWT.BORDER | SWT.DOUBLE_BUFFERED);
    final AnimationRenderer animationRenderer = new AnimationRenderer(renderer, configurer);
    renderer.addPaintListener(animationRenderer);

    final TabItem animatorTab = new TabItem(parent, SWT.NONE);
    animatorTab.setText(Messages.AnimationEditor_Animator);
    animatorTab.setControl(content);

    return animationRenderer;
  }
Пример #18
0
  private void addNodesTab(final TabFolder tabFolder) {
    final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText("Nodes");

    final Composite container = new Composite(tabFolder, SWT.NONE);
    final GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    containerLayout.marginWidth = 0;
    containerLayout.marginHeight = 0;
    containerLayout.verticalSpacing = 3;

    tabItem.setControl(container);
    createNodeButtonsPanel(container);
    createNodesTable(container);
  }
Пример #19
0
  /**
   * Save this WaveTab´s audio data to the given file using the given AudioFileOutputStream
   *
   * @param f The file to save to (will be set as new source file)
   * @param out The AudioFileOutputStream to use for writing
   * @throws NotFinishedException If the save operation could not be completed
   * @throws NotReadyException If the audio data could not be provided
   */
  protected void saveFile(AudioInputStream in, File f, AudioFileOutputStream out)
      throws NotFinishedException, NotReadyException {
    if (!in.getFormat().equals(out.getFormat()))
      in = AudioSystem.getAudioInputStream(out.getFormat(), in);
    ProgressThread saver =
        new SaveFileThread(in, out, (int) in.getFrameLength(), in.getFormat().getFrameSize());
    ProgressMonitor progress =
        new ProgressMonitor(
            editor.getShell(), saver, "Saving Audio File...", "Saving " + f.getAbsolutePath());

    try {
      // Save Audio File
      progress.start();
    } catch (NotFinishedException e) {
      try {
        out.close();
      } catch (IOException e1) {
        e1.printStackTrace();
      }
      throw e;
    }

    try {
      out.close();
    } catch (IOException e1) {
      e1.printStackTrace();
      throw new NotFinishedException(e1.getMessage());
    }

    source = f;
    savePeak();
    tabItem.setText(source.getName());
    modified = false;
  }
  public void createControl(Composite parent) {
    Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new FillLayout());
    folder = new TabFolder(c, SWT.TOP);
    simpleItem = new TabItem(folder, SWT.NONE);
    simpleItem.setText(Messages.DefaultConnectionWizardPage_Simple);
    simpleItem.setControl(createSimpleConnectionPage(folder));

    advancedItem = new TabItem(folder, SWT.NONE);
    advancedItem.setText(Messages.DefaultConnectionWizardPage_Advanced);
    advancedItem.setControl(createAdvancedConnectionPage(folder));
    setControl(c);

    addListeners();
    validate();
  }
Пример #21
0
  private void addProcessesTab(final TabFolder tabFolder) {
    final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText("Processes");

    final Composite container = new Composite(tabFolder, SWT.NONE);
    final GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    containerLayout.marginWidth = 0;
    containerLayout.marginHeight = 0;
    containerLayout.makeColumnsEqualWidth = false;
    containerLayout.verticalSpacing = 3;

    tabItem.setControl(container);
    createProcessRadioButtons(container);
    createProcessControl(currentProcessMode, null, container);
  }
Пример #22
0
  @Override
  public void createContents(Composite parent, int style) {
    _panel = new Composite(parent, style);
    _panel.setLayout(new FillLayout());
    if (getRootGridData() != null) {
      _panel.setLayoutData(getRootGridData());
    }

    _tabFolder = new TabFolder(_panel, SWT.NONE);

    TabItem one = new TabItem(_tabFolder, SWT.NONE);
    one.setText("Consumer");
    one.setControl(getConsumerTabControl(_tabFolder));

    addTabs(_tabFolder);
  }
Пример #23
0
  protected void handleToolChanged() {
    try {
      // create dynamicTab
      loadDynamicArea();

      if (launchConfigurationWorkingCopy == null) {
        if (launchConfiguration.isWorkingCopy()) {
          launchConfigurationWorkingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration;
        } else {
          launchConfigurationWorkingCopy = launchConfiguration.getWorkingCopy();
        }
      }

      // setDefaults called on this tab so call on dynamicTab OR
      // user changed tool, not just restoring state
      if (initDefaults) {
        dynamicTab.setDefaults(launchConfigurationWorkingCopy);
      }
      initDefaults = false;
      dynamicTab.initializeFrom(launchConfigurationWorkingCopy);

      // change name of tool TabItem
      toolTab.setText(dynamicTab.getName());
      optionsFolder.layout(true);

      // adjust minimum size for ScrolledComposite
      recomputeSize();
    } catch (CoreException e) {
      ex = e;
    }
  }
 public static void sliderTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Sliders and Progress bars");
   tab.setToolTipText("Tied Slider to ProgressBar");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(2, true));
   final Slider slider = new Slider(composite, SWT.HORIZONTAL);
   final ProgressBar progress = new ProgressBar(composite, SWT.HORIZONTAL);
   slider.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           progress.setSelection(slider.getSelection());
         }
       });
   tab.setControl(composite);
 }
 public static void browserTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("A Browser");
   tab.setToolTipText("A Web browser");
   Browser browser = null;
   try {
     browser = new Browser(folder, SWT.NONE);
   } catch (SWTError e) {
     Label label = new Label(folder, SWT.BORDER);
     label.setText("Could not initialize browser");
     tab.setControl(label);
   }
   if (browser != null) {
     browser.setUrl("http://www.mindview.net");
     tab.setControl(browser);
   }
 }
 public static void directoryDialogTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Directory Dialog");
   tab.setToolTipText("Select a directory");
   final Button b = new Button(folder, SWT.PUSH);
   b.setText("Select a Directory");
   b.addListener(
       SWT.MouseDown,
       new Listener() {
         public void handleEvent(Event e) {
           DirectoryDialog dd = new DirectoryDialog(shell);
           String path = dd.open();
           if (path != null) b.setText(path);
         }
       });
   tab.setControl(b);
 }
 public static void buttonTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Buttons");
   tab.setToolTipText("Different kinds of Buttons");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(4, true));
   for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) {
     Button b = new Button(composite, SWT.ARROW | dir);
     b.addListener(SWT.MouseDown, listener);
   }
   newButton(composite, SWT.CHECK, "Check button");
   newButton(composite, SWT.PUSH, "Push button");
   newButton(composite, SWT.RADIO, "Radio button");
   newButton(composite, SWT.TOGGLE, "Toggle button");
   newButton(composite, SWT.FLAT, "Flat button");
   tab.setControl(composite);
 }
Пример #28
0
 /**
  * Set the source file for this WaveTab
  *
  * @param f The source file to set
  * @param waveForm The WaveForm corresponding to the file
  */
 protected void setInput(File f, AudioFileWaveForm waveForm) {
   tabItem.setText(f.getName());
   source = f;
   cutList.removeModificationListener(this);
   cutList = new CutList(new AudioFileSource(f, waveForm));
   cutList.addModificationListener(this);
   waveDisplay.redraw();
 }
Пример #29
0
  /** This method initializes tabFolder */
  private void createTabFolder() {
    tabFolder = new TabFolder(shell, SWT.NONE);

    createScanningTab();
    TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText(Labels.getLabel("title.preferences.scanning"));
    tabItem.setControl(scanningTab);
    scanningTabItem = tabItem;

    createPortsTab();
    tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText(Labels.getLabel("title.preferences.ports"));
    tabItem.setControl(portsTab);
    portsTabItem = tabItem;

    createDisplayTab();
    tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText(Labels.getLabel("title.preferences.display"));
    tabItem.setControl(displayTab);

    //		createFetchersTab();
    //		tabItem = new TabItem(tabFolder, SWT.NONE);
    //		tabItem.setText(Labels.getLabel("title.preferences.fetchers"));
    //		tabItem.setControl(fetchersTab);

    tabFolder.pack();
  }
  /**
   * Create the animation frame selector.
   *
   * @param parent The composite parent.
   * @return The created frame selector.
   */
  private AnimationFrameSelector createAnimationFrameSelector(TabFolder parent) {
    final Composite sheet = new Composite(parent, SWT.NONE);
    sheet.setLayout(new GridLayout(1, false));
    sheet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final TabItem sheetTab = new TabItem(parent, SWT.NONE);
    sheetTab.setText(Messages.AnimationEditor_Sheet);
    sheetTab.setControl(sheet);

    final Composite renderer = new Composite(sheet, SWT.BORDER | SWT.DOUBLE_BUFFERED);
    final AnimationFrameSelector animationFrameSelector =
        new AnimationFrameSelector(renderer, configurer);
    renderer.addPaintListener(animationFrameSelector);
    renderer.addMouseListener(animationFrameSelector);
    renderer.addMouseMoveListener(animationFrameSelector);

    return animationFrameSelector;
  }