Search in sources :

Example 1 with IViewAlwaysInitialize

use of com.biglybt.ui.swt.views.IViewAlwaysInitialize in project BiglyBT by BiglySoftware.

the class TabbedMDI method createEntryFromEventListener.

@Override
public MdiEntry createEntryFromEventListener(String parentEntryID, String parentViewID, UISWTViewEventListener l, String id, boolean closeable, Object datasource, String preferredAfterID) {
    if (isEntryClosedByUser(id)) {
        return null;
    }
    MdiEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        return oldEntry;
    }
    TabbedEntry entry = new TabbedEntry(this, skin, id, parentViewID);
    if (datasource == null && l instanceof UISWTViewEventListenerHolder) {
        datasource = ((UISWTViewEventListenerHolder) l).getInitialDataSource();
    }
    try {
        // hack - seteventlistener will create view it needs to have item available now, not a little later
        addItem(entry);
        entry.setEventListener(l, true);
    } catch (UISWTViewEventCancelledException e) {
        entry.close(true);
        removeItem(entry, false);
        return null;
    }
    entry.setDatasource(datasource);
    entry.setPreferredAfterID(preferredAfterID);
    setupNewEntry(entry, id, -1, closeable);
    addMenus(entry, id);
    if (l instanceof IViewAlwaysInitialize) {
        entry.build();
    }
    return entry;
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) MdiEntry(com.biglybt.ui.mdi.MdiEntry) IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize) UISWTViewEventListenerHolder(com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)

Example 2 with IViewAlwaysInitialize

use of com.biglybt.ui.swt.views.IViewAlwaysInitialize in project BiglyBT by BiglySoftware.

the class UISWTViewImpl method setEventListener.

public void setEventListener(UISWTViewEventListener _eventListener, boolean doCreate) throws UISWTViewEventCancelledException {
    if (this.eventListener instanceof UISWTViewEventListenerHolder) {
        ((UISWTViewEventListenerHolder) this.eventListener).removeListener(this);
    }
    this.eventListener = _eventListener;
    if (eventListener == null) {
        return;
    }
    if (_eventListener instanceof UISWTViewEventListenerHolder) {
        UISWTViewEventListenerHolder h = (UISWTViewEventListenerHolder) _eventListener;
        UISWTViewEventListener delegatedEventListener = h.getDelegatedEventListener(this);
        if (delegatedEventListener != null) {
            h.removeListener(this);
            this.eventListener = delegatedEventListener;
        }
    }
    if (eventListener instanceof IViewAlwaysInitialize) {
        delayInitializeToFirstActivate = false;
    }
    if (eventListener instanceof UISWTViewCoreEventListener) {
        setUseCoreDataSource(true);
    }
    // there's a bunch of crap out there that assumes that data is the view object :(
    if (doCreate && !triggerBooleanEvent(UISWTViewEvent.TYPE_CREATE, this)) {
        throw new UISWTViewEventCancelledException();
    }
// <<
}
Also used : IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener)

Example 3 with IViewAlwaysInitialize

use of com.biglybt.ui.swt.views.IViewAlwaysInitialize in project BiglyBT by BiglySoftware.

the class SideBar method createEntry.

@Override
public SideBarEntrySWT createEntry(UISWTViewBuilderCore builder, boolean closeable) {
    String id = builder.getViewID();
    SideBarEntrySWT oldEntry = getEntry(id);
    if (oldEntry != null) {
        oldEntry.setDatasource(builder.getInitialDataSource());
        return oldEntry;
    }
    SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id);
    entry.setDatasource(builder.getInitialDataSource());
    entry.setPreferredAfterID(builder.getPreferredAfterID());
    entry.setParentView(getParentView());
    try {
        // setEventListener will create the UISWTView.
        // We need to have the entry available for the view to use if it wants
        addItem(entry);
        UISWTViewEventListener l = builder.createEventListener(entry);
        entry.setEventListener(l, builder, true);
        entry.setParentEntryID(builder.getParentEntryID());
        setupNewEntry(entry, id, false, closeable);
        if (l instanceof IViewAlwaysInitialize) {
            entry.build();
        }
    } catch (Exception e) {
        Debug.out(e);
        closeEntry(entry, false);
        return null;
    }
    return entry;
}
Also used : IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener)

Example 4 with IViewAlwaysInitialize

use of com.biglybt.ui.swt.views.IViewAlwaysInitialize in project BiglyBT by BiglySoftware.

the class TabbedMDI method createEntry.

@Override
public TabbedEntry createEntry(UISWTViewBuilderCore builder, boolean closeable) {
    String id = builder.getViewID();
    if (isEntryClosedByUser(id)) {
        return null;
    }
    TabbedEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        oldEntry.setDatasource(builder.getInitialDataSource());
        return oldEntry;
    }
    TabbedEntry entry = new TabbedEntry(this, skin, id);
    // Set some defaults. Must be done before entry.setEventListener, as listener
    // might want to override
    entry.setDatasource(dataSource == null ? builder.getInitialDataSource() : dataSource);
    String preferredAfterID = builder.getPreferredAfterID();
    entry.setPreferredAfterID(preferredAfterID);
    entry.setDestroyOnDeactivate(destroyEntriesOnDeactivate);
    entry.setTitle(builder.getInitialTitle());
    entry.setCloseable(closeable);
    entry.setParentView(getParentView());
    try {
        // setEventListner will create the UISWTView.
        // We need to have the entry available for the view to use if it wants
        addItem(entry);
        UISWTViewEventListener l = builder.createEventListener(entry);
        entry.setEventListener(l, builder, true);
        // Do not set ParentEntry ID -- Tabbed MDI doesn't have parents
        // entry.setParentEntryID(parentEntryID);
        setupNewEntry(entry);
        addMenus(entry, id);
        if (l instanceof IViewAlwaysInitialize) {
            entry.build();
        }
    } catch (Exception e) {
        if (!(e instanceof UISWTViewEventCancelledException)) {
            Debug.out("Can't create " + builder.getViewID(), e);
        }
        closeEntry(entry, false);
        return null;
    }
    return entry;
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)

Example 5 with IViewAlwaysInitialize

use of com.biglybt.ui.swt.views.IViewAlwaysInitialize in project BiglyBT by BiglySoftware.

the class SideBar method createEntryFromEventListener.

@Override
public MdiEntry createEntryFromEventListener(String parentEntryID, String parentViewID, UISWTViewEventListener l, String id, boolean closeable, Object datasource, String preferredAfterID) {
    MdiEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        return oldEntry;
    }
    SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id, parentViewID);
    try {
        // hack: setEventListner will create the UISWTView.
        // We need to have the entry available for the view to use
        // if it wants
        addItem(entry);
        entry.setEventListener(l, true);
        entry.setParentID(parentEntryID);
        entry.setDatasource(datasource);
        entry.setPreferredAfterID(preferredAfterID);
        setupNewEntry(entry, id, false, closeable);
        if (l instanceof IViewAlwaysInitialize) {
            entry.build();
        }
    } catch (Exception e) {
        Debug.out(e);
        entry.close(true);
        entry = null;
    }
    return entry;
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize)

Aggregations

IViewAlwaysInitialize (com.biglybt.ui.swt.views.IViewAlwaysInitialize)5 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)3 MdiEntry (com.biglybt.ui.mdi.MdiEntry)2 UISWTViewEventCancelledException (com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)2 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)1 UISWTViewEventListenerHolder (com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)1