use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SideBar method createHeader.
@Override
public MdiEntry createHeader(String id, String titleID, String preferredAfterID) {
MdiEntry oldEntry = getEntry(id);
if (oldEntry != null) {
return oldEntry;
}
SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id, null);
entry.setSelectable(false);
entry.setPreferredAfterID(preferredAfterID);
entry.setTitleID(titleID);
setupNewEntry(entry, id, true, false);
return entry;
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SideBar method removeItem.
@Override
public void removeItem(MdiEntry entry) {
super.removeItem(entry);
if (Utils.isDisplayDisposed()) {
return;
}
if (entry instanceof SideBarEntrySWT) {
MdiEntry current = getCurrentEntry();
SideBarEntrySWT next = null;
synchronized (stack) {
stack.remove(entry);
if (current == null || current == entry) {
while (!stack.isEmpty()) {
next = stack.pop();
if (next.isDisposed()) {
next = null;
} else {
break;
}
}
}
}
if (next != null) {
showEntry(next);
}
}
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SideBarEntrySWT method widgetDisposed.
@Override
public void widgetDisposed(DisposeEvent e) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (imageLoader != null) {
imageLoader.releaseImage("image.sidebar.closeitem");
imageLoader.releaseImage("image.sidebar.closeitem-selected");
}
setDisposed(true);
final TreeItem treeItem = (TreeItem) e.widget;
if (treeItem != swtItem) {
Debug.out("Warning: TreeItem changed for sidebar " + id);
return;
}
if (swtItem == null) {
return;
}
if (swtItem != null && !Constants.isOSX) {
// In theory, the disposal of swtItem will trigger the disposal of the
// children. Let's force it just in case
// On OSX this will cause disposal confusion in SWT, and possibly result
// in a SIGSEGV crash.
TreeItem[] children = swtItem.getItems();
for (TreeItem child : children) {
if (child.isDisposed()) {
continue;
}
MdiEntry entry = (MdiEntry) child.getData("MdiEntry");
if (entry != null) {
entry.close(true);
}
}
}
final Tree tree = sidebar.getTree();
if (tree.isDisposed() || (swtItem != null && swtItem.isDisposed()) || tree.getShell().isDisposed()) {
return;
}
setTreeItem(null);
mdi.removeItem(SideBarEntrySWT.this);
SWTThread instance = SWTThread.getInstance();
boolean user = instance != null && !instance.isTerminated();
if (user) {
// It's not a user close if the parent is making the children (this entry)
// close. parent will be marked disposed, so use that as a check.
String parentID = getParentID();
if (parentID != null) {
MdiEntry entry = mdi.getEntry(parentID);
if (entry != null && entry.isDisposed()) {
user = false;
}
}
}
triggerCloseListeners(user);
SWTSkinObject so = getSkinObject();
if (so != null) {
setSkinObjectMaster(null);
so.getSkin().removeSkinObject(so);
}
for (SideBarVitalityImageSWT vitalityImage : listVitalityImages) {
vitalityImage.dispose();
}
listVitalityImages.clear();
// 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) {
// opposed to closing the sidebar)
if (tree.isDisposed()) {
return;
}
try {
COConfigurationManager.removeParameter("SideBar.AutoOpen." + id);
// Force selection
if (Constants.isOSX && !tree.isDisposed() && tree.getSelectionCount() == 0) {
String parentid = getParentID();
if (parentid != null && mdi.getEntry(parentid) != null) {
mdi.showEntryByID(parentid);
} else {
mdi.showEntryByID(SideBar.SIDEBAR_SECTION_LIBRARY);
}
}
} catch (Exception e2) {
Debug.out(e2);
}
// See if this entry has been replaced by another in the meantime. This happens when we are
// moving an entry in the sidebar by removing it and then re-adding it. We assume that the
// auto-open properties of the replacement are the same as those of the initial entry
boolean replaced = false;
String my_id = SideBarEntrySWT.this.getId();
if (my_id != null) {
MdiEntry entry = mdi.getEntry(my_id);
if (entry != null && entry != SideBarEntrySWT.this) {
replaced = true;
}
}
if (!replaced) {
mdi.removeEntryAutoOpen(id);
}
}
});
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class TabbedMDI method createEntryFromSkinRef.
private MdiEntry createEntryFromSkinRef(String parentID, String id, String configID, String title, ViewTitleInfo titleInfo, Object params, boolean closeable, int index) {
MdiEntry oldEntry = getEntry(id);
if (oldEntry != null) {
return oldEntry;
}
TabbedEntry entry = new TabbedEntry(this, skin, id, null);
entry.setTitle(title);
entry.setSkinRef(configID, params);
entry.setViewTitleInfo(titleInfo);
setupNewEntry(entry, id, index, closeable);
return entry;
}
use of com.biglybt.ui.mdi.MdiEntry 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