| Methods from java.awt.Component: |
|---|
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
| Method from com.sshtools.common.ui.SshToolsApplicationPanel Detail: |
public void addFavorite(StandardAction action) {
for (int i = 0; i < menuBar.getMenuCount(); i++) {
JMenu menu = menuBar.getMenu(i);
if ((menu.getText() != null) && menu.getText().equals("Favorites")) {
menu.add(action);
}
}
}
|
abstract public boolean canClose()
Called by the application framework to test the closing state |
abstract public void close()
Called by the application framework to close the panel |
public void deregisterAction(StandardAction action) {
actions.removeElement(action);
}
|
public StandardAction getAction(String name) {
for (Iterator i = actions.iterator(); i.hasNext();) {
StandardAction a = (StandardAction) i.next();
if (a.getName().equals(name)) {
return a;
}
}
return null;
}
|
public SshToolsApplicationPanel.ActionMenu getActionMenu(String actionMenuName) {
return getActionMenu(actionMenus.iterator(), actionMenuName);
}
|
public SshToolsApplication getApplication() {
return application;
}
Get the application attached to the panel |
public SshToolsApplicationContainer getContainer() {
return container;
}
Gets the container for this panel. |
public JPopupMenu getContextMenu() {
return contextMenu;
}
|
abstract public ResourceIcon getIcon()
Get the icon for the panel |
public JMenuBar getJMenuBar() {
return menuBar;
}
|
public StatusBar getStatusBar() {
return null;
}
|
public JToolBar getToolBar() {
return toolBar;
}
|
public void init(SshToolsApplication application) throws SshToolsApplicationException {
this.application = application;
menuBar = new JMenuBar();
// Creat the tool bar
toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.setBorderPainted(false);
toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
// Create the context menu
contextMenu = new JPopupMenu();
registerActionMenu(new ActionMenu("Tools", "Tools", 't", 30));
if (PreferencesStore.isStoreAvailable()) {
log.debug("Preferences store is available, adding options action");
registerAction(new OptionsAction() {
public void actionPerformed(ActionEvent evt) {
showOptions();
}
});
}
}
|
abstract public boolean isConnected()
Returns the connected state of the panel |
public boolean isToolsVisible() {
return toolsVisible;
}
Determine if the toolbar, menu and statusbar are visible |
public void rebuildActionComponents() {
// Clear the current state of the component
log.debug("Rebuild action components");
toolBar.removeAll();
//
Vector enabledActions = new Vector();
for (Iterator i = actions.iterator(); i.hasNext();) {
StandardAction a = (StandardAction) i.next();
String n = (String) a.getValue(Action.NAME);
Boolean s = (Boolean) actionsVisible.get(n);
if (s == null) {
s = Boolean.TRUE;
}
if (Boolean.TRUE.equals(s)) {
log.debug("Action " + n + " is enabled.");
enabledActions.add(a);
} else {
log.debug("Action " + n + " not enabled.");
}
}
// Build the tool bar, grouping the actions
Vector v = new Vector();
for (Iterator i = enabledActions.iterator(); i.hasNext();) {
StandardAction a = (StandardAction) i.next();
if (Boolean.TRUE.equals(
(Boolean) a.getValue(StandardAction.ON_TOOLBAR))) {
v.addElement(a);
}
}
Collections.sort(v, new ToolBarActionComparator());
Integer grp = null;
for (Iterator i = v.iterator(); i.hasNext();) {
StandardAction z = (StandardAction) i.next();
if ((grp != null) &&
!grp.equals(
(Integer) z.getValue(StandardAction.TOOLBAR_GROUP))) {
toolBar.add(new ToolBarSeparator());
}
if (Boolean.TRUE.equals(
(Boolean) z.getValue(StandardAction.IS_TOGGLE_BUTTON))) {
ToolToggleButton tBtn = new ToolToggleButton(z);
toolBar.add(tBtn);
} else {
ToolButton btn = new ToolButton(z);
toolBar.add(btn);
}
grp = (Integer) z.getValue(StandardAction.TOOLBAR_GROUP);
}
toolBar.revalidate();
toolBar.repaint();
// Build the context menu, grouping the actions
Vector c = new Vector();
contextMenu.removeAll();
for (Iterator i = enabledActions.iterator(); i.hasNext();) {
StandardAction a = (StandardAction) i.next();
if (Boolean.TRUE.equals(
(Boolean) a.getValue(StandardAction.ON_CONTEXT_MENU))) {
c.addElement(a);
}
}
Collections.sort(c, new ContextActionComparator());
grp = null;
for (Iterator i = c.iterator(); i.hasNext();) {
StandardAction z = (StandardAction) i.next();
if ((grp != null) &&
!grp.equals(
(Integer) z.getValue(StandardAction.CONTEXT_MENU_GROUP))) {
contextMenu.addSeparator();
}
contextMenu.add(z);
grp = (Integer) z.getValue(StandardAction.CONTEXT_MENU_GROUP);
}
contextMenu.revalidate();
// Build the menu bar
menuBar.removeAll();
v.removeAllElements();
for (Enumeration e = enabledActions.elements(); e.hasMoreElements();) {
StandardAction a = (StandardAction) e.nextElement();
if (Boolean.TRUE.equals(
(Boolean) a.getValue(StandardAction.ON_MENUBAR))) {
v.addElement(a);
}
}
Vector menus = (Vector) actionMenus.clone();
Collections.sort(menus);
HashMap map = new HashMap();
for (Iterator i = v.iterator(); i.hasNext();) {
StandardAction z = (StandardAction) i.next();
String menuName = (String) z.getValue(StandardAction.MENU_NAME);
if (menuName == null) {
log.error("Action " + z.getName() +
" doesnt specify a value for " + StandardAction.MENU_NAME);
} else {
String m = (String) z.getValue(StandardAction.MENU_NAME);
ActionMenu menu = getActionMenu(menus.iterator(), m);
if (menu == null) {
log.error("Action menu " + z.getName() + " does not exist");
} else {
Vector x = (Vector) map.get(menu.name);
if (x == null) {
x = new Vector();
map.put(menu.name, x);
}
x.addElement(z);
}
}
}
for (Iterator i = menus.iterator(); i.hasNext();) {
ActionMenu m = (ActionMenu) i.next();
Vector x = (Vector) map.get(m.name);
if (x != null) {
Collections.sort(x, new MenuItemActionComparator());
JMenu menu = new JMenu(m.displayName);
menu.setMnemonic(m.mnemonic);
grp = null;
for (Iterator j = x.iterator(); j.hasNext();) {
StandardAction a = (StandardAction) j.next();
Integer g = (Integer) a.getValue(StandardAction.MENU_ITEM_GROUP);
if ((grp != null) && !g.equals(grp)) {
menu.addSeparator();
}
grp = g;
if (a instanceof MenuAction) {
JMenu mnu = (JMenu) a.getValue(MenuAction.MENU);
menu.add(mnu);
} else {
JMenuItem item = new JMenuItem(a);
menu.add(item);
}
}
menuBar.add(menu);
} else {
log.error("Can't find menu " + m.name);
}
}
menuBar.validate();
menuBar.repaint();
}
Rebuild all the action components such as toobar, context menu |
public void registerAction(StandardAction action) {
actions.addElement(action);
}
|
public void registerActionMenu(SshToolsApplicationPanel.ActionMenu actionMenu) {
ActionMenu current = getActionMenu(actionMenu.name);
if (current == null) {
actionMenus.addElement(actionMenu);
}
}
|
public void setActionVisible(String name,
boolean visible) {
log.debug("Setting action '" + name + "' to visibility " + visible);
actionsVisible.put(name, new Boolean(visible));
}
Set an actions visible state |
abstract public void setAvailableActions()
Called by the application framework when a change in connection state
has occured. The available actions should be enabled/disabled in this
methods implementation |
public void setContainer(SshToolsApplicationContainer container) {
this.container = container;
}
Sets the container for this panel |
public void setContainerTitle(File file) {
String verString = "";
if (application != null) {
verString = ConfigurationLoader.getVersionString(application.getApplicationName(),
application.getApplicationVersion());
}
if (container != null) {
container.setContainerTitle((file == null) ? verString
: (verString + " [" +
file.getName() + "]"));
}
}
Set the title of the container |
public void setMenuBarVisible(boolean visible) {
if ((getJMenuBar() != null) && (getJMenuBar().isVisible() != visible)) {
getJMenuBar().setVisible(visible);
revalidate();
}
}
Set the visible state of the menu bar |
public void setStatusBarVisible(boolean visible) {
if ((getStatusBar() != null) &&
(getStatusBar().isVisible() != visible)) {
getStatusBar().setVisible(visible);
revalidate();
}
}
Set the visible state of the statusbar |
public void setToolBarVisible(boolean visible) {
if ((getToolBar() != null) && (getToolBar().isVisible() != visible)) {
getToolBar().setVisible(visible);
revalidate();
}
}
Set the visible state of the toolbar |
public void setToolsVisible(boolean visible) {
synchronized (getTreeLock()) {
if ((getToolBar() != null) &&
(getToolBar().isVisible() != visible)) {
getToolBar().setVisible(visible);
}
if ((getJMenuBar() != null) &&
(getJMenuBar().isVisible() != visible)) {
getJMenuBar().setVisible(visible);
}
if ((getStatusBar() != null) &&
(getStatusBar().isVisible() != visible)) {
getStatusBar().setVisible(visible);
}
toolsVisible = visible;
revalidate();
}
}
Set the visible state of all tools. This will set the toolbar, menu and
status bar visible states to the value provided. |
public static void showErrorMessage(Component parent,
String title,
Throwable exception) {
showErrorMessage(parent, null, title, exception);
}
Show an error message with detail |
public static void showErrorMessage(Component parent,
String mesg,
String title,
Throwable exception) {
boolean details = false;
while (true) {
String[] opts = new String[] {
details ? "Hide Details" : "Details", "Ok"
};
StringBuffer buf = new StringBuffer();
if (mesg != null) {
buf.append(mesg);
}
appendException(exception, 0, buf, details);
MultilineLabel message = new MultilineLabel(buf.toString());
int opt = JOptionPane.showOptionDialog(parent, message, title,
JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE,
null, opts, opts[1]);
if (opt == 0) {
details = !details;
} else {
break;
}
}
}
Show an error message with toggable detail |
public void showExceptionMessage(String title,
String message) {
JOptionPane.showMessageDialog(this, message, title,
JOptionPane.ERROR_MESSAGE);
}
Show an exception message |
public void showOptions() {
OptionsTab[] tabs = getApplication().getAdditionalOptionsTabs();
OptionsPanel.showOptionsDialog(this, tabs);
}
|