public class Sandbox extends javax.swing.JFrame implements PluginHost
Sandbox(AlgorithmPlugin)
or Sandbox(AlgorithmPlugin, String)
and invoke
setVisible(boolean)
to make the sandbox visible, like:
// replace new MyPlugin() with the instantiation of your plugin you would like to test public class PluginTest extends Sandbox { private static final long serialVersionUID = 1L; public PluginTest() throws IllegalArgumentException { super(new MyPlugin()); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new PluginTest().setVisible(true); } }); } }You can test all the basic functionality of your algorithm.
Sandbox
).
This logs all the information messages, warnings or errors of the plugin. If your plugin implementation crashs first
have a look at this file. An empty log file means that no messages were logged.javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
Sandbox(AlgorithmPlugin plugin)
Creates the sandbox.
|
Sandbox(AlgorithmPlugin plugin,
java.lang.String langID)
Creates the sandbox.
|
Modifier and Type | Method and Description |
---|---|
void |
adaptDialog(javax.swing.JDialog dialog)
Adapts the dialog to the host application meaning that the dialog is centered in the host
and the application icon is set to the dialog.
|
boolean |
checkPermission(PluginHost host)
Checks if the given host is accepted by this host.
|
AlgorithmExerciseProvider |
getDefaultExerciseProvider()
Gets the default exercise provider that is implemented by the host system.
|
LanguageFile |
getLanguageFile()
Gets the language file of the host application.
|
java.lang.String |
getLanguageID()
Gets the language id that is used and set in the host application.
|
java.lang.String |
getPluginAssumptions(int index)
Gets the assumptions of a plugin.
|
java.lang.String |
getPluginAuthor(int index)
Gets the author of a plugin.
|
java.lang.String |
getPluginAuthorContact(int index)
Gets the author contact details of a plugin.
|
int |
getPluginCount()
Gets the number of the currently installed plugins in the host application.
|
java.lang.String |
getPluginDescription(int index)
Gets the description of a plugin.
|
java.lang.String |
getPluginInstructions(int index)
Gets the instructions of a plugin.
|
java.lang.String |
getPluginName(int index)
Gets the name of a plugin.
|
java.lang.String |
getPluginProblemAffiliation(int index)
Gets the problem affiliation of a plugin.
|
java.lang.String |
getPluginSubject(int index)
Gets the subject of a plugin.
|
AlgorithmText |
getPluginText(int index)
Gets the algorithm text of a plugin.
|
java.lang.String |
getPluginType(int index)
Gets the type of a plugin.
|
java.lang.String |
getPluginVersion(int index)
Gets the version of a plugin.
|
boolean |
isActivePlugin(AlgorithmPlugin plugin)
Indicates if the given plugin is currently enabled in the host application.
|
void |
rteModeChanged()
Indicates that the mode of the runtime environment of the active plugin changed from normal mode to exercise
mode or the other way around.
|
void |
setVisible(boolean visible)
Shows the sandbox but only if the plugin is valid meaning that their have not been occurred errors when validating
the plugin.
|
void |
showMessage(AlgorithmPlugin plugin,
java.lang.String msg,
java.lang.String title,
MessageIcon icon)
Displays a message box in the host application.
|
void |
writeLogMessage(AlgorithmPlugin plugin,
java.lang.String msg,
java.lang.Exception e,
LogType type)
Writes a message to the log file.
|
void |
writeLogMessage(AlgorithmPlugin plugin,
java.lang.String msg,
LogType type)
Writes a message to the log file.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public Sandbox(AlgorithmPlugin plugin) throws java.lang.IllegalArgumentException
plugin
- the plugin that should be testedjava.lang.IllegalArgumentException
- public Sandbox(AlgorithmPlugin plugin, java.lang.String langID) throws java.lang.IllegalArgumentException
plugin
- the plugin that should be testedlangID
- the language id that should be used (like en, de, ...)java.lang.IllegalArgumentException
- public java.lang.String getLanguageID()
PluginHost
getLanguageID
in interface PluginHost
LanguageFile
,
PluginHost.getLanguageFile()
public LanguageFile getLanguageFile()
PluginHost
Resources.LANGUAGE_FILE
)
that means all the language dependent labels of graphical views (like GraphView
and so on) which are part of the LAVESDK
can be requested by using this file.getLanguageFile
in interface PluginHost
LanguageFile
,
PluginHost.getLanguageID()
public boolean isActivePlugin(AlgorithmPlugin plugin)
PluginHost
isActivePlugin
in interface PluginHost
plugin
- AlgorithmPlugin
true
if plugin is the active one otherwise false
public void showMessage(AlgorithmPlugin plugin, java.lang.String msg, java.lang.String title, MessageIcon icon)
PluginHost
showMessage
in interface PluginHost
plugin
- AlgorithmPlugin
that wants to show a messagemsg
- the message texttitle
- the title of the messageicon
- the icon type of the messagepublic void writeLogMessage(AlgorithmPlugin plugin, java.lang.String msg, LogType type)
PluginHost
writeLogMessage
in interface PluginHost
plugin
- the AlgorithmPlugin
that wants to log a messagemsg
- the messagetype
- the message typeLogFile
public void writeLogMessage(AlgorithmPlugin plugin, java.lang.String msg, java.lang.Exception e, LogType type)
PluginHost
writeLogMessage
in interface PluginHost
plugin
- the AlgorithmPlugin
that wants to log a messagemsg
- the messagee
- the exception that occurredtype
- the message typeLogFile
public boolean checkPermission(PluginHost host)
PluginHost
checkPermission
in interface PluginHost
host
- the hosttrue
if the host is accepted by this one otherwise false
(in general it is done by returning host == this
)HostSecurity
public AlgorithmExerciseProvider getDefaultExerciseProvider()
PluginHost
getDefaultExerciseProvider
in interface PluginHost
ExercisesListView
public void rteModeChanged()
PluginHost
rteModeChanged
in interface PluginHost
public void adaptDialog(javax.swing.JDialog dialog)
PluginHost
public void adaptDialog(final JDialog dialog) { dialog.setLocationRelativeTo(this); dialog.setIconImage(this.getIconImage()); }
adaptDialog
in interface PluginHost
dialog
- the dialog that should be adaptedpublic int getPluginCount()
PluginHost
getPluginCount
in interface PluginHost
public java.lang.String getPluginName(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginName
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getName()
public java.lang.String getPluginDescription(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginDescription
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getDescription()
public java.lang.String getPluginType(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginType
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getType()
public java.lang.String getPluginAuthor(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginAuthor
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getAuthor()
public java.lang.String getPluginAuthorContact(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginAuthorContact
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getAuthorContact()
public java.lang.String getPluginAssumptions(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginAssumptions
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getAssumptions()
public java.lang.String getPluginProblemAffiliation(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginProblemAffiliation
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getProblemAffiliation()
public java.lang.String getPluginSubject(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginSubject
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getSubject()
public java.lang.String getPluginInstructions(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginInstructions
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getInstructions()
public java.lang.String getPluginVersion(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginVersion
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getVersion()
public AlgorithmText getPluginText(int index) throws java.lang.IndexOutOfBoundsException
PluginHost
getPluginText
in interface PluginHost
index
- the index of the pluginjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getPluginCount()
)AlgorithmPlugin.getText()
public void setVisible(boolean visible)
setVisible
in class java.awt.Window
visible
- true
to make the sandbox visible