Search in sources :

Example 1 with DesktopEvent

use of org.eclipse.scout.rt.client.ui.desktop.DesktopEvent in project scout.rt by eclipse.

the class AbstractOutlineButton method execInitField.

/**
 * Initializes this outline button.
 * <p>
 * This implementation does the following:
 * <ul>
 * <li>find an instance of {@code IOutline} on the desktop consistent with the configured outline of this button, this
 * becomes the associated outline instance for this button
 * <li>the label for this button is taken from the outline
 * <li>a property change listener is registered with the outline such that this button can react on dynamic changes of
 * its associated outline (label, icon, visible, enabled etc.)
 * </ul>
 *
 * @throws ProcessingException
 *           if initialization fails
 */
@Override
protected void execInitField() {
    final IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    for (IOutline o : desktop.getAvailableOutlines()) {
        if (o.getClass() == getConfiguredOutline()) {
            m_outline = o;
            break;
        }
    }
    if (m_outline != null) {
        setVisible(m_outline.isVisible());
        setEnabled(m_outline.isEnabled(), true, false);
        setLabel(m_outline.getTitle());
        setTooltipText(m_outline.getTitle());
        setSelected(desktop.getOutline() == m_outline);
        // add selection listener
        desktop.addDesktopListener(new DesktopListener() {

            @Override
            public void desktopChanged(DesktopEvent e) {
                switch(e.getType()) {
                    case DesktopEvent.TYPE_OUTLINE_CHANGED:
                        {
                            setSelected(e.getOutline() == m_outline);
                            break;
                        }
                }
            }
        });
        // add change listener
        m_outline.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                String n = e.getPropertyName();
                Object v = e.getNewValue();
                if (n.equals(IOutline.PROP_VISIBLE)) {
                    setVisible((Boolean) v);
                } else if (n.equals(IOutline.PROP_ENABLED)) {
                    setEnabled((Boolean) v, true, false);
                } else if (n.equals(IOutline.PROP_TITLE)) {
                    setLabel((String) v);
                } else if (n.equals(IOutline.PROP_DEFAULT_ICON_ID)) {
                    setIconId((String) v);
                }
            }
        });
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DesktopListener(org.eclipse.scout.rt.client.ui.desktop.DesktopListener) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) DesktopEvent(org.eclipse.scout.rt.client.ui.desktop.DesktopEvent)

Example 2 with DesktopEvent

use of org.eclipse.scout.rt.client.ui.desktop.DesktopEvent in project scout.rt by eclipse.

the class AbstractOutlineTreeField method execInitField.

@Override
protected void execInitField() {
    m_desktopListener = new DesktopListener() {

        @Override
        public void desktopChanged(DesktopEvent e) {
            switch(e.getType()) {
                case DesktopEvent.TYPE_OUTLINE_CHANGED:
                    {
                        installOutline(e.getOutline());
                        break;
                    }
            }
        }
    };
    m_treePropertyListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals(ITree.PROP_TITLE)) {
                setLabel((String) e.getNewValue());
            }
        }
    };
    // 
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    desktop.addDesktopListener(m_desktopListener);
    installOutline(desktop.getOutline());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DesktopListener(org.eclipse.scout.rt.client.ui.desktop.DesktopListener) DesktopEvent(org.eclipse.scout.rt.client.ui.desktop.DesktopEvent) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 3 with DesktopEvent

use of org.eclipse.scout.rt.client.ui.desktop.DesktopEvent in project scout.rt by eclipse.

the class AbstractOutlineViewButton method execInitAction.

@Override
protected void execInitAction() {
    setVisibleGranted(m_outline.isVisibleGranted());
    setVisible(m_outline.isVisible());
    setEnabled(m_outline.isEnabled());
    setText(m_outline.getTitle());
    setIconId(m_outline.getIconId());
    setSelected(m_desktop.getOutline() == m_outline);
    // add selection listener
    m_desktop.addDesktopListener(new DesktopListener() {

        @Override
        public void desktopChanged(DesktopEvent e) {
            switch(e.getType()) {
                case DesktopEvent.TYPE_OUTLINE_CHANGED:
                    {
                        setSelected(e.getOutline() == m_outline);
                        break;
                    }
            }
        }
    });
    // add change listener
    m_outline.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            String n = e.getPropertyName();
            Object v = e.getNewValue();
            if (n.equals(IOutline.PROP_VISIBLE)) {
                setVisible((Boolean) v);
            } else if (n.equals(IOutline.PROP_ENABLED)) {
                setEnabled((Boolean) v);
            } else if (n.equals(IOutline.PROP_TITLE)) {
                setText((String) v);
            } else if (n.equals(IOutline.PROP_ICON_ID)) {
                setIconId((String) v);
            }
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DesktopListener(org.eclipse.scout.rt.client.ui.desktop.DesktopListener) DesktopEvent(org.eclipse.scout.rt.client.ui.desktop.DesktopEvent)

Example 4 with DesktopEvent

use of org.eclipse.scout.rt.client.ui.desktop.DesktopEvent in project scout.rt by eclipse.

the class JsonDesktop method init.

@Override
public void init() {
    super.init();
    // Replay missed events
    IEventHistory<DesktopEvent> eventHistory = getModel().getEventHistory();
    if (eventHistory != null) {
        for (DesktopEvent event : eventHistory.getRecentEvents()) {
            handleModelDesktopEvent(event);
        }
    }
}
Also used : DesktopEvent(org.eclipse.scout.rt.client.ui.desktop.DesktopEvent)

Aggregations

DesktopEvent (org.eclipse.scout.rt.client.ui.desktop.DesktopEvent)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 DesktopListener (org.eclipse.scout.rt.client.ui.desktop.DesktopListener)3 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)2