Search in sources :

Example 41 with EJFrameworkExtensionProperties

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

the class EJRWTSingleRecordBlockRenderer method buildGuiComponent.

@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
    EJBlockProperties blockProperties = _block.getProperties();
    EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
    EJFrameworkExtensionProperties brendererProperties = blockProperties.getBlockRendererProperties();
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = mainScreenProperties.getWidth();
    gridData.heightHint = mainScreenProperties.getHeight();
    gridData.horizontalSpan = mainScreenProperties.getHorizontalSpan();
    gridData.verticalSpan = mainScreenProperties.getVerticalSpan();
    gridData.grabExcessHorizontalSpace = mainScreenProperties.canExpandHorizontally();
    gridData.grabExcessVerticalSpace = mainScreenProperties.canExpandVertically();
    if (gridData.grabExcessHorizontalSpace) {
        gridData.minimumWidth = mainScreenProperties.getWidth();
    }
    if (gridData.grabExcessVerticalSpace) {
        gridData.minimumHeight = mainScreenProperties.getHeight();
    }
    blockCanvas.setLayoutData(gridData);
    ScrolledComposite scrollComposite = null;
    EJFrameworkExtensionProperties sectionProperties = null;
    if (brendererProperties != null) {
        sectionProperties = brendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
    }
    if (sectionProperties != null && sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
        int style = ExpandableComposite.TITLE_BAR;
        String mode = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
        if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
            style = style | ExpandableComposite.TWISTIE;
        } else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
            style = style | ExpandableComposite.TREE_NODE;
        }
        if (sectionProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
            style = style | ExpandableComposite.EXPANDED;
        }
        Section section = toolkit.createSection(blockCanvas, style);
        section.setLayoutData(gridData);
        String title = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
        if (title != null) {
            section.setText(title);
        }
        EJRWTImageRetriever.getGraphicsProvider().rendererSection(section);
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(section, SWT.NONE);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            scrollComposite = new EJRWTScrolledComposite(group, SWT.V_SCROLL | SWT.H_SCROLL);
            _mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setText(frameTitle);
            section.setClient(group);
        } else {
            Composite composite = new Composite(blockCanvas, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            composite.setLayout(new FillLayout());
            scrollComposite = new EJRWTScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
            _mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            _mainPane.setLayoutData(gridData);
            section.setClient(composite);
        }
        final EJFrameworkExtensionPropertyList propertyList = sectionProperties.getPropertyList(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTIONS);
        if (propertyList != null && propertyList.getAllListEntries().size() > 0) {
            ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
            final ToolBar toolbar = toolBarManager.createControl(section);
            final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
            toolbar.setCursor(handCursor);
            // Cursor needs to be explicitly disposed
            toolbar.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent e) {
                    if (handCursor != null && handCursor.isDisposed() == false) {
                        handCursor.dispose();
                    }
                }
            });
            List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
            for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
                final String actionID = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_ID);
                String actionImage = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_IMAGE);
                String actionName = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_NAME);
                String actionTooltip = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_TOOLTIP);
                if (actionID != null) {
                    Action action = new Action(actionID, IAction.AS_PUSH_BUTTON) {

                        @Override
                        public void runWithEvent(Event event) {
                            _block.executeActionCommand(actionID, EJScreenType.MAIN);
                        }
                    };
                    if (actionName != null) {
                        action.setText(actionName);
                    }
                    if (actionTooltip != null) {
                        action.setDescription(actionTooltip);
                    }
                    if (actionImage != null && actionImage.length() > 0) {
                        action.setImageDescriptor((EJRWTImageRetriever.createDescriptor(actionImage)));
                    }
                    toolBarManager.add(action);
                }
            }
            toolBarManager.update(true);
            section.setTextClient(toolbar);
        }
    } else {
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(blockCanvas, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            group.setText(frameTitle);
            scrollComposite = new EJRWTScrolledComposite(group, SWT.V_SCROLL | SWT.H_SCROLL);
            _mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
        } else {
            Composite composite = new Composite(blockCanvas, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            composite.setLayout(new FillLayout());
            scrollComposite = new EJRWTScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
            _mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            composite.setLayoutData(gridData);
        }
    }
    EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
    if (rendererProp != null) {
        EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
        if (propertyGroup != null) {
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY);
        }
    }
    hookKeyListener(_mainPane);
    hookFocusListener(_mainPane);
    _mainPane.cleanLayout();
    EJDataRecord registeredRecord = _mainItemRegister.getRegisteredRecord();
    _mainItemRegister.resetRegister();
    EJItemGroupPropertiesContainer container = blockProperties.getScreenItemGroupContainer(EJScreenType.MAIN);
    Collection<EJItemGroupProperties> itemGroupProperties = container.getAllItemGroupProperties();
    for (EJItemGroupProperties ejItemGroupProperties : itemGroupProperties) {
        createItemGroup(_mainPane, ejItemGroupProperties);
    }
    _mainItemRegister.clearRegisteredValues();
    if (registeredRecord == null) {
        registeredRecord = getFirstRecord();
    }
    if (registeredRecord != null) {
        _mainItemRegister.register(registeredRecord);
    }
    _mainPane.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            setHasFocus(true);
        }
    });
    if (scrollComposite != null) {
        scrollComposite.setContent(_mainPane);
        scrollComposite.setLayout(new FillLayout());
        scrollComposite.setExpandHorizontal(true);
        scrollComposite.setExpandVertical(true);
        scrollComposite.setMinSize(_mainPane.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) EJRWTDeleteAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTDeleteAction) EJRWTQueryAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTQueryAction) EJRWTUpdateAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTUpdateAction) EJRWTInsertAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTInsertAction) Action(org.eclipse.jface.action.Action) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) EJItemGroupPropertiesContainer(org.entirej.framework.core.properties.containers.interfaces.EJItemGroupPropertiesContainer) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) EJMainScreenProperties(org.entirej.framework.core.properties.interfaces.EJMainScreenProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 42 with EJFrameworkExtensionProperties

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

the class EJRWTTreeTableRecordBlockRenderer method createScreenItem.

public ColumnLabelProvider createScreenItem(EJRWTTreeTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
    if (itemProps.isSpacerItem()) {
        return null;
    }
    EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
    EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
    if (renderer != null) {
        EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
        EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
        if (labelProvider != null) {
            String labelOrientation = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.COLUMN_ALIGNMENT);
            int displayedWidth = blockProperties.getIntProperty(EJRWTTreeTableBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
            // width
            if (displayedWidth == 0) {
                if (itemProps.getLabel() != null) {
                    // add
                    displayedWidth = itemProps.getLabel().length() + 2;
                // offset
                } else {
                    displayedWidth = 5;
                }
            }
            String visualAttribute = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
            if (visualAttribute != null) {
                EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
                if (va != null) {
                    itemRenderer.setInitialVisualAttribute(va);
                }
            }
            if (item.getProperties().getVisualAttributeProperties() != null) {
                renderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
            }
            TreeViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), displayedWidth, labelProvider, getComponentStyle(labelOrientation));
            TreeColumn column = viewerColumn.getColumn();
            EJ_RWT.setTestId(column, blockProperties.getName() + "." + itemProps.getReferencedItemName());
            column.setData("KEY", itemProps.getReferencedItemName());
            column.setData("VIEWER", viewerColumn);
            column.setData("ITEM", item);
            column.setToolTipText(itemProps.getHint());
            ColumnInfo info = new ColumnInfo();
            column.setData("INFO", info);
            column.setMoveable(blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
            column.setResizable(info.resizable = blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
            if (blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
                EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
                if (columnSorter != null) {
                    new EJRWTTreeTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
                }
            }
            // ensure that the width property of the table column is in
            // Characters
            Font font = labelProvider.getFont(new Object());
            if (font == null) {
                font = _tableViewer.getTree().getFont();
            }
            if (font != null) {
                float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
                if (avgCharWidth > 0) {
                    // add
                    column.setWidth(info.width = ((int) ((column.getWidth() + 1) * avgCharWidth)));
                // +1
                // padding
                }
            }
            return labelProvider;
        }
    }
    return null;
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJRWTTreeTableSortSelectionListener(org.entirej.applicationframework.rwt.table.EJRWTTreeTableSortSelectionListener) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) TreeColumn(org.eclipse.swt.widgets.TreeColumn) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Example 43 with EJFrameworkExtensionProperties

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

the class EJRWTTreeRecordBlockRenderer method createScreenItem.

public TreeNodeTextProvider createScreenItem(EJCoreMainScreenItemProperties itemProps) {
    if (itemProps.isSpacerItem()) {
        return null;
    }
    EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
    EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
    if (renderer != null) {
        EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
        EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
        if (labelProvider != null) {
            return new TreeNodeTextProvider(blockProperties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_PREFIX), blockProperties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_SUFFIX), labelProvider);
        }
    }
    return null;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)

Example 44 with EJFrameworkExtensionProperties

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

the class EJRWTComboItemRenderer method createComponent.

@Override
public void createComponent(Composite composite) {
    _actionControl = new EJRWTAbstractActionCombo(composite) {

        private static final long serialVersionUID = 2592484612013403481L;

        @Override
        public Combo createCombo(Composite parent) {
            String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
            if (alignmentProperty == null) {
                alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
            }
            String hint = _screenItemProperties.getHint();
            int style = SWT.READ_ONLY;
            style = getComponentStyle(alignmentProperty, style);
            _comboField = new Combo(parent, style);
            _comboField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_COMBOBOX);
            String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
            if (customCSSKey != null && customCSSKey.trim().length() > 0) {
                _comboField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
            }
            _comboViewer = new ComboViewer(_comboField);
            if (hint != null && hint.trim().length() > 0) {
                _comboField.setToolTipText(hint);
            }
            _comboField.setData(_item.getReferencedItemProperties().getName());
            if (_visibleItemCount > 5) {
                _comboField.setVisibleItemCount(_visibleItemCount);
            }
            _comboField.addFocusListener(EJRWTComboItemRenderer.this);
            _comboViewer.setLabelProvider(new ColumnLabelProvider() {

                @Override
                public String getText(Object element) {
                    if (element instanceof ComboBoxValue) {
                        ComboBoxValue value = (ComboBoxValue) element;
                        return value.getItemValueAsString();
                    }
                    return "";
                }
            });
            _comboViewer.setContentProvider(new ArrayContentProvider());
            _comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(SelectionChangedEvent event) {
                    if (!_activeEvent)
                        return;
                    Object old = _baseValue;
                    if (isValid()) {
                        ComboBoxValue value = getComboBoxValue();
                        _item.itemValueChaged(value.getItemValue());
                        if (value != null) {
                            value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
                        }
                        setMandatoryBorder(_mandatory);
                    } else {
                        _isValid = true;
                    }
                    _item.executeActionCommand();
                }
            });
            return _comboField;
        }

        @Override
        public Control createActionLabel(Composite parent) {
            Label label = new Label(parent, SWT.NONE);
            label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
            label.addFocusListener(EJRWTComboItemRenderer.this);
            label.addMouseListener(new MouseListener() {

                @Override
                public void mouseUp(MouseEvent arg0) {
                    _item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
                }

                @Override
                public void mouseDown(MouseEvent arg0) {
                }

                @Override
                public void mouseDoubleClick(MouseEvent arg0) {
                }
            });
            final EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
            final EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
            String lovKey = "SHIFT+ARROW_DOWN";
            if (propertyGroup != null) {
                lovKey = propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_LOV_KEY);
            }
            if (lovKey == null) {
                lovKey = "SHIFT+ARROW_DOWN";
            }
            label.setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
            getComboControl().setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
            addKeyListener(new KeyListener() {

                @Override
                public void keyReleased(KeyEvent arg0) {
                    if ((arg0.stateMask & SWT.SHIFT) != 0 && arg0.keyCode == SWT.ARROW_DOWN && isLovActivated()) {
                        _item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
                    }
                }

                @Override
                public void keyPressed(KeyEvent arg0) {
                }
            });
            return label;
        }
    };
    _visualContext = new EJRWTItemRendererVisualContext(_comboField.getBackground(), _comboField.getForeground(), _comboField.getFont());
    _mandatoryDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
    _errorDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
    _mandatoryDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_REQUIRED));
    _mandatoryDecoration.setShowHover(true);
    _mandatoryDecoration.setDescriptionText(_screenItemProperties.getLabel() == null || _screenItemProperties.getLabel().isEmpty() ? "Required Item" : String.format("%s is required", _screenItemProperties.getLabel()));
    if (_isValid) {
        _errorDecoration.hide();
    }
    if (message != null) {
        setMessage(message);
    }
    _mandatoryDecoration.hide();
    refreshCombo();
    setInitialValue(_baseValue);
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) EJRWTAbstractActionCombo(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionCombo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EJRWTAbstractActionCombo(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionCombo) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Control(org.eclipse.swt.widgets.Control) MouseListener(org.eclipse.swt.events.MouseListener) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) KeyListener(org.eclipse.swt.events.KeyListener) EJRWTItemRendererVisualContext(org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext)

Example 45 with EJFrameworkExtensionProperties

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

the class EJRWTStandardLovRenderer method createScreenItem.

public ColumnLabelProvider createScreenItem(EJRWTTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
    if (itemProps.isSpacerItem()) {
        return null;
    }
    EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
    EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
    if (renderer != null) {
        EJFrameworkExtensionProperties blockProperties = itemProps.getLovRendererRequiredProperties();
        EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
        if (labelProvider != null) {
            int _widthHint = blockProperties.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
            // width
            if (_widthHint == 0) {
                if (itemProps.getLabel() != null) {
                    // offset
                    _widthHint = itemProps.getLabel().length() + 2;
                } else {
                    _widthHint = 5;
                }
            }
            String alignmentProperty = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
            TableViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), _widthHint, labelProvider, getComponentStyle(alignmentProperty));
            TableColumn column = viewerColumn.getColumn();
            column.setToolTipText(itemProps.getHint());
            column.setMoveable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
            column.setResizable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
            if (blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
                EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
                if (columnSorter != null) {
                    new EJRWTTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
                }
            }
            // ensure that the width property of the table column is in
            // Characters
            Font font = labelProvider.getFont(new Object());
            if (font == null) {
                font = _tableViewer.getTable().getFont();
            }
            if (font != null) {
                float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
                if (avgCharWidth > 0) {
                    // add
                    column.setWidth((int) ((column.getWidth() + 1) * avgCharWidth));
                // +1
                // padding
                }
            }
            return labelProvider;
        }
    }
    return null;
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) TableColumn(org.eclipse.swt.widgets.TableColumn) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) Font(org.eclipse.swt.graphics.Font) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTTableSortSelectionListener(org.entirej.applicationframework.rwt.table.EJRWTTableSortSelectionListener) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Aggregations

EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)49 Composite (org.eclipse.swt.widgets.Composite)23 Group (org.eclipse.swt.widgets.Group)20 Section (org.eclipse.ui.forms.widgets.Section)19 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)17 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)14 MouseEvent (org.eclipse.swt.events.MouseEvent)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 GridLayout (org.eclipse.swt.layout.GridLayout)14 KeyEvent (org.eclipse.swt.events.KeyEvent)13 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)13 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)13 GridData (org.eclipse.swt.layout.GridData)12 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)12 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)12 EJBlockProperties (org.entirej.framework.core.properties.interfaces.EJBlockProperties)12 Label (org.eclipse.swt.widgets.Label)11 EJRWTAppItemRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)11 EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)11 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)11