Search in sources :

Example 6 with Layout

use of org.eclipse.swt.widgets.Layout in project mylyn.docs by eclipse.

the class EditorPreferencePage method createFieldEditors.

/**
 * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various
 * types of preferences. Each field editor knows how to save and restore itself.
 */
@Override
public void createFieldEditors() {
    Preferences prefs = new Preferences();
    Layout fieldEditorParentLayout = getFieldEditorParent().getLayout();
    if (fieldEditorParentLayout instanceof GridLayout) {
        GridLayout layout = (GridLayout) fieldEditorParentLayout;
        layout.marginRight = 5;
    }
    Group blockGroup = new Group(getFieldEditorParent(), SWT.NULL);
    blockGroup.setText(Messages.EditorPreferencePage_blockModifiers);
    blockGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    CssStyleManager cssStyleManager = new CssStyleManager(getFont());
    for (Map.Entry<String, String> ent : prefs.getCssByBlockModifierType().entrySet()) {
        String preferenceKey = Preferences.toPreferenceKey(ent.getKey(), true);
        addField(new CssStyleFieldEditor(cssStyleManager, preferenceKey, ent.getKey(), blockGroup));
    }
    // bug 260427
    Layout layout = blockGroup.getLayout();
    if (layout instanceof GridLayout) {
        GridLayout gridLayout = (GridLayout) layout;
        gridLayout.marginWidth = 5;
        gridLayout.marginHeight = 5;
    }
    Group phraseModifierGroup = new Group(getFieldEditorParent(), SWT.NULL);
    phraseModifierGroup.setText(Messages.EditorPreferencePage_phraseModifiers);
    phraseModifierGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    for (Map.Entry<String, String> ent : prefs.getCssByPhraseModifierType().entrySet()) {
        String preferenceKey = Preferences.toPreferenceKey(ent.getKey(), false);
        addField(new CssStyleFieldEditor(cssStyleManager, preferenceKey, ent.getKey(), phraseModifierGroup));
    }
    // bug 260427
    layout = phraseModifierGroup.getLayout();
    if (layout instanceof GridLayout) {
        GridLayout gridLayout = (GridLayout) layout;
        gridLayout.marginWidth = 5;
        gridLayout.marginHeight = 5;
    }
    applyDialogFont(getFieldEditorParent());
    blockGroup.setFont(getFieldEditorParent().getFont());
    phraseModifierGroup.setFont(getFieldEditorParent().getFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), // $NON-NLS-1$
    "org.eclipse.mylyn.wikitext.help.ui.preferences");
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Layout(org.eclipse.swt.widgets.Layout) GridLayout(org.eclipse.swt.layout.GridLayout) Map(java.util.Map) CssStyleManager(org.eclipse.mylyn.internal.wikitext.ui.viewer.CssStyleManager)

Example 7 with Layout

use of org.eclipse.swt.widgets.Layout in project egit by eclipse.

the class SpellcheckableMessageArea method configureHardWrap.

private void configureHardWrap() {
    if (shouldHardWrap()) {
        if (hardWrapSegmentListener == null) {
            final StyledText textWidget = getTextWidget();
            hardWrapSegmentListener = new BidiSegmentListener() {

                @Override
                public void lineGetSegments(BidiSegmentEvent e) {
                    if (e.widget == textWidget) {
                        int footerOffset = CommonUtils.getFooterOffset(textWidget.getText());
                        if (footerOffset >= 0 && e.lineOffset >= footerOffset) {
                            return;
                        }
                    }
                    int[] segments = calculateWrapOffsets(e.lineText, MAX_LINE_WIDTH);
                    if (segments != null) {
                        char[] segmentsChars = new char[segments.length];
                        Arrays.fill(segmentsChars, '\n');
                        e.segments = segments;
                        e.segmentsChars = segmentsChars;
                    }
                }
            };
            textWidget.addBidiSegmentListener(hardWrapSegmentListener);
            // XXX: workaround for https://bugs.eclipse.org/384886
            textWidget.setText(textWidget.getText());
            if (brokenBidiPlatformTextWidth != -1) {
                Layout restrictedWidthLayout = new Layout() {

                    @Override
                    protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
                        Point size = SpellcheckableMessageArea.this.getSize();
                        Rectangle trim = SpellcheckableMessageArea.this.computeTrim(0, 0, 0, 0);
                        size.x -= trim.width;
                        size.y -= trim.height;
                        if (size.x > brokenBidiPlatformTextWidth)
                            size.x = brokenBidiPlatformTextWidth;
                        return size;
                    }

                    @Override
                    protected void layout(Composite composite, boolean flushCache) {
                        Point size = computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache);
                        textWidget.setBounds(0, 0, size.x, size.y);
                    }
                };
                setLayout(restrictedWidthLayout);
            }
        }
    } else if (hardWrapSegmentListener != null) {
        StyledText textWidget = getTextWidget();
        textWidget.removeBidiSegmentListener(hardWrapSegmentListener);
        // XXX: workaround for https://bugs.eclipse.org/384886
        textWidget.setText(textWidget.getText());
        hardWrapSegmentListener = null;
        if (brokenBidiPlatformTextWidth != -1)
            setLayout(new FillLayout());
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) BidiSegmentEvent(org.eclipse.swt.custom.BidiSegmentEvent) FillLayout(org.eclipse.swt.layout.FillLayout) Layout(org.eclipse.swt.widgets.Layout) BidiSegmentListener(org.eclipse.swt.custom.BidiSegmentListener) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 8 with Layout

use of org.eclipse.swt.widgets.Layout in project dbeaver by serge-rider.

the class MultiPageAbstractEditor method setContainerStyles.

protected void setContainerStyles() {
    Composite pageContainer = getContainer();
    if (pageContainer instanceof CTabFolder && !pageContainer.isDisposed()) {
        CTabFolder tabFolder = (CTabFolder) pageContainer;
        tabFolder.setSimple(true);
        tabFolder.setMRUVisible(true);
        tabFolder.setTabPosition(SWT.TOP);
        Control topRight = createTopRightControl(tabFolder);
        if (topRight != null) {
            Point trSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            tabFolder.setTabHeight(trSize.y);
            tabFolder.setTopRight(topRight, SWT.RIGHT | SWT.WRAP);
        }
        // tabFolder.setSimple(false);
        // tabFolder.setBorderVisible(true);
        Layout parentLayout = tabFolder.getParent().getLayout();
        if (parentLayout instanceof FillLayout) {
            ((FillLayout) parentLayout).marginHeight = 0;
        // ((FillLayout)parentLayout).marginWidth = 5;
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Layout(org.eclipse.swt.widgets.Layout) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 9 with Layout

use of org.eclipse.swt.widgets.Layout in project hale by halestudio.

the class DefinitionInstanceTreeViewer method setInput.

/**
 * @see InstanceViewer#setInput(TypeDefinition, Iterable)
 */
@Override
public void setInput(TypeDefinition type, Iterable<Instance> instances) {
    // remove old columns
    TreeColumn[] columns = treeViewer.getTree().getColumns();
    if (columns != null) {
        for (TreeColumn column : columns) {
            column.dispose();
        }
        labelProviders.clear();
    }
    // set input
    if (type != null) {
        // pass metadatas to the treeviewer, if instances contain metadatas
        Set<String> completeMetaNames = new HashSet<String>();
        for (Instance inst : instances) {
            for (String name : inst.getMetaDataNames()) {
                completeMetaNames.add(name);
            }
        }
        Pair<TypeDefinition, Set<String>> pair = new Pair<TypeDefinition, Set<String>>(type, completeMetaNames);
        treeViewer.setInput(pair);
    } else
        treeViewer.setInput(Collections.emptySet());
    Layout layout = treeViewer.getTree().getParent().getLayout();
    // add type column
    if (type != null) {
        TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.LEFT);
        column.getColumn().setText(type.getDisplayName());
        column.setLabelProvider(new TreeColumnViewerLabelProvider(new DefinitionMetaCompareLabelProvider(treeViewer)));
        if (layout instanceof TreeColumnLayout) {
            ((TreeColumnLayout) layout).setColumnData(column.getColumn(), new ColumnWeightData(1));
        }
    }
    // add columns for features
    int index = 1;
    if (instances != null) {
        // // sort features
        // List<Feature> sortedFeatures = new ArrayList<Feature>();
        // for (Feature f : features) {
        // sortedFeatures.add(f);
        // }
        // Collections.sort(sortedFeatures, new Comparator<Feature>() {
        // 
        // @Override
        // public int compare(Feature o1, Feature o2) {
        // FeatureId id1 = FeatureBuilder.getSourceID(o1);
        // if (id1 == null) {
        // id1 = o1.getIdentifier();
        // }
        // 
        // FeatureId id2 = FeatureBuilder.getSourceID(o2);
        // if (id2 == null) {
        // id2 = o2.getIdentifier();
        // }
        // 
        // return id1.getID().compareTo(id2.getID());
        // }
        // 
        // });
        List<Instance> insts = new ArrayList<Instance>();
        for (Instance instance : instances) {
            // sortedFeatures) {
            final TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.LEFT);
            // FeatureId id = FeatureBuilder.getSourceID(feature);
            // if (id == null) {
            // id = feature.getIdentifier();
            // }
            // column.getColumn().setText(id.toString());
            // XXX
            column.getColumn().setText(String.valueOf(index));
            // identifier?
            DefinitionInstanceLabelProvider labelProvider = new DefinitionInstanceLabelProvider(instance);
            labelProviders.put(index, labelProvider);
            column.setLabelProvider(labelProvider);
            if (layout instanceof TreeColumnLayout) {
                ((TreeColumnLayout) layout).setColumnData(column.getColumn(), new ColumnWeightData(1));
            }
            // add tool tip
            // new ColumnBrowserTip(treeViewer, 400, 300, true, index, null);
            insts.add(instance);
            index++;
        }
        ((MetadataCompareActionProvider) maep).setInput(insts, labelProviders);
    }
    treeViewer.refresh();
    treeViewer.getTree().getParent().layout(true, true);
    selectionProvider.updateSelection(instances);
    // auto-expand attributes/metadata
    treeViewer.expandToLevel(2);
}
Also used : TreeColumnViewerLabelProvider(org.eclipse.jface.viewers.TreeColumnViewerLabelProvider) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Set(java.util.Set) HashSet(java.util.HashSet) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) Layout(org.eclipse.swt.widgets.Layout) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) HashSet(java.util.HashSet) Pair(eu.esdihumboldt.util.Pair)

Example 10 with Layout

use of org.eclipse.swt.widgets.Layout in project dbeaver by dbeaver.

the class MultiPageAbstractEditor method setContainerStyles.

protected void setContainerStyles() {
    Composite pageContainer = getContainer();
    if (pageContainer instanceof CTabFolder && !pageContainer.isDisposed()) {
        CTabFolder tabFolder = (CTabFolder) pageContainer;
        tabFolder.setSimple(true);
        tabFolder.setMRUVisible(true);
        tabFolder.setTabPosition(SWT.TOP);
        Control topRight = createTopRightControl(tabFolder);
        if (topRight != null) {
            Point trSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            tabFolder.setTabHeight(trSize.y);
            tabFolder.setTopRight(topRight, SWT.RIGHT | SWT.WRAP);
        }
        // tabFolder.setSimple(false);
        // tabFolder.setBorderVisible(true);
        Layout parentLayout = tabFolder.getParent().getLayout();
        if (parentLayout instanceof FillLayout) {
            ((FillLayout) parentLayout).marginHeight = 0;
        // ((FillLayout)parentLayout).marginWidth = 5;
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Layout(org.eclipse.swt.widgets.Layout) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

Layout (org.eclipse.swt.widgets.Layout)18 GridLayout (org.eclipse.swt.layout.GridLayout)10 Composite (org.eclipse.swt.widgets.Composite)10 GridData (org.eclipse.swt.layout.GridData)8 Point (org.eclipse.swt.graphics.Point)7 FillLayout (org.eclipse.swt.layout.FillLayout)4 Control (org.eclipse.swt.widgets.Control)4 CTabFolder (org.eclipse.swt.custom.CTabFolder)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 FormLayout (org.eclipse.swt.layout.FormLayout)3 Button (org.eclipse.swt.widgets.Button)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 ArrayList (java.util.ArrayList)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 StyledText (org.eclipse.swt.custom.StyledText)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Color (org.eclipse.swt.graphics.Color)2 Display (org.eclipse.swt.widgets.Display)2