use of org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan in project linuxtools by eclipse.
the class RepositoryQuerySchemaPage method createFieldControls.
private void createFieldControls(Composite attributesComposite, FormToolkit toolkit, int columnCount, TaskAttribute target) {
int currentColumn = 1;
int currentPriority = 0;
int currentLayoutPriority = 0;
for (Field field : schema.getFields()) {
TaskAttribute dataAttribute = target.getAttribute(field.getKey());
AbstractAttributeEditor attributeEditor = factory.createEditor(field.getType(), dataAttribute);
editorMap.put(dataAttribute.getId(), attributeEditor);
String layoutPriorityString = dataAttribute.getMetaData().getValue("LayoutPriority");
int layoutPriority = layoutPriorityString == null ? -1 : Integer.parseInt(layoutPriorityString);
int priority = (attributeEditor.getLayoutHint() != null) ? attributeEditor.getLayoutHint().getPriority() : LayoutHint.DEFAULT_PRIORITY;
// TODO: copied from AbstractTaskEditorAttributeSection.createAttributeControls (only layoutPriority is new)
if (priority != currentPriority || currentLayoutPriority != layoutPriority) {
currentPriority = priority;
currentLayoutPriority = layoutPriority;
if (currentColumn > 1) {
while (currentColumn <= columnCount) {
// $NON-NLS-1$
Label l = toolkit.createLabel(attributesComposite, "");
GridData gd = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(0, SWT.DEFAULT).create();
l.setLayoutData(gd);
currentColumn++;
}
currentColumn = 1;
}
}
if (attributeEditor.hasLabel()) {
attributeEditor.createLabelControl(attributesComposite, toolkit);
Label label = attributeEditor.getLabelControl();
label.setBackground(attributesComposite.getBackground());
label.setForeground(attributesComposite.getForeground());
String text = label.getText();
String shortenText = TaskDiffUtil.shortenText(label, text, LABEL_WIDTH);
label.setText(shortenText);
if (!text.equals(shortenText)) {
label.setToolTipText(text);
}
GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).grab(true, true).hint(LABEL_WIDTH, SWT.DEFAULT).create();
if (currentColumn > 1) {
gd.horizontalIndent = COLUMN_GAP;
gd.widthHint = LABEL_WIDTH + COLUMN_GAP;
}
label.setLayoutData(gd);
currentColumn++;
}
attributeEditor.createControl(attributesComposite, toolkit);
attributeEditor.getControl().setBackground(attributesComposite.getParent().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
attributeEditor.getControl().setForeground(attributesComposite.getForeground());
LayoutHint layoutHint = attributeEditor.getLayoutHint();
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
RowSpan rowSpan = (layoutHint != null && layoutHint.rowSpan != null) ? layoutHint.rowSpan : RowSpan.SINGLE;
ColumnSpan columnSpan = (layoutHint != null && layoutHint.columnSpan != null) ? layoutHint.columnSpan : ColumnSpan.SINGLE;
// prevent clipping of decorators on Windows
gd.horizontalIndent = 1;
if (rowSpan == RowSpan.SINGLE && columnSpan == ColumnSpan.SINGLE) {
gd.widthHint = COLUMN_WIDTH;
gd.horizontalSpan = 1;
} else {
if (rowSpan == RowSpan.MULTIPLE) {
gd.heightHint = MULTI_ROW_HEIGHT;
}
if (columnSpan == ColumnSpan.SINGLE) {
gd.widthHint = COLUMN_WIDTH;
gd.horizontalSpan = 1;
} else {
gd.widthHint = MULTI_COLUMN_WIDTH;
gd.horizontalSpan = columnCount - currentColumn + 1;
}
}
attributeEditor.getControl().setLayoutData(gd);
currentColumn += gd.horizontalSpan;
currentColumn %= columnCount;
}
}
use of org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan in project linuxtools by eclipse.
the class OSIORestTaskEditorAttributePart method createAttributeControls.
private void createAttributeControls(Composite attributesComposite, FormToolkit toolkit, int columnCount) {
int currentColumn = 1;
int currentPriority = 0;
for (AbstractAttributeEditor attributeEditor : attributeEditors) {
int priority = (attributeEditor.getLayoutHint() != null) ? attributeEditor.getLayoutHint().getPriority() : LayoutHint.DEFAULT_PRIORITY;
if (priority != currentPriority) {
currentPriority = priority;
if (currentColumn > 1) {
while (currentColumn <= columnCount) {
// $NON-NLS-1$
getManagedForm().getToolkit().createLabel(attributesComposite, "");
currentColumn++;
}
currentColumn = 1;
}
}
if (attributeEditor.hasLabel()) {
attributeEditor.createLabelControl(attributesComposite, toolkit);
Label label = attributeEditor.getLabelControl();
String text = label.getText();
String shortenText = TaskDiffUtil.shortenText(label, text, LABEL_WIDTH);
label.setText(shortenText);
if (!text.equals(shortenText)) {
label.setToolTipText(text);
}
GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(LABEL_WIDTH, SWT.DEFAULT).create();
if (currentColumn > 1) {
gd.horizontalIndent = COLUMN_GAP;
gd.widthHint = LABEL_WIDTH + COLUMN_GAP;
}
label.setLayoutData(gd);
currentColumn++;
}
attributeEditor.createControl(attributesComposite, toolkit);
LayoutHint layoutHint = attributeEditor.getLayoutHint();
GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
RowSpan rowSpan = (layoutHint != null && layoutHint.rowSpan != null) ? layoutHint.rowSpan : RowSpan.SINGLE;
ColumnSpan columnSpan = (layoutHint != null && layoutHint.columnSpan != null) ? layoutHint.columnSpan : ColumnSpan.SINGLE;
// prevent clipping of decorators on Windows
gd.horizontalIndent = 1;
if (rowSpan == RowSpan.SINGLE && columnSpan == ColumnSpan.SINGLE) {
gd.widthHint = COLUMN_WIDTH;
gd.horizontalSpan = 1;
} else {
if (rowSpan == RowSpan.MULTIPLE) {
gd.heightHint = MULTI_ROW_HEIGHT;
}
if (columnSpan == ColumnSpan.SINGLE) {
gd.widthHint = COLUMN_WIDTH;
gd.horizontalSpan = 1;
} else {
gd.widthHint = MULTI_COLUMN_WIDTH;
gd.horizontalSpan = columnCount - currentColumn + 1;
}
}
attributeEditor.getControl().setLayoutData(gd);
getTaskEditorPage().getAttributeEditorToolkit().adapt(attributeEditor);
currentColumn += gd.horizontalSpan;
currentColumn %= columnCount;
}
}
Aggregations