Skip to content

Commit

Permalink
reformat src (no functional change)
Browse files Browse the repository at this point in the history
  • Loading branch information
homebeaver committed Oct 31, 2022
1 parent bead5bb commit fc60f67
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 69 deletions.
18 changes: 6 additions & 12 deletions swingx-core/src/main/java/org/jdesktop/swingx/JXSearchField.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ public enum SearchMode {
* </p>
* <p>
* The find button can have a rollover and a pressed icon, defined by
* the "SearchField.rolloverIcon" and "SearchField.pressedIcon" UI
* properties. When a find popup menu is set,
* "SearchField.popupRolloverIcon" and "SearchField.popupPressedIcon"
* are used.
* the "SearchField.rolloverIcon" and "SearchField.pressedIcon" UI properties.
* When a find popup menu is set, "SearchField.popupRolloverIcon"
* and "SearchField.popupPressedIcon" are used.
* </p>
*
*/
Expand Down Expand Up @@ -505,8 +504,7 @@ public boolean isUseSeperatePopupButton() {
}

/**
* Set if the popup button should be used for displaying the find popup
* menu.
* Set if the popup button should be used for displaying the find popup menu.
*
* @param useSeperatePopupButton
*/
Expand Down Expand Up @@ -606,8 +604,6 @@ public JPopupMenu getFindPopupMenu() {
}

/**
* TODO
*
* @return
*/
public final boolean isManagingRecentSearches() {
Expand Down Expand Up @@ -645,8 +641,8 @@ public void setRecentSearchesSaveKey(String recentSearchesSaveKey) {
this.recentSearchesSaveKey = recentSearchesSaveKey;

if (recentSearches != null) {
// set null before uninstalling. otherwise the popup menu is not
// allowed to be changed.
// set null before uninstalling.
// otherwise the popup menu is not allowed to be changed.
RecentSearches rs = recentSearches;
recentSearches = null;
rs.uninstall(this);
Expand All @@ -661,8 +657,6 @@ public void setRecentSearchesSaveKey(String recentSearchesSaveKey) {
}

/**
* TODO
*
* @return
*/
public RecentSearches getRecentSearches() {
Expand Down
28 changes: 9 additions & 19 deletions swingx-core/src/main/java/org/jdesktop/swingx/JXSearchPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
* }
* </pre>
* <p>
* TODO: allow custom PatternModel and/or access to configuration of bound
* PatternModel.
* TODO: allow custom PatternModel and/or access to configuration of bound PatternModel.
* </p>
* <p>
* TODO: fully support control of multiple PatternMatchers.
Expand All @@ -73,6 +72,7 @@
* @author Ramesh Gupta
* @author Jeanette Winzenburg
*/
@SuppressWarnings("serial")
@JavaBean
public class JXSearchPanel extends AbstractPatternPanel {
/**
Expand Down Expand Up @@ -172,8 +172,7 @@ protected void updateFieldName(PatternMatcher matcher) {
@Override
public void match() {
for (Iterator<PatternMatcher> iter = getPatternMatchers().iterator(); iter.hasNext();) {
iter.next().setPattern(getPattern());

iter.next().setPattern(getPattern());
}
}

Expand All @@ -185,8 +184,7 @@ public void match() {
* No need to ever call directly.
*/
public void updateMatchRule() {
getPatternModel().setMatchRule(
(String) searchCriteria.getSelectedItem());
getPatternModel().setMatchRule( (String) searchCriteria.getSelectedItem() );
}

private List<PatternMatcher> getPatternMatchers() {
Expand Down Expand Up @@ -222,22 +220,16 @@ protected void bind() {
model.setSelectedItem(getPatternModel().getMatchRule());
searchCriteria.setModel(model);
searchCriteria.setAction(getAction(MATCH_RULE_ACTION_COMMAND));
searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(getLocale())));

searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(getLocale())));
}


private StringValue createStringValue(Locale locale) {
// TODO Auto-generated method stub
Map<Object, String> keys = new HashMap<Object, String>();
keys.put(PatternModel.MATCH_RULE_CONTAINS,
PatternModel.MATCH_RULE_CONTAINS);
keys.put(PatternModel.MATCH_RULE_ENDSWITH,
PatternModel.MATCH_RULE_ENDSWITH);
keys.put(PatternModel.MATCH_RULE_EQUALS,
PatternModel.MATCH_RULE_EQUALS);
keys.put(PatternModel.MATCH_RULE_STARTSWITH,
PatternModel.MATCH_RULE_STARTSWITH);
keys.put(PatternModel.MATCH_RULE_CONTAINS, PatternModel.MATCH_RULE_CONTAINS);
keys.put(PatternModel.MATCH_RULE_ENDSWITH, PatternModel.MATCH_RULE_ENDSWITH);
keys.put(PatternModel.MATCH_RULE_EQUALS, PatternModel.MATCH_RULE_EQUALS);
keys.put(PatternModel.MATCH_RULE_STARTSWITH, PatternModel.MATCH_RULE_STARTSWITH);
return new LocalizableStringValue(keys, PatternModel.SEARCH_PREFIX, locale);
}

Expand All @@ -246,7 +238,6 @@ private StringValue createStringValue(Locale locale) {
*/
@Override
protected void updateLocaleState(Locale locale) {
// TODO Auto-generated method stub
super.updateLocaleState(locale);
searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(locale)));
}
Expand Down Expand Up @@ -274,5 +265,4 @@ protected void initComponents() {
searchCriteria = new JXComboBox();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,9 @@ protected void installDefaults() {

popupButton().setIcon(getNewIcon(popupButton().getIcon(), "SearchField.popupIcon"));
popupButton().setRolloverIcon(
getNewIcon(popupButton().getRolloverIcon(),
"SearchField.popupRolloverIcon"));
getNewIcon(popupButton().getRolloverIcon(), "SearchField.popupRolloverIcon"));
popupButton().setPressedIcon(
getNewIcon(popupButton().getPressedIcon(),
"SearchField.popupPressedIcon"));
getNewIcon(popupButton().getPressedIcon(), "SearchField.popupPressedIcon"));
}

/**
Expand Down Expand Up @@ -330,8 +328,7 @@ protected final JButton popupButton() {
* @return the popup button is used in addition to the search button
*/
public boolean usingSeperatePopupButton() {
return searchField.isUseSeperatePopupButton()
&& searchField.getFindPopupMenu() != null;
return searchField.isUseSeperatePopupButton() && searchField.getFindPopupMenu() != null;
}

/**
Expand Down Expand Up @@ -359,28 +356,20 @@ protected int getPopupOffset() {
*/
protected void updateButtons() {
clearButton().setVisible(
(!searchField.isRegularSearchMode() || searchField
.isMacLayoutStyle())
&& hasText());
(!searchField.isRegularSearchMode() || searchField.isMacLayoutStyle()) && hasText());

boolean clearNotHere = (searchField.isMacLayoutStyle() || !clearButton()
.isVisible());
boolean clearNotHere = (searchField.isMacLayoutStyle() || !clearButton().isVisible());

searchButton()
.setVisible(
(searchField.getFindPopupMenu() == null || usingSeperatePopupButton())
&& clearNotHere);
searchButton().setVisible(
(searchField.getFindPopupMenu() == null || usingSeperatePopupButton()) && clearNotHere);
popupButton().setVisible(
searchField.getFindPopupMenu() != null
&& (clearNotHere || usingSeperatePopupButton()));
searchField.getFindPopupMenu() != null && (clearNotHere || usingSeperatePopupButton()));

if (searchField.isRegularSearchMode()) {
searchButton().setRolloverIcon(
getNewIcon(searchButton().getRolloverIcon(),
"SearchField.rolloverIcon"));
getNewIcon(searchButton().getRolloverIcon(), "SearchField.rolloverIcon"));
searchButton().setPressedIcon(
getNewIcon(searchButton().getPressedIcon(),
"SearchField.pressedIcon"));
getNewIcon(searchButton().getPressedIcon(), "SearchField.pressedIcon"));
} else {
// no action, therefore no rollover icon.
if (shouldReplaceResource(searchButton().getRolloverIcon())) {
Expand All @@ -393,12 +382,10 @@ protected void updateButtons() {
}

private boolean hasText() {
return searchField.getText() != null
&& searchField.getText().length() > 0;
return searchField.getText() != null && searchField.getText().length() > 0;
}

class Handler implements PropertyChangeListener, ActionListener,
DocumentListener {
class Handler implements PropertyChangeListener, ActionListener, DocumentListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
Expand Down Expand Up @@ -435,8 +422,7 @@ public void actionPerformed(ActionEvent e) {
: (Component) e.getSource();

Rectangle r = SwingUtilities.getLocalBounds(src);
int popupWidth = searchField.getFindPopupMenu()
.getPreferredSize().width;
int popupWidth = searchField.getFindPopupMenu().getPreferredSize().width;
int x = searchField.isVistaLayoutStyle()
|| usingSeperatePopupButton() ? r.x + r.width
- popupWidth : r.x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
public class BuddyButton extends JButton {

/** TODO doc */
public BuddyButton() {
this(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public LocalizableStringValue(Map<Object, String> lookup, String prefix) {
* @param locale the locale to lookup the localized strings, may be null to
* denote using JComponent.defaultLocale
*/
public LocalizableStringValue(Map<Object, String> lookup, String prefix,
Locale locale) {
public LocalizableStringValue(Map<Object, String> lookup, String prefix, Locale locale) {
this.lookup = Contract.asNotNull(lookup, "map must not be null");
this.prefix = prefix;
setLocale(locale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.jdesktop.swingx.util.OS;

/**
* TODO: comment
* NativeSearchFieldSupport for Mac
*
* @author Peter Weishapl petw@gmx.net
*/
Expand All @@ -38,15 +38,13 @@ public static boolean isNativeSearchFieldSupported() {
return OS.isMacOSX() && Float.parseFloat(versionString) >= 10.5
&& UIManager.getLookAndFeel().getName().equals("Mac OS X");
} catch (Exception e) {
// in case the os.version cannot be parsed, we are surely not
// running mac os x.
// in case the os.version cannot be parsed, we are surely not running mac os x.
return false;
}
}

public static void setSearchField(JTextField txt, boolean isSearchField) {
// Leopard Hack: ensure property change event is triggered, if nothing
// changes.
// Leopard Hack: ensure property change event is triggered, if nothing changes.
if (isSearchField == isSearchField(txt)) {
txt.putClientProperty(MAC_TEXT_FIELD_VARIANT_PROPERTY, "_triggerevent_");
} else if (isSearchField) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.AccessControlException;
import java.security.AccessControlException; // deprecated
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -68,8 +68,7 @@ public RecentSearches(Preferences prefs, String saveName) {
try {
prefs = Preferences.userRoot();
} catch (AccessControlException ace) {
// disable persistency, if we aren't allowed to access
// preferences.
// disable persistency, if we aren't allowed to access preferences.
Logger.getLogger(getClass().getName()).warning("cannot acces preferences. persistency disabled.");
}
}
Expand Down

0 comments on commit fc60f67

Please sign in to comment.