| Summary: | Default column width for template preference is too small | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Samantha Chan <chanskw> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jan, mkomor, sebastian.zarnekow, sven.efftinge |
| Version: | 1.0.1 | Flags: | sven.efftinge:
indigo+
|
| Target Milestone: | SR1 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Samantha Chan
We would like to ask for this to be considered for 2.0 SR1. Unfortunately, JFace does not export the essential parts it uses to do the layouting. The column width is determined in the superclass
org.eclipse.ui.texteditor.templates.TemplatePreferencePage.createContents(Composite)
but neither the used ColumnLayout nor the method
org.eclipse.ui.texteditor.templates.TemplatePreferencePage.computeMinimumColumnWidth(GC, String)
is exported. Furthermore, the minimum width depends on the width of the column title only.
You can override createContents in a customized implementation of the XtextTemplatePreferencePage/AdvancedTemplatePreferencePage and use another layout, similar to this snippet:
@Override
protected Control createContents(Composite ancestor) {
Control contents = super.createContents(ancestor);
Table table = getTableViewer().getTable();
Composite tableComposite = table.getParent();
TableColumnLayout tableColumnLayout = new TableColumnLayout();
tableColumnLayout.setColumnData(table.getColumn(0), new ColumnWeightData(2, 10, true));
tableColumnLayout.setColumnData(table.getColumn(1), new ColumnWeightData(1, 10, true));
tableColumnLayout.setColumnData(table.getColumn(2), new ColumnWeightData(1, 10, true));
tableColumnLayout.setColumnData(table.getColumn(3), new ColumnPixelData(10, true));
tableComposite.setLayout(tableColumnLayout);
return contents;
}
This will give the first column more "weight".
As this looks more like hack, I'd rather not apply that to the Xtext codebase, but still you can try the workaround given above.
I found the template page looking nicely with
@Override
protected Control createContents(Composite ancestor) {
Control result = super.createContents(ancestor);
ancestor.layout();
return result;
}
@Override
public void createControl(Composite parent) {
super.createControl(parent);
getTableViewer().getTable().getColumns()[0].pack();
}
Pushed to master.
Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |