mirror of https://github.com/sipwise/jitsi.git
parent
b318199f63
commit
90d3ac2230
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license. See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
/**
|
||||
* Custom <tt>TableCellRenderer</tt> that renders
|
||||
* <tt>ProtocolProviderService</tt> objects, <tt>MetaContactGroup</tt>
|
||||
* objects and JLabels.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ButtonTableCellRenderer
|
||||
extends JPanel
|
||||
implements TableCellRenderer
|
||||
{
|
||||
public ButtonTableCellRenderer()
|
||||
{
|
||||
super(new FlowLayout(FlowLayout.CENTER));
|
||||
|
||||
this.setOpaque(true);
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column)
|
||||
{
|
||||
this.removeAll();
|
||||
|
||||
if(value instanceof JButton)
|
||||
{
|
||||
this.add((JButton) value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @version 1.0 11/09/98
|
||||
*/
|
||||
public class ButtonTableEditor
|
||||
extends DefaultCellEditor
|
||||
{
|
||||
private JButton button;
|
||||
|
||||
private JPanel buttonPanel;
|
||||
|
||||
private boolean isPushed;
|
||||
|
||||
public ButtonTableEditor()
|
||||
{
|
||||
super(new JCheckBox());
|
||||
}
|
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||
boolean isSelected, int row, int column)
|
||||
{
|
||||
isPushed = true;
|
||||
if (value instanceof JButton)
|
||||
{
|
||||
this.button = (JButton) value;
|
||||
|
||||
buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
|
||||
buttonPanel.add(button);
|
||||
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getCellEditorValue()
|
||||
{
|
||||
isPushed = false;
|
||||
return button;
|
||||
}
|
||||
|
||||
public boolean stopCellEditing()
|
||||
{
|
||||
isPushed = false;
|
||||
return super.stopCellEditing();
|
||||
}
|
||||
|
||||
protected void fireEditingStopped()
|
||||
{
|
||||
super.fireEditingStopped();
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
public class ColorsPanel
|
||||
extends JScrollPane
|
||||
{
|
||||
private JTable colorsTable = new JTable();
|
||||
|
||||
private CustomTableModel colorsTableModel = new CustomTableModel();
|
||||
|
||||
public ColorsPanel()
|
||||
{
|
||||
this.getViewport().add(colorsTable);
|
||||
|
||||
colorsTable.setModel(colorsTableModel);
|
||||
colorsTableModel.addColumn("Description");
|
||||
colorsTableModel.addColumn("Color");
|
||||
colorsTableModel.addColumn("Change color");
|
||||
|
||||
colorsTable.getColumnModel().getColumn(1).setCellRenderer(
|
||||
new LabelTableCellRenderer());
|
||||
|
||||
TableColumn buttonColumn
|
||||
= colorsTable.getColumnModel().getColumn(2);
|
||||
|
||||
buttonColumn.setCellRenderer(new ButtonTableCellRenderer());
|
||||
buttonColumn.setCellEditor(new ButtonTableEditor());
|
||||
|
||||
this.initColorTable();
|
||||
}
|
||||
|
||||
private void initColorTable()
|
||||
{
|
||||
Iterator colorKeys
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getCurrentColors();
|
||||
|
||||
while (colorKeys.hasNext())
|
||||
{
|
||||
String key = (String) colorKeys.next();
|
||||
final Color color = new Color(
|
||||
GuiCustomizationActivator.getResources().getColor(key));
|
||||
|
||||
final JLabel colorLabel = new JLabel();
|
||||
colorLabel.setBackground(color);
|
||||
|
||||
JButton colorChooserButton = new JButton();
|
||||
colorChooserButton.setAction(
|
||||
new ChooseColorAction(color, colorLabel));
|
||||
|
||||
colorsTableModel.addRow(new Object[]{ key,
|
||||
colorLabel,
|
||||
colorChooserButton});
|
||||
colorChooserButton.setText("Choose a colour");
|
||||
|
||||
int rowHeight = 40;
|
||||
colorsTable.setRowHeight( colorsTableModel.getRowCount() - 1,
|
||||
rowHeight );
|
||||
}
|
||||
}
|
||||
|
||||
private class ChooseColorAction extends AbstractAction
|
||||
{
|
||||
private Color defaultColor;
|
||||
private JLabel colorLabel;
|
||||
|
||||
public ChooseColorAction(Color defaultColor, JLabel colorLabel)
|
||||
{
|
||||
this.defaultColor = defaultColor;
|
||||
this.colorLabel = colorLabel;
|
||||
}
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
Color newColor
|
||||
= JColorChooser.showDialog( new JColorChooser(),
|
||||
"Choose a colour",
|
||||
defaultColor);
|
||||
|
||||
colorLabel.setBackground(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable<String, String> getColors()
|
||||
{
|
||||
Hashtable res = new Hashtable();
|
||||
int rows = colorsTableModel.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
String key = (String)colorsTableModel.getValueAt(i, 0);
|
||||
JLabel colorLabel = (JLabel)colorsTableModel.getValueAt(i, 1);
|
||||
|
||||
res.put(
|
||||
key,
|
||||
Integer.toHexString(colorLabel.getBackground().getRGB()).substring(2));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
public class CustomTableModel
|
||||
extends DefaultTableModel
|
||||
{
|
||||
public boolean isCellEditable(int row, int column)
|
||||
{
|
||||
Object o = getValueAt(row, column);
|
||||
|
||||
if (column == 0 || o instanceof JLabel)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,349 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license. See terms of license at gnu.org.
|
||||
*/
|
||||
/*
|
||||
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
|
||||
* Builder, which is free for non-commercial use. If Jigloo is being used
|
||||
* commercially (ie, by a corporation, company or business for any purpose
|
||||
* whatever) then you should purchase a license for each developer using Jigloo.
|
||||
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
|
||||
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
|
||||
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
|
||||
* ANY CORPORATE OR COMMERCIAL PURPOSE.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.zip.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.plugin.guicustomization.resourcepack.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
public class CustomizationWindow
|
||||
extends JFrame
|
||||
{
|
||||
private JTabbedPane tabbedPane;
|
||||
|
||||
private ImagesPanel imagesPanel;
|
||||
|
||||
private SoundsPanel soundsPanel;
|
||||
|
||||
private ColorsPanel colorsPanel;
|
||||
|
||||
private I18nStringsPanel stringsPanel;
|
||||
|
||||
private SettingsPanel settingsPanel;
|
||||
|
||||
private Logger logger = Logger.getLogger(CustomizationWindow.class);
|
||||
|
||||
private JButton saveProjectButton = new JButton("Create Skin");
|
||||
|
||||
private JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
private final String srcPackagePath =
|
||||
"/net/java/sip/communicator/plugin/guicustomization/resourcepack";
|
||||
private final String manifestFileName = "customresourcepack.manifest.mf";
|
||||
|
||||
private final String[] customClassFiles = new String[]{
|
||||
"CustomColorPackImpl",
|
||||
"CustomImagePackImpl",
|
||||
"CustomLanguagePackImpl",
|
||||
"CustomResourcePackActivator",
|
||||
"CustomSettingsPackImpl",
|
||||
"CustomSoundPackImpl"
|
||||
};
|
||||
|
||||
private final String dstPackagePath =
|
||||
"net/java/sip/communicator/plugin/guicustomization/resourcepack";
|
||||
|
||||
public CustomizationWindow()
|
||||
{
|
||||
super("SIP Communicator Branding Studio");
|
||||
|
||||
this.initGUI();
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
this.imagesPanel = new ImagesPanel(this);
|
||||
this.colorsPanel = new ColorsPanel();
|
||||
this.soundsPanel = new SoundsPanel(this);
|
||||
this.stringsPanel = new I18nStringsPanel();
|
||||
this.settingsPanel = new SettingsPanel();
|
||||
|
||||
this.tabbedPane = new JTabbedPane();
|
||||
this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
|
||||
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.tabbedPane.addTab("Images", imagesPanel);
|
||||
this.tabbedPane.addTab("Colors", colorsPanel);
|
||||
this.tabbedPane.addTab("Sounds", soundsPanel);
|
||||
this.tabbedPane.addTab("Strings", stringsPanel);
|
||||
this.tabbedPane.addTab("Settings", settingsPanel);
|
||||
|
||||
this.buttonPanel.add(saveProjectButton);
|
||||
|
||||
this.saveProjectButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
//TODO: Implement jar creation here.
|
||||
performSaveProject();
|
||||
}
|
||||
});
|
||||
|
||||
this.setSize(570, 337);
|
||||
}
|
||||
|
||||
private void performSaveProject()
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = null;
|
||||
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
|
||||
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
|
||||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
fileChooser.setDialogTitle("Select Destination");
|
||||
fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
|
||||
|
||||
int result
|
||||
= fileChooser.showOpenDialog(CustomizationWindow.this);
|
||||
|
||||
if (result == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
file = fileChooser.getSelectedFile();
|
||||
file = new File(file, "customresources.jar");
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
InputStream manifestIs =
|
||||
CustomizationWindow.class.
|
||||
getResource(srcPackagePath + "/" + manifestFileName).
|
||||
openStream();
|
||||
|
||||
JarOutputStream outFile =
|
||||
new JarOutputStream(
|
||||
new FileOutputStream(file),
|
||||
new Manifest(manifestIs));
|
||||
|
||||
for (int i = 0; i < customClassFiles.length; i++)
|
||||
{
|
||||
String cf = customClassFiles[i];
|
||||
|
||||
InputStream clIs =
|
||||
CustomizationWindow.class.
|
||||
getResourceAsStream(srcPackagePath + "/" + cf + ".class");
|
||||
byte[] bs = new byte[clIs.available()];
|
||||
clIs.read(bs);
|
||||
clIs.close();
|
||||
|
||||
addNewZipEntry(dstPackagePath + "/" + cf + ".class", outFile, bs);
|
||||
}
|
||||
|
||||
saveColorPack(outFile);
|
||||
saveImagePack(outFile);
|
||||
saveLanguagePack(outFile);
|
||||
saveSettingsPack(outFile);
|
||||
saveSoundsPack(outFile);
|
||||
|
||||
outFile.flush();
|
||||
outFile.close();
|
||||
manifestIs.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
logger.error("",e);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveColorPack(JarOutputStream outFile)
|
||||
throws Exception
|
||||
{
|
||||
String resources =
|
||||
new CustomColorPackImpl().getResourcePackBaseName();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
Hashtable h = colorsPanel.getColors();
|
||||
Iterator<String> iter = h.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String k = iter.next();
|
||||
props.put(k, h.get(k));
|
||||
}
|
||||
|
||||
ByteArrayOutputStream outB = new ByteArrayOutputStream();
|
||||
props.store(outB, "Custom Color resources");
|
||||
|
||||
addNewZipEntry(resources.replaceAll("\\.", "/") + ".properties",
|
||||
outFile, outB.toByteArray());
|
||||
}
|
||||
|
||||
private void saveImagePack(JarOutputStream outFile)
|
||||
throws Exception
|
||||
{
|
||||
String resources =
|
||||
new CustomImagePackImpl().getResourcePackBaseName();
|
||||
|
||||
Properties props = new Properties();
|
||||
String imagePathPrefix = "resources/images/";
|
||||
int imageName = 0;
|
||||
|
||||
Hashtable<String, byte[]> h = imagesPanel.getImages();
|
||||
Iterator<String> iter = h.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String k = iter.next();
|
||||
String fileName = imagePathPrefix + String.valueOf(imageName++) + ".png";
|
||||
byte[] bs = h.get(k);
|
||||
|
||||
if(bs.length > 0)
|
||||
{
|
||||
props.put(k, fileName);
|
||||
|
||||
addNewZipEntry(fileName,
|
||||
outFile, bs);
|
||||
}
|
||||
else
|
||||
props.put(k, "");
|
||||
}
|
||||
ByteArrayOutputStream outB = new ByteArrayOutputStream();
|
||||
props.store(outB, "Custom Color resources");
|
||||
|
||||
addNewZipEntry(resources.replaceAll("\\.", "/") + ".properties",
|
||||
outFile, outB.toByteArray());
|
||||
}
|
||||
|
||||
private void saveLanguagePack(JarOutputStream outFile)
|
||||
throws Exception
|
||||
{
|
||||
String resources =
|
||||
new CustomLanguagePackImpl().getResourcePackBaseName();
|
||||
|
||||
Hashtable languages = stringsPanel.getLanguages();
|
||||
Iterator<String> iter = languages.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String l = iter.next();
|
||||
Properties props = new Properties();
|
||||
|
||||
Hashtable<String,String> strings = (Hashtable<String,String>)languages.get(l);
|
||||
|
||||
Iterator<String> stringsIter = strings.keySet().iterator();
|
||||
while (stringsIter.hasNext())
|
||||
{
|
||||
String k = stringsIter.next();
|
||||
String v = strings.get(k);
|
||||
|
||||
props.put(k, v);
|
||||
}
|
||||
|
||||
String filename = null;
|
||||
if(l.equals("en"))
|
||||
filename =
|
||||
resources.replaceAll("\\.", "/") + ".properties";
|
||||
else
|
||||
filename =
|
||||
resources.replaceAll("\\.", "/") + "_" + l + ".properties";
|
||||
|
||||
ByteArrayOutputStream outB = new ByteArrayOutputStream();
|
||||
props.store(outB, "Custom Color resources");
|
||||
|
||||
addNewZipEntry(filename,
|
||||
outFile, outB.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSettingsPack(JarOutputStream outFile)
|
||||
throws Exception
|
||||
{
|
||||
String resources =
|
||||
new CustomSettingsPackImpl().getResourcePackBaseName();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
Hashtable h = settingsPanel.getSettings();
|
||||
Iterator<String> iter = h.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String k = iter.next();
|
||||
props.put(k, h.get(k));
|
||||
}
|
||||
|
||||
ByteArrayOutputStream outB = new ByteArrayOutputStream();
|
||||
props.store(outB, "Custom Color resources");
|
||||
|
||||
addNewZipEntry(resources.replaceAll("\\.", "/") + ".properties",
|
||||
outFile, outB.toByteArray());
|
||||
|
||||
// fix for missing styles, must also add the styles css
|
||||
String entryName =
|
||||
GuiCustomizationActivator.getResources().getSettingsString("textStyle");
|
||||
InputStream in =
|
||||
GuiCustomizationActivator.getResources().getSettingsInputStream("textStyle");
|
||||
byte[] bs = new byte[in.available()];
|
||||
in.read(bs);
|
||||
in.close();
|
||||
|
||||
addNewZipEntry(entryName, outFile, bs);
|
||||
}
|
||||
|
||||
private void saveSoundsPack(JarOutputStream outFile)
|
||||
throws Exception
|
||||
{
|
||||
String resources =
|
||||
new CustomSoundPackImpl().getResourcePackBaseName();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
String sndPathPrefix = "resources/sounds/";
|
||||
int sndName = 0;
|
||||
|
||||
Hashtable<String,URL> h = soundsPanel.getSounds();
|
||||
Iterator<String> iter = h.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String k = iter.next();
|
||||
URL u = h.get(k);
|
||||
|
||||
String fileName = sndPathPrefix + String.valueOf(sndName++);
|
||||
|
||||
props.put(k, fileName);
|
||||
|
||||
InputStream in = u.openStream();
|
||||
byte[] bs = new byte[in.available()];
|
||||
in.read(bs);
|
||||
|
||||
addNewZipEntry(fileName,
|
||||
outFile, bs);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream outB = new ByteArrayOutputStream();
|
||||
props.store(outB, "Custom Color resources");
|
||||
|
||||
addNewZipEntry(resources.replaceAll("\\.", "/") + ".properties",
|
||||
outFile, outB.toByteArray());
|
||||
}
|
||||
|
||||
private void addNewZipEntry(String name, JarOutputStream outFile, byte[] data)
|
||||
throws Exception
|
||||
{
|
||||
ZipEntry z = new ZipEntry(name);
|
||||
outFile.putNextEntry(z);
|
||||
outFile.write(data);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
|
||||
public class GuiCustomizationActivator implements BundleActivator
|
||||
{
|
||||
private Logger logger = Logger.getLogger(GuiCustomizationActivator.class);
|
||||
|
||||
static BundleContext bundleContext;
|
||||
|
||||
private static ResourceManagementService resourceService;
|
||||
|
||||
public void start(BundleContext bc) throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
// CustomizationWindow customizationWindow
|
||||
// = new CustomizationWindow();
|
||||
//
|
||||
// customizationWindow.pack();
|
||||
// customizationWindow.setSize(600, 500);
|
||||
// customizationWindow.setVisible(true);
|
||||
}
|
||||
|
||||
public void stop(BundleContext bc) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public static ResourceManagementService getResources()
|
||||
{
|
||||
if (resourceService == null)
|
||||
{
|
||||
ServiceReference serviceReference = bundleContext
|
||||
.getServiceReference(ResourceManagementService.class.getName());
|
||||
|
||||
if(serviceReference == null)
|
||||
return null;
|
||||
|
||||
resourceService = (ResourceManagementService) bundleContext
|
||||
.getService(serviceReference);
|
||||
}
|
||||
|
||||
return resourceService;
|
||||
}
|
||||
}
|
||||
@ -1,228 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
public class I18nStringsPanel
|
||||
extends JPanel
|
||||
{
|
||||
private JScrollPane tablePane = new JScrollPane();
|
||||
|
||||
private JScrollPane languageListPane = new JScrollPane();
|
||||
|
||||
private JTable stringsTable = new JTable();
|
||||
|
||||
private JList languageList = new JList();
|
||||
|
||||
private DefaultListModel languageListModel = new DefaultListModel();
|
||||
|
||||
private JButton addLanguageButton = new JButton("Add new language");
|
||||
|
||||
private JPanel leftPanel = new JPanel(new BorderLayout());
|
||||
|
||||
private Hashtable languagesTable = new Hashtable();
|
||||
|
||||
public I18nStringsPanel()
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.add(tablePane, BorderLayout.CENTER);
|
||||
this.add(leftPanel, BorderLayout.WEST);
|
||||
|
||||
leftPanel.add(languageListPane, BorderLayout.CENTER);
|
||||
leftPanel.add(addLanguageButton, BorderLayout.NORTH);
|
||||
|
||||
languageListPane.getViewport().add(languageList);
|
||||
languageList.setModel(languageListModel);
|
||||
languageList
|
||||
.addListSelectionListener(new LanguageListSelectionListener());
|
||||
|
||||
addLanguageButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
NewLanguageDialog dialog = new NewLanguageDialog();
|
||||
|
||||
dialog.pack();
|
||||
dialog.setLocation(
|
||||
(Toolkit.getDefaultToolkit().getScreenSize().width
|
||||
- dialog.getWidth()) / 2,
|
||||
(Toolkit.getDefaultToolkit().getScreenSize().height
|
||||
- dialog.getHeight()) / 2);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
tablePane.getViewport().add(stringsTable);
|
||||
|
||||
stringsTable.setShowGrid(true);
|
||||
stringsTable.setGridColor(Color.GRAY);
|
||||
|
||||
this.initLocalesList();
|
||||
this.languageList.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
private void initLocalesList()
|
||||
{
|
||||
ResourceManagementService resourceService
|
||||
= GuiCustomizationActivator.getResources();
|
||||
|
||||
Iterator locales = resourceService.getAvailableLocales();
|
||||
|
||||
Locale locale;
|
||||
CustomTableModel stringsTableModel;
|
||||
|
||||
while(locales.hasNext())
|
||||
{
|
||||
locale = (Locale) locales.next();
|
||||
|
||||
languageListModel.addElement(locale.getLanguage());
|
||||
|
||||
stringsTableModel = new CustomTableModel();
|
||||
|
||||
stringsTableModel.addColumn("Key");
|
||||
stringsTableModel.addColumn("Text");
|
||||
|
||||
this.initStringsTable(stringsTableModel, locale);
|
||||
|
||||
languagesTable.put( locale.getLanguage(),
|
||||
stringsTableModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void initStringsTable(CustomTableModel tableModel, Locale l)
|
||||
{
|
||||
Iterator stringKeys = GuiCustomizationActivator
|
||||
.getResources().getI18nStringsByLocale(l);
|
||||
|
||||
while (stringKeys.hasNext())
|
||||
{
|
||||
String key = (String) stringKeys.next();
|
||||
String value
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getI18NString(key, l);
|
||||
|
||||
tableModel.addRow(new Object[]{ key, value});
|
||||
}
|
||||
}
|
||||
|
||||
private class LanguageListSelectionListener implements ListSelectionListener
|
||||
{
|
||||
public void valueChanged(ListSelectionEvent e)
|
||||
{
|
||||
if (!e.getValueIsAdjusting())
|
||||
{
|
||||
CustomTableModel newModel
|
||||
= (CustomTableModel) languagesTable
|
||||
.get(languageList.getSelectedValue());
|
||||
|
||||
stringsTable.setModel(newModel);
|
||||
stringsTable.getColumnModel().getColumn(1)
|
||||
.setCellRenderer(new TextAreaCellRenderer());
|
||||
stringsTable.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NewLanguageDialog
|
||||
extends JDialog
|
||||
implements ActionListener
|
||||
{
|
||||
private JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
|
||||
|
||||
private JLabel enterLocaleLabel = new JLabel("Enter new locale: ");
|
||||
|
||||
private JComboBox localeBox
|
||||
= new JComboBox(Locale.getAvailableLocales());
|
||||
|
||||
private JButton okButton = new JButton("Ok");
|
||||
|
||||
private JButton cancelButton = new JButton("Cancel");
|
||||
|
||||
private JPanel buttonPanel
|
||||
= new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
public NewLanguageDialog()
|
||||
{
|
||||
this.getContentPane().add(mainPanel);
|
||||
|
||||
this.mainPanel.add(enterLocaleLabel, BorderLayout.WEST);
|
||||
this.mainPanel.add(localeBox, BorderLayout.CENTER);
|
||||
this.mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.buttonPanel.add(okButton);
|
||||
this.buttonPanel.add(cancelButton);
|
||||
|
||||
this.okButton.addActionListener(this);
|
||||
this.cancelButton.addActionListener(this);
|
||||
|
||||
this.mainPanel.setBorder(
|
||||
BorderFactory.createEmptyBorder(15, 15, 15, 15));
|
||||
this.mainPanel.setPreferredSize(new Dimension(210, 120));
|
||||
|
||||
this.getRootPane().setDefaultButton(okButton);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
JButton button = (JButton) evt.getSource();
|
||||
|
||||
if (button.equals(okButton))
|
||||
{
|
||||
Locale locale = (Locale)localeBox.getSelectedItem();
|
||||
|
||||
languageListModel.addElement(locale);
|
||||
|
||||
CustomTableModel stringsTableModel = new CustomTableModel();
|
||||
|
||||
stringsTableModel.addColumn("Key");
|
||||
stringsTableModel.addColumn("Text");
|
||||
|
||||
initStringsTable(stringsTableModel, locale);
|
||||
|
||||
languagesTable.put( locale,
|
||||
stringsTableModel);
|
||||
|
||||
this.dispose();
|
||||
}
|
||||
else if (button.equals(cancelButton))
|
||||
{
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable<String, Hashtable<String, String>> getLanguages()
|
||||
{
|
||||
Hashtable res = new Hashtable();
|
||||
Enumeration e = languageListModel.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String locale = (String)e.nextElement();
|
||||
|
||||
CustomTableModel model =
|
||||
(CustomTableModel)languagesTable.get(locale);
|
||||
|
||||
Hashtable strings = new Hashtable();
|
||||
|
||||
int rows = model.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
String key = (String)model.getValueAt(i, 0);
|
||||
String val = (String)model.getValueAt(i, 1);
|
||||
|
||||
strings.put(key, val);
|
||||
}
|
||||
|
||||
res.put(locale, strings);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,282 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
public class ImagesPanel
|
||||
extends JScrollPane
|
||||
{
|
||||
private Logger logger = Logger.getLogger(ImagesPanel.class);
|
||||
|
||||
private CustomTableModel imagesTableModel = new CustomTableModel();
|
||||
|
||||
private JTable imagesTable = new JTable();
|
||||
|
||||
private JFrame parentWindow;
|
||||
|
||||
public ImagesPanel(JFrame parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
this.getViewport().add(imagesTable);
|
||||
|
||||
imagesTableModel.addColumn("File path");
|
||||
imagesTableModel.addColumn("Image size");
|
||||
imagesTableModel.addColumn("Image");
|
||||
imagesTableModel.addColumn("Change image");
|
||||
|
||||
imagesTable.setModel(imagesTableModel);
|
||||
|
||||
TableColumn sizeColumn
|
||||
= imagesTable.getColumnModel().getColumn(1);
|
||||
|
||||
sizeColumn.setCellRenderer(
|
||||
new LabelTableCellRenderer());
|
||||
sizeColumn.setMaxWidth(100);
|
||||
|
||||
imagesTable.getColumnModel().getColumn(2).setCellRenderer(
|
||||
new LabelTableCellRenderer());
|
||||
|
||||
TableColumn buttonColumn
|
||||
= imagesTable.getColumnModel().getColumn(3);
|
||||
buttonColumn.setCellRenderer(new ButtonTableCellRenderer());
|
||||
buttonColumn.setCellEditor(new ButtonTableEditor());
|
||||
|
||||
this.initImageTable();
|
||||
}
|
||||
|
||||
private void initImageTable()
|
||||
{
|
||||
Iterator imageKeys
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getCurrentImages();
|
||||
|
||||
// we set an initial row height, to fit the button.
|
||||
int rowHeight = 40;
|
||||
|
||||
while (imageKeys.hasNext())
|
||||
{
|
||||
String key = (String) imageKeys.next();
|
||||
ImageIcon image = getImage(key);
|
||||
final JLabel imageLabel = new JLabel();
|
||||
JLabel imageSizeLabel = new JLabel();
|
||||
int currentImageWidth = 0;
|
||||
int currentImageHeight = 0;
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
imageLabel.setIcon(image);
|
||||
currentImageWidth = image.getImage().getWidth(null);
|
||||
currentImageHeight = image.getImage().getHeight(null);
|
||||
|
||||
imageSizeLabel
|
||||
.setText(currentImageWidth + "x" + currentImageHeight);
|
||||
|
||||
images.put(key, getImageBytes(key));
|
||||
}
|
||||
|
||||
JButton fileChooserButton = new JButton();
|
||||
|
||||
fileChooserButton.setAction(
|
||||
new ChangeImageAction( key,
|
||||
imageLabel,
|
||||
imageSizeLabel,
|
||||
currentImageWidth,
|
||||
currentImageHeight));
|
||||
|
||||
imagesTableModel.addRow(new Object[]{ key,
|
||||
imageSizeLabel,
|
||||
imageLabel,
|
||||
fileChooserButton});
|
||||
|
||||
fileChooserButton.setText("Change image");
|
||||
|
||||
if (image != null && rowHeight < image.getIconHeight())
|
||||
{
|
||||
imagesTable.setRowHeight( imagesTableModel.getRowCount() - 1,
|
||||
image.getIconHeight() );
|
||||
}
|
||||
else
|
||||
{
|
||||
imagesTable.setRowHeight( imagesTableModel.getRowCount() - 1,
|
||||
rowHeight );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads an image from a given image identifier.
|
||||
*
|
||||
* @param imageID The identifier of the image.
|
||||
* @return The image for the given identifier.
|
||||
*/
|
||||
private ImageIcon getImage(String imageID)
|
||||
{
|
||||
BufferedImage image = null;
|
||||
|
||||
InputStream in =
|
||||
GuiCustomizationActivator.getResources()
|
||||
.getImageInputStream(imageID);
|
||||
|
||||
if(in == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageIO.read(in);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Failed to load image:" + imageID, e);
|
||||
}
|
||||
|
||||
return new ImageIcon(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from a given image identifier.
|
||||
*
|
||||
* @param imageID The identifier of the image.
|
||||
* @return The image for the given identifier.
|
||||
*/
|
||||
private byte[] getImageBytes(String imageID)
|
||||
{
|
||||
InputStream in =
|
||||
GuiCustomizationActivator.getResources()
|
||||
.getImageInputStream(imageID);
|
||||
|
||||
if(in == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] bs = new byte[in.available()];
|
||||
in.read(bs);
|
||||
|
||||
return bs;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Failed to load image:" + imageID, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private class ChangeImageAction extends AbstractAction
|
||||
{
|
||||
private JLabel imageLabel;
|
||||
private JLabel imageSizeLabel;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private String key;
|
||||
|
||||
public ChangeImageAction( String key,
|
||||
JLabel imageLabel,
|
||||
JLabel imageSizeLabel,
|
||||
int imageWidth,
|
||||
int imageHeight)
|
||||
{
|
||||
this.key = key;
|
||||
this.imageLabel = imageLabel;
|
||||
this.imageSizeLabel = imageSizeLabel;
|
||||
this.imageWidth = imageWidth;
|
||||
this.imageHeight = imageHeight;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
JFileChooser fileChooser
|
||||
= new JFileChooser();
|
||||
|
||||
int result
|
||||
= fileChooser.showOpenDialog(parentWindow);
|
||||
|
||||
if (result == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File newImageFile = fileChooser.getSelectedFile();
|
||||
ImageIcon newImageIcon = new ImageIcon(newImageFile.getPath());
|
||||
|
||||
try
|
||||
{
|
||||
FileInputStream in = new FileInputStream(newImageFile);
|
||||
byte[] bs = new byte[in.available()];
|
||||
in.read(bs);
|
||||
in.close();
|
||||
|
||||
images.put(key, bs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
imageLabel.setIcon(newImageIcon);
|
||||
|
||||
if (newImageIcon.getIconWidth() > imageWidth
|
||||
|| newImageIcon.getIconHeight() > imageHeight)
|
||||
{
|
||||
imageSizeLabel.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public static byte[] convertImage(Image img)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// int[] pix = new int[img.getWidth(null) * img.getHeight(null)];
|
||||
// PixelGrabber pg =
|
||||
// new PixelGrabber(img, 0, 0, img.getWidth(null),
|
||||
// img.getHeight(null), pix, 0, img.getWidth(null));
|
||||
// pg.grabPixels();
|
||||
//
|
||||
// byte[] pixels = new byte[img.getWidth(null) * img.getHeight(null)];
|
||||
//
|
||||
// for (int j = 0; j < pix.length; j++)
|
||||
// pixels[j] = new Integer(pix[j]).byteValue();
|
||||
//
|
||||
// return pixels;
|
||||
// }
|
||||
// catch (InterruptedException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
Hashtable<String, byte[]> images = new Hashtable<String, byte[]>();
|
||||
|
||||
Hashtable<String, byte[]> getImages()
|
||||
{
|
||||
return images;
|
||||
// Hashtable res = new Hashtable();
|
||||
// int rows = imagesTableModel.getRowCount();
|
||||
// for (int i = 0; i < rows; i++)
|
||||
// {
|
||||
// String key = (String)imagesTableModel.getValueAt(i, 0);
|
||||
// JLabel imageLabel = (JLabel)imagesTableModel.getValueAt(i, 2);
|
||||
//
|
||||
// Icon icon = imageLabel.getIcon();
|
||||
// if(icon != null && icon instanceof ImageIcon)
|
||||
// res.put(
|
||||
// key,
|
||||
// convertImage(((ImageIcon)icon).getImage()));
|
||||
// else
|
||||
// res.put(key,new byte[0]);
|
||||
// }
|
||||
//
|
||||
// return res;
|
||||
}
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
public class LabelTableCellRenderer
|
||||
extends JLabel
|
||||
implements TableCellRenderer
|
||||
{
|
||||
public LabelTableCellRenderer()
|
||||
{
|
||||
this.setOpaque(true);
|
||||
}
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
setBackground(table.getSelectionBackground());
|
||||
setForeground(table.getSelectionForeground());
|
||||
}
|
||||
else
|
||||
{
|
||||
setBackground(table.getBackground());
|
||||
setForeground(table.getForeground());
|
||||
}
|
||||
|
||||
if (value instanceof JLabel)
|
||||
{
|
||||
JLabel labelValue = (JLabel) value;
|
||||
this.setText(labelValue.getText());
|
||||
this.setIcon(labelValue.getIcon());
|
||||
this.setBackground(labelValue.getBackground());
|
||||
}
|
||||
|
||||
setEnabled(table.isEnabled());
|
||||
setFont(table.getFont());
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SettingsPanel
|
||||
extends JScrollPane
|
||||
{
|
||||
private JTable settingsTable = new JTable();
|
||||
|
||||
private CustomTableModel settingsTableModel = new CustomTableModel();
|
||||
|
||||
public SettingsPanel()
|
||||
{
|
||||
this.getViewport().add(settingsTable);
|
||||
|
||||
settingsTable.setModel(settingsTableModel);
|
||||
settingsTableModel.addColumn("Key");
|
||||
settingsTableModel.addColumn("Text");
|
||||
|
||||
settingsTable.getColumnModel().getColumn(1)
|
||||
.setCellRenderer(new TextAreaCellRenderer());
|
||||
settingsTable.setShowGrid(true);
|
||||
settingsTable.setGridColor(Color.GRAY);
|
||||
this.initSettingTable();
|
||||
}
|
||||
|
||||
private void initSettingTable()
|
||||
{
|
||||
Iterator settingKeys
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getCurrentSettings();
|
||||
|
||||
while (settingKeys.hasNext())
|
||||
{
|
||||
String key = (String) settingKeys.next();
|
||||
String value
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getSettingsString(key);
|
||||
|
||||
settingsTableModel.addRow(new Object[]{ key,
|
||||
value});
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable<String, String> getSettings()
|
||||
{
|
||||
Hashtable res = new Hashtable();
|
||||
int rows = settingsTableModel.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
String key = (String)settingsTableModel.getValueAt(i, 0);
|
||||
String value = (String)settingsTableModel.getValueAt(i, 1);
|
||||
|
||||
res.put(key, value);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,239 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import net.java.sip.communicator.plugin.guicustomization.CustomizationWindow.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
public class SoundsPanel
|
||||
extends JScrollPane
|
||||
{
|
||||
private Logger logger = Logger.getLogger(SoundsPanel.class);
|
||||
|
||||
private JTable soundsTable = new JTable();
|
||||
|
||||
private CustomTableModel soundsTableModel = new CustomTableModel();
|
||||
|
||||
private static Constructor acConstructor = null;
|
||||
|
||||
private JFrame parentWindow;
|
||||
|
||||
public SoundsPanel(JFrame parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
this.getViewport().add(soundsTable);
|
||||
|
||||
soundsTable.setModel(soundsTableModel);
|
||||
soundsTableModel.addColumn("Description");
|
||||
soundsTableModel.addColumn("File path");
|
||||
soundsTableModel.addColumn("Change sound");
|
||||
|
||||
TableColumn buttonColumn1
|
||||
= soundsTable.getColumnModel().getColumn(1);
|
||||
|
||||
buttonColumn1.setCellRenderer(new ButtonTableCellRenderer());
|
||||
buttonColumn1.setCellEditor(new ButtonTableEditor());
|
||||
buttonColumn1.setWidth(40);
|
||||
|
||||
TableColumn buttonColumn2
|
||||
= soundsTable.getColumnModel().getColumn(2);
|
||||
|
||||
buttonColumn2.setCellRenderer(new ButtonTableCellRenderer());
|
||||
buttonColumn2.setCellEditor(new ButtonTableEditor());
|
||||
buttonColumn2.setWidth(40);
|
||||
|
||||
this.initSoundTable();
|
||||
}
|
||||
|
||||
private void initSoundTable()
|
||||
{
|
||||
Iterator soundKeys
|
||||
= GuiCustomizationActivator.getResources()
|
||||
.getCurrentSounds();
|
||||
|
||||
int rowHeight = 40;
|
||||
while (soundKeys.hasNext())
|
||||
{
|
||||
String key = (String) soundKeys.next();
|
||||
URL soundURL
|
||||
= GuiCustomizationActivator.getResources().getSoundURL(key);
|
||||
|
||||
PlaySoundButton playSoundButton = new PlaySoundButton(soundURL);
|
||||
playSoundButton.setAction(new PlaySoundAction());
|
||||
|
||||
JButton fileChooserButton = new JButton();
|
||||
fileChooserButton.setAction(new ChangeSoundAction(playSoundButton));
|
||||
|
||||
soundsTableModel.addRow(new Object[]{ key,
|
||||
playSoundButton,
|
||||
fileChooserButton});
|
||||
playSoundButton.setText("Play!");
|
||||
fileChooserButton.setText("Choose sound");
|
||||
|
||||
soundsTable.setRowHeight( soundsTableModel.getRowCount() - 1,
|
||||
rowHeight );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class ChangeSoundAction extends AbstractAction
|
||||
{
|
||||
private PlaySoundButton playSoundButton;
|
||||
|
||||
public ChangeSoundAction(PlaySoundButton button)
|
||||
{
|
||||
this.playSoundButton = button;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
JFileChooser fileChooser
|
||||
= new JFileChooser();
|
||||
|
||||
int result
|
||||
= fileChooser.showOpenDialog(parentWindow);
|
||||
|
||||
if (result == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File newSoundFile = fileChooser.getSelectedFile();
|
||||
try
|
||||
{
|
||||
playSoundButton
|
||||
.setSoundURL(newSoundFile.toURL());
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
logger.error("Faile to create sound file.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PlaySoundAction extends AbstractAction
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
PlaySoundButton button = (PlaySoundButton) evt.getSource();
|
||||
AudioClip ac;
|
||||
try
|
||||
{
|
||||
ac = createAppletAudioClip(button.getSoundURL().openStream());
|
||||
|
||||
ac.play();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Failed to open sound file.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PlaySoundButton extends JButton
|
||||
{
|
||||
private URL soundURL;
|
||||
|
||||
public PlaySoundButton(URL soundURL)
|
||||
{
|
||||
this.soundURL = soundURL;
|
||||
}
|
||||
|
||||
public URL getSoundURL()
|
||||
{
|
||||
return soundURL;
|
||||
}
|
||||
|
||||
public void setSoundURL(URL url)
|
||||
{
|
||||
this.soundURL = url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AppletAudioClip.
|
||||
*
|
||||
* @param inputstream the audio input stream
|
||||
* @throws IOException
|
||||
*/
|
||||
private AudioClip createAppletAudioClip(InputStream inputstream)
|
||||
throws IOException
|
||||
{
|
||||
if(acConstructor == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
acConstructor = (Constructor) AccessController
|
||||
.doPrivileged(new PrivilegedExceptionAction()
|
||||
{
|
||||
public Object run()
|
||||
throws NoSuchMethodException,
|
||||
SecurityException,
|
||||
ClassNotFoundException
|
||||
{
|
||||
|
||||
Class class1 = null;
|
||||
try
|
||||
{
|
||||
class1 = Class.forName(
|
||||
"com.sun.media.sound.JavaSoundAudioClip",
|
||||
true, ClassLoader.getSystemClassLoader());
|
||||
}
|
||||
catch(ClassNotFoundException ex)
|
||||
{
|
||||
class1 = Class.forName(
|
||||
"sun.audio.SunAudioClip", true, null);
|
||||
}
|
||||
Class aclass[] = new Class[1];
|
||||
aclass[0] = Class.forName("java.io.InputStream");
|
||||
return class1.getConstructor(aclass);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(PrivilegedActionException privilegedactionexception)
|
||||
{
|
||||
throw new IOException("Failed to get AudioClip constructor: "
|
||||
+ privilegedactionexception.getException());
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
Object aobj[] = {
|
||||
inputstream
|
||||
};
|
||||
|
||||
return (AudioClip)acConstructor.newInstance(aobj);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
throw new IOException("Failed to construct the AudioClip: "
|
||||
+ exception);
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable<String, URL> getSounds()
|
||||
{
|
||||
Hashtable res = new Hashtable();
|
||||
int rows = soundsTableModel.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
String key = (String)soundsTableModel.getValueAt(i, 0);
|
||||
PlaySoundButton sndButton =
|
||||
(PlaySoundButton)soundsTableModel.getValueAt(i, 1);
|
||||
|
||||
res.put(
|
||||
key,
|
||||
sndButton.getSoundURL());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package net.java.sip.communicator.plugin.guicustomization;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
public class TextAreaCellRenderer
|
||||
extends JTextArea
|
||||
implements TableCellRenderer
|
||||
{
|
||||
public TextAreaCellRenderer()
|
||||
{
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
String stringValue = (String) value;
|
||||
|
||||
setText(stringValue);
|
||||
setSize(table.getColumnModel().getColumn(column).getWidth(),
|
||||
getPreferredSize().height);
|
||||
if (table.getRowHeight(row) != getPreferredSize().height)
|
||||
{
|
||||
table.setRowHeight(row, getPreferredSize().height);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
Bundle-Activator: net.java.sip.communicator.plugin.guicustomization.GuiCustomizationActivator
|
||||
Bundle-Name: Gui Customization Activator
|
||||
Bundle-Description: The plugin offering gui customization interface.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
Import-Package: org.osgi.framework,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.service.resources,
|
||||
javax.swing,
|
||||
javax.swing.event,
|
||||
javax.swing.table,
|
||||
javax.swing.text,
|
||||
javax.swing.text.html,
|
||||
javax.imageio
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CustomColorPackImpl
|
||||
implements ColorPack
|
||||
{
|
||||
|
||||
public String getResourcePackBaseName()
|
||||
{
|
||||
return "resources.colors.colorResources";
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Color Resources";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "Provide SIP Communicator Color resource pack.";
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CustomImagePackImpl
|
||||
implements ImagePack
|
||||
{
|
||||
|
||||
public String getResourcePackBaseName()
|
||||
{
|
||||
return "resources.images.images";
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Image Resources";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "Provide SIP Communicator Image resource pack.";
|
||||
}
|
||||
}
|
||||
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CustomLanguagePackImpl
|
||||
implements LanguagePack
|
||||
{
|
||||
private ArrayList localeList = new ArrayList();
|
||||
|
||||
public CustomLanguagePackImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
JarFile jf = new JarFile(getJarfileName());
|
||||
|
||||
Enumeration resources = jf.entries();
|
||||
while (resources.hasMoreElements())
|
||||
{
|
||||
JarEntry je = (JarEntry) resources.nextElement();
|
||||
|
||||
Locale locale;
|
||||
String entryName = je.getName();
|
||||
if (entryName.matches("resources/languages/.*\\.properties"))
|
||||
{
|
||||
int localeIndex = entryName.indexOf('_');
|
||||
|
||||
if (localeIndex == -1)
|
||||
locale = new Locale("EN");
|
||||
else
|
||||
{
|
||||
String localeName =
|
||||
entryName.substring(localeIndex + 1,
|
||||
entryName.indexOf('.'));
|
||||
|
||||
locale = new Locale(localeName);
|
||||
}
|
||||
|
||||
localeList.add(locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
// logger.error("Cannot load locales.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getResourcePackBaseName()
|
||||
{
|
||||
return "resources.languages.resources";
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Language Resources";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "Provide SIP Communicator Language resource pack.";
|
||||
}
|
||||
|
||||
public Iterator getAvailableLocales()
|
||||
{
|
||||
return localeList.iterator();
|
||||
}
|
||||
|
||||
private String getJarfileName()
|
||||
{
|
||||
// Get the location of the jar file and the jar file name
|
||||
java.net.URL outputURL =
|
||||
CustomLanguagePackImpl.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation();
|
||||
|
||||
String outputString = outputURL.toString();
|
||||
|
||||
String[] parseString;
|
||||
parseString = outputString.split("file:");
|
||||
|
||||
String jarFilename = parseString[1];
|
||||
return jarFilename;
|
||||
}
|
||||
}
|
||||
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import java.util.*;
|
||||
import org.osgi.framework.*;
|
||||
import org.osgi.service.startlevel.*;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author damencho
|
||||
*/
|
||||
public class CustomResourcePackActivator
|
||||
implements BundleActivator
|
||||
{
|
||||
|
||||
private Logger logger =
|
||||
Logger.getLogger(CustomResourcePackActivator.class);
|
||||
|
||||
private static BundleContext bundleContext;
|
||||
|
||||
public void start(BundleContext bc) throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
ServiceReference serviceReference = bundleContext
|
||||
.getServiceReference(StartLevel.class.getName());
|
||||
|
||||
StartLevel startLevelService = (StartLevel) bundleContext
|
||||
.getService(serviceReference);
|
||||
|
||||
startLevelService.setBundleStartLevel(bc.getBundle(), 39);
|
||||
|
||||
CustomColorPackImpl colPackImpl =
|
||||
new CustomColorPackImpl();
|
||||
|
||||
Hashtable props = new Hashtable();
|
||||
props.put(ColorPack.RESOURCE_NAME,
|
||||
ColorPack.RESOURCE_NAME_DEFAULT_VALUE);
|
||||
|
||||
bundleContext.registerService( ColorPack.class.getName(),
|
||||
colPackImpl,
|
||||
props);
|
||||
|
||||
CustomImagePackImpl imgPackImpl =
|
||||
new CustomImagePackImpl();
|
||||
|
||||
Hashtable imgProps = new Hashtable();
|
||||
imgProps.put(ImagePack.RESOURCE_NAME,
|
||||
ImagePack.RESOURCE_NAME_DEFAULT_VALUE);
|
||||
|
||||
bundleContext.registerService( ImagePack.class.getName(),
|
||||
imgPackImpl,
|
||||
imgProps);
|
||||
|
||||
CustomLanguagePackImpl langPackImpl =
|
||||
new CustomLanguagePackImpl();
|
||||
|
||||
Hashtable langProps = new Hashtable();
|
||||
langProps.put(LanguagePack.RESOURCE_NAME,
|
||||
LanguagePack.RESOURCE_NAME_DEFAULT_VALUE);
|
||||
|
||||
bundleContext.registerService( LanguagePack.class.getName(),
|
||||
langPackImpl,
|
||||
langProps);
|
||||
|
||||
CustomSettingsPackImpl setPackImpl =
|
||||
new CustomSettingsPackImpl();
|
||||
|
||||
Hashtable setProps = new Hashtable();
|
||||
langProps.put(SettingsPack.RESOURCE_NAME,
|
||||
SettingsPack.RESOURCE_NAME_DEFAULT_VALUE);
|
||||
|
||||
bundleContext.registerService( SettingsPack.class.getName(),
|
||||
setPackImpl,
|
||||
setProps);
|
||||
|
||||
CustomSoundPackImpl sndPackImpl =
|
||||
new CustomSoundPackImpl();
|
||||
|
||||
Hashtable sndProps = new Hashtable();
|
||||
langProps.put(SoundPack.RESOURCE_NAME,
|
||||
SoundPack.RESOURCE_NAME_DEFAULT_VALUE);
|
||||
|
||||
bundleContext.registerService( SoundPack.class.getName(),
|
||||
sndPackImpl,
|
||||
sndProps);
|
||||
|
||||
logger.info("Custom resources ... [REGISTERED]");
|
||||
}
|
||||
|
||||
public void stop(BundleContext bc) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CustomSettingsPackImpl
|
||||
implements SettingsPack
|
||||
{
|
||||
|
||||
public String getResourcePackBaseName()
|
||||
{
|
||||
return "resources.config.defaults";
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Settings Resources";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "Provide SIP Communicator Settings resource pack.";
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.guicustomization.resourcepack;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class CustomSoundPackImpl
|
||||
implements SoundPack
|
||||
{
|
||||
|
||||
public String getResourcePackBaseName()
|
||||
{
|
||||
return "resources.sounds";
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Sounds Resources";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "Provide SIP Communicator Sounds resource pack.";
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-Activator: net.java.sip.communicator.plugin.guicustomization.resourcepack.CustomResourcePackActivator
|
||||
Bundle-Name: Custom Resource Pack
|
||||
Bundle-Description: The plugin offering custom images and languages.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
Import-Package: org.osgi.framework,
|
||||
org.osgi.service.startlevel,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.service.resources
|
||||
Loading…
Reference in new issue