use of org.jivesoftware.spark.component.LinkLabel in project Spark by igniterealtime.
the class RoomInformation method showFormInformation.
public void showFormInformation(Form form, final RequestUtils utils) {
setLayout(new GridBagLayout());
setBackground(Color.white);
int count = 1;
for (final FormField field : form.getFields()) {
String variable = field.getVariable();
String label = field.getLabel();
if (label != null) {
final JLabel nameLabel = new JLabel(label);
nameLabel.setFont(new Font("Dialog", Font.BOLD, 11));
String value = utils.getValue(variable);
if (value == null) {
value = "";
}
final WrappedLabel valueLabel = new WrappedLabel();
valueLabel.setBackground(Color.white);
valueLabel.setText(value);
add(nameLabel, new GridBagConstraints(0, count, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
add(valueLabel, new GridBagConstraints(1, count, 3, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
count++;
}
}
final Color linkColor = new Color(69, 92, 137);
LinkLabel viewLabel = new LinkLabel(FpRes.getString("message.view.more.information"), null, linkColor, Color.red);
viewLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
RoomInformation roomInformation = new RoomInformation();
roomInformation.showAllInformation(utils.getMap());
roomInformation.showRoomInformation();
}
});
add(viewLabel, new GridBagConstraints(0, count, 3, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
}
use of org.jivesoftware.spark.component.LinkLabel in project Spark by igniterealtime.
the class ChatQueue method offerRecieved.
public void offerRecieved(Offer offer) {
this.offer = offer;
// Retrieve workgroup form
Form form;
try {
form = FastpathPlugin.getWorkgroup().getWorkgroupForm();
} catch (XMPPException | SmackException e) {
Log.error("Unable to retrieve Workgroup form.", e);
return;
}
final RequestUtils utils = new RequestUtils(offer.getMetaData());
nameLabel.setText(FpRes.getString("message.incoming.chat.request", utils.getUsername()));
nameLabel.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_16x16));
Color linkColor = new Color(69, 92, 137);
int count = 1;
for (final FormField field : form.getFields()) {
String variable = field.getVariable();
String label = field.getLabel();
if (label != null) {
final JLabel nameLabel = new JLabel(label);
nameLabel.setFont(new Font("Dialog", Font.BOLD, 11));
String value = utils.getValue(variable);
if (value == null) {
value = "";
}
final WrappedLabel valueLabel = new WrappedLabel();
valueLabel.setBackground(Color.white);
valueLabel.setText(value);
add(nameLabel, new GridBagConstraints(0, count, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(valueLabel, new GridBagConstraints(1, count, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
count++;
}
}
add(progressBar, new GridBagConstraints(0, count, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 5, 5), 0, 0));
count++;
viewLabel = new LinkLabel(FpRes.getString("message.view.more.information"), null, linkColor, Color.red);
add(viewLabel, new GridBagConstraints(0, count, 1, 1, 0.0, 1.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.setOpaque(false);
buttonPanel.add(acceptButton);
buttonPanel.add(declineButton);
add(buttonPanel, new GridBagConstraints(1, count, 2, 1, 1.0, 1.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
viewLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
showInformation();
}
});
final Date endTime = offer.getExpiresDate();
Date now = new Date();
long mill = endTime.getTime() - now.getTime();
int seconds = (int) (mill / 1000);
progressBar.setMaximum(seconds);
progressBar.setValue(seconds);
SwingWorker worker = new SwingWorker() {
public Object construct() {
while (true) {
Date now = new Date();
if (now.getTime() >= endTime.getTime()) {
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Log.error(e);
}
progressBar.setValue(progressBar.getValue() - 1);
progressBar.setStringPainted(true);
int seconds = (int) (endTime.getTime() - now.getTime()) / 1000;
if (seconds <= 60) {
String timeString = seconds + " " + FpRes.getString("seconds");
progressBar.setString(timeString);
} else {
long difference = endTime.getTime() - now.getTime();
String timeString = ModelUtil.getTimeFromLong(difference);
progressBar.setString(timeString);
}
}
return progressBar;
}
};
worker.start();
}
Aggregations