1998-09-09 00:52:38 +00:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Grendel mail/news client.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1997
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Created: Will Scullin <scullin@netscape.com>, 13 Oct 1997.
|
1999-03-07 19:58:40 +00:00
|
|
|
*
|
|
|
|
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
1999-04-17 22:57:44 +00:00
|
|
|
* Edwin Woudt <edwin@woudt.nl>
|
1998-09-09 00:52:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package grendel.ui;
|
|
|
|
|
1999-01-09 03:55:32 +00:00
|
|
|
import grendel.ui.UIAction;
|
1999-01-10 21:49:40 +00:00
|
|
|
import grendel.ui.ToolBarLayout;
|
|
|
|
|
|
|
|
import grendel.widgets.GrendelToolBar;
|
1999-01-09 03:55:32 +00:00
|
|
|
|
1998-09-09 00:52:38 +00:00
|
|
|
import java.awt.BorderLayout;
|
1999-04-17 22:51:57 +00:00
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.Font;
|
1998-09-09 00:52:38 +00:00
|
|
|
import java.awt.Image;
|
|
|
|
import java.awt.datatransfer.Clipboard;
|
1999-01-09 03:55:32 +00:00
|
|
|
import java.util.Enumeration;
|
1998-09-09 00:52:38 +00:00
|
|
|
import java.util.Hashtable;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.MissingResourceException;
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
import java.util.StringTokenizer;
|
|
|
|
|
1999-01-10 21:49:40 +00:00
|
|
|
import javax.swing.BorderFactory;
|
1999-01-09 03:55:32 +00:00
|
|
|
import javax.swing.Icon;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.JButton;
|
1998-09-09 00:52:38 +00:00
|
|
|
|
|
|
|
public class GeneralPanel extends JPanel {
|
1999-01-09 03:55:32 +00:00
|
|
|
private final boolean DEBUG = true;
|
1998-09-09 00:52:38 +00:00
|
|
|
static ResourceBundle fLabels = ResourceBundle.getBundle("grendel.ui.Labels",
|
1999-01-10 21:49:40 +00:00
|
|
|
Locale.getDefault());
|
1998-09-09 00:52:38 +00:00
|
|
|
|
|
|
|
static Clipboard fPrivateClipboard = new Clipboard("Grendel");
|
|
|
|
|
|
|
|
protected String fResourceBase = "grendel.ui";
|
1999-01-10 21:49:40 +00:00
|
|
|
protected GrendelToolBar fToolBar;
|
1998-09-09 00:52:38 +00:00
|
|
|
|
|
|
|
public GeneralPanel() {
|
|
|
|
setLayout(new BorderLayout());
|
1999-06-16 05:13:53 +00:00
|
|
|
setFont(new Font("Helvetica", Font.PLAIN, 12));
|
1998-09-09 00:52:38 +00:00
|
|
|
}
|
|
|
|
|
1999-01-09 03:55:32 +00:00
|
|
|
public UIAction[] getActions() {
|
1998-09-09 00:52:38 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
1999-01-10 21:49:40 +00:00
|
|
|
protected GrendelToolBar buildToolBar(String aToolbar, UIAction[] aActions) {
|
|
|
|
GrendelToolBar res = null;
|
1998-09-09 00:52:38 +00:00
|
|
|
|
|
|
|
Hashtable commands = new Hashtable();
|
|
|
|
for (int i = 0; i < aActions.length; i++)
|
1999-01-09 03:55:32 +00:00
|
|
|
{
|
|
|
|
UIAction a = aActions[i];
|
|
|
|
String name = a.getName();
|
|
|
|
commands.put(name, a);
|
|
|
|
}
|
|
|
|
|
1998-09-09 00:52:38 +00:00
|
|
|
|
|
|
|
try {
|
1999-01-10 21:49:40 +00:00
|
|
|
res = new GrendelToolBar();
|
|
|
|
// res.setLayout(new ToolBarLayout());
|
1998-09-09 00:52:38 +00:00
|
|
|
|
1999-04-17 23:53:53 +00:00
|
|
|
ResourceBundle toolbarresources = ResourceBundle.getBundle(fResourceBase + ".Toolbar");
|
|
|
|
ResourceBundle menuresources = ResourceBundle.getBundle(fResourceBase + ".Menus");
|
|
|
|
String toolbar = menuresources.getString(aToolbar);
|
1998-09-09 00:52:38 +00:00
|
|
|
StringTokenizer tokens = new StringTokenizer(toolbar, " ", false);
|
|
|
|
while (tokens.hasMoreTokens()) {
|
|
|
|
String token = tokens.nextToken();
|
1999-01-09 03:55:32 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
System.out.println("Local token = " + token);
|
|
|
|
}
|
|
|
|
UIAction action = (UIAction)commands.get(token);
|
1999-04-17 23:53:53 +00:00
|
|
|
String icon = toolbarresources.getString(token + "Icon");
|
|
|
|
String label = toolbarresources.getString(token + "Label");
|
|
|
|
String tooltip = toolbarresources.getString(token + "Tooltip");
|
|
|
|
|
|
|
|
res.addButton(action, icon, label, tooltip);
|
1998-09-09 00:52:38 +00:00
|
|
|
}
|
|
|
|
} catch (MissingResourceException e) {
|
|
|
|
System.err.println(e);
|
|
|
|
}
|
|
|
|
|
1999-01-09 03:55:32 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
System.out.println("Toolbar status:");
|
|
|
|
if (res == null) {
|
|
|
|
System.out.println("\tbuildToolBar failed.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
System.out.println("\tbuildToolBar succeeded.");
|
1999-01-10 21:49:40 +00:00
|
|
|
System.out.println("\tGrendelToolBar res contains " + res.getComponentCount() + " components.");
|
1999-01-09 03:55:32 +00:00
|
|
|
}
|
|
|
|
}
|
1999-01-10 21:49:40 +00:00
|
|
|
|
1998-09-09 00:52:38 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1999-01-10 21:49:40 +00:00
|
|
|
public GrendelToolBar getToolBar() {
|
1998-09-09 00:52:38 +00:00
|
|
|
return fToolBar;
|
|
|
|
}
|
|
|
|
}
|