use of org.eclipse.scout.rt.client.ui.desktop.DesktopListener 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);
}
}
});
}
}
use of org.eclipse.scout.rt.client.ui.desktop.DesktopListener 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());
}
use of org.eclipse.scout.rt.client.ui.desktop.DesktopListener 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);
}
}
});
}
use of org.eclipse.scout.rt.client.ui.desktop.DesktopListener in project scout.rt by eclipse.
the class AbstractClientSession method setDesktop.
@Override
public void setDesktop(IDesktop desktop) {
if (desktop == null) {
throw new IllegalArgumentException("argument must not be null");
}
if (m_desktop != null) {
throw new IllegalStateException("desktop is active");
}
m_desktop = desktop;
if (m_virtualDesktop != null) {
for (DesktopListener listener : m_virtualDesktop.getDesktopListeners()) {
m_desktop.addDesktopListener(listener);
}
for (Map.Entry<String, EventListenerList> e : m_virtualDesktop.getPropertyChangeListenerMap().entrySet()) {
String propName = e.getKey();
EventListenerList list = e.getValue();
if (propName == null) {
for (PropertyChangeListener listener : list.getListeners(PropertyChangeListener.class)) {
m_desktop.addPropertyChangeListener(listener);
}
} else {
for (PropertyChangeListener listener : list.getListeners(PropertyChangeListener.class)) {
m_desktop.addPropertyChangeListener(propName, listener);
}
}
}
for (Map.Entry<Object, EventListenerList> e : m_virtualDesktop.getDataChangeListenerMap().entrySet()) {
Object dataType = e.getKey();
EventListenerList list = e.getValue();
if (dataType == null) {
for (DataChangeListener listener : list.getListeners(DataChangeListener.class)) {
m_desktop.addDataChangeListener(listener);
}
} else {
for (DataChangeListener listener : list.getListeners(DataChangeListener.class)) {
m_desktop.addDataChangeListener(listener, dataType);
}
}
}
m_virtualDesktop = null;
}
m_desktop.initDesktop();
}
Aggregations