use of com.biglybt.ui.swt.skin.SWTSkinObject 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.SWTSkinObject 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.skin.SWTSkinObject in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method showView.
@Override
public void showView() {
SWTSkinObject so_list = getSkinObject("search-results-list");
if (so_list != null) {
MetaSearchManagerFactory.getSingleton().getMetaSearch().addListener(this);
so_list.setVisible(true);
initTable((Composite) so_list.getControl());
}
}
use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method skinObjectInitialShow.
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
image_loader = new ImageLoader(null, null);
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
initColumns(core);
}
});
SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
if (soFilterBox != null) {
txtFilter = soFilterBox.getTextControl();
}
if (vitality_images == null) {
ImageLoader loader = ImageLoader.getInstance();
vitality_images = loader.getImages("image.sidebar.vitality.dots");
ok_image = loader.getImage("tick_mark");
fail_image = loader.getImage("progress_cancel");
auth_image = loader.getImage("image.sidebar.vitality.auth");
}
final SWTSkinObject soFilterArea = getSkinObject("filterarea");
if (soFilterArea != null) {
SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
if (soFilterButton != null) {
boolean toggled = COConfigurationManager.getBooleanParameter("Search View Filter Options Expanded", false);
if (toggled) {
soFilterButton.setToggled(true);
soFilterArea.setVisible(true);
}
soFilterButton.addSelectionListener(new SWTSkinToggleListener() {
@Override
public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
COConfigurationManager.setParameter("Search View Filter Options Expanded", toggled);
soFilterArea.setVisible(toggled);
Utils.relayout(soFilterArea.getControl().getParent());
}
});
}
Composite parent = (Composite) soFilterArea.getControl();
Composite filter_area = new Composite(parent, SWT.NONE);
FormData fd = Utils.getFilledFormData();
filter_area.setLayoutData(fd);
GridLayout layout = new GridLayout();
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
filter_area.setLayout(layout);
Label label;
int sepHeight = 20;
Composite cRow = new Composite(filter_area, SWT.NONE);
cRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.spacing = 5;
rowLayout.marginBottom = rowLayout.marginTop = rowLayout.marginLeft = rowLayout.marginRight = 0;
rowLayout.center = true;
cRow.setLayout(rowLayout);
// with/without keywords
ImageLoader imageLoader = ImageLoader.getInstance();
for (int i = 0; i < 2; i++) {
final boolean with = i == 0;
if (!with) {
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
}
Composite cWithKW = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cWithKW.setLayout(layout);
// Label lblWithKW = new Label(cWithKW, SWT.NONE);
// lblWithKW.setText(MessageText.getString(with?"SubscriptionResults.filter.with.words":"SubscriptionResults.filter.without.words"));
Label lblWithKWImg = new Label(cWithKW, SWT.NONE);
lblWithKWImg.setImage(imageLoader.getImage(with ? "icon_filter_plus" : "icon_filter_minus"));
final Text textWidget = new Text(cWithKW, SWT.BORDER);
if (with) {
textWithKW = textWidget;
} else {
textWithoutKW = textWidget;
}
textWidget.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
GridData gd = new GridData();
gd.widthHint = Utils.adjustPXForDPI(100);
textWidget.setLayoutData(gd);
textWidget.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = textWidget.getText().toLowerCase(Locale.US);
String[] bits = text.split("\\s+");
Set<String> temp = new HashSet<>();
for (String bit : bits) {
bit = bit.trim();
if (bit.length() > 0) {
temp.add(bit);
}
}
String[] words = temp.toArray(new String[temp.size()]);
synchronized (filter_lock) {
if (with) {
with_keywords = words;
} else {
without_keywords = words;
}
}
refilter_dispatcher.dispatch();
}
});
}
// min size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMinSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMinSize.setLayout(layout);
Label lblMinSize = new Label(cMinSize, SWT.NONE);
lblMinSize.setText(MessageText.getString("SubscriptionResults.filter.min_size"));
spinMinSize = new Spinner(cMinSize, SWT.BORDER);
spinMinSize.setMinimum(0);
// 100 TB should do...
spinMinSize.setMaximum(100 * 1024 * 1024);
spinMinSize.setSelection(minSize);
spinMinSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
minSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
// max size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMaxSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMaxSize.setLayout(layout);
Label lblMaxSize = new Label(cMaxSize, SWT.NONE);
lblMaxSize.setText(MessageText.getString("SubscriptionResults.filter.max_size"));
spinMaxSize = new Spinner(cMaxSize, SWT.BORDER);
spinMaxSize.setMinimum(0);
// 100 TB should do...
spinMaxSize.setMaximum(100 * 1024 * 1024);
spinMaxSize.setSelection(maxSize);
spinMaxSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
maxSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
engine_area = new Composite(filter_area, SWT.NONE);
engine_area.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buildEngineArea(null);
parent.layout(true);
}
return null;
}
use of com.biglybt.ui.swt.skin.SWTSkinObject 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;
}
});
}
Aggregations