1 /* 2 * Created on 05-Sep-2005 3 * Created by Paul Gardner 4 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 package org.gudy.azureus2.ui.swt.plugins; 21 22 import org.eclipse.swt.graphics.Image; 23 import org.eclipse.swt.widgets.Display; 24 import org.eclipse.swt.widgets.Shell; 25 26 import org.gudy.azureus2.plugins.download.Download; 27 import org.gudy.azureus2.plugins.ui.UIInstance; 28 import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel; 29 import org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel; 30 import org.gudy.azureus2.plugins.ui.tables.TableManager; 31 import org.gudy.azureus2.ui.common.UIInstanceBase; 32 33 /** 34 * Tools to manage a SWT Instance 35 * 36 * @see org.gudy.azureus2.plugins.ui.UIManagerListener 37 * @see org.gudy.azureus2.plugins.ui.UIManager#addUIListener(UIManagerListener) 38 */ 39 public interface UISWTInstance extends UIInstanceBase { 40 /** ID of main view */ 41 public static final String VIEW_MAIN = "Main"; 42 43 /** 44 * ID of "My Torrents" view 45 * 46 * @since 2.3.0.7 47 */ 48 public static final String VIEW_MYTORRENTS = "MyTorrents"; 49 50 /** 51 * ID of the torrent details view (The one you see when you right click on a torrent in Library and select "Details" 52 * 53 * @since 4901 54 */ 55 56 public static final String VIEW_TORRENT_DETAILS = "TorrentDetailsView"; 57 58 /** 59 * ID of "Peers" view 60 * 61 * @since 2.3.0.7 62 */ 63 public static final String VIEW_TORRENT_PEERS = TableManager.TABLE_TORRENT_PEERS; 64 65 /** 66 * ID of "Pieces" view 67 * 68 * @since 2.3.0.7 69 */ 70 public static final String VIEW_TORRENT_PIECES = TableManager.TABLE_TORRENT_PIECES; 71 72 /** 73 * ID of "Files" view 74 * 75 * @since 2.3.0.7 76 */ 77 public static final String VIEW_TORRENT_FILES = TableManager.TABLE_TORRENT_FILES; 78 79 /** 80 * ID of the top bar of az3ui 81 * 82 * @since 3.0.1.3 83 */ 84 public static final String VIEW_TOPBAR = "TopBar"; 85 86 public static final String VIEW_STATISTICS = "StatsView"; 87 88 public static final String VIEW_CONFIG = "ConfigView"; 89 90 public static final String VIEW_SIDEBAR_AREA = "SideBarArea"; 91 92 93 /** Retrieve the SWT Display object that Azureus uses (when in SWT mode). 94 * If you have a thread that does some periodic/asynchronous stuff, Azureus 95 * will crashes with and 'InvalidThreadAccess' exception unless you 96 * embed your calls in a Runnable, and use getDisplay().aSyncExec(Runnable r); 97 * 98 * @return SWT Display object that Azureus uses 99 * 100 * @since 2.3.0.5 101 */ getDisplay()102 public Display getDisplay(); 103 104 public Image loadImage( String resource )105 loadImage( 106 String resource ); 107 108 /** Creates an UISWTGraphic object with the supplied SWT Image 109 * 110 * @param img Image to assign to the object 111 * @return a new UISWTGraphic object 112 * 113 * @since 2.3.0.5 114 */ createGraphic(Image img)115 public UISWTGraphic createGraphic(Image img); 116 117 /** 118 * Add a detail view to an Azureus parent view. For views added to the Main 119 * window, this adds a menu option. For the other parent views, this adds 120 * a new tab within Azureus' own detail view. 121 * 122 * @param sParentID VIEW_* constant 123 * @param sViewID of your view. Used as part of the resource id.<br> 124 * "Views.plugins." + ID + ".title" = title of your view 125 * @param l Listener to be triggered when parent view wants to tell you 126 * an event has happened 127 * 128 * @note If you want the window to auto-open, use openMainView when you gain 129 * access to the UISWTInstance 130 * 131 * @since 2.3.0.6 132 */ addView(String sParentID, String sViewID, UISWTViewEventListener l)133 public void addView(String sParentID, String sViewID, UISWTViewEventListener l); 134 135 /** 136 * Add a view to an Azureus parent view. For views added to the {@link #VIEW_MAIN} 137 * window, this adds a menu option. 138 * <P> 139 * In comparison to {@link #addView(String, String, UISWTViewEventListener)}, 140 * this method saves memory by not creating the {@link UISWTViewEventListener} 141 * until it is needed. It also ensures that only one 142 * {@link UISWTViewEvent#TYPE_CREATE} event is triggered per instance. 143 * 144 * @param sParentID VIEW_* constant 145 * @param sViewID of your view. Used as part of the resource id.<br> 146 * "Views.plugins." + ID + ".title" = title of your view 147 * @param cla Class of the Listener to be created and triggered 148 * 149 * @note If you want the window to auto-open, use openMainView when you gain 150 * access to the UISWTInstance 151 * 152 * @since 4.6.0.5 153 */ addView(String sParentID, String sViewID, Class<? extends UISWTViewEventListener> cla, Object initalDatasource)154 public void addView(String sParentID, String sViewID, 155 Class<? extends UISWTViewEventListener> cla, Object initalDatasource); 156 157 /** 158 * Open a previously added view 159 * 160 * @param sParentID ParentID of the view to be shown 161 * @param sViewID id of the view to be shown 162 * @param dataSource any data you need to pass the view 163 * @return success level 164 * 165 * @since 2.5.0.1 166 */ openView(String sParentID, String sViewID, Object dataSource)167 public boolean openView(String sParentID, String sViewID, Object dataSource); 168 169 /** 170 * Open a previously added view 171 * 172 * @param sParentID ParentID of the view to be shown 173 * @param sViewID id of the view to be shown 174 * @param dataSource any data you need to pass the view 175 * @param setfocus <tt>true</tt> if you want to display the view immediately, 176 * <tt>false</tt> if you want to display it in the background. 177 * @return success level 178 * @since 3.0.5.3 179 */ openView(String sParentID, String sViewID, Object dataSource, boolean setfocus)180 public boolean openView(String sParentID, String sViewID, Object dataSource, boolean setfocus); 181 182 183 /** 184 * Create and open a view in the main window immediately. If you are calling 185 * this from {@link org.gudy.azureus2.plugins.ui.UIManagerListener#UIAttached(UIInstance)}, 186 * the view will not gain focus. 187 * <p> 188 * Tip: You can add a menu item to a table view, and when triggered, have 189 * it open a new window, passing the datasources that were selected 190 * 191 * @param sViewID ID to give your view 192 * @param l Listener to be triggered when View Events occur 193 * @param dataSource objects to set {@link UISWTView#getDataSource()} with 194 * 195 * @since 2.3.0.6 196 */ openMainView(String sViewID, UISWTViewEventListener l, Object dataSource)197 public void openMainView(String sViewID, UISWTViewEventListener l, 198 Object dataSource); 199 200 /** 201 * Create and open a view in the main window immediately. If you are calling 202 * this from {@link org.gudy.azureus2.plugins.ui.UIManagerListener#UIAttached(UIInstance)}, 203 * the view will not gain focus. 204 * <p> 205 * Tip: You can add a menu item to a table view, and when triggered, have 206 * it open a new window, passing the datasources that were selected 207 * 208 * @param sViewID ID to give your view 209 * @param l Listener to be triggered when View Events occur 210 * @param dataSource objects to set {@link UISWTView#getDataSource()} with 211 * @param setfocus <tt>true</tt> if you want to display the view immediately, 212 * <tt>false</tt> if you want to display it in the background. 213 * 214 * @since 3.0.5.3 215 */ openMainView(String sViewID, UISWTViewEventListener l, Object dataSource, boolean setfocus)216 public void openMainView(String sViewID, UISWTViewEventListener l, 217 Object dataSource, boolean setfocus); 218 219 /** 220 * Remove all views that belong to a specific parent and of a specific View 221 * ID. If the parent is the main window, the menu item will be removed.<br> 222 * If you wish to remove (close) just one view, use 223 * {@link UISWTView#closeView()} 224 * 225 * @param sParentID One of VIEW_* constants 226 * @param sViewID View ID to remove 227 * 228 * @since 2.3.0.6 229 */ removeViews(String sParentID, String sViewID)230 public void removeViews(String sParentID, String sViewID); 231 232 /** 233 * Get a list of views currently open on the specified VIEW_* view 234 * 235 * @param sParentID VIEW_* constant 236 * @return list of views currently open 237 * 238 * @since 2.3.0.6 239 */ getOpenViews(String sParentID)240 public UISWTView[] getOpenViews(String sParentID); 241 242 /** 243 * 244 * @since 4.8.0.0 245 */ 246 public UISWTViewEventListenerWrapper[] getViewListeners( String sParentID )247 getViewListeners( 248 String sParentID ); 249 250 /** 251 * Shows or hides a download bar for a given download. 252 * 253 * @since 3.0.0.5 254 * @param download Download to use. 255 * @param display <tt>true</tt> to show a download bar, <tt>false</tt> to hide it. 256 */ showDownloadBar(Download download, boolean display)257 public void showDownloadBar(Download download, boolean display); 258 259 /** 260 * Shows or hides the transfers bar. 261 * 262 * @since 3.0.1.3 263 * @param display <tt>true</tt> to show the bar, <tt>false</tt> to hide it. 264 */ showTransfersBar(boolean display)265 public void showTransfersBar(boolean display); 266 267 /** 268 * Creates an entry in the status bar to display custom status information. 269 * 270 * @since 3.0.0.7 271 * @see UISWTStatusEntry 272 */ createStatusEntry()273 public UISWTStatusEntry createStatusEntry(); 274 275 /** 276 * Opens the window linked to a given BasicPluginViewModel object. 277 * 278 * @return <tt>true</tt> if the view was opened successfully. 279 * @since 3.0.5.3 280 */ openView(BasicPluginViewModel model)281 public boolean openView(BasicPluginViewModel model); 282 283 /** 284 * Opens the window linked to a given BasicPluginViewModel object. 285 * 286 * @return <tt>true</tt> if the view was opened successfully. 287 * @since 3.0.5.3 288 */ openConfig(BasicPluginConfigModel model)289 public void openConfig(BasicPluginConfigModel model); 290 291 /** 292 * Creates a SWT Shell, ensuring Vuze knows about it (ie. Icon, "Window" menu) 293 * 294 * @param style 295 * @return 296 * 297 * @since 4.2.0.9 298 */ createShell(int style)299 public Shell createShell(int style); 300 301 public interface 302 UISWTViewEventListenerWrapper 303 extends UISWTViewEventListener 304 { 305 public String getViewID()306 getViewID(); 307 } 308 } 309