use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.
the class ToolBarView method rebuild.
private void rebuild() {
synchronized (itemMap) {
if (rebuilding) {
rebuild_pending = true;
return;
}
rebuilding = true;
}
Utils.execSWTThread(() -> {
synchronized (itemMap) {
Set<String> groups = new HashSet<>();
for (ToolBarItemSO so : itemMap.values()) {
groups.add(so.getBase().getGroupID());
}
itemMap.clear();
for (String group : groups) {
SWTSkinObjectContainer groupSO = peekGroupSO(group);
if (groupSO != null) {
SWTSkinObject[] children = groupSO.getChildren();
for (SWTSkinObject so : children) {
so.dispose();
}
groupSO.dispose();
}
}
}
Map<UIToolBarItem, ToolBarItemSO> newMap = new HashMap<>();
try {
skin.constructionStart();
build(newMap);
} finally {
skin.constructionEnd();
}
Composite comp = (Composite) soMain.getControl();
addMenus(comp);
Utils.relayout(comp);
synchronized (itemMap) {
itemMap.putAll(newMap);
rebuilding = false;
if (rebuild_pending) {
rebuild_pending = false;
Utils.getOffOfSWTThread(() -> {
rebuild();
});
}
}
});
}
use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.
the class ToolBarView method createItemSO.
private void createItemSO(ToolBarItem item, String templatePrefix, int position) {
ToolBarItemSO existingItemSO;
synchronized (mapToolBarItemToSO) {
existingItemSO = mapToolBarItemToSO.get(item);
}
if (existingItemSO != null) {
SWTSkinObject so = existingItemSO.getSO();
if (so != null) {
so.dispose();
}
}
String templateID = templatePrefix;
if (position == SWT.RIGHT) {
templateID += ".right";
} else if (position == SWT.LEFT) {
templateID += ".left";
} else if (position == SWT.SINGLE) {
templateID += ".lr";
}
Control attachToControl = getLastControl(item.getGroupID());
String id = "toolbar:" + item.getID();
SWTSkinObject so = skin.createSkinObject(id, templateID, getGroupSO(item.getGroupID()));
if (so != null) {
ToolBarItemSO itemSO;
itemSO = new ToolBarItemSO((UIToolBarItemImpl) item, so);
if (attachToControl != null) {
FormData fd = (FormData) so.getControl().getLayoutData();
fd.left = new FormAttachment(attachToControl);
}
initSO(so, itemSO);
if (initComplete) {
Utils.relayout(so.getControl().getParent());
}
}
}
use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.
the class ToolBarView method createItemSO.
private void createItemSO(Map<UIToolBarItem, ToolBarItemSO> newMap, ToolBarItem item, String templatePrefix, int position) {
ToolBarItemSO existingItemSO = newMap.get(item);
if (existingItemSO != null) {
SWTSkinObject so = existingItemSO.getSO();
if (so != null) {
so.dispose();
}
}
String templateID = templatePrefix;
if (position == SWT.RIGHT) {
templateID += ".right";
} else if (position == SWT.LEFT) {
templateID += ".left";
} else if (position == SWT.SINGLE) {
templateID += ".lr";
}
Control attachToControl = getLastControl(item.getGroupID());
String id = "toolbar:" + item.getID();
SWTSkinObject so = skin.createSkinObject(id, templateID, getGroupSO(item.getGroupID()));
if (so != null) {
ToolBarItemSO itemSO;
itemSO = new ToolBarItemSO((UIToolBarItemImpl) item, so);
if (attachToControl != null) {
FormData fd = (FormData) so.getControl().getLayoutData();
fd.left = new FormAttachment(attachToControl);
}
initSO(newMap, so, itemSO);
if (initComplete) {
Utils.relayout(so.getControl().getParent());
}
}
}
Aggregations