mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Updating Themes.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6016 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -29,8 +29,6 @@ import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -70,6 +68,9 @@ public class TranscriptWindow extends JPanel {
|
|||||||
|
|
||||||
private VCardManager vcardManager;
|
private VCardManager vcardManager;
|
||||||
|
|
||||||
|
private List scriptList = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default instance of <code>TranscriptWindow</code>.
|
* Creates a default instance of <code>TranscriptWindow</code>.
|
||||||
*/
|
*/
|
||||||
@ -121,6 +122,8 @@ public class TranscriptWindow extends JPanel {
|
|||||||
extraPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
extraPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||||
|
|
||||||
add(extraPanel, BorderLayout.SOUTH);
|
add(extraPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
startCommandListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -432,61 +435,24 @@ public class TranscriptWindow extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void executeScript(final String script) {
|
public void executeScript(final String script) {
|
||||||
SwingWorker worker = new SwingWorker() {
|
scriptList.add(script);
|
||||||
public Object construct() {
|
|
||||||
while (true) {
|
|
||||||
if (documentLoaded) {
|
|
||||||
browser.executeScript(script);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return documentLoaded;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
worker.start();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCommandListener() {
|
private void startCommandListener() {
|
||||||
SwingWorker worker = new SwingWorker() {
|
Timer timer = new Timer();
|
||||||
public Object construct() {
|
|
||||||
while (true) {
|
|
||||||
if (documentLoaded) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return documentLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finished() {
|
|
||||||
final Timer timer = new Timer();
|
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
public void run() {
|
public void run() {
|
||||||
final String command = browser.executeScript("getNextCommand();");
|
if (documentLoaded) {
|
||||||
if (command != null) {
|
if (scriptList.size() > 0) {
|
||||||
System.out.println(command);
|
String script = (String)scriptList.get(0);
|
||||||
|
scriptList.remove(0);
|
||||||
|
System.out.println(script);
|
||||||
|
String str = browser.executeScript(script);
|
||||||
|
System.out.println(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 500, 500);
|
|
||||||
}
|
}
|
||||||
};
|
}, 50, 50);
|
||||||
|
|
||||||
worker.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComponent(JComponent component) {
|
public void addComponent(JComponent component) {
|
||||||
|
|||||||
@ -32,15 +32,13 @@ import org.jivesoftware.spark.ui.ContactItem;
|
|||||||
import org.jivesoftware.spark.ui.ContactList;
|
import org.jivesoftware.spark.ui.ContactList;
|
||||||
import org.jivesoftware.spark.ui.MessageEventListener;
|
import org.jivesoftware.spark.ui.MessageEventListener;
|
||||||
import org.jivesoftware.spark.ui.RosterDialog;
|
import org.jivesoftware.spark.ui.RosterDialog;
|
||||||
import org.jivesoftware.spark.ui.VCardPanel;
|
|
||||||
import org.jivesoftware.spark.util.ModelUtil;
|
import org.jivesoftware.spark.util.ModelUtil;
|
||||||
import org.jivesoftware.spark.util.log.Log;
|
import org.jivesoftware.spark.util.log.Log;
|
||||||
import org.jivesoftware.sparkimpl.profile.VCardManager;
|
import org.jivesoftware.sparkimpl.profile.VCardManager;
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -196,7 +194,12 @@ public class ChatRoomImpl extends ChatRoom {
|
|||||||
|
|
||||||
String time = formatter.format(new Date());
|
String time = formatter.format(new Date());
|
||||||
transcriptWindow.setInnerHTML("chatName", participantNickname);
|
transcriptWindow.setInnerHTML("chatName", participantNickname);
|
||||||
transcriptWindow.setInnerHTML("timeOpened", "Conversation started on "+time);
|
transcriptWindow.setInnerHTML("timeOpened", "Conversation started on " + time);
|
||||||
|
|
||||||
|
URL url = SparkManager.getVCardManager().getAvatar(SparkManager.getSessionManager().getJID());
|
||||||
|
if (url != null) {
|
||||||
|
transcriptWindow.setInnerHTML("incomingIconPath", "<img src=\"" + url.toExternalForm() + "\">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -86,8 +86,10 @@ public class ThemeManager {
|
|||||||
// not about mozilla. Me love Mozilla.
|
// not about mozilla. Me love Mozilla.
|
||||||
be.setEnginePath("C:\\crapola\\mozilla\\mozilla.exe");
|
be.setEnginePath("C:\\crapola\\mozilla\\mozilla.exe");
|
||||||
|
|
||||||
|
|
||||||
URL url = getClass().getResource("/themes/renkoo2.3/renkoo.AdiumMessageStyle");
|
URL url = getClass().getResource("/themes/renkoo2.3/renkoo.AdiumMessageStyle");
|
||||||
setTheme(URLFileSystem.url2File(url));
|
setTheme(URLFileSystem.url2File(url));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTheme(File theme) {
|
public void setTheme(File theme) {
|
||||||
@ -321,11 +323,10 @@ public class ThemeManager {
|
|||||||
text = text.replaceAll("%chatName%", getChatName());
|
text = text.replaceAll("%chatName%", getChatName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String timestamp = findTimeStamp(text);
|
final SimpleDateFormat formatter = new SimpleDateFormat("h:mm");
|
||||||
if (timestamp != null) {
|
String time = formatter.format(new Date());
|
||||||
String newTimestamp = getTimeStamp(timestamp);
|
|
||||||
text = StringUtils.replace(text, timestamp, newTimestamp);
|
text = text.replaceAll("%timeOpened", time);
|
||||||
}
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,11 +337,10 @@ public class ThemeManager {
|
|||||||
text = text.replaceAll("\t", "");
|
text = text.replaceAll("\t", "");
|
||||||
text = text.replaceAll("\r", "");
|
text = text.replaceAll("\r", "");
|
||||||
|
|
||||||
String timestamp = findTimeStamp(text);
|
final SimpleDateFormat formatter = new SimpleDateFormat("h:mm");
|
||||||
if (timestamp != null) {
|
String time = formatter.format(new Date());
|
||||||
String newTimestamp = getTimeStamp(timestamp);
|
|
||||||
text = StringUtils.replace(text, timestamp, newTimestamp);
|
text = text.replaceAll("%timeOpened", time);
|
||||||
}
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,48 +353,11 @@ public class ThemeManager {
|
|||||||
return chatName;
|
return chatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String findTimeStamp(String text) {
|
|
||||||
int index = text.indexOf("%timeOpened{");
|
|
||||||
if (index != 1) {
|
|
||||||
int index2 = text.indexOf("}");
|
|
||||||
if (index2 != -1) {
|
|
||||||
String timestamp = text.substring(index, index2 + 2);
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getTimeStamp(String timestamp) {
|
|
||||||
//%timeOpened{%B %e, %Y}%
|
|
||||||
String token = "%timeOpened{";
|
|
||||||
int index = timestamp.indexOf("%timeOpened{");
|
|
||||||
if (index != 1) {
|
|
||||||
int index2 = timestamp.indexOf("}");
|
|
||||||
if (index2 != -1) {
|
|
||||||
String inner = timestamp.substring(index + token.length(), index2);
|
|
||||||
|
|
||||||
// Do the replacements
|
|
||||||
inner = inner.replace("%B", "MMMMM");
|
|
||||||
inner = inner.replace("%e", "d");
|
|
||||||
inner = inner.replace("%Y", "yyyy");
|
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(inner);
|
|
||||||
String time = formatter.format(new Date());
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "November 3, 2006";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
File file = new File("C:\\adium\\renkoo2.3\\renkoo.AdiumMessageStyle");
|
|
||||||
ThemeManager themeManager = ThemeManager.getInstance();
|
ThemeManager themeManager = ThemeManager.getInstance();
|
||||||
themeManager.setTheme(file);
|
|
||||||
System.out.println(themeManager.getTemplate());
|
System.out.println(themeManager.getTemplate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,20 +33,7 @@ import org.jivesoftware.spark.util.log.Log;
|
|||||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
|
||||||
import javax.swing.Action;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.text.BadLocationException;
|
|
||||||
import javax.swing.text.SimpleAttributeSet;
|
|
||||||
import javax.swing.text.StyleConstants;
|
|
||||||
import javax.swing.text.StyledDocument;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@ -59,6 +46,14 @@ import java.util.Date;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>ChatTranscriptPlugin</code> is responsible for transcript handling within Spark.
|
* The <code>ChatTranscriptPlugin</code> is responsible for transcript handling within Spark.
|
||||||
*
|
*
|
||||||
@ -202,14 +197,21 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
|||||||
Log.error("Exception in Chat Transcript Loading.", e);
|
Log.error("Exception in Chat Transcript Loading.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ChatTranscripts.getChatTranscript(jid);
|
||||||
|
}
|
||||||
|
|
||||||
ChatTranscript transcript = ChatTranscripts.getChatTranscript(jid);
|
|
||||||
|
public void finished() {
|
||||||
|
ChatTranscript transcript = (ChatTranscript)get();
|
||||||
|
if(transcript == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
TranscriptWindow window = room.getTranscriptWindow();
|
TranscriptWindow window = room.getTranscriptWindow();
|
||||||
final Iterator messages = transcript.getNumberOfEntries(20).iterator();
|
final Iterator messages = transcript.getNumberOfEntries(20).iterator();
|
||||||
boolean isNew = false;
|
|
||||||
while (messages.hasNext()) {
|
while (messages.hasNext()) {
|
||||||
while (messages != null && messages.hasNext()) {
|
while (messages != null && messages.hasNext()) {
|
||||||
isNew = true;
|
|
||||||
try {
|
try {
|
||||||
HistoryMessage message = (HistoryMessage)messages.next();
|
HistoryMessage message = (HistoryMessage)messages.next();
|
||||||
String from = StringUtils.parseName(message.getFrom());
|
String from = StringUtils.parseName(message.getFrom());
|
||||||
@ -232,14 +234,6 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return Boolean.valueOf(isNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finished() {
|
|
||||||
Boolean boo = (Boolean)get();
|
|
||||||
if (boo) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -413,5 +407,4 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user