use of com.biglybt.ui.swt.skin.SWTSkinObjectListener in project BiglyBT by BiglySoftware.
the class TabbedEntry method buildStandAlone.
public static SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent, String skinRef, SWTSkin skin, String parentID, String id, Object datasource, int controlType, CTabItem swtItem, UISWTViewEventListener original_event_listener, boolean listener_is_new) {
Control control = null;
// SWTSkin skin = soParent.getSkin();
Composite parent = soParent.getComposite();
if (skinRef != null) {
Shell shell = parent.getShell();
Cursor cursor = shell.getCursor();
try {
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
// wrap skinRef with a container that we control visibility of
// (invisible by default)
SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiContents." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent, null);
SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soContents, datasource);
control = skinObject.getControl();
control.setLayoutData(Utils.getFilledFormData());
control.getParent().layout(true, true);
soContents.setVisible(true);
return (soContents);
} finally {
shell.setCursor(cursor);
}
} else {
if ((original_event_listener instanceof UISWTViewCoreEventListenerEx && ((UISWTViewCoreEventListenerEx) original_event_listener).isCloneable()) || (original_event_listener instanceof UISWTViewEventListenerEx)) {
final UISWTViewImpl view = new UISWTViewImpl(id, parentID, true);
final UISWTViewEventListener event_listener = listener_is_new ? original_event_listener : original_event_listener instanceof UISWTViewEventListenerEx ? ((UISWTViewEventListenerEx) original_event_listener).getClone() : ((UISWTViewCoreEventListenerEx) original_event_listener).getClone();
try {
view.setEventListener(event_listener, false);
} catch (Throwable e) {
// shouldn't happen as we aren't asking for 'create' to occur which means it can't fail
Debug.out(e);
}
view.setDatasource(datasource);
try {
SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent);
parent.setBackgroundMode(SWT.INHERIT_NONE);
final Composite viewComposite = soContents.getComposite();
boolean doGridLayout = true;
if (controlType == CONTROLTYPE_SKINOBJECT) {
doGridLayout = false;
}
// SWT.COLOR_WIDGET_FOREGROUND));
if (doGridLayout) {
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
viewComposite.setLayout(gridLayout);
viewComposite.setLayoutData(Utils.getFilledFormData());
}
view.setPluginSkinObject(soContents);
view.initialize(viewComposite);
// without this some views get messed up layouts (chat view for example)
viewComposite.setData(Utils.RELAYOUT_UP_STOP_HERE, true);
soContents.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_OBFUSCATE) {
Map data = new HashMap();
data.put("image", (Image) params);
data.put("obfuscateTitle", false);
view.triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, data);
}
return null;
}
});
// swtItem.setText(view.getFullTitle());
Composite iviewComposite = view.getComposite();
control = iviewComposite;
// that instead of form)
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);
}
}
parent.layout(true, true);
final UIUpdater updater = UIUpdaterSWT.getInstance();
if (updater != null) {
updater.addUpdater(new UIUpdatable() {
@Override
public void updateUI() {
if (viewComposite.isDisposed()) {
updater.removeUpdater(this);
} else {
view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
}
}
@Override
public String getUpdateUIName() {
return ("popout");
}
});
if (event_listener instanceof IViewRequiresPeriodicUpdates) {
updater.addPeriodicUpdater(new UIUpdatable() {
@Override
public void updateUI() {
if (viewComposite.isDisposed()) {
updater.removePeriodicUpdater(this);
} else {
event_listener.eventOccurred(new UISWTViewEvent() {
@Override
public UISWTView getView() {
return null;
}
@Override
public int getType() {
return (StatsView.EVENT_PERIODIC_UPDATE);
}
@Override
public Object getData() {
return null;
}
});
}
}
@Override
public String getUpdateUIName() {
return ("popout");
}
});
}
}
soContents.setVisible(true);
view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
iviewComposite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
view.triggerEvent(UISWTViewEvent.TYPE_DESTROY, null);
}
});
return (soContents);
} catch (Throwable e) {
Debug.out(e);
}
}
}
return (null);
}
use of com.biglybt.ui.swt.skin.SWTSkinObjectListener in project BiglyBT by BiglySoftware.
the class SearchResultsTabAreaBrowser method init.
protected void init(SWTSkinObjectBrowser _browserSkinObject) {
browserSkinObject = _browserSkinObject;
browserSkinObject.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == EVENT_SHOW) {
browserSkinObject.removeListener(this);
createBrowseArea(browserSkinObject);
}
return null;
}
});
}
use of com.biglybt.ui.swt.skin.SWTSkinObjectListener in project BiglyBT by BiglySoftware.
the class TopBarView method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
this.skin = skinObject.getSkin();
skin.addListener("topbar-plugins", new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
skin.removeListener("topbar-plugins", this);
// building needs UISWTInstance, which needs core.
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
Utils.execSWTThreadLater(0, new AERunnable() {
@Override
public void runSupport() {
buildTopBarViews();
}
});
}
});
}
return null;
}
});
// trigger autobuild and hook in events
skin.getSkinObject("topbar-area-plugin").addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
}
} else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
}
}
return (null);
}
});
return null;
}
use of com.biglybt.ui.swt.skin.SWTSkinObjectListener in project BiglyBT by BiglySoftware.
the class SideBarEntrySWT method buildStandAlone.
public static SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent, String skinRef, SWTSkin skin, String parentID, String id, Object datasource, int controlType, TreeItem swtItem, UISWTViewEventListener original_event_listener, boolean listener_is_new) {
Control control = null;
// SWTSkin skin = soParent.getSkin();
Composite parent = soParent.getComposite();
if (skinRef != null) {
Shell shell = parent.getShell();
Cursor cursor = shell.getCursor();
try {
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
// wrap skinRef with a container that we control visibility of
// (invisible by default)
SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiContents." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent, null);
SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soContents, datasource);
control = skinObject.getControl();
control.setLayoutData(Utils.getFilledFormData());
control.getParent().layout(true, true);
soContents.setVisible(true);
return (soContents);
} finally {
shell.setCursor(cursor);
}
} else {
if ((original_event_listener instanceof UISWTViewCoreEventListenerEx && ((UISWTViewCoreEventListenerEx) original_event_listener).isCloneable()) || (original_event_listener instanceof UISWTViewEventListenerEx)) {
final UISWTViewImpl view = new UISWTViewImpl(id, parentID, true);
final UISWTViewEventListener event_listener = original_event_listener instanceof UISWTViewEventListenerEx ? ((UISWTViewEventListenerEx) original_event_listener).getClone() : ((UISWTViewCoreEventListenerEx) original_event_listener).getClone();
try {
view.setEventListener(event_listener, false);
} catch (Throwable e) {
// shouldn't happen as we aren't asking for 'create' to occur which means it can't fail
Debug.out(e);
}
view.setDatasource(datasource);
try {
SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent);
parent.setBackgroundMode(SWT.INHERIT_NONE);
final Composite viewComposite = soContents.getComposite();
boolean doGridLayout = true;
if (controlType == CONTROLTYPE_SKINOBJECT) {
doGridLayout = false;
}
// SWT.COLOR_WIDGET_FOREGROUND));
if (doGridLayout) {
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
viewComposite.setLayout(gridLayout);
viewComposite.setLayoutData(Utils.getFilledFormData());
}
view.setPluginSkinObject(soContents);
view.initialize(viewComposite);
// without this some views get messed up layouts (chat view for example)
viewComposite.setData(Utils.RELAYOUT_UP_STOP_HERE, true);
soContents.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_OBFUSCATE) {
Map data = new HashMap();
data.put("image", (Image) params);
data.put("obfuscateTitle", false);
view.triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, data);
}
return null;
}
});
if (PAINT_BG) {
if (swtItem != null) {
swtItem.setText(view.getFullTitle());
}
}
Composite iviewComposite = view.getComposite();
control = iviewComposite;
// that instead of form)
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);
}
}
parent.layout(true, true);
final UIUpdater updater = UIUpdaterSWT.getInstance();
if (updater != null) {
updater.addUpdater(new UIUpdatable() {
@Override
public void updateUI() {
if (viewComposite.isDisposed()) {
updater.removeUpdater(this);
} else {
view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
}
}
@Override
public String getUpdateUIName() {
return ("popout");
}
});
if (event_listener instanceof IViewRequiresPeriodicUpdates) {
updater.addPeriodicUpdater(new UIUpdatable() {
@Override
public void updateUI() {
if (viewComposite.isDisposed()) {
updater.removePeriodicUpdater(this);
} else {
event_listener.eventOccurred(new UISWTViewEvent() {
@Override
public UISWTView getView() {
return null;
}
@Override
public int getType() {
return (StatsView.EVENT_PERIODIC_UPDATE);
}
@Override
public Object getData() {
return null;
}
});
}
}
@Override
public String getUpdateUIName() {
return ("popout");
}
});
}
}
soContents.setVisible(true);
view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
iviewComposite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
view.triggerEvent(UISWTViewEvent.TYPE_DESTROY, null);
}
});
return (soContents);
} catch (Throwable e) {
Debug.out(e);
}
}
}
return (null);
}
use of com.biglybt.ui.swt.skin.SWTSkinObjectListener in project BiglyBT by BiglySoftware.
the class SBC_ActivityTableView method skinObjectInitialShow.
// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
skinObject.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
SelectedContentManager.changeCurrentlySelectedContent(tableID, getCurrentlySelectedContent(), view);
} else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
SelectedContentManager.changeCurrentlySelectedContent(tableID, null, view);
}
return null;
}
});
SWTSkinObject soParent = skinObject.getParent();
Object data = soParent.getControl().getData("ViewMode");
if (data instanceof Long) {
viewMode = (int) ((Long) data).longValue();
}
boolean big = viewMode == SBC_ActivityView.MODE_BIGTABLE;
tableID = big ? TableManager.TABLE_ACTIVITY_BIG : TableManager.TABLE_ACTIVITY;
TableColumnCore[] columns = big ? TableColumnCreatorV3.createActivityBig(tableID) : TableColumnCreatorV3.createActivitySmall(tableID);
view = TableViewFactory.createTableViewSWT(ActivitiesEntry.class, tableID, tableID, columns, "name", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
view.setRowDefaultHeightEM(big ? 3 : 2);
view.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.DEL) {
removeSelected();
} else if (e.keyCode == SWT.F5) {
if ((e.stateMask & SWT.SHIFT) != 0) {
ActivitiesManager.resetRemovedEntries();
}
if ((e.stateMask & SWT.CONTROL) != 0) {
System.out.println("pull all vuze news entries");
ActivitiesManager.clearLastPullTimes();
ActivitiesManager.pullActivitiesNow(0, "^F5", true);
} else {
System.out.println("pull latest vuze news entries");
ActivitiesManager.pullActivitiesNow(0, "F5", true);
}
}
}
});
view.addSelectionListener(new TableSelectionAdapter() {
// @see TableSelectionAdapter#selected(TableRowCore[])
@Override
public void selected(TableRowCore[] rows) {
selectionChanged();
for (int i = 0; i < rows.length; i++) {
ActivitiesEntry entry = (ActivitiesEntry) rows[i].getDataSource(true);
if (entry != null && !entry.isRead() && entry.canFlipRead()) {
entry.setRead(true);
}
}
}
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
if (rows.length == 1) {
ActivitiesEntry ds = (ActivitiesEntry) rows[0].getDataSource();
if (ds.getTypeID().equals(ActivitiesConstants.TYPEID_LOCALNEWS)) {
String[] actions = ds.getActions();
if (actions.length == 1) {
ds.invokeCallback(actions[0]);
}
} else {
TorrentListViewsUtils.playOrStreamDataSource(ds, false);
}
}
}
@Override
public void deselected(TableRowCore[] rows) {
selectionChanged();
}
public void selectionChanged() {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
ISelectedContent[] contents = getCurrentlySelectedContent();
if (soMain.isVisible()) {
SelectedContentManager.changeCurrentlySelectedContent(tableID, contents, view);
}
}
});
}
}, false);
view.addLifeCycleListener(new TableLifeCycleListener() {
@Override
public void tableLifeCycleEventOccurred(TableView tv, int eventType, Map<String, Object> data) {
switch(eventType) {
case EVENT_TABLELIFECYCLE_INITIALIZED:
view.addDataSources(ActivitiesManager.getAllEntries().toArray(new ActivitiesEntry[0]));
ActivitiesManager.addListener(SBC_ActivityTableView.this);
break;
case EVENT_TABLELIFECYCLE_DESTROYED:
ActivitiesManager.removeListener(SBC_ActivityTableView.this);
break;
}
}
});
SWTSkinObjectContainer soContents = new SWTSkinObjectContainer(skin, skin.getSkinProperties(), getUpdateUIName(), "", soMain);
skin.layout();
viewComposite = soContents.getComposite();
viewComposite.setBackground(Colors.getSystemColor(viewComposite.getDisplay(), SWT.COLOR_WIDGET_BACKGROUND));
viewComposite.setForeground(Colors.getSystemColor(viewComposite.getDisplay(), SWT.COLOR_WIDGET_FOREGROUND));
viewComposite.setLayoutData(Utils.getFilledFormData());
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
viewComposite.setLayout(gridLayout);
view.initialize(viewComposite);
return null;
}
Aggregations