public static Text createTextArea(final Composite parent, final String text, final int height, final int width) { final Text textComponent = new Text(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); textComponent.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(width, height).create()); textComponent.setText(text); return textComponent; }
protected Text createText(final Composite parent, final int style) { final Text text = new Text(parent, style); text.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT) .align(GridData.FILL, GridData.BEGINNING).create()); return text; }
@Override protected Control createButtonBar(Composite pParent) { Control bar = super.createButtonBar(pParent); bar.setLayoutData(GridDataFactory.swtDefaults().hint(1, 1).create()); return bar; }
if (control instanceof Text) { GridDataFactory.fillDefaults() .hint(convertVerticalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .applyTo(control);
/** * @param control * the <code>Control</code> to lay out. * @since 3.0 */ protected void layoutTreeAreaControl(Control control) { GridDataFactory.fillDefaults().hint(getLastRightWidth(), convertVerticalDLUsToPixels(120)).grab(false, true) .applyTo(control); }
/** * @param control * the <code>Control</code> to lay out. * @since 3.0 */ protected void layoutTreeAreaControl(Control control) { GridDataFactory.fillDefaults().hint(getLastRightWidth(), convertVerticalDLUsToPixels(120)).grab(false, true) .applyTo(control); }
private void createWarningArea(Composite composite) { Composite warningArea = new Composite(composite, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).hint(100, SWT.DEFAULT) .applyTo(warningArea); warningArea.setLayout(new GridLayout(2, false)); Label warningImg = new Label(warningArea, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(warningImg); warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); Text warningLabel = new Text(warningArea, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); warningLabel.setBackground(composite.getBackground()); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).grab(true, false).applyTo(warningLabel); warningLabel.setText(Messages.MavenPomSelectionComponent_UnavailableRemoteRepositoriesIndexes); }
protected void addIconAndLabel(Composite parent, Image image, String text, boolean bold) { Label imageLabel = new Label(parent, SWT.NONE); imageLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); imageLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); imageLabel.setImage(image); Label textLabel = new Label(parent, SWT.WRAP); if (bold) { textLabel.setFont(CommonFonts.BOLD); } textLabel.setForeground(getTitleColor()); textLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); textLabel.setText(CommonUiUtil.toLabel(text)); int width = Math.min(textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, MAX_WIDTH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(width, SWT.DEFAULT).applyTo(textLabel); }
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80) .applyTo(fileArea); GridLayoutFactory.fillDefaults().applyTo(fileArea);
protected void addIconAndLabel(Composite parent, Image image, StyledString text) { Label imageLabel = new Label(parent, SWT.NONE); imageLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); imageLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); imageLabel.setImage(image); StyledText textLabel = new StyledText(parent, 0); textLabel.setText(text.getString()); textLabel.setStyleRanges(text.getStyleRanges()); // textLabel.setForeground(getTitleColor()); textLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); //textLabel.setText(""); int width = Math.min(textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, MAX_WIDTH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(width, SWT.DEFAULT).applyTo(textLabel); }
.align(SWT.FILL, SWT.BEGINNING) .grab(true, false) .hint( convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT).applyTo(messageLabel);
workspacePath.setSelection(workspacePath.getText().length()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .hint(convertHorizontalDLUsToPixels(200), SWT.DEFAULT).applyTo(workspacePath);
/** * Create fetch result table under given parent composite * * @param parent * @return main result table control */ public Control createFetchResultTable(Composite parent) { final FetchResultTable table = new FetchResultTable(parent); if (result.getFetchResult() != null) table.setData(localDb, result.getFetchResult()); final Control tableControl = table.getControl(); GridDataFactory.fillDefaults().grab(true, true).hint(600, 300) .applyTo(tableControl); return table.getControl(); }
.align(SWT.FILL, SWT.BEGINNING) .grab(true, false) .hint( convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT).applyTo(messageLabel);
title.setFont(getTitleFont()); GridDataFactory.createFrom((GridData)title.getLayoutData()) .hint(SWT.DEFAULT, SWT.DEFAULT) .minSize(CustomizePerspectiveDialog.MIN_TOOLTIP_WIDTH, 1) .applyTo(title);
branchTree.setContentProvider(new RepositoriesViewContentProvider()); GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo( tree); branchTree.addSelectionChangedListener(new ISelectionChangedListener() {
private void updateQuickAccessText() { if (txtQuickAccess == null || txtQuickAccess.isDisposed()) { return; } updateQuickAccessTriggerSequence(); if (triggerSequence != null) { txtQuickAccess.setToolTipText( NLS.bind(QuickAccessMessages.QuickAccess_TooltipDescription, triggerSequence.format())); } else { txtQuickAccess.setToolTipText(QuickAccessMessages.QuickAccess_TooltipDescription_Empty); } GC gc = new GC(txtQuickAccess); // workaround for Bug 491317 if (Util.isWin32() || Util.isGtk()) { FontMetrics fm = gc.getFontMetrics(); int wHint = QuickAccessMessages.QuickAccess_EnterSearch.length() * fm.getAverageCharWidth(); int hHint = fm.getHeight(); gc.dispose(); txtQuickAccess.setSize(txtQuickAccess.computeSize(wHint, hHint)); } else { Point p = gc.textExtent(QuickAccessMessages.QuickAccess_EnterSearch); Rectangle r = txtQuickAccess.computeTrim(0, 0, p.x, p.y); gc.dispose(); // computeTrim() may result in r.x < 0 GridDataFactory.fillDefaults().hint(r.width - r.x, SWT.DEFAULT).applyTo(txtQuickAccess); } txtQuickAccess.requestLayout(); }
private void createFilesArea(Composite parent, FormToolkit toolkit, int span) { diffSection = createSection(parent, toolkit, span); diffSection.setText(UIText.CommitEditorPage_SectionFilesEmpty); Composite filesArea = createSectionClient(diffSection, toolkit); diffViewer = new CommitFileDiffViewer(filesArea, getSite(), SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | toolkit.getBorderStyle()); diffViewer.getTable().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80) .applyTo(diffViewer.getControl()); diffViewer.setContentProvider(ArrayContentProvider.getInstance()); diffViewer.setTreeWalk(getCommit().getRepository(), null); updateSectionClient(diffSection, filesArea, toolkit); }
private void createBranchesArea(Composite parent, FormToolkit toolkit, int span) { branchSection = createSection(parent, toolkit, span); branchSection.setText(UIText.CommitEditorPage_SectionBranchesEmpty); Composite branchesArea = createSectionClient(branchSection, toolkit); branchViewer = new TableViewer(toolkit.createTable(branchesArea, SWT.V_SCROLL | SWT.H_SCROLL)); GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 50) .applyTo(branchViewer.getControl()); branchViewer.setSorter(new ViewerSorter()); branchViewer.setLabelProvider(new GitLabelProvider() { public String getText(Object element) { return Repository.shortenRefName(super.getText(element)); } }); branchViewer.setContentProvider(ArrayContentProvider.getInstance()); branchViewer.getTable().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); updateSectionClient(branchSection, branchesArea, toolkit); }
textContent.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 80).grab(true, true) .applyTo(textContent);