mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Updated SparkTabbedPane to handle tab placement variables from JTabbedPane.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4552 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -114,7 +114,7 @@ public final class MainWindow extends JFrame implements ActionListener {
|
|||||||
this.setJMenuBar(mainWindowBar);
|
this.setJMenuBar(mainWindowBar);
|
||||||
this.getContentPane().add(topBar, BorderLayout.NORTH);
|
this.getContentPane().add(topBar, BorderLayout.NORTH);
|
||||||
|
|
||||||
setTitle(title);
|
setTitle(title + " - " + SparkManager.getSessionManager().getUsername());
|
||||||
|
|
||||||
setIconImage(icon.getImage());
|
setIconImage(icon.getImage());
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import org.jivesoftware.spark.ui.conferences.Conferences;
|
|||||||
import org.jivesoftware.spark.ui.status.StatusBar;
|
import org.jivesoftware.spark.ui.status.StatusBar;
|
||||||
import org.jivesoftware.spark.util.SwingWorker;
|
import org.jivesoftware.spark.util.SwingWorker;
|
||||||
import org.jivesoftware.spark.util.log.Log;
|
import org.jivesoftware.spark.util.log.Log;
|
||||||
|
import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane;
|
||||||
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
|
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
|
||||||
import org.jivesoftware.sparkimpl.plugin.transcripts.ChatTranscriptPlugin;
|
import org.jivesoftware.sparkimpl.plugin.transcripts.ChatTranscriptPlugin;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ import java.util.TimerTask;
|
|||||||
* <li>Retrieve the ContactList.
|
* <li>Retrieve the ContactList.
|
||||||
*/
|
*/
|
||||||
public class Workspace extends JPanel implements PacketListener {
|
public class Workspace extends JPanel implements PacketListener {
|
||||||
private JTabbedPane workspacePane;
|
private SparkTabbedPane workspacePane;
|
||||||
private final StatusBar statusBox = new StatusBar();
|
private final StatusBar statusBox = new StatusBar();
|
||||||
private ContactList contactList;
|
private ContactList contactList;
|
||||||
private Conferences conferences;
|
private Conferences conferences;
|
||||||
@ -132,7 +133,7 @@ public class Workspace extends JPanel implements PacketListener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize workspace pane, defaulting the tabs to the bottom.
|
// Initialize workspace pane, defaulting the tabs to the bottom.
|
||||||
workspacePane = new JTabbedPane(JTabbedPane.BOTTOM);
|
workspacePane = new SparkTabbedPane(JTabbedPane.BOTTOM);
|
||||||
//workspacePane.setBoldActiveTab(true);
|
//workspacePane.setBoldActiveTab(true);
|
||||||
//workspacePane.setHideOneTab(true);
|
//workspacePane.setHideOneTab(true);
|
||||||
|
|
||||||
@ -391,7 +392,7 @@ public class Workspace extends JPanel implements PacketListener {
|
|||||||
*
|
*
|
||||||
* @return the workspace JideTabbedPane
|
* @return the workspace JideTabbedPane
|
||||||
*/
|
*/
|
||||||
public JTabbedPane getWorkspacePane() {
|
public SparkTabbedPane getWorkspacePane() {
|
||||||
return workspacePane;
|
return workspacePane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class SparkTab extends TabPanel {
|
|||||||
add(iconLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 2, 3, 2), 0, 0));
|
add(iconLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 2, 3, 2), 0, 0));
|
||||||
|
|
||||||
// add text label
|
// add text label
|
||||||
add(textLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 2, 3, 2), 0, 0));
|
add(textLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 2, 3, 5), 0, 0));
|
||||||
|
|
||||||
// Set fonts
|
// Set fonts
|
||||||
defaultFont = new Font("Dialog", Font.PLAIN, 11);
|
defaultFont = new Font("Dialog", Font.PLAIN, 11);
|
||||||
@ -64,7 +64,7 @@ public class SparkTab extends TabPanel {
|
|||||||
|
|
||||||
public void addComponent(Component component) {
|
public void addComponent(Component component) {
|
||||||
// add Component
|
// add Component
|
||||||
add(component, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 2, 3, 2), 0, 0));
|
add(component, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 2), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPop(JComponent comp) {
|
public void addPop(JComponent comp) {
|
||||||
|
|||||||
@ -14,12 +14,6 @@ import org.jivesoftware.resource.SparkRes;
|
|||||||
import org.jivesoftware.spark.component.RolloverButton;
|
import org.jivesoftware.spark.component.RolloverButton;
|
||||||
import org.jivesoftware.spark.util.ModelUtil;
|
import org.jivesoftware.spark.util.ModelUtil;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.CardLayout;
|
import java.awt.CardLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@ -41,6 +35,13 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -61,12 +62,24 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
|||||||
private Map<Component, JFrame> framesMap = new HashMap<Component, JFrame>();
|
private Map<Component, JFrame> framesMap = new HashMap<Component, JFrame>();
|
||||||
|
|
||||||
|
|
||||||
|
private int tabPlacement = JTabbedPane.TOP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listeners
|
* Listeners
|
||||||
*/
|
*/
|
||||||
private List<SparkTabbedPaneListener> listeners = new ArrayList<SparkTabbedPaneListener>();
|
private List<SparkTabbedPaneListener> listeners = new ArrayList<SparkTabbedPaneListener>();
|
||||||
|
|
||||||
public SparkTabbedPane() {
|
public SparkTabbedPane() {
|
||||||
|
createUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SparkTabbedPane(int placement) {
|
||||||
|
this.tabPlacement = placement;
|
||||||
|
|
||||||
|
createUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createUI() {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
tabs = new JPanel(new
|
tabs = new JPanel(new
|
||||||
@ -103,11 +116,18 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
|||||||
|
|
||||||
final JPanel topPanel = new JPanel();
|
final JPanel topPanel = new JPanel();
|
||||||
topPanel.setLayout(new GridBagLayout());
|
topPanel.setLayout(new GridBagLayout());
|
||||||
topPanel.add(tabs, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
|
topPanel.add(new JLabel(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||||
topPanel.add(new JLabel(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
|
||||||
topPanel.setOpaque(false);
|
topPanel.setOpaque(false);
|
||||||
|
|
||||||
// Add Tabs panel to top of panel.
|
// Add Tabs panel to top of panel.
|
||||||
|
if (tabPlacement == JTabbedPane.TOP) {
|
||||||
|
topPanel.add(tabs, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 0, 0), 0, 0));
|
||||||
add(topPanel, BorderLayout.NORTH);
|
add(topPanel, BorderLayout.NORTH);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
topPanel.add(tabs, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 2, 0), 0, 0));
|
||||||
|
add(topPanel, BorderLayout.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
// Create mainPanel
|
// Create mainPanel
|
||||||
mainPanel = new JPanel(new CardLayout());
|
mainPanel = new JPanel(new CardLayout());
|
||||||
@ -119,7 +139,7 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
|||||||
closeInactiveButtonIcon = SparkRes.getImageIcon(SparkRes.CLOSE_WHITE_X_IMAGE);
|
closeInactiveButtonIcon = SparkRes.getImageIcon(SparkRes.CLOSE_WHITE_X_IMAGE);
|
||||||
closeActiveButtonIcon = SparkRes.getImageIcon(SparkRes.CLOSE_DARK_X_IMAGE);
|
closeActiveButtonIcon = SparkRes.getImageIcon(SparkRes.CLOSE_DARK_X_IMAGE);
|
||||||
|
|
||||||
setBackground(Color.white);
|
setOpaque(false);
|
||||||
tabs.setOpaque(false);
|
tabs.setOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +152,7 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
|||||||
|
|
||||||
public SparkTab addTab(String text, Icon icon, final Component component) {
|
public SparkTab addTab(String text, Icon icon, final Component component) {
|
||||||
final SparkTab tab = new SparkTab(icon, text);
|
final SparkTab tab = new SparkTab(icon, text);
|
||||||
|
tab.setTabPlacement(tabPlacement);
|
||||||
//tabs.add(tab, new GridBagConstraints(tabs.getComponentCount(), 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 0), 0, 0));
|
//tabs.add(tab, new GridBagConstraints(tabs.getComponentCount(), 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 0), 0, 0));
|
||||||
|
|
||||||
tabs.add(tab);
|
tabs.add(tab);
|
||||||
@ -506,7 +527,7 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
|||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
JFrame f = new JFrame();
|
JFrame f = new JFrame();
|
||||||
SparkTabbedPane pane = new SparkTabbedPane();
|
SparkTabbedPane pane = new SparkTabbedPane(JTabbedPane.BOTTOM);
|
||||||
pane.setCloseButtonEnabled(true);
|
pane.setCloseButtonEnabled(true);
|
||||||
pane.setPopupAllowed(true);
|
pane.setPopupAllowed(true);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|||||||
@ -15,12 +15,6 @@ import org.jivesoftware.Spark;
|
|||||||
import org.jivesoftware.resource.Default;
|
import org.jivesoftware.resource.Default;
|
||||||
import org.jivesoftware.spark.util.log.Log;
|
import org.jivesoftware.spark.util.log.Log;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.plaf.basic.BasicPanelUI;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.GradientPaint;
|
import java.awt.GradientPaint;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@ -31,9 +25,20 @@ import java.awt.Shape;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.plaf.basic.BasicPanelUI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single instance of a Tab Paint Component.
|
||||||
|
*
|
||||||
|
* @author Derek DeMoro
|
||||||
|
*/
|
||||||
public class TabPanelUI extends BasicPanelUI {
|
public class TabPanelUI extends BasicPanelUI {
|
||||||
private Color backgroundColor1 = Color.white;//new Color(235, 247, 223);
|
private Color backgroundColor1 = new Color(0,0,0,0);
|
||||||
private Color backgroundColor2 = Color.white;//new Color(214, 219, 191);
|
private Color backgroundColor2 = new Color(0,0,0,0);
|
||||||
|
|
||||||
private Color borderColor = new Color(86, 88, 72);
|
private Color borderColor = new Color(86, 88, 72);
|
||||||
private Color borderColorAlpha1 = new Color(86, 88, 72, 100);
|
private Color borderColorAlpha1 = new Color(86, 88, 72, 100);
|
||||||
@ -59,8 +64,8 @@ public class TabPanelUI extends BasicPanelUI {
|
|||||||
backgroundColor2 = getSelectedEndColor();
|
backgroundColor2 = getSelectedEndColor();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
backgroundColor1 = Color.white;
|
backgroundColor1 = new Color(0, 0, 0, 0);
|
||||||
backgroundColor2 = Color.white;
|
backgroundColor2 = new Color(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
@ -83,6 +88,7 @@ public class TabPanelUI extends BasicPanelUI {
|
|||||||
int y = vInsets.top;
|
int y = vInsets.top;
|
||||||
int arc = 8;
|
int arc = 8;
|
||||||
|
|
||||||
|
|
||||||
Shape vButtonShape = new RoundRectangle2D.Double((double)x, (double)y, (double)w, (double)h, (double)arc, (double)arc);
|
Shape vButtonShape = new RoundRectangle2D.Double((double)x, (double)y, (double)w, (double)h, (double)arc, (double)arc);
|
||||||
Shape vOldClip = g.getClip();
|
Shape vOldClip = g.getClip();
|
||||||
|
|
||||||
@ -96,6 +102,8 @@ public class TabPanelUI extends BasicPanelUI {
|
|||||||
GradientPaint vPaint = new GradientPaint(x, y, borderColor, x, y + h, borderHighlight);
|
GradientPaint vPaint = new GradientPaint(x, y, borderColor, x, y + h, borderHighlight);
|
||||||
g2d.setPaint(vPaint);
|
g2d.setPaint(vPaint);
|
||||||
|
|
||||||
|
// Handle custom actions.
|
||||||
|
if (placement == JTabbedPane.TOP) {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
g2d.setColor(Color.lightGray);
|
g2d.setColor(Color.lightGray);
|
||||||
g2d.drawRoundRect(x, y, w, h, arc, arc);
|
g2d.drawRoundRect(x, y, w, h, arc, arc);
|
||||||
@ -107,11 +115,15 @@ public class TabPanelUI extends BasicPanelUI {
|
|||||||
g2d.setClip(vOldClip);
|
g2d.setClip(vOldClip);
|
||||||
g2d.setColor(borderColorAlpha2);
|
g2d.setColor(borderColorAlpha2);
|
||||||
|
|
||||||
if (placement == JTabbedPane.TOP) {
|
|
||||||
g2d.setColor(backgroundColor2);
|
g2d.setColor(backgroundColor2);
|
||||||
g2d.fillRect(x, h - 5, w, h);
|
g2d.fillRect(x, h - 5, w, h);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Make straight line.
|
||||||
|
g2d.setColor(backgroundColor2);
|
||||||
|
g2d.fillRect(x, y, w, 4);
|
||||||
|
}
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
|
||||||
@ -121,7 +133,6 @@ public class TabPanelUI extends BasicPanelUI {
|
|||||||
g2d.setColor(Color.lightGray);
|
g2d.setColor(Color.lightGray);
|
||||||
g2d.drawLine(w - 1, 4, w - 1, h - 4);
|
g2d.drawLine(w - 1, 4, w - 1, h - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be subclassed to track all available ChatRooms.
|
* Contains all <code>ChatRoom</code> objects within Spark.
|
||||||
|
*
|
||||||
|
* @author Derek DeMoro
|
||||||
*/
|
*/
|
||||||
public class ChatContainer extends SparkTabbedPane implements MessageListener, ChangeListener {
|
public class ChatContainer extends SparkTabbedPane implements MessageListener, ChangeListener {
|
||||||
/**
|
/**
|
||||||
@ -113,6 +115,9 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
|||||||
addKeyNavigation();
|
addKeyNavigation();
|
||||||
|
|
||||||
this.setFocusable(false);
|
this.setFocusable(false);
|
||||||
|
|
||||||
|
setOpaque(true);
|
||||||
|
setBackground(Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user