} else {
soGap = null;
}
}
ToolBarItem item;
if (!uiClassic) {
// ==download
item = new ToolBarItem("download", "image.button.download",
"v3.MainWindow.button.download") {
// @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
public void triggerToolBarItem() {
String viewID = SelectedContentManager.getCurrentySelectedViewID();
if (viewID == null && triggerIViewToolBar(getId())) {
return;
}
// This is for our CDP pages
ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
if (sc != null && sc.length == 1
&& (sc[0].getHash() != null || sc[0].getDownloadInfo() != null)) {
TorrentListViewsUtils.downloadDataSource(sc[0], false,
DLReferals.DL_REFERAL_TOOLBAR);
}
}
};
addToolBarItem(item);
// ==play
item = new ToolBarItem("play", "image.button.play", "iconBar.play") {
// @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
public void triggerToolBarItem() {
String viewID = SelectedContentManager.getCurrentySelectedViewID();
if (viewID == null && triggerIViewToolBar(getId())) {
return;
}
ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
if (sc != null && sc.length > 0 ) {
if ( PlayUtils.canStreamDS(sc[0], sc[0].getFileIndex())){
TorrentListViewsUtils.playOrStreamDataSource(sc[0],
DLReferals.DL_REFERAL_TOOLBAR, true, false);
}else{
TorrentListViewsUtils.playOrStreamDataSource(sc[0],
DLReferals.DL_REFERAL_TOOLBAR, false, true);
}
}
}
};
addToolBarItem(item);
addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep",
soMain);
lastControl = null;
} else {
lastControl = null;
// ==OPEN
item = new ToolBarItem("open", "image.toolbar.open", "Button.add") {
public void triggerToolBarItem() {
TorrentOpener.openTorrentWindow();
}
};
item.setAlwaysAvailable(true);
addToolBarItem(item, "toolbar.area.sitem.left", so2nd);
addSeperator(so2nd);
// ==SEARCH
item = new ToolBarItem("search", "search", "Button.search") {
public void triggerToolBarItem() {
UIFunctionsManagerSWT.getUIFunctionsSWT().promptForSearch();
}
};
item.setAlwaysAvailable(true);
addToolBarItem(item, "toolbar.area.sitem.right", so2nd);
addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep3",
so2nd);
addNonToolBar("toolbar.area.sitem.left2", so2nd);
}
boolean first = true;
// ==transcode
if (!DeviceManagerUI.DISABLED) {
item = new ToolBarItem("transcode", "image.button.transcode",
"iconBar.transcode") {
// @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
public void triggerToolBarItem() {
String viewID = SelectedContentManager.getCurrentySelectedViewID();
if (viewID == null && triggerIViewToolBar(getId())) {
return;
}
ISelectedContent[] contents = SelectedContentManager.getCurrentlySelectedContent();
if (contents.length == 0) {
return;
}
deviceSelected(contents, true);
}
};
addToolBarItem(item, first ? "toolbar.area.sitem.left"
: "toolbar.area.sitem", so2nd);
first = false;
addSeperator(so2nd);
}
// ==run
item = new ToolBarItem("run", "image.toolbar.run", "iconBar.run") {
public void triggerToolBarItem() {
if (!triggerBasicToolBarItem(getId())) {
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
if (dms != null) {
TorrentUtil.runDataSources(dms);
for (int i = 0; i < dms.length; i++) {
DownloadManager dm = dms[i];
PlatformTorrentUtils.setHasBeenOpened(dm, true);
}
}
}
}
};
addToolBarItem(item, first ? "toolbar.area.sitem.left"
: "toolbar.area.sitem", so2nd);
first = false;
//addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
if (uiClassic) {
// ==TOP
item = new ToolBarItem("top", "image.toolbar.top", "iconBar.top") {
public void triggerToolBarItem() {
moveTop();
}
public boolean triggerToolBarItemHold() {
return false;
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
}
// ==UP
item = new ToolBarItem("up", "image.toolbar.up", "v3.iconBar.up") {
public void triggerToolBarItem() {
if (!AzureusCoreFactory.isCoreRunning()) {
return;
}
if (!triggerBasicToolBarItem(getId())) {
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
if (dms != null) {
Arrays.sort(dms, new Comparator<DownloadManager>() {
public int compare(DownloadManager a, DownloadManager b) {
return a.getPosition() - b.getPosition();
}
});
GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
for (int i = 0; i < dms.length; i++) {
DownloadManager dm = dms[i];
if (gm.isMoveableUp(dm)) {
gm.moveUp(dm);
}
}
}
}
}
// @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItemHold()
public boolean triggerToolBarItemHold() {
return moveTop();
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
// ==down
item = new ToolBarItem("down", "image.toolbar.down", "v3.iconBar.down") {
public void triggerToolBarItem() {
if (!AzureusCoreFactory.isCoreRunning()) {
return;
}
if (!triggerBasicToolBarItem(getId())) {
GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
if (dms != null) {
Arrays.sort(dms, new Comparator<DownloadManager>() {
public int compare(DownloadManager a, DownloadManager b) {
return b.getPosition() - a.getPosition();
}
});
for (int i = 0; i < dms.length; i++) {
DownloadManager dm = dms[i];
if (gm.isMoveableDown(dm)) {
gm.moveDown(dm);
}
}
}
}
}
// @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItemHold()
public boolean triggerToolBarItemHold() {
return moveBottom();
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
if (uiClassic) {
// ==BOTTOM
item = new ToolBarItem("bottom", "image.toolbar.bottom", "iconBar.bottom") {
public void triggerToolBarItem() {
moveBottom();
}
public boolean triggerToolBarItemHold() {
return false;
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
}
// ==start
item = new ToolBarItem("start", "image.toolbar.start", "iconBar.start") {
public void triggerToolBarItem() {
if (!triggerBasicToolBarItem(getId())) {
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
if (dms != null) {
TorrentUtil.queueDataSources(dms, true);
}
}
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
//SWTSkinObjectContainer so = (SWTSkinObjectContainer) item.getSkinButton().getSkinObject();
//so.setDebugAndChildren(true);
addSeperator(so2nd);
// ==stop
item = new ToolBarItem("stop", "image.toolbar.stop", "iconBar.stop") {
public void triggerToolBarItem() {
if (!triggerBasicToolBarItem(getId())) {
ISelectedContent[] currentContent = SelectedContentManager.getCurrentlySelectedContent();
TorrentUtil.stopDataSources(currentContent);
}
}
};
addToolBarItem(item, "toolbar.area.sitem", so2nd);
addSeperator(so2nd);
// ==remove
item = new ToolBarItem("remove", "image.toolbar.remove", "iconBar.remove") {
public void triggerToolBarItem() {
if (!triggerBasicToolBarItem(getId())) {
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
TorrentUtil.removeDownloads(dms, null);
}
}
};
addToolBarItem(item, "toolbar.area.sitem.right", so2nd);
///////////////////////
addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep3",
so2nd);
addNonToolBar("toolbar.area.sitem.left2", so2nd);
// == mode big
item = new ToolBarItem("modeBig", "image.toolbar.table_large",
"v3.iconBar.view.big") {
public void triggerToolBarItem() {
triggerBasicToolBarItem(getId());
}
public void setEnabled(boolean enabled) {
if (!enabled) {
SWTSkinObject so = getSkinButton().getSkinObject();
if (so != null && so.getSuffix().contains("-down")) {
so.switchSuffix("");
}
}
super.setEnabled(enabled);
}
};
addToolBarItem(item, "toolbar.area.vitem.left", so2nd);
SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title",
item.getSkinButton().getSkinObject());
if (soTitle instanceof SWTSkinObjectText) {
((SWTSkinObjectText) soTitle).setStyle(SWT.RIGHT);
}
addSeperator(so2nd);
// == mode small
item = new ToolBarItem("modeSmall", "image.toolbar.table_normal",
"v3.iconBar.view.small") {
public void triggerToolBarItem() {
triggerBasicToolBarItem(getId());
}
public void setEnabled(boolean enabled) {
if (!enabled) {
SWTSkinObject so = getSkinButton().getSkinObject();
if (so != null && so.getSuffix().contains("-down")) {
so.switchSuffix("");
}
}
super.setEnabled(enabled);
}
};
addToolBarItem(item, "toolbar.area.vitem.right", so2nd);
soTitle = skin.getSkinObject("toolbar-item-title",
item.getSkinButton().getSkinObject());
if (soTitle instanceof SWTSkinObjectText) {
((SWTSkinObjectText) soTitle).setStyle(SWT.LEFT);
}
//addSeperator(so2nd);