Methods Summary |
---|
private static void | addListener(java.util.List listenerList, Listener listener)
try
{
class_mon.enter();
listenerList.add(listener);
}
finally
{
class_mon.exit();
}
|
public static void | addTabAddedListener(Listener listener)
addListener(tabAddListeners, listener);
|
public static void | addTabRemovedListener(Listener listener)
addListener(tabRemoveListeners, listener);
|
public static void | closeAllDetails()
Item[] tab_items;
try{
class_mon.enter();
tab_items = (Item[]) tabs.keySet().toArray(new Item[tabs.size()]);
}finally{
class_mon.exit();
}
for (int i = 0; i < tab_items.length; i++) {
IView view = (IView) tabs.get(tab_items[i]);
if (view instanceof ManagerView) {
closed(tab_items[i]);
}
}
|
public static void | closeAllTabs()
Item[] tab_items;
try{
class_mon.enter();
tab_items = (Item[]) tabs.keySet().toArray(new Item[tabs.size()]);
}finally{
class_mon.exit();
}
for (int i = 0; i < tab_items.length; i++) {
closed(tab_items[i], true);
}
|
public static void | closeCurrent()
if (_folder == null || _folder.isDisposed())
return;
if(_folder instanceof TabFolder) {
TabItem[] items = ((TabFolder)_folder).getSelection();
if(items.length == 1) {
closed(items[0]);
}
} else {
closed(((CTabFolder)_folder).getSelection());
}
|
public static boolean | closed(Item item)
return closed(item, false);
|
public static boolean | closed(Item item, boolean bForceClose)
if (item == null) {
return true;
}
IView view = (IView) tabs.get(item);
if (!bForceClose && view instanceof UISWTViewImpl) {
if (!((UISWTViewImpl)view).requestClose()) {
return false;
}
}
try{
class_mon.enter();
view = (IView) tabs.remove(item);
}finally{
class_mon.exit();
}
if (view != null) {
try {
if(view instanceof PluginView) {
mainwindow.removeActivePluginView(((PluginView)view).getPluginViewName());
}
if(view instanceof UISWTPluginView) {
mainwindow.removeActivePluginView(((UISWTPluginView)view).getPluginViewName());
}
if(view instanceof UISWTView)
mainwindow.removeActivePluginView(((UISWTView)view).getViewID());
view.delete();
} catch (Exception e) {
Debug.printStackTrace( e );
}
if (view instanceof MyTorrentsSuperView) {
//TODO : There is a problem here on OSX when using Normal TABS
/* org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:2691)
at org.eclipse.swt.SWT.error(SWT.java:2616)
at org.eclipse.swt.SWT.error(SWT.java:2587)
at org.eclipse.swt.widgets.Widget.error(Widget.java:546)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:296)
at org.eclipse.swt.widgets.Control.setVisible(Control.java:2573)
at org.eclipse.swt.widgets.TabItem.releaseChild(TabItem.java:180)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:480)
at org.gudy.azureus2.ui.swt.Tab.closed(Tab.java:322)
*/
//Tried to add a if(! item.isDisposed()) but it's not fixing it
//Need to investigate...
item.dispose();
return true;
}
if (view instanceof MyTrackerView) {
item.dispose();
return true;
}
if (view instanceof MySharesView) {
item.dispose();
return true;
}
}
try {
/*Control control;
if(item instanceof CTabItem) {
control = ((CTabItem)item).getControl();
} else {
control = ((TabItem)item).getControl();
}
if (control != null && !control.isDisposed())
control.dispose();
*/
item.dispose();
}
catch (Exception e) {
Debug.printStackTrace( e );
}
return true;
|
public void | dispose()
IView localView = null;
try{
class_mon.enter();
localView = (IView) tabs.get(tabItem);
if (localView instanceof UISWTViewImpl) {
if (!((UISWTViewImpl) localView).requestClose())
return;
}
tabs.remove(tabItem);
}finally{
class_mon.exit();
}
try {
if (localView != null) {
if(localView instanceof PluginView) {
mainwindow.removeActivePluginView(((PluginView)localView).getPluginViewName());
}
if(localView instanceof UISWTPluginView) {
mainwindow.removeActivePluginView(((UISWTPluginView)localView).getPluginViewName());
}
localView.delete();
}
tabItem.dispose();
}
catch (Exception e) {}
|
protected static java.lang.String | escapeAccelerators(java.lang.String str)
if ( str == null ){
return( str );
}
return( str.replaceAll( "&", "&&" ));
|
public void | generateDiagnostics(org.gudy.azureus2.core3.util.IndentWriter writer)
view.generateDiagnostics( writer );
|
public static Item[] | getAllTabs()
try {
class_mon.enter();
Item[] tabItems = new Item[tabs.size()];
if (tabItems.length > 0) {
tabItems = (Item[]) tabs.keySet().toArray(tabItems);
}
return tabItems;
} finally {
class_mon.exit();
}
|
public static IView[] | getAllViews()
try {
class_mon.enter();
IView[] views = new IView[tabs.size()];
if (views.length > 0) {
views = (IView[])tabs.values().toArray(views);
}
return views;
} finally {
class_mon.exit();
}
|
private static Event | getEvent(Item sender)
Event e = new Event();
e.widget = sender;
return e;
|
public static Item | getTab(IView view)
try{
class_mon.enter();
Iterator iter = tabs.keySet().iterator();
while( iter.hasNext()){
Item item = (Item) iter.next();
IView this_view = (IView) tabs.get(item);
if ( this_view == view ){
return( item );
}
}
return( null );
}finally{
class_mon.exit();
}
|
public Item | getTabItem()
tabs = new HashMap();
tabAddListeners = new LinkedList();
tabRemoveListeners = new LinkedList();
return tabItem;
|
public static IView | getView(Item item)
return (IView) tabs.get(item);
|
public IView | getView()
return( view );
|
public static boolean | hasDetails()
boolean hasDetails = false;
try
{
class_mon.enter();
Iterator iter = tabs.values().iterator();
while (iter.hasNext())
{
IView view = (IView) iter.next();
if(view instanceof ManagerView)
{
hasDetails = true;
break;
}
}
}
finally
{
class_mon.exit();
}
return hasDetails;
|
public static void | initialize(org.gudy.azureus2.ui.swt.mainwindow.MainWindow mainwindow, Composite folder)
Tab.mainwindow = mainwindow;
_folder = folder;
|
private static void | notifyListeners(java.util.List listenerList, Item sender)
try
{
class_mon.enter();
Iterator iter = listenerList.iterator();
for (int i = 0; i < listenerList.size(); i++)
{
((Listener)iter.next()).handleEvent(getEvent(sender));
}
}
finally
{
class_mon.exit();
}
|
public static void | refresh()
try{
class_mon.enter();
Iterator iter = tabs.keySet().iterator();
while (iter.hasNext()) {
//TabItem item = (TabItem) iter.next();
//CTabItem item = (CTabItem) iter.next();
Item item = (Item) iter.next();
IView view = (IView) tabs.get(item);
try {
if (item.isDisposed())
continue;
String lastTitle = item.getText();
String newTitle = view.getShortTitle();
if (lastTitle == null || !lastTitle.equals(newTitle)) {
item.setText(escapeAccelerators(newTitle));
}
if (item instanceof CTabItem) {
// Disabled for SWT 3.2RC5.. CTabItem tooltip doesn't always disappear
// String lastToolTip = ((CTabItem) item).getToolTipText();
// String newToolTip = view.getFullTitle();
// if (lastToolTip == null || !lastToolTip.equals(newToolTip)) {
// ((CTabItem) item).setToolTipText(newToolTip);
// }
}
else if (item instanceof TabItem) {
String lastToolTip = ((TabItem) item).getToolTipText();
String newToolTip = view.getFullTitle() + " " +
MessageText.getString("Tab.closeHint");
if (lastToolTip == null || !lastToolTip.equals(newToolTip)) {
((TabItem) item).setToolTipText(newToolTip);
}
}
}
catch (Exception e){
Debug.printStackTrace(e);
}
}
}finally{
class_mon.exit();
}
|
private static void | removeListener(java.util.List listenerList, Listener listener)
try
{
class_mon.enter();
listenerList.remove(listener);
}
finally
{
class_mon.exit();
}
|
public static void | removeTabAddedListener(Listener listener)
removeListener(tabAddListeners, listener);
|
public static void | removeTabRemovedListener(Listener listener)
removeListener(tabRemoveListeners, listener);
|
public static void | selectNextTab(boolean selectNext)
if (_folder == null || _folder.isDisposed())
return;
final int nextOrPrevious = selectNext ? 1 : -1;
if(_folder instanceof TabFolder) {
TabFolder tabFolder = (TabFolder)_folder;
int index = tabFolder.getSelectionIndex() + nextOrPrevious;
if(index == 0 && selectNext || index == -2 || tabFolder.getItemCount() < 2)
return;
if(index == tabFolder.getItemCount())
index = 0;
else if(index < 0)
index = tabFolder.getItemCount() - 1;
tabFolder.setSelection(index);
} else {
CTabFolder tabFolder = (CTabFolder)_folder;
int index = tabFolder.getSelectionIndex() + nextOrPrevious;
if(index == 0 && selectNext || index == -2 || tabFolder.getItemCount() < 2)
return;
if(index == tabFolder.getItemCount())
index = 0;
else if(index < 0)
index = tabFolder.getItemCount() - 1;
tabFolder.setSelection(index);
}
|
public void | setFocus()
if (folder != null && !folder.isDisposed()) {
if(useCustomTab) {
((CTabFolder)folder).setSelection((CTabItem)tabItem);
} else {
TabItem items[] = {(TabItem)tabItem};
((TabFolder)folder).setSelection(items);
}
}
|
public static void | updateLanguage()
IView[] views;
try{
class_mon.enter();
views = (IView[]) tabs.values().toArray(new IView[tabs.size()]);
}finally{
class_mon.exit();
}
for (int i = 0; i < views.length; i++) {
IView view = views[i];
try {
view.updateLanguage();
view.refresh();
}
catch (Exception e) {
Debug.printStackTrace(e);
}
}
|