java source code formatting

This commit is contained in:
honfika
2014-06-22 09:52:54 +02:00
parent 38335ec2e4
commit 6e7e92ddf2
63 changed files with 3160 additions and 3196 deletions

View File

@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Color;
@@ -46,30 +45,29 @@ import jsyntaxpane.components.Markers;
* @author JPEXS
*/
public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpane.actions.QuickFindHandler {
public JTextField findTextField;
public JButton prevButton,nextButton;
public JCheckBox ignoreCaseCheckbox,regExpCheckbox,wrapCheckbox;
public JButton prevButton, nextButton;
public JCheckBox ignoreCaseCheckbox, regExpCheckbox, wrapCheckbox;
public JLabel statusLabel;
private final Markers.SimpleMarker marker = new Markers.SimpleMarker(Color.PINK);
private WeakReference<JTextComponent> target;
private WeakReference<DocumentSearchData> dsd;
private int oldCaretPosition;
public QuickFindPanel(){
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
private WeakReference<JTextComponent> target;
private WeakReference<DocumentSearchData> dsd;
private int oldCaretPosition;
public QuickFindPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
JPanel pan1 = new JPanel(new WrapLayout());
JPanel pan2 = new JPanel(new WrapLayout());
pan1.setAlignmentX(0);
pan2.setAlignmentX(0);
pan1.setAlignmentY(0);
pan2.setAlignmentY(0);
JLabel jLabel1 = new javax.swing.JLabel();
findTextField = new javax.swing.JTextField();
prevButton = new javax.swing.JButton();
@@ -78,21 +76,20 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
regExpCheckbox = new javax.swing.JCheckBox();
wrapCheckbox = new javax.swing.JCheckBox();
statusLabel = new javax.swing.JLabel();
setName("QuickFindDialog"); // NOI18N
jLabel1.setLabelFor(findTextField);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N
jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); // NOI18N
pan1.add(jLabel1);
findTextField.setColumns(30);
findTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
findTextField.setMaximumSize(new java.awt.Dimension(200, 24));
findTextField.setMinimumSize(new java.awt.Dimension(60, 24));
pan1.add(findTextField);
prevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); // NOI18N
prevButton.setFocusable(false);
prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@@ -136,124 +133,117 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
pan2.add(wrapCheckbox);
wrapCheckbox.addActionListener(this);
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize()-2));
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize() - 2));
statusLabel.setForeground(java.awt.Color.red);
pan2.add(statusLabel);
add(pan1);
add(pan2);
setPreferredSize(getMinimumSize());
setVisible(false);
setVisible(false);
}
@Override
public void actionPerformed(ActionEvent e) {
switch(e.getActionCommand()){
switch (e.getActionCommand()) {
case "PREVIOUS":
if (dsd.get().doFindPrev(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
break;
case "NEXT":
if (dsd.get().doFindNext(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
break;
}
}
@Override
public void showQuickFind(final JTextComponent t,DocumentSearchData ds) {
public void showQuickFind(final JTextComponent t, DocumentSearchData ds) {
dsd = new WeakReference<DocumentSearchData>(ds);
oldCaretPosition = t.getCaretPosition();
Container view = t.getParent();
Dimension wd = getSize();
wd.width = t.getVisibleRect().width;
Point loc = new Point(0, view.getHeight());
setSize(wd);
SwingUtilities.convertPointToScreen(loc, view);
setLocation(loc);
findTextField.setFont(t.getFont());
final DocumentListener dl;
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
Container view = t.getParent();
Dimension wd = getSize();
wd.width = t.getVisibleRect().width;
Point loc = new Point(0, view.getHeight());
setSize(wd);
SwingUtilities.convertPointToScreen(loc, view);
setLocation(loc);
findTextField.setFont(t.getFont());
final DocumentListener dl;
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updateFind();
}
public void insertUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateFind();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateFind();
}
private void updateFind() {
JTextComponent t = target.get();
DocumentSearchData d = dsd.get();
String toFind = findTextField.getText();
if (toFind == null || toFind.isEmpty()) {
statusLabel.setText(null);
return;
}
try {
d.setWrap(wrapCheckbox.isSelected());
d.setPattern(toFind,
regExpCheckbox.isSelected(),
ignoreCaseCheckbox.isSelected());
// The dsd doFindNext will always find from current pos,
// so we need to relocate to our saved pos before we call doFindNext
statusLabel.setText(null);
t.setCaretPosition(oldCaretPosition);
if (!d.doFindNext(t)) {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
} else {
statusLabel.setText(null);
}
} catch (PatternSyntaxException e) {
statusLabel.setText(e.getDescription());
}
private void updateFind() {
JTextComponent t = target.get();
DocumentSearchData d = dsd.get();
String toFind = findTextField.getText();
if (toFind == null || toFind.isEmpty()) {
statusLabel.setText(null);
return;
}
try {
d.setWrap(wrapCheckbox.isSelected());
d.setPattern(toFind,
regExpCheckbox.isSelected(),
ignoreCaseCheckbox.isSelected());
// The dsd doFindNext will always find from current pos,
// so we need to relocate to our saved pos before we call doFindNext
statusLabel.setText(null);
t.setCaretPosition(oldCaretPosition);
if (!d.doFindNext(t)) {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
} else {
statusLabel.setText(null);
}
} catch (PatternSyntaxException e) {
statusLabel.setText(e.getDescription());
}
}
});
this.target = new WeakReference<>(t);
Pattern p = dsd.get().getPattern();
if (p != null) {
findTextField.setText(p.pattern());
}
});
this.target = new WeakReference<>(t);
Pattern p = dsd.get().getPattern();
if (p != null) {
findTextField.setText(p.pattern());
}
wrapCheckbox.setSelected(dsd.get().isWrap());
setVisible(true);
wrapCheckbox.setSelected(dsd.get().isWrap());
setVisible(true);
getParent().revalidate();
getParent().repaint();
getParent().repaint();
findTextField.requestFocusInWindow();
}
/*
@Override
public void focusGained(FocusEvent e) {
/*
@Override
public void focusGained(FocusEvent e) {
}
}
@Override
public void focusLost(FocusEvent e) {
removeFocusListener(this);
setVisible(false);
getParent().revalidate();
getParent().repaint();
}*/
@Override
public void focusLost(FocusEvent e) {
removeFocusListener(this);
setVisible(false);
getParent().revalidate();
getParent().repaint();
}*/
}