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);
}
});
}
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;
}
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;
}
Aggregations