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); } }
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); }
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); }
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); }
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); }
/** * 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; }
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 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); }
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 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); } }
long /*int*/ gtk_switch_page(long /*int*/ widget, long /*int*/ page, long /*int*/ page_num) { int index = OS.gtk_notebook_get_current_page(handle); if (index != -1) { Control control = items[index].getControl(); if (control != null && !control.isDisposed()) { control.setVisible(false); } } TabItem item = items[(int) /*64*/ page_num]; Control control = item.getControl(); if (control != null && !control.isDisposed()) { control.setBounds(getClientArea()); control.setVisible(true); } Event event = new Event(); event.item = item; sendSelectionEvent(SWT.Selection, event, false); return 0; }
void createItem(TabItem item, int index) { long /*int*/ list = OS.gtk_container_get_children(handle); int itemCount = 0; if (list != 0) { itemCount = OS.g_list_length(list); OS.g_list_free(list); } if (!(0 <= index && index <= itemCount)) error(SWT.ERROR_INVALID_RANGE); if (itemCount == items.length) { TabItem[] newItems = new TabItem[items.length + 4]; System.arraycopy(items, 0, newItems, 0, items.length); items = newItems; } long /*int*/ boxHandle = gtk_box_new(OS.GTK_ORIENTATION_HORIZONTAL, false, 0); if (boxHandle == 0) error(SWT.ERROR_NO_HANDLES); long /*int*/ labelHandle = OS.gtk_label_new_with_mnemonic(null); if (labelHandle == 0) error(SWT.ERROR_NO_HANDLES); long /*int*/ imageHandle = OS.gtk_image_new(); if (imageHandle == 0) error(SWT.ERROR_NO_HANDLES); OS.gtk_container_add(boxHandle, imageHandle); OS.gtk_container_add(boxHandle, labelHandle); long /*int*/ pageHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0); if (pageHandle == 0) error(SWT.ERROR_NO_HANDLES); if (OS.GTK3) { OS.gtk_widget_override_background_color(pageHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA()); long /*int*/ region = OS.gdk_region_new(); OS.gtk_widget_input_shape_combine_region(pageHandle, region); OS.gdk_region_destroy(region); } OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE); OS.gtk_notebook_insert_page(handle, pageHandle, boxHandle, index); OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE); OS.gtk_widget_show(boxHandle); OS.gtk_widget_show(labelHandle); OS.gtk_widget_show(pageHandle); item.state |= HANDLE; item.handle = boxHandle; item.labelHandle = labelHandle; item.imageHandle = imageHandle; item.pageHandle = pageHandle; System.arraycopy(items, index, items, index + 1, itemCount++ - index); items[index] = item; if ((state & FOREGROUND) != 0) { item.setForegroundColor(getForegroundColor()); } if ((state & FONT) != 0) { item.setFontDescription(getFontDescription()); } if (itemCount == 1) { OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE); OS.gtk_notebook_set_current_page(handle, 0); OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE); Event event = new Event(); event.item = items[0]; sendSelectionEvent(SWT.Selection, event, false); // the widget could be destroyed at this point } }
/* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1); fNameText = SWTFactory.createSingleText(nameComp, 1); fNameText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String name = fNameText.getText().trim(); if (name.length() == 0) { setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7); } else { setErrorMessage(null); setMessage(PDEUIMessages.TargetDefinitionContentPage_2); } getTargetDefinition().setName(name); setPageComplete(isPageComplete()); } }); TabFolder tabs = new TabFolder(comp, SWT.NONE); tabs.setLayoutData(new GridData(GridData.FILL_BOTH)); tabs.setFont(comp.getFont()); fLocationTab = new TabItem(tabs, SWT.NONE); fLocationTab.setText(PDEUIMessages.LocationSection_0); Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); SWTFactory.createWrapLabel( pluginTabContainer, PDEUIMessages.TargetDefinitionContentPage_LocationDescription, 2, 400); fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer); fLocationTab.setControl(pluginTabContainer); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(pluginTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_LOCATIONS_TAB); TabItem contentTab = new TabItem(tabs, SWT.NONE); contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6); Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400); fContentTree = TargetContentsGroup.createInDialog(contentTabContainer); contentTab.setControl(contentTabContainer); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(contentTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_CONTENT_TAB); TabItem envTab = new TabItem(tabs, SWT.NONE); envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3); Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); createTargetEnvironmentGroup(envTabContainer); createJREGroup(envTabContainer); envTab.setControl(envTabContainer); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(envTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_ENVIRONMENT_TAB); TabItem argsTab = new TabItem(tabs, SWT.NONE); argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4); argsTab.setControl(createArgumentsGroup(tabs)); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(argsTab.getControl(), IHelpContextIds.EDIT_TARGET_WIZARD_ARGUMENT_TAB); TabItem depTab = new TabItem(tabs, SWT.NONE); depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5); depTab.setControl(createImplicitTabContents(tabs)); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(depTab.getControl(), IHelpContextIds.EDIT_TARGET_WIZARD_IMPLICIT_TAB); PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.EDIT_TARGET_WIZARD); initializeListeners(); targetChanged(getTargetDefinition()); setControl(comp); }