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");
}
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());
}
}
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;
}
}
}
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);
}
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;
}
}
}
Aggregations