use of org.jivesoftware.spark.component.VerticalFlowLayout in project Spark by igniterealtime.
the class SipCodecs method init.
private void init() {
_listSelectedModel = new DefaultListModel();
_listSelected = new JList(_listSelectedModel);
_listAvailableModel = new DefaultListModel();
_listAvailable = new JList(_listAvailableModel);
JScrollPane scrollSel = new JScrollPane(_listSelected);
JScrollPane scrollAvail = new JScrollPane(_listAvailable);
JButton btnLeft = new JButton(PhoneRes.getIString("codecs.select"));
JButton btnRight = new JButton(PhoneRes.getIString("codecs.unselect"));
JButton btnUp = new JButton(PhoneRes.getIString("codecs.up"));
JButton btnDown = new JButton(PhoneRes.getIString("codecs.down"));
btnUp.setMinimumSize(new Dimension(80, 25));
btnUp.setPreferredSize(new Dimension(80, 25));
btnUp.setMaximumSize(new Dimension(80, 25));
btnDown.setMaximumSize(new Dimension(80, 25));
btnDown.setPreferredSize(new Dimension(80, 25));
btnDown.setMaximumSize(new Dimension(80, 25));
JPanel panelButtonUpDown = new JPanel();
JPanel panelSelect = new JPanel();
JPanel panelAvailable = new JPanel();
// add actionlisteners
btnLeft.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
left();
}
});
btnRight.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
right();
}
});
btnUp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
up();
}
});
btnDown.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
down();
}
});
// add Components
panelButtonUpDown.setLayout(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE));
panelButtonUpDown.add(btnUp);
panelButtonUpDown.add(btnDown);
panelSelect.setLayout(new BoxLayout(panelSelect, BoxLayout.Y_AXIS));
panelSelect.add(btnRight);
panelSelect.add(new JLabel(PhoneRes.getIString("codecs.audio.selected") + ":"));
panelSelect.add(scrollSel);
panelAvailable.setLayout(new BoxLayout(panelAvailable, BoxLayout.Y_AXIS));
panelAvailable.add(btnLeft);
panelAvailable.add(new JLabel(PhoneRes.getIString("codecs.audio.avail") + ":"));
panelAvailable.add(scrollAvail);
this.setLayout(new GridBagLayout());
this.add(panelButtonUpDown, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
this.add(panelSelect, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
this.add(panelAvailable, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
}
use of org.jivesoftware.spark.component.VerticalFlowLayout in project Spark by igniterealtime.
the class ChatPreferencePanel method createUI.
private void createUI() {
setLayout(new VerticalFlowLayout());
timeFormat.add(format24);
timeFormat.add(format24s);
timeFormat.add(format12);
timeFormat.add(format12s);
final LocalPreferences pref = SettingsManager.getLocalPreferences();
if (pref.getTimeFormat().equals("HH:mm")) {
format24.setSelected(true);
} else if (pref.getTimeFormat().equals("HH:mm:ss")) {
format24s.setSelected(true);
} else if (pref.getTimeFormat().equals("h:mm a")) {
format12.setSelected(true);
} else {
format12s.setSelected(true);
}
// Setup Mnemonics
ResourceUtils.resButton(showTimeBox, Res.getString("checkbox.show.time.in.chat.window"));
ResourceUtils.resLabel(passwordLabel, passwordField, Res.getString("label.change.password.to") + ":");
ResourceUtils.resLabel(confirmationPasswordLabel, confirmationPasswordField, Res.getString("label.confirm.password") + ":");
ResourceUtils.resButton(groupChatNotificationBox, Res.getString("checkbox.show.notifications.in.conference"));
ResourceUtils.resButton(hideChatHistory, Res.getString("checkbox.disable.chat.history"));
ResourceUtils.resButton(hidePrevChatHistory, Res.getString("checkbox.disable.prev.chat.history"));
ResourceUtils.resButton(sortChatHistoryAscending, Res.getString("checkbox.sort.asc.history"));
ResourceUtils.resButton(tabsOnTopBox, Res.getString("checkbox.tabs.on.top"));
ResourceUtils.resButton(buzzBox, Res.getString("checkbox.allow.buzz"));
generalPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.general.information")));
chatWindowPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.chat.window.information")));
if (!Default.getBoolean("CHANGE_PASSWORD_DISABLED") && Enterprise.containsFeature(Enterprise.PASSWORD_CHANGE_FEATURE))
add(generalPanel);
add(chatWindowPanel);
generalPanel.setLayout(new GridBagLayout());
chatWindowPanel.setLayout(new GridBagLayout());
// Chat Window Panel settings
chatWindowPanel.add(showTimeBox, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(format24, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(format24s, new GridBagConstraints(1, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(format12, new GridBagConstraints(2, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(format12s, new GridBagConstraints(2, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(groupChatNotificationBox, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
if (!Default.getBoolean("HISTORY_DISABLED") && !Default.getBoolean("HIDE_HISTORY_SETTINGS") && Enterprise.containsFeature(Enterprise.HISTORY_SETTINGS_FEATURE) && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
chatWindowPanel.add(hideChatHistory, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(hidePrevChatHistory, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
chatWindowPanel.add(sortChatHistoryAscending, new GridBagConstraints(0, 5, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(tabsOnTopBox, new GridBagConstraints(0, 6, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(buzzBox, new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
JLabel chatTimeoutLabel = new JLabel();
ResourceUtils.resLabel(chatTimeoutLabel, chatTimeoutField, Res.getString("label.minutes.before.stale.chat") + ":");
chatWindowPanel.add(chatTimeoutLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(chatTimeoutField, new GridBagConstraints(1, 8, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
generalPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
generalPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0));
generalPanel.add(confirmationPasswordLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
generalPanel.add(confirmationPasswordField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0));
showTimeBox.addActionListener(e -> {
if (showTimeBox.isSelected()) {
format12.setEnabled(true);
format24.setEnabled(true);
format12s.setEnabled(true);
format24s.setEnabled(true);
} else {
format12.setEnabled(false);
format24.setEnabled(false);
format12s.setEnabled(false);
format24s.setEnabled(false);
}
});
hideChatHistory.addActionListener(this);
}
use of org.jivesoftware.spark.component.VerticalFlowLayout in project Spark by igniterealtime.
the class GatewayPlugin method initialize.
public void initialize() {
ProviderManager.addIQProvider(Gateway.ELEMENT_NAME, Gateway.NAMESPACE, new Gateway.Provider());
LocalPreferences localPref = SettingsManager.getLocalPreferences();
useTab = localPref.getShowTransportTab();
transferTab.setBackground((Color) UIManager.get("ContactItem.background"));
SwingWorker thread = new SwingWorker() {
public Object construct() {
try {
// Let's try and avoid any timing issues with the gateway presence.
Thread.sleep(5000);
populateTransports();
} catch (Exception e) {
Log.error(e);
return false;
}
return true;
}
public void finished() {
transferTab.setLayout(new VerticalFlowLayout(0, 0, 0, true, false));
Boolean transportExists = (Boolean) get();
if (!transportExists) {
return;
}
if (TransportUtils.getTransports().size() > 0 && useTab) {
SparkManager.getWorkspace().getWorkspacePane().addTab(Res.getString("title.transports"), SparkRes.getImageIcon(SparkRes.TRANSPORT_ICON), transferTab);
}
for (final Transport transport : TransportUtils.getTransports()) {
addTransport(transport);
}
// Register presences.
registerPresenceListener();
}
};
thread.start();
}
use of org.jivesoftware.spark.component.VerticalFlowLayout in project Spark by igniterealtime.
the class PluginViewer method loadDeactivatedPlugins.
/**
* Initializes the Deactivated Plugins Tab
*/
private void loadDeactivatedPlugins() {
deactivatedPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
if (!Default.getBoolean(Default.DEINSTALL_PLUGINS_DISABLED)) {
tabbedPane.addTab(Res.getString("tab.deactivated.plugins"), new JScrollPane(deactivatedPanel));
}
for (final String s : _deactivatedPlugins) {
PublicPlugin plg = new PublicPlugin();
plg.setName(s);
final SparkPlugUI ui = new SparkPlugUI(plg);
ui.useLocalIcon();
deactivatedPanel.add(ui);
addDeactivatedListener(ui);
}
}
use of org.jivesoftware.spark.component.VerticalFlowLayout in project Spark by igniterealtime.
the class ScratchPadPlugin method showTaskList.
private void showTaskList() {
frame = new JFrame(Res.getString("title.tasks"));
frame.setIconImage(SparkManager.getMainWindow().getIconImage());
panel_events.removeAll();
mainPanel.removeAll();
// final List<TaskUI> taskList = new ArrayList<TaskUI>();
// final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
mainPanel.setBackground(Color.white);
final JPanel topPanel = new JPanel(new GridBagLayout());
final JTextField taskField = new JTextField();
final JTextField dueDateField = new JTextField();
final JButton addButton = new JButton(Res.getString("add"));
final JLabel addTaskLabel = new JLabel(Res.getString("label.add.task"));
topPanel.setOpaque(false);
topPanel.add(addTaskLabel, new GridBagConstraints(0, 0, 1, 1, .9, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
topPanel.add(taskField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 0, 2), 0, 0));
topPanel.add(dueDateField, new GridBagConstraints(1, 1, 1, 1, 0.1, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 0, 2), 50, 0));
topPanel.add(addButton, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 2), 0, 0));
topPanel.add(new JLabel(Res.getString("label.timeformat", formatter.toPattern())), new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
mainPanel.add(topPanel);
// Add Selection
final JPanel middlePanel = new JPanel(new GridBagLayout());
final JLabel showLabel = new JLabel(Res.getString("label.show"));
final JToggleButton allButton = new JToggleButton(Res.getString("button.tasks.all"));
final JToggleButton activeButton = new JToggleButton(Res.getString("button.tasks.active"));
final ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(allButton);
buttonGroup.add(activeButton);
middlePanel.setOpaque(false);
middlePanel.add(showLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
middlePanel.add(allButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
middlePanel.add(activeButton, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
mainPanel.add(middlePanel);
mainPanel.setBackground(Color.white);
final JPanel titlePanel = new JPanel(new BorderLayout()) {
private static final long serialVersionUID = -8812868562658925280L;
public void paintComponent(Graphics g) {
Color startColor = Color.white;
Color endColor = new Color(198, 211, 247);
Graphics2D g2 = (Graphics2D) g;
int w = getWidth();
int h = getHeight();
GradientPaint gradient = new GradientPaint(0, 0, startColor, w, h, endColor, true);
g2.setPaint(gradient);
g2.fillRect(0, 0, w, h);
}
};
final JLabel taskLabel = new JLabel(Res.getString("label.due") + " ");
taskLabel.setFont(taskLabel.getFont().deriveFont(Font.BOLD));
titlePanel.add(taskLabel, BorderLayout.EAST);
mainPanel.add(titlePanel);
Action showAllAction = new AbstractAction() {
private static final long serialVersionUID = -7031122285194582204L;
public void actionPerformed(ActionEvent e) {
for (TaskUI ui : taskList) {
ui.setVisible(true);
}
SHOW_ALL_TASKS = true;
}
};
Action showActiveAction = new AbstractAction() {
private static final long serialVersionUID = -7551153291479117311L;
public void actionPerformed(ActionEvent e) {
for (TaskUI ui : taskList) {
if (ui.isSelected()) {
ui.setVisible(false);
}
}
SHOW_ALL_TASKS = false;
}
};
final Action addAction = new AbstractAction() {
private static final long serialVersionUID = -5937301529216080813L;
public void actionPerformed(ActionEvent e) {
String taskTitle = taskField.getText();
if (!ModelUtil.hasLength(taskTitle)) {
return;
}
Task task = new Task();
task.setTitle(taskTitle);
// Set creation time.
final Date creationDate = new Date();
task.setCreatedDate(creationDate.getTime());
// Set due date.
String dueDate = dueDateField.getText();
if (ModelUtil.hasLength(dueDate)) {
try {
Date date = formatter.parse(dueDate);
task.setDueDate(date.getTime());
} catch (ParseException e1) {
// Nothing to do
}
}
taskField.setText("");
final TaskUI taskUI = new TaskUI(task);
// mainPanel.add(taskUI);
panel_events.add(taskUI);
taskList.add(taskUI);
panel_events.invalidate();
panel_events.validate();
panel_events.repaint();
mainPanel.invalidate();
mainPanel.validate();
mainPanel.repaint();
frame.invalidate();
frame.validate();
frame.repaint();
}
};
mainPanel.add(panel_events);
panel_events.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
panel_events.setBackground(Color.white);
allButton.addActionListener(showAllAction);
activeButton.addActionListener(showActiveAction);
GraphicUtils.makeSameSize(allButton, activeButton);
addButton.addActionListener(addAction);
Tasks tasks = Tasks.getTaskList(SparkManager.getConnection());
updateTaskUI(tasks);
if (SHOW_ALL_TASKS) {
allButton.setSelected(true);
} else {
activeButton.setSelected(true);
showActiveAction.actionPerformed(null);
}
long tomorrow = DateUtils.addDays(new Date().getTime(), 1);
SimpleDateFormat formatter = new SimpleDateFormat(dateShortFormat);
dueDateField.setText(formatter.format(new Date(tomorrow)));
final JScrollPane pane = new JScrollPane(mainPanel);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(pane, BorderLayout.CENTER);
frame.pack();
frame.setSize(400, 400);
final Action saveAction = new AbstractAction() {
private static final long serialVersionUID = -4287799161421970177L;
public void actionPerformed(ActionEvent actionEvent) {
// Save it.
Tasks tasks = new Tasks();
for (TaskUI ui : taskList) {
Task task = ui.getTask();
tasks.addTask(task);
}
Tasks.saveTasks(tasks, SparkManager.getConnection());
}
};
addButton.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
frame.dispose();
saveAction.actionPerformed(null);
}
}
});
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent) {
saveAction.actionPerformed(null);
}
});
taskField.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
addAction.actionPerformed(null);
}
}
});
GraphicUtils.centerWindowOnComponent(frame, SparkManager.getMainWindow());
frame.setVisible(true);
}
Aggregations