mirror of
https://github.com/mirror/jdownloader.git
synced 2025-03-03 09:57:30 +00:00
Nullpointer fixed
git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@6379 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
parent
f31e911a82
commit
d300813b03
@ -1,125 +0,0 @@
|
||||
// jDownloader - Downloadmanager
|
||||
// Copyright (C) 2008 JD-Team support@jdownloader.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import jd.gui.skins.simple.components.JLinkButton;
|
||||
import jd.nutils.Screen;
|
||||
import jd.utils.JDLocale;
|
||||
import jd.utils.JDUtilities;
|
||||
|
||||
/**
|
||||
* Dieser Dialog wird angezeigt, wenn ein Download mit einem Plugin getätigt
|
||||
* wird, dessen Agbs noch nicht akzeptiert wurden
|
||||
*
|
||||
* @author eXecuTe
|
||||
*/
|
||||
|
||||
public class ConfirmCheckBoxDialog extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JButton btnCancel;
|
||||
|
||||
private JButton btnOK;
|
||||
|
||||
private JCheckBox checkBox;
|
||||
|
||||
public boolean isChecked = false;
|
||||
public boolean isOk = false;
|
||||
|
||||
/**
|
||||
* Zeigt einen Dialog, in dem man die Hoster AGB akzeptieren kann
|
||||
*
|
||||
* @param downloadLink
|
||||
* abzuarbeitender Link
|
||||
*/
|
||||
public ConfirmCheckBoxDialog(String title, String text, String checkBoxText) {
|
||||
this(title, text, checkBoxText, false);
|
||||
}
|
||||
|
||||
public ConfirmCheckBoxDialog(String title, String text, String checkBoxText, boolean html) {
|
||||
|
||||
super();
|
||||
JPanel panel = new JPanel();
|
||||
setContentPane(panel);
|
||||
|
||||
setModal(true);
|
||||
setLayout(new GridBagLayout());
|
||||
getRootPane().setDefaultButton(btnOK);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setTitle(title);
|
||||
|
||||
JTextPane labelInfo = new JTextPane();
|
||||
|
||||
labelInfo.setEditable(false);
|
||||
if (html) {
|
||||
labelInfo.setContentType("text/html");
|
||||
labelInfo.requestFocusInWindow();
|
||||
labelInfo.addHyperlinkListener(JLinkButton.getHyperlinkListener());
|
||||
|
||||
} else {
|
||||
labelInfo.setForeground(Color.red);
|
||||
}
|
||||
labelInfo.setText(text);
|
||||
checkBox = new JCheckBox(checkBoxText);
|
||||
checkBox.addActionListener(this);
|
||||
checkBox.setFocusable(false);
|
||||
|
||||
btnOK = new JButton(JDLocale.L("gui.btn_ok", "OK"));
|
||||
btnOK.addActionListener(this);
|
||||
|
||||
btnCancel = new JButton(JDLocale.L("gui.btn_cancel", "Cancel"));
|
||||
btnCancel.addActionListener(this);
|
||||
btnCancel.setFocusable(false);
|
||||
|
||||
JDUtilities.addToGridBag(this, labelInfo, 1, 1, 2, 1, 1, 1, new Insets(10, 5, 0, 5), GridBagConstraints.NONE, GridBagConstraints.CENTER);
|
||||
|
||||
JDUtilities.addToGridBag(this, checkBox, 1, 4, 2, 1, 1, 1, new Insets(5, 5, 15, 5), GridBagConstraints.NONE, GridBagConstraints.CENTER);
|
||||
JDUtilities.addToGridBag(this, btnCancel, 2, 5, 1, 1, 1, 1, new Insets(5, 5, 5, 5), GridBagConstraints.NONE, GridBagConstraints.WEST);
|
||||
JDUtilities.addToGridBag(this, btnOK, 1, 5, 1, 1, 1, 1, new Insets(5, 5, 5, 5), GridBagConstraints.NONE, GridBagConstraints.EAST);
|
||||
|
||||
int n = 10;
|
||||
panel.setBorder(new EmptyBorder(n, n, n, n));
|
||||
|
||||
pack();
|
||||
setLocation(Screen.getCenterOfComponent(null, this));
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == btnOK) {
|
||||
if (checkBox.isSelected()) isChecked = true;
|
||||
isOk = true;
|
||||
dispose();
|
||||
} else if (e.getSource() == btnCancel) {
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,172 +0,0 @@
|
||||
// jDownloader - Downloadmanager
|
||||
// Copyright (C) 2008 JD-Team support@jdownloader.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import jd.gui.skins.simple.SimpleGuiUtils;
|
||||
import jd.utils.JDLocale;
|
||||
import jd.utils.JDUtilities;
|
||||
|
||||
public class MiniLogDialog extends JFrame implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -1749561448228487759L;
|
||||
|
||||
private String lineSeparator = System.getProperty("line.separator");
|
||||
|
||||
private JButton btnNotOK;
|
||||
|
||||
private JButton btnOK;
|
||||
|
||||
private JTextArea htmlArea;
|
||||
|
||||
private JLabel lblMessage;
|
||||
|
||||
private JProgressBar progress;
|
||||
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
public MiniLogDialog(String message) {
|
||||
super();
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
setVisible(true);
|
||||
setTitle(message);
|
||||
setAlwaysOnTop(true);
|
||||
setPreferredSize(new Dimension(400, 300));
|
||||
setTitle(JDLocale.L("gui.dialogs.progress.title", "Fortschritt...bitte warten"));
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
btnOK = new JButton(JDLocale.L("gui.btn_ok", "OK"));
|
||||
btnOK.addActionListener(this);
|
||||
btnNotOK = new JButton(JDLocale.L("gui.btn_cancel", "Abbrechen"));
|
||||
btnNotOK.addActionListener(this);
|
||||
lblMessage = new JLabel(message);
|
||||
htmlArea = new JTextArea();
|
||||
htmlArea.setEditable(false);
|
||||
htmlArea.setLineWrap(false);
|
||||
htmlArea.setText("");
|
||||
scrollPane = new JScrollPane(htmlArea);
|
||||
progress = new JProgressBar();
|
||||
|
||||
getRootPane().setDefaultButton(btnOK);
|
||||
|
||||
JDUtilities.addToGridBag(this, lblMessage, 0, 0, 4, 1, 0, 0, null, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
|
||||
JDUtilities.addToGridBag(this, progress, 0, 1, 4, 1, 1, 0, null, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
|
||||
JDUtilities.addToGridBag(this, scrollPane, 0, 2, 4, 1, 1, 1, null, GridBagConstraints.BOTH, GridBagConstraints.EAST);
|
||||
JDUtilities.addToGridBag(this, btnOK, 3, 3, 1, 1, 1, 0, null, GridBagConstraints.NONE, GridBagConstraints.EAST);
|
||||
|
||||
SimpleGuiUtils.restoreWindow(null, this);
|
||||
|
||||
pack();
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == btnOK || e.getSource() == btnNotOK) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void appendLine(String text) {
|
||||
if (htmlArea.getText().equals("")) {
|
||||
htmlArea.setText(text);
|
||||
} else {
|
||||
htmlArea.append(lineSeparator + text);
|
||||
}
|
||||
}
|
||||
|
||||
public JButton getBtnNOTOK() {
|
||||
return btnNotOK;
|
||||
}
|
||||
|
||||
public JButton getBtnOK() {
|
||||
return btnOK;
|
||||
}
|
||||
|
||||
public int getMaximum() {
|
||||
return progress.getMaximum();
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return lblMessage.getText();
|
||||
}
|
||||
|
||||
public int getMinimum() {
|
||||
return progress.getMinimum();
|
||||
}
|
||||
|
||||
public JProgressBar getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public JScrollPane getScrollPane() {
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return progress.getString();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return htmlArea.getText();
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return progress.getValue();
|
||||
}
|
||||
|
||||
public void setMaximum(int value) {
|
||||
progress.setMaximum(value);
|
||||
}
|
||||
|
||||
public void setMessage(String txt) {
|
||||
lblMessage.setText(txt);
|
||||
}
|
||||
|
||||
public void setMinimum(int value) {
|
||||
progress.setMinimum(value);
|
||||
}
|
||||
|
||||
public void setString(String txt) {
|
||||
progress.setString(txt);
|
||||
}
|
||||
|
||||
public void setStringPainted(boolean v) {
|
||||
progress.setStringPainted(v);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
htmlArea.setText(text);
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
progress.setValue(value);
|
||||
}
|
||||
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
// jDownloader - Downloadmanager
|
||||
// Copyright (C) 2008 JD-Team support@jdownloader.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.PlainDocument;
|
||||
|
||||
import jd.utils.JDLocale;
|
||||
|
||||
public class TextArea extends JScrollPane implements MouseListener, ClipboardOwner {
|
||||
|
||||
private class InternalPopup extends JPopupMenu implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 7718129427883204876L;
|
||||
|
||||
private JMenuItem copy;
|
||||
|
||||
private JMenuItem delete;
|
||||
|
||||
private JMenuItem paste;
|
||||
|
||||
private JPopupMenu popup;
|
||||
|
||||
// private int[] indeces;
|
||||
|
||||
public InternalPopup(Component parent, int x, int y) {
|
||||
popup = new JPopupMenu();
|
||||
|
||||
// Create and add a menu item
|
||||
copy = new JMenuItem(JDLocale.L("gui.component.textarea.context.copy", "Kopieren"));
|
||||
paste = new JMenuItem(JDLocale.L("gui.component.textarea.context.paste", "Einfügen"));
|
||||
delete = new JMenuItem(JDLocale.L("gui.component.textarea.context.delete", "Löschen"));
|
||||
copy.addActionListener(this);
|
||||
|
||||
paste.addActionListener(this);
|
||||
|
||||
delete.addActionListener(this);
|
||||
|
||||
// Add menu item to the JPopupMenu
|
||||
popup.add(copy);
|
||||
popup.add(paste);
|
||||
popup.add(delete);
|
||||
popup.add(new JSeparator());
|
||||
|
||||
popup.show(parent, x, y);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if (e.getSource() == copy) {
|
||||
Clipboard clip = getToolkit().getSystemClipboard();
|
||||
|
||||
StringSelection cont = new StringSelection(txt.getSelectedText());
|
||||
clip.setContents(cont, _this);
|
||||
}
|
||||
|
||||
if (e.getSource() == paste) {
|
||||
Clipboard clip = getToolkit().getSystemClipboard();
|
||||
|
||||
Transferable cont = clip.getContents(_this);
|
||||
if (cont != null) {
|
||||
try {
|
||||
String s = (String) cont.getTransferData(DataFlavor.stringFlavor);
|
||||
String str = txt.getText();
|
||||
String a = str.substring(0, txt.getSelectionStart());
|
||||
String b = str.substring(txt.getSelectionEnd());
|
||||
txt.setText(a + s + b);
|
||||
} catch (Exception e2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getSource() == delete) {
|
||||
String str = txt.getText();
|
||||
String a = str.substring(0, txt.getSelectionStart());
|
||||
String b = str.substring(txt.getSelectionEnd());
|
||||
txt.setText(a + b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -3642394448923083114L;
|
||||
|
||||
private static JTextArea txt;
|
||||
protected TextArea _this;
|
||||
protected Logger logger = jd.controlling.JDLogger.getLogger();
|
||||
|
||||
private int maxHeight;
|
||||
|
||||
private int minHeight;
|
||||
|
||||
public TextArea() {
|
||||
super(txt = new JTextArea());
|
||||
init();
|
||||
_this = this;
|
||||
|
||||
}
|
||||
|
||||
public int getMaxHeight() {
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
public int getMinHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return txt.getText();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
txt.addMouseListener(this);
|
||||
maxHeight = 200;
|
||||
minHeight = 35;
|
||||
|
||||
PlainDocument doc = (PlainDocument) txt.getDocument();
|
||||
doc.addDocumentListener(new DocumentListener() {
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
onChanged();
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
|
||||
onChanged();
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
|
||||
onChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void lostOwnership(Clipboard clipboard, Transferable contents) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
logger.info("PRESSED");
|
||||
if (e.isPopupTrigger() || e.getButton() == MouseEvent.BUTTON3) {
|
||||
// Point point = e.getPoint();
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
new InternalPopup(this, x, y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
private void onChanged() {
|
||||
int height = getHeight();
|
||||
int lines = txt.getLineCount();
|
||||
// if (lines < minHeight) lines = minHeight;
|
||||
// if (lines > maxHeight) lines = maxHeight;
|
||||
txt.setPreferredSize(new Dimension(-1, 1));
|
||||
|
||||
txt.setRows(lines);
|
||||
|
||||
// logger.info("Set size: "+lines+" - "+txt.getHeight());
|
||||
|
||||
if (txt.getHeight() < maxHeight && txt.getHeight() > minHeight) {
|
||||
|
||||
setPreferredSize(new Dimension(-1, txt.getHeight()));
|
||||
}
|
||||
|
||||
this.firePropertyChange("HEIGHT", height, getHeight() + 1);
|
||||
|
||||
}
|
||||
|
||||
public void setMaxHeight(int maxLines) {
|
||||
maxHeight = maxLines;
|
||||
onChanged();
|
||||
}
|
||||
|
||||
public void setMinHeight(int minLines) {
|
||||
minHeight = minLines;
|
||||
onChanged();
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
txt.setText(text);
|
||||
onChanged();
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import jd.gui.skins.simple.SimpleGUI;
|
||||
|
||||
public class JDCheckBoxListRenderer extends JCheckBox implements ActionListener, ListCellRenderer {
|
||||
|
||||
private static final long serialVersionUID = 6771031916814464267L;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new JDCheckBoxListRenderer().showGUI();
|
||||
}
|
||||
|
||||
private void showGUI() {
|
||||
JComboBox cmb = new JComboBox(new JDCheckBoxContainer[] { new JDCheckBoxContainer("test1", true), new JDCheckBoxContainer("test2", true), new JDCheckBoxContainer("test3", false) });
|
||||
cmb.setRenderer(new JDCheckBoxListRenderer());
|
||||
cmb.addActionListener(this);
|
||||
JFrame f = new JFrame();
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.getContentPane().add(cmb);
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public JDCheckBoxListRenderer() {
|
||||
if (SimpleGUI.isSubstance()) {
|
||||
setOpaque(false);
|
||||
} else {
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
setHorizontalTextPosition(JCheckBox.RIGHT);
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (SimpleGUI.isSubstance()) {
|
||||
if (isSelected) {
|
||||
setOpaque(true);
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
} else {
|
||||
setOpaque(false);
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
} else {
|
||||
if (isSelected) {
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
} else {
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
}
|
||||
|
||||
setText(((JDCheckBoxContainer) value).getName());
|
||||
setSelected(((JDCheckBoxContainer) value).isSelected());
|
||||
setFont(list.getFont());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JComboBox cmb = (JComboBox) e.getSource();
|
||||
JDCheckBoxContainer cont = (JDCheckBoxContainer) cmb.getSelectedItem();
|
||||
setSelected(cont.invertSelection());
|
||||
}
|
||||
|
||||
public static class JDCheckBoxContainer {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean selected;
|
||||
|
||||
public JDCheckBoxContainer(String name, boolean selected) {
|
||||
this.name = name;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public boolean invertSelection() {
|
||||
return (selected = !selected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -204,7 +204,7 @@ public class Installer {
|
||||
|
||||
String def = null;
|
||||
for (JDLocale id : JDLocale.getLocaleIDs()) {
|
||||
if (id.getCountryCode().equalsIgnoreCase(languageCode)) {
|
||||
if (id.getCountryCode() != null && id.getCountryCode().equalsIgnoreCase(languageCode)) {
|
||||
def = languageCode;
|
||||
break;
|
||||
}
|
||||
|
@ -1,282 +0,0 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import jd.gui.skins.simple.components.JDFileChooser;
|
||||
import jd.nutils.io.JDFileFilter;
|
||||
import jd.nutils.io.JDIO;
|
||||
import jd.parser.Regex;
|
||||
import jd.utils.JDTheme;
|
||||
import jd.utils.JDUtilities;
|
||||
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
import org.jdesktop.swingx.decorator.ColorHighlighter;
|
||||
import org.jdesktop.swingx.decorator.ComponentAdapter;
|
||||
import org.jdesktop.swingx.decorator.HighlightPredicate;
|
||||
import org.jdesktop.swingx.decorator.HighlighterFactory;
|
||||
|
||||
public class ThemeKeys extends JFrame {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ThemeKeys().setVisible(true);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -1906208643728258195L;
|
||||
|
||||
private final boolean highlightReady = false;
|
||||
private final boolean highlightOld = true;
|
||||
private final boolean highlightMissing = true;
|
||||
|
||||
private final String sourceDir = "C:\\Dokumente und Einstellungen\\Towelie\\Eigene Dateien\\Java\\jd\\src\\";
|
||||
|
||||
private final int themeFile = 1;
|
||||
private final ArrayList<String> themes = JDTheme.getThemeIDs();
|
||||
|
||||
private Vector<KeyInfo> themeData = new Vector<KeyInfo>();
|
||||
|
||||
private JXTable table;
|
||||
|
||||
public ThemeKeys() {
|
||||
File folder = new File(sourceDir);
|
||||
if (!folder.exists()) folder = selectFolder();
|
||||
if (folder == null) System.exit(0);
|
||||
|
||||
initThemeData(folder, JDUtilities.getResourceFile(JDTheme.THEME_DIR + themes.get(themeFile) + ".thm"));
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
int columnSize = 100;
|
||||
|
||||
table = new JXTable(new TableModel());
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setAutoStartEditOnKeyStroke(false);
|
||||
table.addHighlighter(HighlighterFactory.createAlternateStriping());
|
||||
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.BLUE));
|
||||
if (highlightReady) table.addHighlighter(new ColorHighlighter(new ReadyPredicate(), Color.GREEN, null));
|
||||
if (highlightOld) table.addHighlighter(new ColorHighlighter(new OldPredicate(), Color.ORANGE, null));
|
||||
if (highlightMissing) table.addHighlighter(new ColorHighlighter(new MissingPredicate(), Color.RED, null));
|
||||
setColumnWidth(table.getColumn(1), columnSize);
|
||||
setColumnWidth(table.getColumn(2), columnSize);
|
||||
|
||||
setTitle(getInfoTitle());
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
add(new JScrollPane(table));
|
||||
setSize(new Dimension(600, 450));
|
||||
setResizable(false);
|
||||
setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
private void setColumnWidth(TableColumn column, int size) {
|
||||
column.setMaxWidth(size);
|
||||
column.setMinWidth(size);
|
||||
column.setPreferredWidth(size);
|
||||
}
|
||||
|
||||
private String getInfoTitle() {
|
||||
int old = 0;
|
||||
int missing = 0;
|
||||
for (KeyInfo ki : themeData) {
|
||||
if (!ki.inSource) ++old;
|
||||
if (!ki.inTheme) ++missing;
|
||||
}
|
||||
return "Theme-Keys (" + themes.get(themeFile) + ") [Alt: " + old + " Fehlend:" + missing + "]";
|
||||
}
|
||||
|
||||
private void initThemeData(File sourceFolder, File themeFile) {
|
||||
Vector<String> sourceEntries = getSourceEntriesFromFolder(sourceFolder);
|
||||
Vector<String> themeEntries = getThemeEntriesFromFile(themeFile);
|
||||
|
||||
themeData.clear();
|
||||
String key;
|
||||
for (int i = sourceEntries.size() - 1; i >= 0; --i) {
|
||||
key = sourceEntries.remove(i);
|
||||
themeData.add(new KeyInfo(key, true, themeEntries.contains(key)));
|
||||
themeEntries.remove(key);
|
||||
}
|
||||
for (int i = themeEntries.size() - 1; i >= 0; --i) {
|
||||
themeData.add(new KeyInfo(themeEntries.remove(i), false, true));
|
||||
}
|
||||
|
||||
Collections.sort(themeData);
|
||||
}
|
||||
|
||||
private Vector<String> getSourceEntriesFromFolder(File sourceFolder) {
|
||||
Vector<String> sourceEntries = new Vector<String>();
|
||||
|
||||
String[] matches;
|
||||
for (File file : getSourceFiles(sourceFolder)) {
|
||||
matches = new Regex(JDIO.getLocalFile(file), "JDTheme[\\s]*\\.(C|II|I|V)[\\s]*\\(\"(.*?)\"[^\\)]*?\\)").getColumn(1);
|
||||
|
||||
for (String match : matches) {
|
||||
match = match.trim();
|
||||
if (sourceEntries.contains(match)) continue;
|
||||
sourceEntries.add(match);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(sourceEntries);
|
||||
|
||||
return sourceEntries;
|
||||
}
|
||||
|
||||
private Vector<String> getThemeEntriesFromFile(File themeFile) {
|
||||
Vector<String> themeEntries = new Vector<String>();
|
||||
|
||||
if (themeFile == null || !themeFile.exists()) {
|
||||
System.out.println("Could not find " + themeFile);
|
||||
return themeEntries;
|
||||
}
|
||||
|
||||
String[] file = Regex.getLines(JDIO.getLocalFile(themeFile));
|
||||
String match;
|
||||
for (String line : file) {
|
||||
match = new Regex(line, "(.*?)=(.*?)").getMatch(0);
|
||||
if (match == null) continue;
|
||||
match = match.trim();
|
||||
if (themeEntries.contains(match)) continue;
|
||||
themeEntries.add(match);
|
||||
}
|
||||
|
||||
Collections.sort(themeEntries);
|
||||
|
||||
return themeEntries;
|
||||
}
|
||||
|
||||
private Vector<File> getSourceFiles(File directory) {
|
||||
Vector<File> files = new Vector<File>();
|
||||
|
||||
for (File file : directory.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(getSourceFiles(file));
|
||||
} else if (file.getName().matches(".*\\.java$")) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private File selectFolder() {
|
||||
JDFileChooser fc = new JDFileChooser();
|
||||
fc.setFileSelectionMode(JDFileChooser.DIRECTORIES_ONLY);
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new JDFileFilter("Ordner der Java-Quelldateien", "", true));
|
||||
|
||||
if (fc.showOpenDialog(this) == JDFileChooser.APPROVE_OPTION) return fc.getSelectedFile();
|
||||
return null;
|
||||
}
|
||||
|
||||
private class KeyInfo implements Comparable<KeyInfo> {
|
||||
|
||||
private String key;
|
||||
|
||||
private boolean inSource;
|
||||
|
||||
private boolean inTheme;
|
||||
|
||||
public KeyInfo(String key, boolean inSource, boolean inTheme) {
|
||||
this.key = key;
|
||||
this.inSource = inSource;
|
||||
this.inTheme = inTheme;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public boolean isInSource() {
|
||||
return this.inSource;
|
||||
}
|
||||
|
||||
public boolean isInTheme() {
|
||||
return this.inTheme;
|
||||
}
|
||||
|
||||
public int compareTo(KeyInfo o) {
|
||||
return this.getKey().compareToIgnoreCase(o.getKey());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public String toString() {
|
||||
return this.getKey() + ": " + isInSource() + " ; " + isInTheme();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ReadyPredicate implements HighlightPredicate {
|
||||
|
||||
public boolean isHighlighted(Component arg0, ComponentAdapter arg1) {
|
||||
return (Boolean) table.getValueAt(arg1.row, 1) && (Boolean) table.getValueAt(arg1.row, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class OldPredicate implements HighlightPredicate {
|
||||
|
||||
public boolean isHighlighted(Component arg0, ComponentAdapter arg1) {
|
||||
return !(Boolean) table.getValueAt(arg1.row, 1) && (Boolean) table.getValueAt(arg1.row, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MissingPredicate implements HighlightPredicate {
|
||||
|
||||
public boolean isHighlighted(Component arg0, ComponentAdapter arg1) {
|
||||
return (Boolean) table.getValueAt(arg1.row, 1) && !(Boolean) table.getValueAt(arg1.row, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class TableModel extends AbstractTableModel {
|
||||
|
||||
private static final long serialVersionUID = 7678245042388067359L;
|
||||
|
||||
private final String[] columns = new String[] { "Key", "In Source?", "In Theme?" };
|
||||
|
||||
//@Override
|
||||
public Class<?> getColumnClass(int col) {
|
||||
if (col == 0) return String.class;
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return columns.length;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return themeData.size();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public String getColumnName(int column) {
|
||||
return columns[column];
|
||||
}
|
||||
|
||||
public Object getValueAt(int row, int column) {
|
||||
switch (column) {
|
||||
case 0:
|
||||
return themeData.get(row).getKey();
|
||||
case 1:
|
||||
return themeData.get(row).isInSource();
|
||||
case 2:
|
||||
return themeData.get(row).isInTheme();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user