Search in sources :

Example 16 with EJItemGroupProperties

use of org.entirej.framework.core.properties.interfaces.EJItemGroupProperties in project rap by entirej.

the class EJRWTStandardLovRenderer method buildGui.

protected void buildGui() {
    int width = _lovController.getDefinitionProperties().getWidth();
    int height = _lovController.getDefinitionProperties().getHeight();
    _dialog = new EJRWTAbstractDialog(getRWTManager().getShell()) {

        private static final long serialVersionUID = -4685316941898120169L;

        private EJRWTAbstractFilteredTable filterTree;

        private String defaultMessage;

        @Override
        public boolean close() {
            _tableViewer = null;
            _dialog = null;
            return super.close();
        }

        @Override
        public void activateDialog() {
            super.activateDialog();
            filterTree.getFilterControl().forceFocus();
        }

        @Override
        public void createBody(Composite parent) {
            GridLayout layout = new GridLayout();
            EJ_RWT.setTestId(parent, "lov." + _lovController.getProperties().getLovDefinition().getName());
            layout.marginWidth = 0;
            // layout.horizontalSpacing = 0;
            layout.marginLeft = 0;
            layout.marginRight = 0;
            layout.marginHeight = 0;
            // layout.verticalSpacing = 0;
            layout.marginBottom = 0;
            layout.marginTop = 0;
            parent.setLayout(layout);
            int style = SWT.VIRTUAL;
            EJFrameworkExtensionProperties rendererProp = _lovController.getDefinitionProperties().getLovRendererProperties();
            if (!rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.HIDE_TABLE_BORDER, false)) {
                style = style | SWT.BORDER;
            }
            defaultMessage = rendererProp.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
            ;
            Table table;
            filterTree = new EJRWTAbstractFilteredTable(parent, style) {

                @Override
                public void filter(String filter) {
                    if (_filteredContentProvider != null && (filter == null && _filteredContentProvider.getFilter() != null || !filter.equals(_filteredContentProvider.getFilter()))) {
                        _filteredContentProvider.setFilter(filter);
                        getViewer().setInput(filter);
                        getViewer().getTable().select(0);
                    }
                }

                @Override
                protected boolean doCreateCustomComponents(Composite parent) {
                    return createToolbar(parent) != null;
                }

                @Override
                protected TableViewer doCreateTableViewer(Composite parent, int style) {
                    _tableViewer = new TableViewer(new Table(parent, style));
                    return _tableViewer;
                }
            };
            if (defaultMessage != null)
                filterTree.getFilterControl().setMessage(defaultMessage);
            EJ_RWT.setTestId(filterTree.getFilterControl(), "lov-search");
            table = (_tableViewer = filterTree.getViewer()).getTable();
            table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
            table.setLinesVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_VERTICAL_LINES, true));
            table.setHeaderVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true));
            EJRWTTableViewerColumnFactory factory = new EJRWTTableViewerColumnFactory(_tableViewer);
            ColumnViewerToolTipSupport.enableFor(_tableViewer);
            Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
            final List<ColumnLabelProvider> nodeTextProviders = new ArrayList<ColumnLabelProvider>();
            for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
                Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
                for (EJScreenItemProperties screenItemProperties : itemProperties) {
                    EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
                    ColumnLabelProvider screenItem = createScreenItem(factory, mainScreenItemProperties);
                    if (screenItem != null) {
                        nodeTextProviders.add(screenItem);
                    }
                }
            }
            final EJBlockController blockController = _block.getBlockController();
            // _mainPane.addControlListener(new
            // TableAutoResizeAdapter(table));
            /*
                 * _tableViewer.setContentProvider(new ILazyContentProvider() {
                 * 
                 * @Override public void inputChanged(Viewer arg0, Object arg1,
                 * Object arg2) {
                 * _tableViewer.setItemCount(blockController.getDataBlock().
                 * getBlockRecordCount());
                 * 
                 * }
                 * 
                 * @Override public void dispose() { // TODO Auto-generated
                 * method stub
                 * 
                 * }
                 * 
                 * @Override public void updateElement(int index) { EJDataRecord
                 * record = null; if (index <=
                 * blockController.getDataBlock().getBlockRecordCount()) {
                 * record = blockController.getDataBlock().getRecord(index);
                 * 
                 * } _tableViewer.replace(record, index);
                 * 
                 * } });
                 */
            _tableViewer.setContentProvider(_filteredContentProvider = new FilteredContentProvider() {

                private static final long serialVersionUID = 7262009393527533868L;

                boolean matchItem(EJDataRecord rec) {
                    if (filter != null && filter.trim().length() > 0) {
                        for (ColumnLabelProvider filterTextProvider : nodeTextProviders) {
                            String text = filterTextProvider.getText(rec);
                            if (text != null && text.toLowerCase().contains(filter.toLowerCase())) {
                                return true;
                            }
                        }
                    }
                    return false;
                }

                @Override
                public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
                    _tableBaseRecords.clear();
                    if (arg2 != null && arg2.equals(filter) && filter.trim().length() > 0) {
                        for (EJDataRecord record : blockController.getBlock().getRecords()) {
                            if (matchItem(record)) {
                                _tableBaseRecords.add(record);
                            }
                        }
                    } else {
                        filter = null;
                        if (filterTree != null) {
                            filterTree.clearText();
                        }
                        _tableBaseRecords.addAll(blockController.getBlock().getRecords());
                    }
                }

                @Override
                public void dispose() {
                }

                @Override
                public Object[] getElements(Object arg0) {
                    return _tableBaseRecords.toArray();
                }
            });
            _tableViewer.addDoubleClickListener(new IDoubleClickListener() {

                @Override
                public void doubleClick(DoubleClickEvent arg0) {
                    buttonPressed(OK_ACTION_COMMAND);
                }
            });
            _tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(SelectionChangedEvent arg0) {
                    if (!_validate) {
                        return;
                    }
                    _validate = false;
                    try {
                        EJDataRecord record = getFocusedRecord();
                        if (_lovController.getFocusedRecord() == null || _lovController.getFocusedRecord() != record) {
                            _lovController.newRecordInstance(record);
                        }
                    } finally {
                        _validate = true;
                    }
                }
            });
        }

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            EJ_RWT.setTestId(createButton(parent, OK_ACTION_COMMAND, "OK", true), "ok");
            EJ_RWT.setTestId(createButton(parent, CANCEL_ACTION_COMMAND, "Cancel", false), "cancel");
        }

        @Override
        public void canceled() {
            _lovController.lovCompleted(_itemToValidate, null);
            close();
        }

        @Override
        protected void buttonPressed(int buttonId) {
            switch(buttonId) {
                case OK_ACTION_COMMAND:
                    {
                        _lovController.lovCompleted(_itemToValidate, _lovController.getFocusedRecord());
                        if (_dialog != null) {
                            _dialog.close();
                        }
                        break;
                    }
                case CANCEL_ACTION_COMMAND:
                    {
                        _lovController.lovCompleted(_itemToValidate, null);
                        if (_dialog != null) {
                            _dialog.close();
                        }
                        break;
                    }
                default:
                    _lovController.lovCompleted(_itemToValidate, null);
                    break;
            }
            super.buttonPressed(buttonId);
        }
    };
    _dialog.create();
    _tableViewer.setInput(new Object());
    selectRow(0);
    // add dialog
    _dialog.getShell().setSize(width + 80, height + 100);
// border
// offsets
}
Also used : EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) EJRWTAbstractFilteredTable(org.entirej.applicationframework.rwt.table.EJRWTAbstractFilteredTable) EJRWTAbstractDialog(org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) List(java.util.List) ArrayList(java.util.ArrayList) EJBlockController(org.entirej.framework.core.data.controllers.EJBlockController) EJRWTTableViewerColumnFactory(org.entirej.applicationframework.rwt.table.EJRWTTableViewerColumnFactory) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) Table(org.eclipse.swt.widgets.Table) EJRWTAbstractFilteredTable(org.entirej.applicationframework.rwt.table.EJRWTAbstractFilteredTable) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredContentProvider(org.entirej.applicationframework.rwt.table.EJRWTAbstractFilteredTable.FilteredContentProvider) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) TableViewer(org.eclipse.jface.viewers.TableViewer) EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 17 with EJItemGroupProperties

use of org.entirej.framework.core.properties.interfaces.EJItemGroupProperties in project rap by entirej.

the class EJRWTAbstractScreenRenderer method createItemGroup.

private void createItemGroup(Composite parent, EJItemGroupProperties groupProperties, EJScreenType screenType) {
    if (groupProperties.isSeparator()) {
        int style = SWT.SEPARATOR;
        if (groupProperties.getSeparatorOrientation() == EJSeparatorOrientation.HORIZONTAL) {
            style = style | SWT.HORIZONTAL;
        } else {
            style = style | SWT.VERTICAL;
        }
        Label layoutBody = new Label(parent, style);
        layoutBody.setLayoutData(createItemGroupGridData(groupProperties));
        switch(groupProperties.getSeparatorLineStyle()) {
            case DASHED:
                layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dashed");
                break;
            case DOTTED:
                layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dotted");
                break;
            case DOUBLE:
                layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_double");
                break;
            default:
                layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator");
                break;
        }
        return;
    }
    EJRWTEntireJGridPane groupPane;
    String frameTitle = groupProperties.getFrameTitle();
    boolean hasGroup = groupProperties.dispayGroupFrame() && frameTitle != null && frameTitle.length() > 0;
    if (hasGroup) {
        Group group = new Group(parent, SWT.NONE);
        group.setLayout(new FillLayout());
        group.setLayoutData(createItemGroupGridData(groupProperties));
        group.setText(frameTitle);
        parent = group;
        groupPane = new EJRWTEntireJGridPane(parent, groupProperties.getNumCols());
    } else {
        groupPane = new EJRWTEntireJGridPane(parent, groupProperties.getNumCols(), groupProperties.dispayGroupFrame() ? SWT.BORDER : SWT.NONE);
    }
    groupPane.getLayout().verticalSpacing = 1;
    groupPane.setPaneName(groupProperties.getName());
    if (!hasGroup) {
        groupPane.setLayoutData(createItemGroupGridData(groupProperties));
    }
    Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
    for (EJScreenItemProperties screenItemProperties : itemProperties) {
        createScreenItem(groupPane, screenItemProperties, screenType);
    }
    // build sub groups
    EJItemGroupPropertiesContainer groupPropertiesContainer = groupProperties.getChildItemGroupContainer();
    Collection<EJItemGroupProperties> itemGroupProperties = groupPropertiesContainer.getAllItemGroupProperties();
    for (EJItemGroupProperties ejItemGroupProperties : itemGroupProperties) {
        createItemGroup(groupPane, ejItemGroupProperties, screenType);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) EJRWTAbstractLabel(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractLabel) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJItemGroupPropertiesContainer(org.entirej.framework.core.properties.containers.interfaces.EJItemGroupPropertiesContainer)

Aggregations

EJItemGroupProperties (org.entirej.framework.core.properties.interfaces.EJItemGroupProperties)17 EJScreenItemProperties (org.entirej.framework.core.properties.interfaces.EJScreenItemProperties)14 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)12 Group (org.eclipse.swt.widgets.Group)11 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)11 FocusEvent (org.eclipse.swt.events.FocusEvent)10 MouseAdapter (org.eclipse.swt.events.MouseAdapter)10 MouseEvent (org.eclipse.swt.events.MouseEvent)10 FillLayout (org.eclipse.swt.layout.FillLayout)10 GridData (org.eclipse.swt.layout.GridData)10 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)10 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)10 Action (org.eclipse.jface.action.Action)9 IAction (org.eclipse.jface.action.IAction)9 ToolBarManager (org.eclipse.jface.action.ToolBarManager)9 DisposeEvent (org.eclipse.swt.events.DisposeEvent)9 DisposeListener (org.eclipse.swt.events.DisposeListener)9 KeyEvent (org.eclipse.swt.events.KeyEvent)9 Cursor (org.eclipse.swt.graphics.Cursor)9 Event (org.eclipse.swt.widgets.Event)9