Search in sources :

Example 1 with UISWTViewEventCancelledException

use of com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException in project BiglyBT by BiglySoftware.

the class TabbedEntry method widgetDisposed.

@Override
public void widgetDisposed(DisposeEvent e) {
    setSwtItem(null);
    SWTThread instance = SWTThread.getInstance();
    triggerCloseListeners(instance != null && !instance.isTerminated());
    try {
        setEventListener(null, false);
    } catch (UISWTViewEventCancelledException e1) {
    }
    SWTSkinObject so = getSkinObject();
    if (so != null) {
        setSkinObjectMaster(null);
        so.getSkin().removeSkinObject(so);
    }
    // delay saving of removing of auto-open flag.  If after the delay, we are
    // still alive, it's assumed the user invoked the close, and we should
    // remove the auto-open flag
    Utils.execSWTThreadLater(0, new SWTRunnable() {

        @Override
        public void runWithDisplay(Display display) {
            // even though execThreadLater will not run on close of app because
            // the display is disposed, do a double check of tree disposal just
            // in case.  We don't want to trigger close listeners or
            // remove autoopen parameters if the user is closing the app (as
            // opposed to closing  the sidebar)
            mdi.removeItem(TabbedEntry.this);
            mdi.removeEntryAutoOpen(id);
        }
    });
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) SWTThread(com.biglybt.ui.swt.mainwindow.SWTThread)

Example 2 with UISWTViewEventCancelledException

use of com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException in project BiglyBT by BiglySoftware.

the class TabbedEntry method swt_build.

public boolean swt_build() {
    if (swtItem == null) {
        buildonSWTItemSet = true;
        return true;
    }
    buildonSWTItemSet = false;
    Control control = swtItem.getControl();
    if (control == null || control.isDisposed()) {
        Composite parent = swtItem.getParent();
        if (parent.isDisposed()) {
            return false;
        }
        SWTSkinObject soParent = (SWTSkinObject) parent.getData("SkinObject");
        String skinRef = getSkinRef();
        if (skinRef != null) {
            Shell shell = parent.getShell();
            Cursor cursor = shell.getCursor();
            try {
                shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
                // SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject(
                // "MdiContents." + uniqueNumber++, "mdi.content.item",
                // soParent, getSkinRefParams());
                // skin.addSkinObject(soContents);
                SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soParent, getDatasourceCore());
                control = skinObject.getControl();
                control.setLayoutData(Utils.getFilledFormData());
                control.getParent().layout(true);
                // swtItem.setControl will set the control's visibility based on
                // whether the control is selected.  To ensure it doesn't set
                // our control invisible, set selection now
                CTabItem oldSelection = swtItem.getParent().getSelection();
                swtItem.getParent().setSelection(swtItem);
                swtItem.setControl(control);
                if (oldSelection != null) {
                    swtItem.getParent().setSelection(oldSelection);
                }
                setPluginSkinObject(skinObject);
                setSkinObjectMaster(skinObject);
                initialize((Composite) control);
            } finally {
                shell.setCursor(cursor);
            }
        } else {
            // XXX: This needs to be merged into BaseMDIEntry.initialize
            try {
                SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, "mdi.content.item", soParent);
                parent.setBackgroundMode(SWT.INHERIT_NONE);
                Composite viewComposite = soContents.getComposite();
                // viewComposite.setBackground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_WIDGET_BACKGROUND));
                // viewComposite.setForeground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_WIDGET_FOREGROUND));
                boolean doGridLayout = true;
                if (getControlType() == CONTROLTYPE_SKINOBJECT) {
                    doGridLayout = false;
                }
                if (doGridLayout) {
                    GridLayout gridLayout = new GridLayout();
                    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
                    viewComposite.setLayout(gridLayout);
                    viewComposite.setLayoutData(Utils.getFilledFormData());
                }
                setPluginSkinObject(soContents);
                initialize(viewComposite);
                Composite iviewComposite = getComposite();
                control = iviewComposite;
                if (doGridLayout) {
                    Object existingLayoutData = iviewComposite.getLayoutData();
                    Object existingParentLayoutData = iviewComposite.getParent().getLayoutData();
                    if (existingLayoutData == null || !(existingLayoutData instanceof GridData) && (existingParentLayoutData instanceof GridLayout)) {
                        GridData gridData = new GridData(GridData.FILL_BOTH);
                        iviewComposite.setLayoutData(gridData);
                    }
                }
                CTabItem oldSelection = swtItem.getParent().getSelection();
                swtItem.getParent().setSelection(swtItem);
                swtItem.setControl(viewComposite);
                if (oldSelection != null) {
                    swtItem.getParent().setSelection(oldSelection);
                }
                setSkinObjectMaster(soContents);
            } catch (Exception e) {
                Debug.out("Error creating sidebar content area for " + id, e);
                try {
                    setEventListener(null, false);
                } catch (UISWTViewEventCancelledException e1) {
                }
                close(true);
            }
        }
        if (control != null && !control.isDisposed()) {
            control.setData("BaseMDIEntry", this);
        /**
         * XXX Removed this because we can dispose of the control and still
         * want the tab (ie. destroy on focus lost, rebuild on focus gain)
         *				control.addDisposeListener(new DisposeListener() {
         *					public void widgetDisposed(DisposeEvent e) {
         *						close(true);
         *					}
         *				});
         */
        } else {
            return false;
        }
    }
    return true;
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) Cursor(org.eclipse.swt.graphics.Cursor) CTabItem(org.eclipse.swt.custom.CTabItem) SWTException(org.eclipse.swt.SWTException) UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) GridData(org.eclipse.swt.layout.GridData) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 3 with UISWTViewEventCancelledException

use of com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException 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)

Aggregations

UISWTViewEventCancelledException (com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)3 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 SWTThread (com.biglybt.ui.swt.mainwindow.SWTThread)1 UISWTViewEventListenerHolder (com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 SWTRunnable (com.biglybt.ui.swt.utils.SWTRunnable)1 IViewAlwaysInitialize (com.biglybt.ui.swt.views.IViewAlwaysInitialize)1 SWTException (org.eclipse.swt.SWTException)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 Cursor (org.eclipse.swt.graphics.Cursor)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1