use of org.jivesoftware.spark.component.TitlePanel in project Spark by igniterealtime.
the class BroadcastDialog method invokeDialog.
/**
* Displays the broadcast dialog.
*/
public void invokeDialog() {
final JDialog dlg;
TitlePanel titlePanel;
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.broadcast.message"), Res.getString("message.enter.broadcast.message"), null, true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
JButton okButton = new JButton(Res.getString("ok"));
JButton closeButton = new JButton(Res.getString("close"));
mainPanel.add(this, BorderLayout.CENTER);
JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonpanel.add(okButton);
buttonpanel.add(closeButton);
mainPanel.add(buttonpanel, BorderLayout.SOUTH);
dlg = new JDialog(SparkManager.getMainWindow(), Res.getString("broadcast"));
dlg.setContentPane(mainPanel);
dlg.pack();
final Rectangle bounds = LayoutSettingsManager.getLayoutSettings().getBroadcastMessageBounds();
if (bounds == null || bounds.width <= 0 || bounds.height <= 0) {
// Use default settings.
dlg.setSize(800, 600);
dlg.setLocationRelativeTo(null);
} else {
dlg.setBounds(bounds);
}
dlg.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastMessageBounds(dlg.getBounds());
}
@Override
public void componentMoved(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastMessageBounds(dlg.getBounds());
}
});
dlg.setResizable(false);
// Add listener
okButton.addActionListener(e -> {
try {
if (sendBroadcasts(dlg)) {
dlg.setVisible(false);
}
} catch (SmackException.NotConnectedException e1) {
Log.warning("Unable to broadcast.", e1);
}
});
closeButton.addActionListener(e -> dlg.setVisible(false));
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
messageBox.requestFocus();
}
use of org.jivesoftware.spark.component.TitlePanel in project Spark by igniterealtime.
the class InputTextAreaDialog method getInput.
/**
* Prompt and return input.
*
* @param title the title of the dialog.
* @param description the dialog description.
* @param icon the icon to use.
* @param parent the parent to use.
* @return the user input.
*/
public String getInput(String title, String description, Icon icon, Component parent) {
textArea = new JTextArea();
textArea.setLineWrap(true);
TitlePanel titlePanel = new TitlePanel(title, description, icon, true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
final Object[] options = { Res.getString("ok"), Res.getString("cancel") };
optionPane = new JOptionPane(new JScrollPane(textArea), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(optionPane, BorderLayout.CENTER);
// Let's make sure that the dialog is modal. Cannot risk people
// losing this dialog.
JOptionPane p = new JOptionPane();
dialog = p.createDialog(parent, title);
dialog.setModal(true);
dialog.pack();
dialog.setSize(width, height);
dialog.setContentPane(mainPanel);
dialog.setLocationRelativeTo(parent);
optionPane.addPropertyChangeListener(this);
// Add Key Listener to Send Field
textArea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_TAB) {
optionPane.requestFocus();
} else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
dialog.dispose();
}
}
});
textArea.requestFocus();
dialog.setVisible(true);
return stringValue;
}
use of org.jivesoftware.spark.component.TitlePanel in project Spark by igniterealtime.
the class JoinConferenceRoomDialog method joinRoom.
public void joinRoom(final String roomJID, final String roomName) {
final LocalPreferences pref = SettingsManager.getLocalPreferences();
// Set default nickname
nicknameField.setText(pref.getNickname());
// Enable password field if a password is required
passwordField.setVisible(false);
passwordLabel.setVisible(false);
roomNameDescription.setText(roomName);
final JOptionPane pane;
TitlePanel titlePanel;
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.join.conference.room"), Res.getString("message.specify.information.for.conference"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = { Res.getString("join"), Res.getString("cancel") };
pane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(pane, BorderLayout.CENTER);
final JOptionPane p = new JOptionPane();
final JDialog dlg = p.createDialog(SparkManager.getMainWindow(), Res.getString("title.conference.rooms"));
dlg.setModal(false);
dlg.pack();
dlg.setSize(350, 250);
dlg.setResizable(true);
dlg.setContentPane(mainPanel);
dlg.setLocationRelativeTo(SparkManager.getMainWindow());
PropertyChangeListener changeListener = e -> {
String value = (String) pane.getValue();
if (Res.getString("cancel").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
dlg.dispose();
} else if (Res.getString("join").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
dlg.dispose();
ConferenceUtils.joinConferenceOnSeperateThread(roomName, roomJID, null);
}
};
pane.addPropertyChangeListener(changeListener);
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
SwingWorker worker = new SwingWorker() {
boolean requiresPassword;
public Object construct() {
requiresPassword = ConferenceUtils.isPasswordRequired(roomJID);
return requiresPassword;
}
public void finished() {
passwordField.setVisible(requiresPassword);
passwordLabel.setVisible(requiresPassword);
}
};
worker.start();
}
use of org.jivesoftware.spark.component.TitlePanel in project Spark by igniterealtime.
the class RoomBrowser method setupRoomInformationUI.
private void setupRoomInformationUI(String roomJID, final RoomInfo roomInfo, final DiscoverItems items) {
descriptionValue.setText(Res.getString("message.no.description.available"));
subjectValue.setText(Res.getString("message.no.subject.available"));
occupantsValue.setText("n/a");
roomNameValue.setText("n/a");
try {
descriptionValue.setText(roomInfo.getDescription());
subjectValue.setText(roomInfo.getSubject());
if (roomInfo.getOccupantsCount() == -1) {
occupantsValue.setText("n/a");
} else {
occupantsValue.setText(Integer.toString(roomInfo.getOccupantsCount()));
}
roomNameValue.setText(roomInfo.getRoom());
for (DiscoverItems.Item item : items.getItems()) {
String jid = item.getEntityID();
rootNode.add(new JiveTreeNode(jid, false, SparkRes.getImageIcon(SparkRes.SMALL_USER1_INFORMATION)));
}
tree.expandRow(0);
} catch (Exception e) {
Log.error(e);
}
final JOptionPane pane;
// Create the title panel for this dialog
TitlePanel titlePanel = new TitlePanel(Res.getString("title.view.room.information"), Res.getString("message.room.information.for", roomJID), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = { Res.getString("close") };
pane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(pane, BorderLayout.CENTER);
final JOptionPane p = new JOptionPane();
final JDialog dlg = p.createDialog(SparkManager.getMainWindow(), Res.getString("title.view.room.information"));
dlg.setModal(false);
dlg.pack();
dlg.setSize(450, 400);
dlg.setResizable(true);
dlg.setContentPane(mainPanel);
dlg.setLocationRelativeTo(SparkManager.getMainWindow());
PropertyChangeListener changeListener = e -> {
String value = (String) pane.getValue();
if (Res.getString("close").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
dlg.dispose();
}
};
pane.addPropertyChangeListener(changeListener);
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
}
use of org.jivesoftware.spark.component.TitlePanel in project Spark by igniterealtime.
the class RoomCreationDialog method createGroupChat.
public MultiUserChat createGroupChat(Component parent, final String serviceName) {
final JOptionPane pane;
final JDialog dlg;
TitlePanel titlePanel;
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.create.or.join"), Res.getString("message.create.or.join.room"), SparkRes.getImageIcon(SparkRes.BLANK_24x24), true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = { Res.getString("create"), Res.getString("close") };
pane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(pane, BorderLayout.CENTER);
JOptionPane p = new JOptionPane();
dlg = p.createDialog(parent, Res.getString("title.conference.rooms"));
dlg.pack();
dlg.setSize(400, 350);
dlg.setContentPane(mainPanel);
dlg.setLocationRelativeTo(parent);
PropertyChangeListener changeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
Object o = pane.getValue();
if (o instanceof Integer) {
dlg.setVisible(false);
return;
}
String value = (String) pane.getValue();
if (Res.getString("close").equals(value)) {
dlg.setVisible(false);
} else if (Res.getString("create").equals(value)) {
boolean isValid = validatePanel();
if (isValid) {
String room = nameField.getText().replaceAll(" ", "_") + "@" + serviceName;
try {
MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getRoomInfo(room);
// JOptionPane.showMessageDialog(dlg, "Room already exists. Please specify a unique room name.", "Room Exists", JOptionPane.ERROR_MESSAGE);
// pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
pane.removePropertyChangeListener(this);
dlg.setVisible(false);
ConferenceUtils.joinConferenceRoom(room, room);
return;
} catch (XMPPException | SmackException e1) {
// Nothing to do
}
groupChat = createGroupChat(nameField.getText(), serviceName);
if (groupChat == null) {
showError("Could not join chat " + nameField.getText());
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
} else {
pane.removePropertyChangeListener(this);
dlg.setVisible(false);
}
} else {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
}
}
}
};
pane.addPropertyChangeListener(changeListener);
nameField.requestFocusInWindow();
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
return groupChat;
}
Aggregations