Search in sources :

Example 1 with AbstractAttributeEditor

use of org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor 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;
    }
}
Also used : Field(org.eclipse.linuxtools.internal.mylyn.osio.rest.ui.provisional.AbstractQueryPageSchema.Field) TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) ColumnSpan(org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan) AbstractAttributeEditor(org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) LayoutHint(org.eclipse.mylyn.tasks.ui.editors.LayoutHint) RowSpan(org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan) Point(org.eclipse.swt.graphics.Point) LayoutHint(org.eclipse.mylyn.tasks.ui.editors.LayoutHint)

Example 2 with AbstractAttributeEditor

use of org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor 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;
    }
}
Also used : ColumnSpan(org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan) AbstractAttributeEditor(org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) LayoutHint(org.eclipse.mylyn.tasks.ui.editors.LayoutHint) RowSpan(org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan) LayoutHint(org.eclipse.mylyn.tasks.ui.editors.LayoutHint)

Example 3 with AbstractAttributeEditor

use of org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor in project linuxtools by eclipse.

the class OSIORestTaskEditorAttributePart method initialize.

private void initialize() {
    attributeEditors = new ArrayList<AbstractAttributeEditor>();
    hasIncoming = false;
    Collection<TaskAttribute> attributes = getAttributes();
    for (TaskAttribute attribute : attributes) {
        AbstractAttributeEditor attributeEditor = createAttributeEditor(attribute);
        if (attributeEditor != null) {
            attributeEditors.add(attributeEditor);
            if (getModel().hasIncomingChanges(attribute)) {
                hasIncoming = true;
            }
        }
    }
    Comparator<AbstractAttributeEditor> attributeSorter = createAttributeEditorSorter();
    if (attributeSorter != null) {
        Collections.sort(attributeEditors, attributeSorter);
    }
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) AbstractAttributeEditor(org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor)

Example 4 with AbstractAttributeEditor

use of org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor in project linuxtools by eclipse.

the class OSIORestSearchQueryPage method doRefreshControls.

@Override
protected void doRefreshControls() {
    try {
        OSIORestConnector connectorREST = (OSIORestConnector) getConnector();
        connectorREST.getRepositoryConfiguration(getTaskRepository()).updateSpaceOptions(getTargetTaskData());
        for (Entry<String, AbstractAttributeEditor> entry : editorMap.entrySet()) {
            entry.getValue().refresh();
        }
    } catch (CoreException e) {
        StatusHandler.log(new Status(IStatus.ERROR, OSIORestUIPlugin.PLUGIN_ID, "OSIORestSearchQueryPage could not refresh!", // $NON-NLS-1$
        e));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) AbstractAttributeEditor(org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor) CoreException(org.eclipse.core.runtime.CoreException) OSIORestConnector(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConnector)

Aggregations

AbstractAttributeEditor (org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor)4 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)2 LayoutHint (org.eclipse.mylyn.tasks.ui.editors.LayoutHint)2 ColumnSpan (org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan)2 RowSpan (org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan)2 GridData (org.eclipse.swt.layout.GridData)2 Label (org.eclipse.swt.widgets.Label)2 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 OSIORestConnector (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConnector)1 Field (org.eclipse.linuxtools.internal.mylyn.osio.rest.ui.provisional.AbstractQueryPageSchema.Field)1 Point (org.eclipse.swt.graphics.Point)1