Search in sources :

Example 1 with EJApplicationActionProcessor

use of org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor in project rap by entirej.

the class EJRWTApplicationContainer method createTabLayout.

private void createTabLayout(Composite parent, final EJCoreLayoutItem.TabGroup group) {
    final CTabFolder layoutBody = new CTabFolder(parent, SWT.BORDER | (group.getOrientation() == TabGroup.ORIENTATION.TOP ? SWT.TOP : SWT.BOTTOM));
    final EJAppTabFolder appTabFolder = new EJAppTabFolder(this, layoutBody);
    _tabFolders.put(group.getName(), appTabFolder);
    EJ_RWT.setTestId(layoutBody, group.getName());
    layoutBody.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            EJApplicationActionProcessor applicationActionProcessor = _applicationManager.getApplicationActionProcessor();
            if (applicationActionProcessor != null) {
                CTabItem selection = layoutBody.getSelection();
                if (selection == null) {
                    return;
                }
                try {
                    String pageName = (String) selection.getData("TAB_KEY");
                    applicationActionProcessor.preShowTabPage(_applicationManager.getFrameworkManager(), group.getName(), pageName);
                } catch (EJActionProcessorException e1) {
                    if (appTabFolder.getLastSelection() != null) {
                        appTabFolder.showPage(appTabFolder.getLastSelection());
                    }
                    if (e1.getFrameworkMessage() != null)
                        _applicationManager.handleMessage(e1.getFrameworkMessage());
                    return;
                }
                try {
                    String pageName = (String) selection.getData("TAB_KEY");
                    appTabFolder.setLastSelection(pageName);
                    applicationActionProcessor.tabPageChanged(_applicationManager.getFrameworkManager(), group.getName(), pageName);
                } catch (EJActionProcessorException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });
    layoutBody.setLayoutData(createGridData(group));
    List<EJCoreLayoutItem> items = group.getItems();
    for (EJCoreLayoutItem item : items) {
        CTabItem tabItem = new CTabItem(layoutBody, SWT.NONE);
        appTabFolder.put(item.getName(), tabItem);
        Composite composite = new Composite(layoutBody, SWT.NO_FOCUS);
        composite.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
        composite.setData("TAB_ITEM", tabItem);
        composite.setData("TAB_KEY", item.getName());
        EJ_RWT.setTestId(tabItem, group.getName() + "." + item.getName());
        tabItem.setData("TAB_KEY", item.getName());
        composite.setLayout(new GridLayout());
        tabItem.setControl(composite);
        tabItem.setText(item.getTitle() != null ? item.getTitle() : item.getName());
        switch(item.getType()) {
            case GROUP:
                createGroupLayout(composite, (LayoutGroup) item);
                break;
            case SPACE:
                createSpace(composite, (LayoutSpace) item);
                break;
            case COMPONENT:
                createComponent(composite, (LayoutComponent) item);
                break;
            case SPLIT:
                createSplitLayout(composite, (SplitGroup) item);
                break;
            case TAB:
                createTabLayout(composite, (TabGroup) item);
                break;
        }
    }
    if (items.size() > 0) {
        layoutBody.setSelection(0);
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) CTabItem(org.eclipse.swt.custom.CTabItem) GridLayout(org.eclipse.swt.layout.GridLayout) EJApplicationActionProcessor(org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EJCoreLayoutItem(org.entirej.framework.core.properties.EJCoreLayoutItem)

Example 2 with EJApplicationActionProcessor

use of org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor in project rap by entirej.

the class EJRWTBanner method createContainer.

@Override
public void createContainer(final EJRWTApplicationManager manager, Composite parent, final EJFrameworkExtensionProperties rendererprop) {
    canvas = new Label(parent, getComponentStyle(rendererprop.getStringProperty(PROPERTY_ALIGNMENT), SWT.NONE));
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    String imagePath = null;
    if (rendererprop != null) {
        String paramName = rendererprop.getStringProperty(IMAGE_PARAM);
        final String action = rendererprop.getStringProperty(ACTION);
        if (action != null && !action.isEmpty()) {
            final Cursor cursor = new Cursor(canvas.getDisplay(), SWT.CURSOR_HAND);
            canvas.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent event) {
                    cursor.dispose();
                }
            });
            canvas.setCursor(cursor);
            canvas.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseUp(MouseEvent e) {
                    EJApplicationActionProcessor applicationActionProcessor = manager.getApplicationActionProcessor();
                    if (applicationActionProcessor != null) {
                        try {
                            applicationActionProcessor.executeActionCommand(manager.getFrameworkManager(), action);
                        } catch (EJActionProcessorException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            });
        }
        if (paramName != null && paramName.length() > 0) {
            final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
            if (applicationLevelParameter != null) {
                Object value = applicationLevelParameter.getValue();
                imagePath = (String) value;
                if (imagePath != null) {
                    updateImage(manager, imagePath);
                } else {
                    imagePath = rendererprop.getStringProperty(IMAGE_PATH);
                    updateImage(manager, imagePath);
                }
                applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        if (newValue != null) {
                            updateImage(manager, (String) newValue);
                        } else {
                            updateImage(manager, rendererprop.getStringProperty(IMAGE_PATH));
                        }
                    }
                });
            } else {
                imagePath = rendererprop.getStringProperty(IMAGE_PATH);
                updateImage(manager, imagePath);
            }
        } else {
            imagePath = rendererprop.getStringProperty(IMAGE_PATH);
            updateImage(manager, imagePath);
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) EJApplicationLevelParameter(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter) ParameterChangedListener(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener) EJApplicationActionProcessor(org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor) GridData(org.eclipse.swt.layout.GridData)

Aggregations

EJActionProcessorException (org.entirej.framework.core.EJActionProcessorException)2 EJApplicationActionProcessor (org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Cursor (org.eclipse.swt.graphics.Cursor)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)1 EJApplicationLevelParameter (org.entirej.framework.core.data.controllers.EJApplicationLevelParameter)1 ParameterChangedListener (org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener)1 EJCoreLayoutItem (org.entirej.framework.core.properties.EJCoreLayoutItem)1