Search in sources :

Example 6 with EJRWTScrolledComposite

use of org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite 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 7 with EJRWTScrolledComposite

use of org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite in project rap by entirej.

the class EJRWTFormRenderer method createStackedCanvas.

private void createStackedCanvas(Composite parent, final EJCanvasProperties canvasProperties, final EJCanvasController canvasController) {
    final String name = canvasProperties.getName();
    final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
    trayPane.setLayoutData(createCanvasGridData(canvasProperties));
    parent = trayPane;
    final EJRWTEntireJStackedPane stackedPane = new EJRWTEntireJStackedPane(parent);
    trayPane.initBase(stackedPane);
    stackedPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
    stackedPane.setLayoutData(createCanvasGridData(canvasProperties));
    _stackedPanes.put(name, stackedPane);
    CanvasHandler canvasHandler = new CanvasHandler() {

        private Collection<EJMessage> msgs;

        @Override
        public void clearCanvasMessages() {
            this.msgs = null;
            if (trayPane != null && !trayPane.isDisposed()) {
                trayPane.closeTray();
            }
        }

        @Override
        public void setCanvasMessages(Collection<EJMessage> messages) {
            this.msgs = messages;
            if (trayPane != null && !trayPane.isDisposed()) {
                if (trayPane.getTray() != null) {
                    trayPane.closeTray();
                }
                {
                    MessageTray messageTray = new MessageTray(canvasProperties.getCloseableMessagePane()) {

                        @Override
                        void close() {
                            if (trayPane != null && !trayPane.isDisposed()) {
                                trayPane.closeTray();
                            }
                        }
                    };
                    messageTray.setMessages(msgs);
                    TrayLocation location = TrayLocation.RIGHT;
                    switch(canvasProperties.getMessagePosition()) {
                        case BOTTOM:
                            location = TrayLocation.BOTTOM;
                            break;
                        case LEFT:
                            location = TrayLocation.LEFT;
                            break;
                        case RIGHT:
                            location = TrayLocation.RIGHT;
                            break;
                        case TOP:
                            location = TrayLocation.TOP;
                            break;
                        default:
                            break;
                    }
                    trayPane.openTray(location, messageTray, canvasProperties.getMessagePaneSize());
                }
            }
        }

        @Override
        public void add(EJInternalBlock block) {
        }

        @Override
        public EJCanvasType getType() {
            return EJCanvasType.STACKED;
        }
    };
    _canvases.put(canvasProperties.getName(), canvasHandler);
    if (!canvasProperties.getCloseableMessagePane()) {
        canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
    }
    for (final EJStackedPageProperties page : canvasProperties.getStackedPageContainer().getAllStackedPageProperties()) {
        stackedPane.add(page.getName(), new EJRWTEntireJStackedPane.StackedPage() {

            Control control;

            @Override
            public String getKey() {
                return page.getName();
            }

            @Override
            public Control getControl() {
                if (control != null && !control.isDisposed()) {
                    return control;
                }
                final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(stackedPane, SWT.V_SCROLL | SWT.H_SCROLL);
                control = scrollComposite;
                final EJRWTEntireJGridPane pagePane = new EJRWTEntireJGridPane(scrollComposite, page.getNumCols());
                pagePane.cleanLayout();
                int width = 0;
                int height = 0;
                for (EJCanvasProperties properties : page.getContainedCanvases().getAllCanvasProperties()) {
                    createCanvas(pagePane, properties, canvasController);
                    int width2 = properties.getWidth();
                    int height2 = properties.getHeight();
                    if (properties.getBlockProperties() != null) {
                        width2 = properties.getBlockProperties().getMainScreenProperties().getWidth();
                        height2 = properties.getBlockProperties().getMainScreenProperties().getHeight();
                    }
                    if (width < width2) {
                        width = width2;
                    }
                    if (height < height2) {
                        height = height2;
                    }
                }
                scrollComposite.setContent(pagePane);
                scrollComposite.setMinSize(width, height);
                scrollComposite.setExpandHorizontal(true);
                scrollComposite.setExpandVertical(true);
                scrollComposite.setContent(pagePane);
                stackedPane.layout();
                return control;
            }
        });
    }
    if (canvasProperties.getInitialStackedPageName() != null) {
        stackedPane.showPane(canvasProperties.getInitialStackedPageName());
    }
    if (_stackedPanesCache.containsKey(name)) {
        stackedPane.showPane(_stackedPanesCache.get(name));
        _stackedPanesCache.remove(name);
    }
    _canvasesIds.add(name);
}
Also used : EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) EJRWTEntireJStackedPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJStackedPageProperties(org.entirej.framework.core.properties.interfaces.EJStackedPageProperties) Control(org.eclipse.swt.widgets.Control) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) Collection(java.util.Collection) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 8 with EJRWTScrolledComposite

use of org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite in project rap by entirej.

the class EJRWTFormRenderer method openEmbeddedForm.

@Override
public void openEmbeddedForm(EJEmbeddedFormController formController) {
    if (formController == null) {
        throw new EJApplicationException("No embedded form controller has been passed to openEmbeddedForm");
    }
    if (formController.getCanvasName() != null) {
        Composite composite = _formPanes.get(formController.getCanvasName());
        if (composite != null) {
            Control[] children = composite.getChildren();
            for (Control control : children) {
                if (!control.isDisposed()) {
                    control.dispose();
                }
            }
            EJRWTFormRenderer renderer = (EJRWTFormRenderer) formController.getEmbeddedForm().getRenderer();
            final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
            renderer.createControl(scrollComposite);
            EJRWTEntireJGridPane entireJGridPane = renderer.getGuiComponent();
            entireJGridPane.cleanLayout();
            scrollComposite.setContent(entireJGridPane);
            scrollComposite.setExpandHorizontal(true);
            scrollComposite.setExpandVertical(true);
            scrollComposite.setMinSize(formController.getEmbeddedForm().getProperties().getFormWidth(), formController.getEmbeddedForm().getProperties().getFormHeight());
            composite.layout(true);
            composite.redraw();
        } else {
            _formPanesCache.put(formController.getCanvasName(), formController);
        }
    }
}
Also used : EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJApplicationException(org.entirej.framework.core.EJApplicationException) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 9 with EJRWTScrolledComposite

use of org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite in project rap by entirej.

the class EJRWTInsertScreenRenderer method setupInsertScreen.

private void setupInsertScreen() {
    // Setup pane for Insert window
    EJFrameworkExtensionProperties rendererProperties = _block.getProperties().getInsertScreenRendererProperties();
    String title = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.TITLE);
    final int width = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.WIDTH, 300);
    _maximize = rendererProperties.getBooleanProperty(EJRWTScreenRendererDefinitionProperties.MAXIMIZE, false);
    final int height = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.HEIGHT, 500);
    final int numCols = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.NUM_COLS, 1);
    final String insertButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXECUTE_BUTTON_TEXT);
    final String cancelButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.CANCEL_BUTTON_TEXT);
    EJFrameworkExtensionProperties extraButtonsGroup = rendererProperties.getPropertyGroup(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTONS_GROUP);
    final String button1Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_ONE_LABEL);
    final String button1Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_ONE_COMMAND);
    final String button2Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_TWO_LABEL);
    final String button2Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_TWO_COMMAND);
    final String button3Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_THREE_LABEL);
    final String button3Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_THREE_COMMAND);
    final String button4Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FOUR_LABEL);
    final String button4Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FOUR_COMMAND);
    final String button5Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FIVE_LABEL);
    final String button5Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FIVE_COMMAND);
    final int ID_BUTTON_1 = 1;
    final int ID_BUTTON_2 = 2;
    final int ID_BUTTON_3 = 3;
    final int ID_BUTTON_4 = 4;
    final int ID_BUTTON_5 = 5;
    _insertDialog = new EJRWTAbstractDialog(getRWTManager().getShell()) {

        @Override
        public void createBody(Composite parent) {
            EJ_RWT.setTestId(parent, _block.getProperties().getName() + ".insert-screen");
            parent.setLayout(new FillLayout());
            final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
            EJRWTEntireJGridPane _mainPane = new EJRWTEntireJGridPane(scrollComposite, numCols);
            _mainPane.cleanLayout();
            EJBlockProperties blockProperties = _block.getProperties();
            addAllItemGroups(blockProperties.getScreenItemGroupContainer(EJScreenType.INSERT), _mainPane, EJScreenType.INSERT);
            scrollComposite.setContent(_mainPane);
            scrollComposite.setExpandHorizontal(true);
            scrollComposite.setExpandVertical(true);
            // remove the offset
            scrollComposite.setMinSize(width, height - 10);
            _block.addItemValueChangedListener(EJRWTInsertScreenRenderer.this);
            EJRWTItemTextChangeNotifier.ChangeListener changeListener = new ChangeListener() {

                @Override
                public void changed() {
                    validate();
                }
            };
            Collection<EJManagedItemRendererWrapper> registeredRenderers = _itemRegister.getRegisteredRenderers();
            for (EJManagedItemRendererWrapper ejManagedItemRendererWrapper : registeredRenderers) {
                if (ejManagedItemRendererWrapper.getUnmanagedRenderer() instanceof EJRWTItemTextChangeNotifier) {
                    ((EJRWTItemTextChangeNotifier) ejManagedItemRendererWrapper.getUnmanagedRenderer()).addListener(changeListener);
                }
            }
        }

        @Override
        public void validate() {
            Button button = getButton(INSERT_OK_ACTION_COMMAND);
            if (button == null) {
                return;
            }
            Collection<EJScreenItemController> allScreenItems = _block.getAllScreenItems(EJScreenType.INSERT);
            for (EJScreenItemController ejScreenItemController : allScreenItems) {
                if (!ejScreenItemController.getManagedItemRenderer().isValid()) {
                    button.setEnabled(false);
                    return;
                }
            }
            button.setEnabled(true);
        }

        @Override
        public int open() {
            validate();
            setFoucsItemRenderer();
            return super.open();
        }

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            // Add the buttons in reverse order, as they will be added from left to right
            addExtraButton(parent, button5Label, ID_BUTTON_5);
            addExtraButton(parent, button4Label, ID_BUTTON_4);
            addExtraButton(parent, button3Label, ID_BUTTON_3);
            addExtraButton(parent, button2Label, ID_BUTTON_2);
            addExtraButton(parent, button1Label, ID_BUTTON_1);
            EJ_RWT.setTestId(createButton(parent, INSERT_OK_ACTION_COMMAND, insertButtonLabel == null ? "Insert" : insertButtonLabel, true), "ok");
            EJ_RWT.setTestId(createButton(parent, INSERT_CANCEL_ACTION_COMMAND, cancelButtonLabel == null ? "Cancel" : cancelButtonLabel, false), "cancel");
        }

        private void addExtraButton(Composite parent, String label, int id) {
            if (label == null) {
                return;
            }
            Button button = createButton(parent, id, label, false);
            EJ_RWT.setTestId(button, _block.getProperties().getName() + ".btn-" + id);
        }

        @Override
        public boolean close() {
            _block.removeItemValueChangedListener(EJRWTInsertScreenRenderer.this);
            _block.setRendererFocus(true);
            return super.close();
        }

        @Override
        public void canceled() {
            _block.insertCancelled();
            close();
        }

        @Override
        protected void buttonPressed(int buttonId) {
            Display.getDefault().asyncExec(() -> {
                try {
                    switch(buttonId) {
                        case INSERT_OK_ACTION_COMMAND:
                            {
                                EJDataRecord newRecord = getInsertRecord();
                                try {
                                    _block.getBlock().insertRecord(newRecord);
                                    if (_block.getInsertScreenDisplayProperties().getBooleanProperty(EJRWTScreenRendererDefinitionProperties.SAVE_FORM_AFTER_EXECUTE, false)) {
                                        _block.getBlock().getForm().saveChanges();
                                    }
                                } catch (EJApplicationException e) {
                                    setButtonEnable(buttonId, false);
                                    throw e;
                                }
                                close();
                                break;
                            }
                        case INSERT_CANCEL_ACTION_COMMAND:
                            {
                                _block.insertCancelled();
                                close();
                                break;
                            }
                        case ID_BUTTON_1:
                            {
                                _block.executeActionCommand(button1Command, EJScreenType.UPDATE);
                                break;
                            }
                        case ID_BUTTON_2:
                            {
                                _block.executeActionCommand(button2Command, EJScreenType.UPDATE);
                                break;
                            }
                        case ID_BUTTON_3:
                            {
                                _block.executeActionCommand(button3Command, EJScreenType.UPDATE);
                                break;
                            }
                        case ID_BUTTON_4:
                            {
                                _block.executeActionCommand(button4Command, EJScreenType.UPDATE);
                                break;
                            }
                        case ID_BUTTON_5:
                            {
                                _block.executeActionCommand(button5Command, EJScreenType.UPDATE);
                                break;
                            }
                        default:
                            _block.updateCancelled();
                            break;
                    }
                } catch (EJApplicationException e) {
                    _logger.trace(e.getMessage());
                    _frameworkManager.handleException(e);
                    return;
                }
            });
        }
    };
    _insertDialog.create();
    _insertDialog.getShell().setData("INSERT - " + _block.getProperties().getName());
    _insertDialog.getShell().setText(title != null ? title : "");
    // add dialog border offsets
    _insertDialog.getShell().setSize(width + 80, height + 100);
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJApplicationException(org.entirej.framework.core.EJApplicationException) FillLayout(org.eclipse.swt.layout.FillLayout) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTAbstractDialog(org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) Button(org.eclipse.swt.widgets.Button) EJRWTItemTextChangeNotifier(org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Collection(java.util.Collection) ChangeListener(org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier.ChangeListener) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 10 with EJRWTScrolledComposite

use of org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite in project rap by entirej.

the class EJRWTQueryScreenRenderer method setupQueryScreen.

private void setupQueryScreen() {
    // Setup pane for query window
    EJFrameworkExtensionProperties rendererProperties = _block.getProperties().getQueryScreenRendererProperties();
    String title = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.TITLE);
    final int width = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.WIDTH, 300);
    final int height = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.HEIGHT, 500);
    _maximize = rendererProperties.getBooleanProperty(EJRWTScreenRendererDefinitionProperties.MAXIMIZE, false);
    final int numCols = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.NUM_COLS, 1);
    final String queryButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXECUTE_BUTTON_TEXT);
    final String cancelButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.CANCEL_BUTTON_TEXT);
    final String clearButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.CLEAR_BUTTON_TEXT);
    _queryDialog = new EJRWTAbstractDialog(getRWTManager().getShell()) {

        private static final long serialVersionUID = -4685316941898120169L;

        @Override
        public void createBody(Composite parent) {
            EJ_RWT.setTestId(parent, _block.getProperties().getName() + ".query-screen");
            parent.setLayout(new FillLayout());
            final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
            EJRWTEntireJGridPane _mainPane = new EJRWTEntireJGridPane(scrollComposite, numCols);
            _mainPane.cleanLayout();
            EJBlockProperties blockProperties = _block.getProperties();
            addAllItemGroups(blockProperties.getScreenItemGroupContainer(EJScreenType.QUERY), _mainPane, EJScreenType.QUERY);
            scrollComposite.setContent(_mainPane);
            scrollComposite.setExpandHorizontal(true);
            scrollComposite.setExpandVertical(true);
            // remove the oddset
            scrollComposite.setMinSize(width, height - 10);
            _block.addItemValueChangedListener(EJRWTQueryScreenRenderer.this);
            EJRWTItemTextChangeNotifier.ChangeListener changeListener = new ChangeListener() {

                @Override
                public void changed() {
                    validate();
                }
            };
            Collection<EJManagedItemRendererWrapper> registeredRenderers = _itemRegister.getRegisteredRenderers();
            for (EJManagedItemRendererWrapper ejManagedItemRendererWrapper : registeredRenderers) {
                if (ejManagedItemRendererWrapper.getUnmanagedRenderer() instanceof EJRWTItemTextChangeNotifier) {
                    ((EJRWTItemTextChangeNotifier) ejManagedItemRendererWrapper.getUnmanagedRenderer()).addListener(changeListener);
                }
            }
        }

        @Override
        public void validate() {
            Button button = getButton(QUERY_OK_ACTION_COMMAND);
            if (button == null) {
                return;
            }
            Collection<EJScreenItemController> allScreenItems = _block.getAllScreenItems(EJScreenType.QUERY);
            for (EJScreenItemController ejScreenItemController : allScreenItems) {
                if (!ejScreenItemController.getManagedItemRenderer().isValid()) {
                    button.setEnabled(false);
                    return;
                }
            }
            button.setEnabled(true);
        }

        @Override
        public int open() {
            validate();
            setFoucsItemRenderer();
            return super.open();
        }

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            EJ_RWT.setTestId(createButton(parent, QUERY_OK_ACTION_COMMAND, queryButtonLabel == null ? "Query" : queryButtonLabel, true), _block.getProperties().getName() + ".ok");
            EJ_RWT.setTestId(createButton(parent, QUERY_CLEAR_ACTION_COMMAND, clearButtonLabel == null ? "Clear" : clearButtonLabel, false), _block.getProperties().getName() + ".clear");
            EJ_RWT.setTestId(createButton(parent, QUERY_CANCEL_ACTION_COMMAND, cancelButtonLabel == null ? "Cancel" : cancelButtonLabel, false), _block.getProperties().getName() + ".cancel");
        }

        @Override
        public void canceled() {
            close();
        }

        @Override
        public boolean close() {
            _block.removeItemValueChangedListener(EJRWTQueryScreenRenderer.this);
            _block.setRendererFocus(true);
            return super.close();
        }

        @Override
        protected void buttonPressed(int buttonId) {
            Display.getDefault().asyncExec(() -> {
                try {
                    switch(buttonId) {
                        case QUERY_OK_ACTION_COMMAND:
                            {
                                EJQueryBlock b = new EJLovBlock(_block.getBlock());
                                EJQueryCriteria queryCriteria = new EJQueryCriteria(b);
                                EJDataRecord record = getQueryRecord();
                                for (EJDataItem item : record.getAllItems()) {
                                    boolean serviceItem = item.isBlockServiceItem();
                                    if (item.getValue() != null) {
                                        if (item.getProperties().getDataTypeClass().isAssignableFrom(String.class)) {
                                            String value = (String) item.getValue();
                                            if (value.contains("%")) {
                                                queryCriteria.add(EJRestrictions.like(item.getName(), serviceItem, item.getValue()));
                                            } else {
                                                queryCriteria.add(EJRestrictions.equals(item.getName(), serviceItem, item.getValue()));
                                            }
                                        } else {
                                            queryCriteria.add(EJRestrictions.equals(item.getName(), serviceItem, item.getValue()));
                                        }
                                    }
                                }
                                try {
                                    _block.executeQuery(queryCriteria);
                                } catch (EJApplicationException e) {
                                    setButtonEnable(buttonId, false);
                                    throw e;
                                }
                                close();
                                break;
                            }
                        case QUERY_CLEAR_ACTION_COMMAND:
                            {
                                _itemRegister.clearRegisteredValues();
                                _itemRegister.register(_block.createRecord(EJRecordType.QUERY));
                                break;
                            }
                        case QUERY_CANCEL_ACTION_COMMAND:
                            {
                                close();
                                break;
                            }
                    }
                } catch (EJApplicationException e) {
                    _logger.trace(e.getMessage());
                    _frameworkManager.handleException(e);
                    return;
                }
            });
        }
    };
    _queryDialog.create();
    _queryDialog.getShell().setData("QUERY - " + _block.getProperties().getName());
    _queryDialog.getShell().setText(title != null ? title : "");
    // add dialog border offsets
    _queryDialog.getShell().setSize(width + 80, height + 100);
}
Also used : EJQueryCriteria(org.entirej.framework.core.service.EJQueryCriteria) EJQueryBlock(org.entirej.framework.core.EJQueryBlock) EJLovBlock(org.entirej.framework.core.EJLovBlock) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJRWTAbstractDialog(org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog) Button(org.eclipse.swt.widgets.Button) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ChangeListener(org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier.ChangeListener) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJDataItem(org.entirej.framework.core.data.EJDataItem) EJApplicationException(org.entirej.framework.core.EJApplicationException) FillLayout(org.eclipse.swt.layout.FillLayout) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) EJRWTItemTextChangeNotifier(org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier) Collection(java.util.Collection) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)10 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)10 Composite (org.eclipse.swt.widgets.Composite)8 FillLayout (org.eclipse.swt.layout.FillLayout)6 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)6 Collection (java.util.Collection)5 EJApplicationException (org.entirej.framework.core.EJApplicationException)5 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)5 EJBlockProperties (org.entirej.framework.core.properties.interfaces.EJBlockProperties)5 EJRWTAbstractDialog (org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog)4 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)4 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)4 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)4 Button (org.eclipse.swt.widgets.Button)3 EJRWTItemTextChangeNotifier (org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier)3 ChangeListener (org.entirej.applicationframework.rwt.renderers.item.EJRWTItemTextChangeNotifier.ChangeListener)3 FocusEvent (org.eclipse.swt.events.FocusEvent)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 GridData (org.eclipse.swt.layout.GridData)2