| Method from com.sshtools.common.ui.SshToolsApplication Detail: |
public void addAdditionalOptionsTab(OptionsTab tab) {
if (!additionalOptionsTabs.contains(tab)) {
additionalOptionsTabs.add(tab);
}
}
|
public void closeContainer(SshToolsApplicationContainer container) {
if (log.isDebugEnabled()) {
log.debug("Asking " + container + " if it can close");
}
if (container.getApplicationPanel().canClose()) {
if (log.isDebugEnabled()) {
log.debug("Closing");
for (Iterator i = containers.iterator(); i.hasNext();) {
log.debug(i.next() + " is currently open");
}
}
container.getApplicationPanel().close();
container.closeContainer();
containers.removeElement(container);
if (containers.size() == 0) {
exit();
} else {
log.debug(
"Not closing completely because there are containers still open");
for (Iterator i = containers.iterator(); i.hasNext();) {
log.debug(i.next() + " is still open");
}
}
}
}
|
public SshToolsApplicationContainer convertContainer(SshToolsApplicationContainer container,
Class newContainerClass) throws SshToolsApplicationException {
log.info("Converting container of class " +
container.getClass().getName() + " to " +
newContainerClass.getName());
int idx = containers.indexOf(container);
if (idx == -1) {
throw new SshToolsApplicationException(
"Container is not being manager by the application.");
}
SshToolsApplicationContainer newContainer = null;
try {
container.closeContainer();
SshToolsApplicationPanel panel = container.getApplicationPanel();
newContainer = (SshToolsApplicationContainer) newContainerClass.newInstance();
newContainer.init(this, panel);
panel.setContainer(newContainer);
if (!newContainer.isContainerVisible()) {
newContainer.setContainerVisible(true);
}
containers.setElementAt(newContainer, idx);
return newContainer;
} catch (Throwable t) {
throw new SshToolsApplicationException(t);
}
}
|
public void exit() {
log.debug("Exiting application");
PreferencesStore.savePreferences();
FileOutputStream out = null;
File a = getApplicationPreferencesDirectory();
if (a != null) {
try {
File f = new File(getApplicationPreferencesDirectory(),
getApplicationName() + ".mru");
;
if (log.isDebugEnabled()) {
log.debug("Saving MRU to " + f.getAbsolutePath());
}
out = new FileOutputStream(f);
PrintWriter w = new PrintWriter(out, true);
w.println(mruModel.getMRUList().toString());
} catch (IOException ioe) {
log.error("Could not save MRU. ", ioe);
} finally {
IOUtil.closeStream(out);
}
} else {
log.debug(
"Not saving preferences because no preferences directory is available.");
}
System.exit(0);
}
|
abstract public String getAboutAuthors()
|
abstract public String getAboutLicenseDetails()
|
abstract public String getAboutURL()
|
public OptionsTab[] getAdditionalOptionsTabs() {
OptionsTab[] t = new OptionsTab[additionalOptionsTabs.size()];
additionalOptionsTabs.toArray(t);
return t;
}
|
public static UIManager.LookAndFeelInfo[] getAllLookAndFeelInfo() {
return allLookAndFeelInfo;
}
|
abstract public Icon getApplicationLargeIcon()
|
abstract public String getApplicationName()
|
abstract public File getApplicationPreferencesDirectory()
|
abstract public String getApplicationVersion()
|
public SshToolsApplicationContainer getContainerAt(int idx) {
return (SshToolsApplicationContainer) containers.elementAt(idx);
}
|
public int getContainerCount() {
return containers.size();
}
|
public SshToolsApplicationContainer getContainerForPanel(SshToolsApplicationPanel panel) {
for (Iterator i = containers.iterator(); i.hasNext();) {
SshToolsApplicationContainer c = (SshToolsApplicationContainer) i.next();
if (c.getApplicationPanel() == panel) {
return c;
}
}
return null;
}
|
public MRUListModel getMRUModel() {
return mruModel;
}
|
public OptionsTab getOptionsTab(String title) {
for (Iterator i = additionalOptionsTabs.iterator(); i.hasNext();) {
OptionsTab t = (OptionsTab) i.next();
if (t.getTabTitle().equals(title)) {
return t;
}
}
return null;
}
|
public void init(String[] args) throws SshToolsApplicationException {
File f = getApplicationPreferencesDirectory();
if (f != null) {
//
PreferencesStore.init(new File(f,
getApplicationName() + ".properties"));
log.info("Preferences will be saved to " + f.getAbsolutePath());
} else {
log.warn("No preferences can be saved.");
}
try {
setLookAndFeel(PreferencesStore.get(PREF_LAF, SYSTEM_LAF));
UIManager.put("OptionPane.errorIcon",
new ResourceIcon(SshToolsApplication.class, "dialog-error4.png"));
UIManager.put("OptionPane.informationIcon",
new ResourceIcon(SshToolsApplication.class,
"dialog-information.png"));
UIManager.put("OptionPane.warningIcon",
new ResourceIcon(SshToolsApplication.class,
"dialog-warning2.png"));
UIManager.put("OptionPane.questionIcon",
new ResourceIcon(SshToolsApplication.class,
"dialog-question3.png"));
} catch (Throwable t) {
log.error(t);
}
}
|
public SshToolsApplicationContainer newContainer() throws SshToolsApplicationException {
SshToolsApplicationContainer container = null;
try {
container = (SshToolsApplicationContainer) defaultContainerClass.newInstance();
newContainer(container);
return container;
} catch (Throwable t) {
throw new SshToolsApplicationException(t);
}
}
|
public void newContainer(SshToolsApplicationContainer container) throws SshToolsApplicationException {
try {
SshToolsApplicationPanel panel = (SshToolsApplicationPanel) panelClass.newInstance();
panel.init(this);
panel.rebuildActionComponents();
panel.setAvailableActions();
container.init(this, panel);
panel.setContainer(container);
if (!container.isContainerVisible()) {
container.setContainerVisible(true);
}
containers.addElement(container);
} catch (Throwable t) {
throw new SshToolsApplicationException(t);
}
}
|
public void removeAdditionalOptionsTab(OptionsTab tab) {
additionalOptionsTabs.remove(tab);
}
|
public void removeAdditionalOptionsTab(String title) {
OptionsTab t = getOptionsTab(title);
if (t != null) {
removeAdditionalOptionsTab(t);
}
}
|
public static void setLookAndFeel(String className) throws Exception {
LookAndFeel laf = null;
if (!className.equals(DEFAULT_LAF)) {
if (className.equals(SYSTEM_LAF)) {
String systemLaf = UIManager.getSystemLookAndFeelClassName();
log.debug("System Look And Feel is " + systemLaf);
laf = (LookAndFeel) Class.forName(systemLaf).newInstance();
} else if (className.equals(CROSS_PLATFORM_LAF)) {
String crossPlatformLaf = UIManager.getCrossPlatformLookAndFeelClassName();
log.debug("Cross Platform Look And Feel is " +
crossPlatformLaf);
laf = (LookAndFeel) Class.forName(crossPlatformLaf).newInstance();
} else {
laf = (LookAndFeel) Class.forName(className).newInstance();
}
}
// Now actually set the look and feel
if (laf != null) {
log.info("Setting look and feel " + laf.getName() + " (" +
laf.getClass().getName() + ")");
UIManager.setLookAndFeel(laf);
UIManager.put("EditorPane.font", UIManager.getFont("TextArea.font"));
}
}
|
public void showAbout(Component parent) {
JPanel p = new JPanel(new GridBagLayout());
p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
GridBagConstraints gBC = new GridBagConstraints();
gBC.anchor = GridBagConstraints.CENTER;
gBC.fill = GridBagConstraints.HORIZONTAL;
gBC.insets = new Insets(1, 1, 1, 1);
JLabel a = new JLabel(getApplicationName());
a.setFont(a.getFont().deriveFont(24f));
UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER);
JLabel v = new JLabel(ConfigurationLoader.getVersionString(
getApplicationName(), getApplicationVersion()));
v.setFont(v.getFont().deriveFont(10f));
UIUtil.jGridBagAdd(p, v, gBC, GridBagConstraints.REMAINDER);
MultilineLabel x = new MultilineLabel(getAboutAuthors());
x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0));
x.setFont(x.getFont().deriveFont(12f));
UIUtil.jGridBagAdd(p, x, gBC, GridBagConstraints.REMAINDER);
MultilineLabel c = new MultilineLabel(getAboutLicenseDetails());
c.setFont(c.getFont().deriveFont(10f));
UIUtil.jGridBagAdd(p, c, gBC, GridBagConstraints.REMAINDER);
final JLabel h = new JLabel(getAboutURL());
h.setForeground(Color.blue);
h.setFont(new Font(h.getFont().getName(), Font.BOLD, 10));
h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
h.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
try {
BrowserLauncher.openURL(getAboutURL());
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
});
UIUtil.jGridBagAdd(p, h, gBC, GridBagConstraints.REMAINDER);
JOptionPane.showMessageDialog(parent, p, "About",
JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon());
}
|