Search in sources :

Example 1 with EJDevMainScreenItemDisplayProperties

use of org.entirej.framework.dev.properties.interfaces.EJDevMainScreenItemDisplayProperties in project rap by entirej.

the class EJRWTTreeTableRecordBlockDefinition method addTreeTable.

private EJRWTTreeRendererDefinitionControl addTreeTable(EJDevBlockDisplayProperties blockDisplayProperties, Composite client, FormToolkit toolkit) {
    Map<String, Integer> columnPositions = new HashMap<String, Integer>();
    final ScrolledForm sc = toolkit.createScrolledForm(client);
    GridData scgd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    scgd.grabExcessHorizontalSpace = true;
    scgd.grabExcessVerticalSpace = true;
    sc.setLayoutData(scgd);
    GridLayout gl = new GridLayout();
    gl.marginHeight = gl.marginWidth = 0;
    sc.getBody().setLayout(gl);
    toolkit.adapt(sc);
    sc.getBody().setLayout(new FillLayout());
    Composite tablePanel = sc.getBody();
    EJDevItemGroupDisplayProperties displayProperties = null;
    if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
        displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
        if (displayProperties.dispayGroupFrame()) {
            Group group = new Group(tablePanel, SWT.NONE);
            group.setLayout(new FillLayout());
            if (displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0)
                group.setText(displayProperties.getFrameTitle());
            tablePanel = group;
        }
    }
    Tree table = new Tree(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    // There is only one item group for a flow layout
    TreeViewer _tableViewer = new TreeViewer(table);
    _tableViewer.setContentProvider(new ITreeContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // TODO Auto-generated method stub
        }

        @Override
        public void dispose() {
        // TODO Auto-generated method stub
        }

        @Override
        public boolean hasChildren(Object element) {
            return true;
        }

        @Override
        public Object getParent(Object element) {
            return null;
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return new Object[] { new Object(), new Object(), new Object() };
        }

        @Override
        public Object[] getChildren(Object parentElement) {
            return new Object[] { new Object(), new Object() };
        }
    });
    int itemCount = 0;
    if (displayProperties != null)
        for (final EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
            if (!screenItem.isSpacerItem()) {
                int width = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
                TreeViewerColumn masterColumn = new TreeViewerColumn(_tableViewer, SWT.NONE);
                masterColumn.getColumn().setData("SCREEN_ITEM", screenItem);
                masterColumn.getColumn().setText(screenItem.getLabel());
                masterColumn.getColumn().setWidth(width);
                String alignment = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
                if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_RIGHT.equals(alignment)) {
                    masterColumn.getColumn().setAlignment(SWT.RIGHT);
                } else if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_CENTER.equals(alignment)) {
                    masterColumn.getColumn().setAlignment(SWT.CENTER);
                }
                masterColumn.setLabelProvider(new ColumnLabelProvider() {

                    @Override
                    public String getText(Object element) {
                        return screenItem.getReferencedItemName();
                    }
                });
                ColumnWeightData colData = new ColumnWeightData(5, 50, true);
                tableLayout.addColumnData(colData);
                columnPositions.put(screenItem.getReferencedItemName(), itemCount);
                itemCount++;
            }
        }
    table.setLayout(tableLayout);
    _tableViewer.setInput(new Object());
    return new EJRWTTreeRendererDefinitionControl(blockDisplayProperties, table, columnPositions);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) EJDevScreenItemDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties) HashMap(java.util.HashMap) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) EJDevMainScreenItemDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevMainScreenItemDisplayProperties) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout) EJDevItemGroupDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevItemGroupDisplayProperties) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FillLayout(org.eclipse.swt.layout.FillLayout) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData)

Example 2 with EJDevMainScreenItemDisplayProperties

use of org.entirej.framework.dev.properties.interfaces.EJDevMainScreenItemDisplayProperties in project rap by entirej.

the class EJRWTMultiRecordBlockDefinition method addTable.

private EJRWTTableRendererDefinitionControl addTable(EJDevBlockDisplayProperties blockDisplayProperties, Composite client, FormToolkit toolkit) {
    Map<String, Integer> columnPositions = new HashMap<String, Integer>();
    final ScrolledForm sc = toolkit.createScrolledForm(client);
    GridData scgd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    scgd.grabExcessHorizontalSpace = true;
    scgd.grabExcessVerticalSpace = true;
    sc.setLayoutData(scgd);
    GridLayout gl = new GridLayout();
    gl.marginHeight = gl.marginWidth = 0;
    sc.getBody().setLayout(gl);
    toolkit.adapt(sc);
    sc.getBody().setLayout(new FillLayout());
    Composite tablePanel = sc.getBody();
    EJDevItemGroupDisplayProperties displayProperties = null;
    if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
        displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
        if (displayProperties.dispayGroupFrame()) {
            Group group = new Group(tablePanel, SWT.NONE);
            group.setLayout(new FillLayout());
            if (displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0)
                group.setText(displayProperties.getFrameTitle());
            tablePanel = group;
        }
    }
    Table table = new Table(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    // There is only one item group for a flow layout
    int itemCount = 0;
    if (displayProperties != null)
        for (EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
            if (!screenItem.isSpacerItem()) {
                int width = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
                TableColumn masterColumn = new TableColumn(table, SWT.NONE);
                masterColumn.setData("SCREEN_ITEM", screenItem);
                masterColumn.setText(screenItem.getLabel());
                masterColumn.setWidth(width);
                String alignment = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
                if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_RIGHT.equals(alignment)) {
                    masterColumn.setAlignment(SWT.RIGHT);
                } else if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_CENTER.equals(alignment)) {
                    masterColumn.setAlignment(SWT.CENTER);
                }
                ColumnWeightData colData = new ColumnWeightData(5, 50, true);
                tableLayout.addColumnData(colData);
                columnPositions.put(screenItem.getReferencedItemName(), itemCount);
                itemCount++;
            }
        }
    table.setLayout(tableLayout);
    return new EJRWTTableRendererDefinitionControl(blockDisplayProperties, table, columnPositions);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) EJDevItemGroupDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevItemGroupDisplayProperties) EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) EJDevScreenItemDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HashMap(java.util.HashMap) FillLayout(org.eclipse.swt.layout.FillLayout) EJDevMainScreenItemDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevMainScreenItemDisplayProperties) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

HashMap (java.util.HashMap)2 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)2 TableLayout (org.eclipse.jface.viewers.TableLayout)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)2 EJPropertyDefinitionGroup (org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup)2 EJDevPropertyDefinitionGroup (org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup)2 EJDevItemGroupDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevItemGroupDisplayProperties)2 EJDevMainScreenItemDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevMainScreenItemDisplayProperties)2 EJDevScreenItemDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)1 Viewer (org.eclipse.jface.viewers.Viewer)1