/** * 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; }
public void showAttributes(Composite parent) { composite = new Splitter(parent, SWT.HORIZONTAL); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 1; composite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); composite.setLayoutData(data); tabs = new TabFolder(composite, SWT.TOP); tabs.setLayoutData(data); general = new TabItem(tabs, SWT.NONE); general.setText(DropWizardMessages.General_Tab_Title); Composite generalTabContent = new Composite(tabs, SWT.NONE); general.setControl(fillGeneralOption(generalTabContent)); TabItem advanced = new TabItem(tabs, SWT.NONE); advanced.setText(DropWizardMessages.Advanced_Tab_Title); TagAttributesComposite advancedTabContent = new TagAttributesComposite(tabs, SWT.NONE, getSpecificWizard().getWizardModel(), context); advanced.setControl(advancedTabContent); tabs.addSelectionListener(advancedTabContent); setControl(composite); getSpecificWizard() .getWizardModel() .addPropertyChangeListener(IDropWizardModel.TAG_PROPOSAL, this); updateTitle(); runValidation(); }
/* (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); }