mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Continue working on themes.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6004 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
BIN
build/lib/dist/windows/IeEmbed.exe
vendored
BIN
build/lib/dist/windows/IeEmbed.exe
vendored
Binary file not shown.
BIN
build/lib/dist/windows/MozEmbed.exe
vendored
BIN
build/lib/dist/windows/MozEmbed.exe
vendored
Binary file not shown.
BIN
build/lib/dist/windows/jdic.dll
vendored
BIN
build/lib/dist/windows/jdic.dll
vendored
Binary file not shown.
BIN
build/lib/dist/windows/jdic.jar
vendored
BIN
build/lib/dist/windows/jdic.jar
vendored
Binary file not shown.
BIN
build/lib/dist/windows/tray.dll
vendored
BIN
build/lib/dist/windows/tray.dll
vendored
Binary file not shown.
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
package org.jivesoftware.spark.component.browser;
|
package org.jivesoftware.spark.component.browser;
|
||||||
|
|
||||||
|
import org.jdesktop.jdic.browser.BrowserEngineManager;
|
||||||
import org.jdesktop.jdic.browser.WebBrowser;
|
import org.jdesktop.jdic.browser.WebBrowser;
|
||||||
import org.jdesktop.jdic.browser.WebBrowserEvent;
|
import org.jdesktop.jdic.browser.WebBrowserEvent;
|
||||||
import org.jdesktop.jdic.browser.WebBrowserListener;
|
import org.jdesktop.jdic.browser.WebBrowserListener;
|
||||||
@ -28,13 +29,18 @@ class NativeBrowserViewer extends BrowserViewer implements WebBrowserListener {
|
|||||||
private WebBrowser browser;
|
private WebBrowser browser;
|
||||||
|
|
||||||
public void initializeBrowser() {
|
public void initializeBrowser() {
|
||||||
|
BrowserEngineManager bem = BrowserEngineManager.instance();
|
||||||
|
//specific engine if you want and the engine you specified will return
|
||||||
|
bem.setActiveEngine(BrowserEngineManager.IE);
|
||||||
|
|
||||||
browser = new WebBrowser();
|
browser = new WebBrowser();
|
||||||
|
|
||||||
|
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
this.add(browser, BorderLayout.CENTER);
|
this.add(browser, BorderLayout.CENTER);
|
||||||
|
|
||||||
browser.addWebBrowserListener(this);
|
browser.addWebBrowserListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadURL(String url) {
|
public void loadURL(String url) {
|
||||||
@ -81,4 +87,8 @@ class NativeBrowserViewer extends BrowserViewer implements WebBrowserListener {
|
|||||||
public void statusTextChange(WebBrowserEvent event) {
|
public void statusTextChange(WebBrowserEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initializationCompleted(WebBrowserEvent webBrowserEvent) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
package org.jivesoftware.spark.ui;
|
package org.jivesoftware.spark.ui;
|
||||||
|
|
||||||
|
import org.jdesktop.jdic.browser.BrowserEngineManager;
|
||||||
|
import org.jdesktop.jdic.browser.IBrowserEngine;
|
||||||
import org.jdesktop.jdic.browser.WebBrowser;
|
import org.jdesktop.jdic.browser.WebBrowser;
|
||||||
import org.jdesktop.jdic.browser.WebBrowserEvent;
|
import org.jdesktop.jdic.browser.WebBrowserEvent;
|
||||||
import org.jdesktop.jdic.browser.WebBrowserListener;
|
import org.jdesktop.jdic.browser.WebBrowserListener;
|
||||||
@ -18,19 +20,22 @@ import org.jivesoftware.smack.packet.Message;
|
|||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.packet.DelayInformation;
|
import org.jivesoftware.smackx.packet.DelayInformation;
|
||||||
import org.jivesoftware.spark.SparkManager;
|
import org.jivesoftware.spark.SparkManager;
|
||||||
import org.jivesoftware.spark.preference.PreferenceManager;
|
import org.jivesoftware.spark.component.VerticalFlowLayout;
|
||||||
import org.jivesoftware.spark.ui.themes.ThemeManager;
|
import org.jivesoftware.spark.ui.themes.ThemeManager;
|
||||||
import org.jivesoftware.spark.util.ModelUtil;
|
import org.jivesoftware.spark.util.ModelUtil;
|
||||||
import org.jivesoftware.spark.util.SwingWorker;
|
import org.jivesoftware.spark.util.SwingWorker;
|
||||||
|
import org.jivesoftware.spark.util.URLFileSystem;
|
||||||
import org.jivesoftware.spark.util.log.Log;
|
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.JComponent;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -61,7 +66,7 @@ public class TranscriptWindow extends JPanel {
|
|||||||
|
|
||||||
private boolean documentLoaded;
|
private boolean documentLoaded;
|
||||||
|
|
||||||
private JPanel downloadPanel = new JPanel();
|
private JPanel extraPanel = new JPanel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default instance of <code>TranscriptWindow</code>.
|
* Creates a default instance of <code>TranscriptWindow</code>.
|
||||||
@ -71,9 +76,18 @@ public class TranscriptWindow extends JPanel {
|
|||||||
|
|
||||||
themeManager = ThemeManager.getInstance();
|
themeManager = ThemeManager.getInstance();
|
||||||
|
|
||||||
|
BrowserEngineManager bem = BrowserEngineManager.instance();
|
||||||
|
//specific engine if you want and the engine you specified will return
|
||||||
|
bem.setActiveEngine(BrowserEngineManager.MOZILLA);
|
||||||
|
|
||||||
|
//IBrowserEngine be = bem.setActiveEngine(...);
|
||||||
|
IBrowserEngine be = bem.getActiveEngine();//default or specified engine is returned
|
||||||
|
be.setEnginePath("C:\\crapoloa\\mozilla\\mozilla.exe");
|
||||||
browser = new WebBrowser();
|
browser = new WebBrowser();
|
||||||
|
|
||||||
browser.setURL(themeManager.getTemplateURL());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
browser.addWebBrowserListener(new WebBrowserListener() {
|
browser.addWebBrowserListener(new WebBrowserListener() {
|
||||||
public void downloadStarted(WebBrowserEvent webBrowserEvent) {
|
public void downloadStarted(WebBrowserEvent webBrowserEvent) {
|
||||||
@ -98,14 +112,18 @@ public class TranscriptWindow extends JPanel {
|
|||||||
|
|
||||||
public void statusTextChange(WebBrowserEvent webBrowserEvent) {
|
public void statusTextChange(WebBrowserEvent webBrowserEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initializationCompleted(WebBrowserEvent webBrowserEvent) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(browser, BorderLayout.CENTER);
|
add(browser, BorderLayout.CENTER);
|
||||||
|
|
||||||
/* Load Preferences for this instance */
|
extraPanel.setBackground(Color.white);
|
||||||
PreferenceManager preferenceManager = SparkManager.getPreferenceManager();
|
extraPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||||
|
|
||||||
startCommandListener();
|
add(extraPanel, BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -439,10 +457,29 @@ public class TranscriptWindow extends JPanel {
|
|||||||
System.out.println(command);
|
System.out.println(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 50, 50);
|
}, 500, 500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
worker.start();
|
worker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addComponent(JComponent component) {
|
||||||
|
extraPanel.add(component);
|
||||||
|
extraPanel.setVisible(true);
|
||||||
|
extraPanel.invalidate();
|
||||||
|
extraPanel.validate();
|
||||||
|
extraPanel.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeComponent(JComponent component) {
|
||||||
|
if (extraPanel.getComponentCount() == 0) {
|
||||||
|
extraPanel.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
extraPanel.remove(component);
|
||||||
|
extraPanel.invalidate();
|
||||||
|
extraPanel.validate();
|
||||||
|
extraPanel.repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -10,23 +10,17 @@
|
|||||||
|
|
||||||
package org.jivesoftware.spark.ui.themes;
|
package org.jivesoftware.spark.ui.themes;
|
||||||
|
|
||||||
|
import org.jdesktop.jdic.browser.BrowserEngineManager;
|
||||||
|
import org.jdesktop.jdic.browser.IBrowserEngine;
|
||||||
import org.jdesktop.jdic.browser.WebBrowser;
|
import org.jdesktop.jdic.browser.WebBrowser;
|
||||||
import org.jivesoftware.spark.util.GraphicUtils;
|
import org.jivesoftware.spark.util.GraphicUtils;
|
||||||
import org.jivesoftware.spark.util.StringUtils;
|
import org.jivesoftware.spark.util.StringUtils;
|
||||||
import org.jivesoftware.spark.util.URLFileSystem;
|
import org.jivesoftware.spark.util.URLFileSystem;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -52,7 +46,6 @@ public class ThemeManager {
|
|||||||
private String outgoingTransferText;
|
private String outgoingTransferText;
|
||||||
private String incomingTransferText;
|
private String incomingTransferText;
|
||||||
|
|
||||||
private File tempFile;
|
|
||||||
|
|
||||||
private String chatName;
|
private String chatName;
|
||||||
|
|
||||||
@ -77,23 +70,14 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ThemeManager() {
|
private ThemeManager() {
|
||||||
File file = new File("C:\\adium\\pin");
|
// URL url = getClass().getResource("/themes/pin");
|
||||||
|
File file = new File("C:\\adium\\renkoo2.3\\renkoo.AdiumMessageStyle");
|
||||||
setTheme(file);
|
setTheme(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTheme(File theme) {
|
public void setTheme(File theme) {
|
||||||
theme = new File(theme, "/Contents/Resources");
|
theme = new File(theme, "/Contents/Resources");
|
||||||
|
|
||||||
// Load Template
|
|
||||||
URL protypeFile = getClass().getResource("/themes/prototype-1.4.0.js");
|
|
||||||
|
|
||||||
try {
|
|
||||||
URLFileSystem.copy(protypeFile, new File(theme, "prototype-1.4.0.js"));
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
File template = new File(theme, "template.html");
|
File template = new File(theme, "template.html");
|
||||||
templateText = URLFileSystem.getContents(template);
|
templateText = URLFileSystem.getContents(template);
|
||||||
|
|
||||||
@ -138,15 +122,6 @@ public class ThemeManager {
|
|||||||
File nextOutgoingTextFile = new File(theme, "/Outgoing/NextContent.html");
|
File nextOutgoingTextFile = new File(theme, "/Outgoing/NextContent.html");
|
||||||
nextOutgoingText = URLFileSystem.getContents(nextOutgoingTextFile);
|
nextOutgoingText = URLFileSystem.getContents(nextOutgoingTextFile);
|
||||||
|
|
||||||
tempFile = new File(theme, "temp.html");
|
|
||||||
try {
|
|
||||||
BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
|
|
||||||
out.write(templateText);
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load outgoing transfer text
|
// Load outgoing transfer text
|
||||||
File outgoingTransferFile = new File(theme, "/Outgoing/filetransfer.html");
|
File outgoingTransferFile = new File(theme, "/Outgoing/filetransfer.html");
|
||||||
outgoingTransferText = URLFileSystem.getContents(outgoingTransferFile);
|
outgoingTransferText = URLFileSystem.getContents(outgoingTransferFile);
|
||||||
@ -156,18 +131,19 @@ public class ThemeManager {
|
|||||||
incomingTransferText = URLFileSystem.getContents(incomingTransferFile);
|
incomingTransferText = URLFileSystem.getContents(incomingTransferFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTemplate() {
|
public String getTemplate(String chatName) {
|
||||||
return templateText;
|
SimpleDateFormat formatter = new SimpleDateFormat("MMMMM, d,yyyy");
|
||||||
|
String time = formatter.format(new Date());
|
||||||
|
|
||||||
|
String text = templateText;
|
||||||
|
text = text.replaceAll("%timeOpened%", time);
|
||||||
|
text = text.replaceAll("%chatOpened%", chatName);
|
||||||
|
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL getTemplateURL() {
|
public String getTemplate() {
|
||||||
try {
|
return templateText;
|
||||||
return tempFile.toURL();
|
|
||||||
}
|
|
||||||
catch (MalformedURLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIncomingMessage(String sender, String time, String message) {
|
public String getIncomingMessage(String sender, String time, String message) {
|
||||||
@ -196,6 +172,22 @@ public class ThemeManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNotificationMessage(String message, boolean allowQuotes) {
|
||||||
|
String status = statusText;
|
||||||
|
status = status.replaceAll("%time%", "");
|
||||||
|
status = status.replaceAll("%message%", message);
|
||||||
|
if (!allowQuotes) {
|
||||||
|
status = html(status);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = status.replaceAll("\"", "\\\"");
|
||||||
|
status = status.replaceAll("\n", "");
|
||||||
|
status = status.replaceAll("\t", "");
|
||||||
|
status = status.replaceAll("\r", "");
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextIncomingMessage(String message, String time) {
|
public String getNextIncomingMessage(String message, String time) {
|
||||||
String incoming = nextIncomingText;
|
String incoming = nextIncomingText;
|
||||||
incoming = incoming.replaceAll("%time%", time);
|
incoming = incoming.replaceAll("%time%", time);
|
||||||
@ -241,6 +233,7 @@ public class ThemeManager {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String html(String text) {
|
private String html(String text) {
|
||||||
text = text.replaceAll("\n", "");
|
text = text.replaceAll("\n", "");
|
||||||
text = text.replaceAll("\'", "´");
|
text = text.replaceAll("\'", "´");
|
||||||
@ -308,59 +301,28 @@ public class ThemeManager {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
final ThemeManager themeManager = ThemeManager.getInstance();
|
File tempFile = new File("C:\\Demo.html");
|
||||||
themeManager.setChatName("Discussion Room");
|
String contents = URLFileSystem.getContents(tempFile);
|
||||||
|
|
||||||
// Write out new template
|
|
||||||
String tempTemplate = themeManager.getTemplate();
|
|
||||||
|
|
||||||
final File file = URLFileSystem.url2File(themeManager.getTemplateURL());
|
|
||||||
File tempFile = new File(file, "temp.html");
|
|
||||||
try {
|
|
||||||
BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
|
|
||||||
out.write(tempTemplate);
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BrowserEngineManager bem = BrowserEngineManager.instance();
|
||||||
|
//specific engine if you want and the engine you specified will return
|
||||||
|
bem.setActiveEngine(BrowserEngineManager.MOZILLA);
|
||||||
|
|
||||||
|
//IBrowserEngine be = bem.setActiveEngine(...);
|
||||||
|
IBrowserEngine be = bem.getActiveEngine();//default or specified engine is returned
|
||||||
|
be.setEnginePath("C:\\crapoloa\\mozilla\\mozilla.exe");
|
||||||
final WebBrowser browser = new WebBrowser();
|
final WebBrowser browser = new WebBrowser();
|
||||||
|
|
||||||
|
|
||||||
browser.setURL(themeManager.getTemplateURL());
|
browser.setContent(contents);
|
||||||
|
|
||||||
|
|
||||||
JFrame frame = new JFrame();
|
JFrame frame = new JFrame();
|
||||||
frame.setLayout(new BorderLayout());
|
frame.setLayout(new BorderLayout());
|
||||||
|
|
||||||
frame.add(browser, BorderLayout.CENTER);
|
frame.add(browser.asComponent(), BorderLayout.CENTER);
|
||||||
|
|
||||||
|
|
||||||
JButton button = new JButton("Add");
|
|
||||||
frame.add(button, BorderLayout.SOUTH);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
boolean ok = false;
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
String incomingText = themeManager.getIncomingMessage("Don", "7 a.m.", "I'm away fuck face.");
|
|
||||||
if (ok) {
|
|
||||||
incomingText = themeManager.getNextIncomingMessage("HI", "8 a.m.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
browser.executeScript("appendMessage('" + incomingText + "')");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
browser.executeScript("appendNextMessage('" + incomingText + "')");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
// ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frame.setSize(400, 400);
|
frame.setSize(400, 400);
|
||||||
GraphicUtils.centerWindowOnScreen(frame);
|
GraphicUtils.centerWindowOnScreen(frame);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user