@PerspectiveInfo(ID="simplecli", title="Simple CLI", toolTipText="Simple CLI for Weka", iconPath="weka/gui/weka_icon_new_small.png") public class SimpleCLIPanel extends ScriptingPanel implements java.awt.event.ActionListener, Perspective
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleCLIPanel.ClassRunner
A class that handles running the main method of the class in a separate
thread.
|
static class |
SimpleCLIPanel.CommandlineCompletion
A class for commandline completion of classnames.
|
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
FILENAME
The filename of the properties file.
|
protected java.util.Vector<java.lang.String> |
m_CommandHistory
The history of commands entered interactively.
|
protected SimpleCLIPanel.CommandlineCompletion |
m_Completion
The commandline completion.
|
protected int |
m_HistoryPos
The current position in the command history.
|
protected javax.swing.JTextField |
m_Input
The command input area.
|
protected GUIApplication |
m_mainApp
Main application (if any) owning this perspective
|
protected javax.swing.JTextPane |
m_OutputArea
The output area canvas added to the frame.
|
protected javax.swing.Icon |
m_perspectiveIcon
The Icon for this perspective
|
protected java.lang.Thread |
m_RunThread
The thread currently running a class main method.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
m_Variables
for storing variables.
|
protected static java.util.Properties |
PROPERTIES
Contains the SimpleCLI properties.
|
protected static java.lang.String |
PROPERTY_FILE
The default location of the properties file.
|
m_Debug, m_ErrRedirector, m_OutRedirector, m_POE, m_POO, m_TitleUpdatedListenerslistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
SimpleCLIPanel() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsInstances()
Returns true if this perspective can do something meaningful with a set of
instances
|
void |
actionPerformed(java.awt.event.ActionEvent e)
Only gets called when return is pressed in the input area, which starts the
command running.
|
void |
doCommandlineCompletion(java.awt.event.KeyEvent e)
performs commandline completion on packages and classnames.
|
void |
doHistory(java.awt.event.KeyEvent e)
Changes the currently displayed command line when certain keys are pressed.
|
java.util.List<java.lang.String> |
getCommandHistory()
Returns the command history.
|
Defaults |
getDefaultSettings()
Get the default settings for this perspective (or null if there are none)
|
javax.swing.ImageIcon |
getIcon()
Returns an icon to be used in a frame.
|
GUIApplication |
getMainApplication()
Get the main application that this perspective belongs to
|
javax.swing.JMenuBar |
getMenuBar()
Not supported.
|
java.util.List<javax.swing.JMenu> |
getMenus()
Get an ordered list of menus to appear in the main menu bar.
|
javax.swing.JTextPane |
getOutput()
Returns the text area that is used for displaying output on stdout and
stderr.
|
javax.swing.JTextPane |
getOutputArea()
The output area.
|
javax.swing.Icon |
getPerspectiveIcon()
Get the icon for this perspective
|
java.lang.String |
getPerspectiveID()
Get the ID of this perspective
|
java.lang.String |
getPerspectiveTipText()
Get the tool tip text for this perspective
|
java.lang.String |
getPerspectiveTitle()
Get the title of this perspective
|
java.lang.String |
getTitle()
Returns the current title for the frame/dialog.
|
java.util.Map<java.lang.String,java.lang.Object> |
getVariables()
Returns the variables.
|
protected void |
initFinish()
Finishes up after initializing members and setting up the GUI.
|
protected void |
initGUI()
Sets up the GUI after initializing the members.
|
protected void |
initialize()
For initializing member variables.
|
void |
instantiationComplete()
Gets called when startup of the application has completed.
|
boolean |
isBusy()
Checks whether a thread is currently running.
|
protected void |
loadHistory()
loads the command history from the user's properties file.
|
static void |
main(java.lang.String[] args)
Displays the panel in a frame.
|
boolean |
okToBeActive()
Returns true if this perspective is OK with being an active perspective -
i.e. the user can click on this perspective at this time in the perspective
toolbar.
|
boolean |
requiresLog()
Whether this perspective requires a graphical log to write to
|
void |
runCommand(java.lang.String command)
Executes a simple cli command.
|
protected void |
saveHistory()
saves the current command history in the user's home directory.
|
void |
setActive(boolean active)
Set active status of this perspective.
|
void |
setInstances(Instances instances)
Set instances (if this perspective can use them)
|
void |
setLoaded(boolean loaded)
Set whether this perspective is "loaded" - i.e. whether or not the user has
opted to have it available in the perspective toolbar.
|
void |
setLog(Logger log)
Set a log to use (if required by the perspective)
|
void |
setMainApplication(GUIApplication main)
Set the main application.
|
void |
settingsChanged()
Called when the user alters settings.
|
void |
startThread(SimpleCLIPanel.ClassRunner runner)
Starts the thread.
|
void |
stopThread()
Stops the currently running thread, if any.
|
addTitleUpdatedListener, getDebug, notifyTitleUpdatedListeners, removeTitleUpdatedListener, setDebug, showPanel, showPanel, titleUpdatedgetAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected static java.lang.String FILENAME
protected static java.lang.String PROPERTY_FILE
protected static java.util.Properties PROPERTIES
protected GUIApplication m_mainApp
protected javax.swing.Icon m_perspectiveIcon
protected javax.swing.JTextPane m_OutputArea
protected javax.swing.JTextField m_Input
protected java.util.Vector<java.lang.String> m_CommandHistory
protected int m_HistoryPos
protected java.lang.Thread m_RunThread
protected SimpleCLIPanel.CommandlineCompletion m_Completion
protected java.util.Map<java.lang.String,java.lang.Object> m_Variables
public void instantiationComplete()
PerspectiveinstantiationComplete in interface Perspectivepublic boolean okToBeActive()
PerspectiveokToBeActive in interface Perspectivepublic void setActive(boolean active)
PerspectivesetActive in interface Perspectiveactive - true if this perspective is the active onepublic void setLoaded(boolean loaded)
PerspectivesetLoaded in interface Perspectiveloaded - true if the perspective is available in the perspective
toolbar of the KnowledgeFlowpublic void setMainApplication(GUIApplication main)
PerspectivesetMainApplication in interface Perspectivemain - the main applicationpublic GUIApplication getMainApplication()
PerspectivegetMainApplication in interface Perspectivepublic java.lang.String getPerspectiveID()
PerspectivegetPerspectiveID in interface Perspectivepublic java.lang.String getPerspectiveTitle()
PerspectivegetPerspectiveTitle in interface Perspectivepublic javax.swing.Icon getPerspectiveIcon()
PerspectivegetPerspectiveIcon in interface Perspectivepublic java.lang.String getPerspectiveTipText()
PerspectivegetPerspectiveTipText in interface Perspectivepublic java.util.List<javax.swing.JMenu> getMenus()
PerspectivegetMenus in interface Perspectivepublic Defaults getDefaultSettings()
PerspectivegetDefaultSettings in interface Perspectivepublic void settingsChanged()
PerspectivesettingsChanged in interface Perspectivepublic boolean acceptsInstances()
PerspectiveacceptsInstances in interface Perspectivepublic void setInstances(Instances instances)
PerspectivesetInstances in interface Perspectiveinstances - the instancespublic boolean requiresLog()
PerspectiverequiresLog in interface Perspectivepublic void setLog(Logger log)
PerspectivesetLog in interface Perspectivelog - the graphical log to useprotected void initialize()
initialize in class ScriptingPanelprotected void initGUI()
initGUI in class ScriptingPanelScriptingPanel.initialize(),
ScriptingPanel.getOutput()protected void initFinish()
initFinish in class ScriptingPanelScriptingPanel.initialize(),
ScriptingPanel.initGUI(),
ScriptingPanel.getOutput()public javax.swing.ImageIcon getIcon()
getIcon in class ScriptingPanelpublic java.lang.String getTitle()
getTitle in class ScriptingPanelpublic javax.swing.JTextPane getOutput()
getOutput in class ScriptingPanelpublic javax.swing.JMenuBar getMenuBar()
getMenuBar in class ScriptingPanelpublic boolean isBusy()
public void startThread(SimpleCLIPanel.ClassRunner runner)
runner - the thread to startpublic void stopThread()
public java.util.Map<java.lang.String,java.lang.Object> getVariables()
public javax.swing.JTextPane getOutputArea()
public java.util.List<java.lang.String> getCommandHistory()
public void runCommand(java.lang.String command)
throws java.lang.Exception
command - the command stringjava.lang.Exception - if an error occurspublic void doHistory(java.awt.event.KeyEvent e)
e - a value of type 'KeyEvent'public void doCommandlineCompletion(java.awt.event.KeyEvent e)
e - a value of type 'KeyEvent'public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - a value of type 'ActionEvent'protected void loadHistory()
protected void saveHistory()
public static void main(java.lang.String[] args)
args - ignored