speedscheduler
Class SpeedSchedulerView

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.views.AbstractIView
      extended by org.gudy.azureus2.plugins.PluginView
          extended by speedscheduler.SpeedSchedulerView
All Implemented Interfaces:
org.gudy.azureus2.ui.swt.IconBarEnabler, org.gudy.azureus2.ui.swt.views.IView, ScheduleSelectionChangeListener

public class SpeedSchedulerView
extends org.gudy.azureus2.plugins.PluginView
implements ScheduleSelectionChangeListener

This is the main graphical portion of the SpeedScheduler, itself an Azureus view. Access this by clicking View -- Plugins -- Speed Scheduler.


Field Summary
private  java.util.Vector activeSchedules
           
private  java.util.Vector allWidgets
           
private static org.eclipse.swt.graphics.Color blue
           
private static int BUTTON_PADDING
           
private  org.eclipse.swt.graphics.Image checkImage
           
private  org.eclipse.swt.widgets.Menu contextMenu
           
private  org.eclipse.swt.graphics.Image defaultImage
           
private  int defaultMaxDownloadRate
           
private  IntegerInput defaultMaxDownloadRateInput
           
private  int defaultMaxUploadRate
           
private  IntegerInput defaultMaxUploadRateInput
           
(package private)  org.eclipse.swt.widgets.Composite defaultSpeedsImageComposite
           
private  org.eclipse.swt.widgets.MenuItem deleteItem
           
private  org.eclipse.swt.widgets.Button deleteScheduleButton
           
private  org.eclipse.swt.widgets.Display display
           
private  org.eclipse.swt.widgets.MenuItem editItem
           
private  org.eclipse.swt.widgets.Button editScheduleButton
           
private  org.eclipse.swt.widgets.MenuItem enableItem
           
private  org.eclipse.swt.widgets.Button enableScheduleButton
           
private static org.eclipse.swt.graphics.Color gray
           
private static org.eclipse.swt.graphics.Cursor handCursor
           
private static java.lang.String HELP_URL
           
private  org.eclipse.swt.widgets.Composite mainComposite
           
private static int MARGIN_HEIGHT
           
private static int MARGIN_WIDTH
           
private  org.eclipse.swt.widgets.MenuItem newItem
           
private  org.eclipse.swt.widgets.Button newScheduleButton
           
private  SchedulePersistencyManager schedulePersistencyManager
           
private  java.util.Vector schedules
          To contain all the configured schedules.
private  org.eclipse.swt.widgets.Table scheduleTable
           
private  org.eclipse.swt.widgets.Shell shell
           
private  boolean viewIsDisposed
           
private  org.eclipse.swt.graphics.Image watchImage
           
private  org.eclipse.swt.graphics.Image watchImageDisabled
           
 
Fields inherited from class org.gudy.azureus2.ui.swt.views.AbstractIView
this_mon
 
Constructor Summary
SpeedSchedulerView()
          Constructor used by Azureus to instantiate me and give me access to the PluginInterface.
 
Method Summary
 void delete()
          Called exactly once when the user clicks the X on my view.
private  void deleteScheduleEvent()
          Deletes the selected Schedule from the table (if any).
private  void editScheduleEvent()
          Pops up an edit Schedule dialog for editing the selected Schedule (if any) from the table.
private  void enableScheduleEvent()
          toggles the selected Schedule from the table between enabled and disabled.
private  void errorMessageBox(java.lang.String msg)
          Draws a (not so) friendly error message dialog.
 org.eclipse.swt.widgets.Composite getComposite()
          If Azureus wants access to my main Composite, here it is.
 java.lang.String getFullTitle()
          Azureus wants to know my long name: Here it is.
 java.lang.String getPluginViewName()
          Azureus wants to know my name: Here it is.
private  java.lang.String getTimeLabelString()
           
 void initialize(org.eclipse.swt.widgets.Composite parent)
          Called by the Azureus plugin system when my plugin is loaded.
 void initView(org.eclipse.swt.widgets.Composite parent)
          Initializes all the graphical controls and loads the saved schedules to display the view.
private  boolean isActive(Schedule t)
           
private  void limitDownloadRateIfNeeded()
          Checks the upload rate and sees if it violates the <5 rule.
private  void newScheduleEvent()
          Pops up a new Schedule dialog for creating a new Schedule.
protected  void refeshScheduleTable()
          Refreshes the Schedule table based on the contents of the schedules vector.
 void refresh()
          Called periodically while the user is looking at my view (like more than once a second).
 void scheduleSelectionChanged(java.util.Vector newActiveSchedules)
          Called by the SpeedSchedulerThread to indicate that it has selected a new schedule.
private  void setAllWidgetsEnabled(boolean enabled)
          Enables or disables all widgets that have been added to the allWidets Vector.
private  void setEditScheduleButtonsEnabledState()
          Sets the edit/delete buttons enabled if there is a schedule selected in the table, sets them disabled if there is no schedule currently selected.
 
Methods inherited from class org.gudy.azureus2.ui.swt.views.AbstractIView
dataSourceChanged, generateDiagnostics, getData, getShortTitle, isEnabled, isSelected, itemActivated, updateLanguage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schedules

private java.util.Vector schedules
To contain all the configured schedules.


BUTTON_PADDING

private static final int BUTTON_PADDING
See Also:
Constant Field Values

MARGIN_WIDTH

private static final int MARGIN_WIDTH
See Also:
Constant Field Values

MARGIN_HEIGHT

private static final int MARGIN_HEIGHT
See Also:
Constant Field Values

HELP_URL

private static final java.lang.String HELP_URL
See Also:
Constant Field Values

scheduleTable

private org.eclipse.swt.widgets.Table scheduleTable

watchImage

private org.eclipse.swt.graphics.Image watchImage

watchImageDisabled

private org.eclipse.swt.graphics.Image watchImageDisabled

checkImage

private org.eclipse.swt.graphics.Image checkImage

defaultImage

private org.eclipse.swt.graphics.Image defaultImage

mainComposite

private org.eclipse.swt.widgets.Composite mainComposite

contextMenu

private org.eclipse.swt.widgets.Menu contextMenu

newItem

private org.eclipse.swt.widgets.MenuItem newItem

editItem

private org.eclipse.swt.widgets.MenuItem editItem

deleteItem

private org.eclipse.swt.widgets.MenuItem deleteItem

enableItem

private org.eclipse.swt.widgets.MenuItem enableItem

shell

private org.eclipse.swt.widgets.Shell shell

display

private org.eclipse.swt.widgets.Display display

schedulePersistencyManager

private SchedulePersistencyManager schedulePersistencyManager

defaultMaxUploadRate

private int defaultMaxUploadRate

defaultMaxDownloadRate

private int defaultMaxDownloadRate

allWidgets

private java.util.Vector allWidgets

defaultMaxUploadRateInput

private IntegerInput defaultMaxUploadRateInput

defaultMaxDownloadRateInput

private IntegerInput defaultMaxDownloadRateInput

activeSchedules

private java.util.Vector activeSchedules

editScheduleButton

private org.eclipse.swt.widgets.Button editScheduleButton

newScheduleButton

private org.eclipse.swt.widgets.Button newScheduleButton

deleteScheduleButton

private org.eclipse.swt.widgets.Button deleteScheduleButton

enableScheduleButton

private org.eclipse.swt.widgets.Button enableScheduleButton

gray

private static org.eclipse.swt.graphics.Color gray

blue

private static org.eclipse.swt.graphics.Color blue

handCursor

private static org.eclipse.swt.graphics.Cursor handCursor

viewIsDisposed

private boolean viewIsDisposed

defaultSpeedsImageComposite

org.eclipse.swt.widgets.Composite defaultSpeedsImageComposite
Constructor Detail

SpeedSchedulerView

public SpeedSchedulerView()
Constructor used by Azureus to instantiate me and give me access to the PluginInterface.

Method Detail

initialize

public void initialize(org.eclipse.swt.widgets.Composite parent)
Called by the Azureus plugin system when my plugin is loaded.

Specified by:
initialize in interface org.gudy.azureus2.ui.swt.views.IView
Overrides:
initialize in class org.gudy.azureus2.ui.swt.views.AbstractIView

delete

public void delete()
Called exactly once when the user clicks the X on my view.

Specified by:
delete in interface org.gudy.azureus2.ui.swt.views.IView
Overrides:
delete in class org.gudy.azureus2.ui.swt.views.AbstractIView

refresh

public void refresh()
Called periodically while the user is looking at my view (like more than once a second).

Specified by:
refresh in interface org.gudy.azureus2.ui.swt.views.IView
Overrides:
refresh in class org.gudy.azureus2.ui.swt.views.AbstractIView

getComposite

public org.eclipse.swt.widgets.Composite getComposite()
If Azureus wants access to my main Composite, here it is.

Specified by:
getComposite in interface org.gudy.azureus2.ui.swt.views.IView
Overrides:
getComposite in class org.gudy.azureus2.ui.swt.views.AbstractIView

initView

public void initView(org.eclipse.swt.widgets.Composite parent)
Initializes all the graphical controls and loads the saved schedules to display the view.


getTimeLabelString

private java.lang.String getTimeLabelString()

setEditScheduleButtonsEnabledState

private void setEditScheduleButtonsEnabledState()
Sets the edit/delete buttons enabled if there is a schedule selected in the table, sets them disabled if there is no schedule currently selected.


limitDownloadRateIfNeeded

private void limitDownloadRateIfNeeded()
Checks the upload rate and sees if it violates the <5 rule. If so, limit the downloads to 2*upload.


setAllWidgetsEnabled

private void setAllWidgetsEnabled(boolean enabled)
Enables or disables all widgets that have been added to the allWidets Vector. This turns off or on the SpeedScheduler display.

Parameters:
enabled - True to enable all widgets, and false to disable.

editScheduleEvent

private void editScheduleEvent()
Pops up an edit Schedule dialog for editing the selected Schedule (if any) from the table.


newScheduleEvent

private void newScheduleEvent()
Pops up a new Schedule dialog for creating a new Schedule.


deleteScheduleEvent

private void deleteScheduleEvent()
Deletes the selected Schedule from the table (if any). Saves changes to disk immediately.


enableScheduleEvent

private void enableScheduleEvent()
toggles the selected Schedule from the table between enabled and disabled.


getPluginViewName

public java.lang.String getPluginViewName()
Azureus wants to know my name: Here it is.

Specified by:
getPluginViewName in class org.gudy.azureus2.plugins.PluginView

getFullTitle

public java.lang.String getFullTitle()
Azureus wants to know my long name: Here it is.

Specified by:
getFullTitle in interface org.gudy.azureus2.ui.swt.views.IView
Overrides:
getFullTitle in class org.gudy.azureus2.ui.swt.views.AbstractIView

refeshScheduleTable

protected void refeshScheduleTable()
Refreshes the Schedule table based on the contents of the schedules vector. The currently selected item will remain selected after the table is refreshed.


isActive

private boolean isActive(Schedule t)

errorMessageBox

private void errorMessageBox(java.lang.String msg)
Draws a (not so) friendly error message dialog.

Parameters:
msg - The message to display in the dialog.

scheduleSelectionChanged

public void scheduleSelectionChanged(java.util.Vector newActiveSchedules)
Called by the SpeedSchedulerThread to indicate that it has selected a new schedule. Note that this is called from a non-SWT thread, so we take precautions to ensure proper thread access.

Specified by:
scheduleSelectionChanged in interface ScheduleSelectionChangeListener
Parameters:
newActiveSchedules - A vector of Schedules that the SpeedSchedulerThread just selected. Empty to indicate that no schedule is currently active.
See Also:
speedscheduler.ScheduleSelectionChangeListener#scheduleSelectionChanged(speedscheduler.Schedule)