gecko-dev/grendel/ui/GeneralPanel.java

123 строки
3.8 KiB
Java
Исходник Обычный вид История

1998-09-09 04:52:38 +04: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.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Edwin Woudt <edwin@woudt.nl>
1998-09-09 04:52:38 +04:00
*/
package grendel.ui;
import grendel.ui.UIAction;
import grendel.ui.ToolBarLayout;
import grendel.widgets.GrendelToolBar;
1998-09-09 04:52:38 +04:00
import java.awt.BorderLayout;
1999-04-18 02:51:57 +04:00
import java.awt.Dimension;
import java.awt.Font;
1998-09-09 04:52:38 +04:00
import java.awt.Image;
import java.awt.datatransfer.Clipboard;
import java.util.Enumeration;
1998-09-09 04:52:38 +04:00
import java.util.Hashtable;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JButton;
1998-09-09 04:52:38 +04:00
public class GeneralPanel extends JPanel {
private final boolean DEBUG = true;
1998-09-09 04:52:38 +04:00
static ResourceBundle fLabels = ResourceBundle.getBundle("grendel.ui.Labels",
Locale.getDefault());
1998-09-09 04:52:38 +04:00
static Clipboard fPrivateClipboard = new Clipboard("Grendel");
protected String fResourceBase = "grendel.ui";
protected GrendelToolBar fToolBar;
1998-09-09 04:52:38 +04:00
public GeneralPanel() {
setLayout(new BorderLayout());
setFont(new Font("Helvetica", Font.PLAIN, 12));
1998-09-09 04:52:38 +04:00
}
public UIAction[] getActions() {
1998-09-09 04:52:38 +04:00
return null;
}
protected GrendelToolBar buildToolBar(String aToolbar, UIAction[] aActions) {
GrendelToolBar res = null;
1998-09-09 04:52:38 +04:00
Hashtable commands = new Hashtable();
for (int i = 0; i < aActions.length; i++)
{
UIAction a = aActions[i];
String name = a.getName();
commands.put(name, a);
}
1998-09-09 04:52:38 +04:00
try {
res = new GrendelToolBar();
// res.setLayout(new ToolBarLayout());
1998-09-09 04:52:38 +04:00
1999-04-18 03:53:53 +04:00
ResourceBundle toolbarresources = ResourceBundle.getBundle(fResourceBase + ".Toolbar");
ResourceBundle menuresources = ResourceBundle.getBundle(fResourceBase + ".Menus");
String toolbar = menuresources.getString(aToolbar);
1998-09-09 04:52:38 +04:00
StringTokenizer tokens = new StringTokenizer(toolbar, " ", false);
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken();
if (DEBUG) {
System.out.println("Local token = " + token);
}
UIAction action = (UIAction)commands.get(token);
1999-04-18 03:53:53 +04: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 04:52:38 +04:00
}
} catch (MissingResourceException e) {
System.err.println(e);
}
if (DEBUG) {
System.out.println("Toolbar status:");
if (res == null) {
System.out.println("\tbuildToolBar failed.");
}
else {
System.out.println("\tbuildToolBar succeeded.");
System.out.println("\tGrendelToolBar res contains " + res.getComponentCount() + " components.");
}
}
1998-09-09 04:52:38 +04:00
return res;
}
public GrendelToolBar getToolBar() {
1998-09-09 04:52:38 +04:00
return fToolBar;
}
}