Search in sources :

Example 11 with EJFrameworkExtensionPropertyList

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

the class EJRWTRadioGroupItemRenderer method createComponent.

@Override
public void createComponent(Composite composite) {
    final String hint = _screenItemProperties.getHint();
    int style = SWT.NO_FOCUS | (_displayFrame ? SWT.SHADOW_ETCHED_IN : SWT.NONE);
    if (_displayFrame) {
        _radioGroup = new Group(composite, style);
        if (_screenItemProperties.getLabel() != null) {
            ((Group) _radioGroup).setText(_screenItemProperties.getLabel());
        }
        _radioGroup.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_RADIO);
        String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
        if (customCSSKey != null && customCSSKey.trim().length() > 0) {
            _radioGroup.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
        }
        composite = _radioGroup;
    } else {
        _radioGroup = new Composite(composite, SWT.NO_FOCUS);
        _radioGroup.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_RADIO);
        String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
        if (customCSSKey != null && customCSSKey.trim().length() > 0) {
            _radioGroup.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
        }
    }
    if (hint != null && hint.trim().length() > 0) {
        _radioGroup.setToolTipText(hint);
    }
    _radioGroup.setData(_item.getReferencedItemProperties().getName());
    int type = SWT.HORIZONTAL;
    if (EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_ORIENTATION_VERTICAL.equals(_rendererProps.getStringProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_ORIENTATION))) {
        type = SWT.VERTICAL;
    }
    RowLayout rowLayout = new RowLayout(type);
    _radioGroup.setLayout(rowLayout);
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    rowLayout.marginRight = 0;
    rowLayout.marginLeft = 0;
    rowLayout.marginHeight = 0;
    rowLayout.marginWidth = 0;
    _radioGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    EJFrameworkExtensionPropertyList radioButtons = _rendererProps.getPropertyList(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_RADIO_BUTTONS);
    String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
    for (EJFrameworkExtensionPropertyListEntry listEntry : radioButtons.getAllListEntries()) {
        Object value = getValueAsObject(_item.getReferencedItemProperties().getDataTypeClass(), listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_VALUE));
        Button button = new Button(_radioGroup, SWT.RADIO);
        button.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_RADIO);
        if (customCSSKey != null && customCSSKey.trim().length() > 0) {
            button.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
        }
        // Store the button and the button values for future reference
        String id = listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_NAME);
        _radioButtons.put(id, new RadioButtonValue(id, button, value));
        // Set the button properties
        button.setData(listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_NAME));
        button.setText(_item.getForm().translateText(listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_LABEL)));
        // button.setActionCommand(screenItemProperties.getActionCommand());
        _defaultButtonId = _rendererProps.getStringProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_DEFAULT_BUTTON);
        if (_defaultButtonId != null) {
            if (_defaultButtonId.equals(listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_NAME))) {
                button.setSelection(true);
            } else {
                button.setSelection(false);
            }
        }
        EJ_RWT.setAttribute(_radioGroup, "ej-item-selection", String.valueOf(getValue()));
        // Add the listeners. These will be needed to trigger events within
        // EntireJ
        button.addFocusListener(this);
        button.addSelectionListener(_radioButtonSelection);
    }
    _mandatoryDecoration = new ControlDecoration(_radioGroup, SWT.TOP | SWT.LEFT);
    _errorDecoration = new ControlDecoration(_radioGroup, SWT.TOP | SWT.LEFT);
    _errorDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_ERROR));
    _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();
    addListeners();
}
Also used : Group(org.eclipse.swt.widgets.Group) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration)

Example 12 with EJFrameworkExtensionPropertyList

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList 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)

Aggregations

EJFrameworkExtensionPropertyList (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList)12 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)12 GridData (org.eclipse.swt.layout.GridData)10 Group (org.eclipse.swt.widgets.Group)10 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)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 FocusEvent (org.eclipse.swt.events.FocusEvent)9 KeyEvent (org.eclipse.swt.events.KeyEvent)9 MouseAdapter (org.eclipse.swt.events.MouseAdapter)9 MouseEvent (org.eclipse.swt.events.MouseEvent)9 Cursor (org.eclipse.swt.graphics.Cursor)9 FillLayout (org.eclipse.swt.layout.FillLayout)9 Event (org.eclipse.swt.widgets.Event)9 ToolBar (org.eclipse.swt.widgets.ToolBar)9 Section (org.eclipse.ui.forms.widgets.Section)9 EJRWTDeleteAction (org.entirej.applicationframework.rwt.application.components.actions.EJRWTDeleteAction)9