Changeset 2145 in josm
- Timestamp:
- 2009-09-16T17:45:50+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r2129 r2145 141 141 : (add.isSelected() ? SearchAction.SearchMode.add 142 142 : (remove.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection)); 143 i f(initialValues instanceof Filter){144 return new Filter(input.getText(), mode, caseSensitive.isSelected(), regexSearch.isSelected());145 } else {146 return new SearchSetting(input.getText(), mode, caseSensitive.isSelected(), regexSearch.isSelected());147 }143 initialValues.text = input.getText(); 144 initialValues.mode = mode; 145 initialValues.caseSensitive = caseSensitive.isSelected(); 146 initialValues.regexSearch = regexSearch.isSelected(); 147 return initialValues; 148 148 } 149 149 … … 179 179 String searchText = s.text; 180 180 if(s instanceof Filter){ 181 searchText = ((Filter)s).inverted ? "-" : "";182 searchText = searchText + "(" + ((Filter)s).text + ")" + (((Filter)s).applyForChildren ? ("| child (" + ((Filter)s).text + ")"): "");181 searchText = "(" + s.text + ")" + (((Filter)s).applyForChildren ? ("| child (" + s.text + ")"): ""); 182 searchText = (((Filter)s).inverted ? "-" : "") + "(" + searchText + ")"; 183 183 } 184 /*System.out.println(searchText); */184 System.out.println(searchText); 185 185 SearchCompiler.Match matcher = SearchCompiler.compile(searchText, s.caseSensitive, s.regexSearch); 186 186 foundMatches = 0; -
trunk/src/org/openstreetmap/josm/data/osm/Filter.java
r2129 r2145 11 11 public class Filter extends SearchSetting { 12 12 private final String version = "1"; 13 public Boolean filtered = false;14 public Boolean disabled = true;13 public Boolean enable = true; 14 public Boolean hide = false; 15 15 public Boolean inverted = false; 16 16 public Boolean applyForChildren = true; … … 34 34 caseSensitive = Boolean.parseBoolean(prfs[3]); 35 35 regexSearch = Boolean.parseBoolean(prfs[4]); 36 filtered= Boolean.parseBoolean(prfs[6]);37 disabled= Boolean.parseBoolean(prfs[7]);36 enable = Boolean.parseBoolean(prfs[6]); 37 hide = Boolean.parseBoolean(prfs[7]); 38 38 inverted = Boolean.parseBoolean(prfs[8]); 39 39 applyForChildren = Boolean.parseBoolean(prfs[9]); … … 44 44 return version + ";" + 45 45 text + ";" + mode + ";" + caseSensitive + ";" + regexSearch + ";" + 46 "legacy" + ";" + filtered + ";" + disabled+ ";" +46 "legacy" + ";" + enable + ";" + hide + ";" + 47 47 inverted + ";" + applyForChildren; 48 48 } -
trunk/src/org/openstreetmap/josm/data/osm/Filters.java
r2129 r2145 21 21 public class Filters extends AbstractTableModel{ 22 22 23 public int disabledCount, hiddenCount; 24 23 25 public Filters(){ 24 26 loadPrefs(); … … 29 31 Collection<OsmPrimitive> seld = new LinkedList<OsmPrimitive> (); 30 32 Collection<OsmPrimitive> self = new LinkedList<OsmPrimitive> (); 33 if(Main.main.getCurrentDataSet() == null)return; 31 34 Main.main.getCurrentDataSet().setFiltered(); 32 35 Main.main.getCurrentDataSet().setDisabled(); 33 36 for (Filter flt : filters){ 34 if(flt.filtered){ 35 SearchAction.getSelection(flt, self, new Function(){ 36 public Boolean isSomething(OsmPrimitive o){ 37 return o.isFiltered(); 38 } 39 }); 40 } 41 if(flt.disabled) { 37 if(flt.enable){ 42 38 SearchAction.getSelection(flt, seld, new Function(){ 43 39 public Boolean isSomething(OsmPrimitive o){ … … 45 41 } 46 42 }); 43 if(flt.hide) { 44 SearchAction.getSelection(flt, self, new Function(){ 45 public Boolean isSomething(OsmPrimitive o){ 46 return o.isFiltered(); 47 } 48 }); 49 } 47 50 } 48 51 } 52 disabledCount = seld.size() - self.size(); 53 hiddenCount = self.size(); 49 54 Main.main.getCurrentDataSet().setFiltered(self); 50 55 Main.main.getCurrentDataSet().setDisabled(seld); … … 134 139 135 140 public String getColumnName(int column){ 136 String[] names = { tr(" F"), tr("D"), tr("Text"), tr("C"), tr("I"), tr("M") };141 String[] names = { tr("E"), tr("H"), tr("Text"), tr("C"), tr("I"), tr("M") }; 137 142 return names[column]; 138 143 } … … 143 148 } 144 149 150 public boolean isCellEnabled(int row, int column){ 151 if(!filters.get(row).enable && column!=0) return false; 152 return true; 153 } 154 145 155 public boolean isCellEditable(int row, int column){ 156 if(!filters.get(row).enable && column!=0) return false; 146 157 if(column < 5)return true; 147 158 return false; … … 151 162 Filter f = filters.get(row); 152 163 switch(column){ 153 case 0: f.filtered = (Boolean)aValue; 154 savePref(row); 155 filter(); 156 return; 157 case 1: f.disabled = (Boolean)aValue; 158 savePref(row); 159 filter(); 160 return; 164 case 0: f.enable = (Boolean)aValue; 165 savePref(row); 166 filter(); 167 fireTableRowsUpdated(row, row); 168 break; 169 case 1: f.hide = (Boolean)aValue; 170 savePref(row); 171 filter(); 172 break; 161 173 case 2: f.text = (String)aValue; 162 174 savePref(row); 163 return;175 break; 164 176 case 3: f.applyForChildren = (Boolean)aValue; 165 177 savePref(row); 166 178 filter(); 167 return;179 break; 168 180 case 4: f.inverted = (Boolean)aValue; 169 181 savePref(row); 170 182 filter(); 171 return; 172 } 183 break; 184 } 185 if(column!=0)fireTableCellUpdated(row, column); 173 186 } 174 187 … … 176 189 Filter f = filters.get(row); 177 190 switch(column){ 178 case 0: return f. filtered;179 case 1: return f. disabled;191 case 0: return f.enable; 192 case 1: return f.hide; 180 193 case 2: return f.text; 181 194 case 3: return f.applyForChildren; -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r2125 r2145 6 6 import static org.openstreetmap.josm.tools.I18n.trn; 7 7 8 import javax.swing.JCheckBox; 8 9 import javax.swing.JPanel; 9 10 import javax.swing.JTable; 10 11 import javax.swing.table.JTableHeader; 12 import javax.swing.table.DefaultTableCellRenderer; 13 import javax.swing.event.TableModelListener; 14 import javax.swing.event.TableModelEvent; 15 import javax.swing.table.TableCellRenderer; 11 16 import javax.swing.ListSelectionModel; 12 17 import javax.swing.JPopupMenu; 13 import javax.swing.table.AbstractTableModel;14 18 import javax.swing.JScrollPane; 15 19 20 import java.awt.Component; 16 21 import java.awt.FlowLayout; 17 22 import java.awt.BorderLayout; … … 38 43 * @author Petr_Dlouhý 39 44 */ 40 public class FilterDialog extends ToggleDialog implements DataChangeListener, LayerChangeListener {45 public class FilterDialog extends ToggleDialog implements DataChangeListener, LayerChangeListener, TableModelListener { 41 46 private JTable userTable; 42 47 private Filters filters = new Filters(); … … 121 126 122 127 protected String[] columnToolTips = { 123 tr("Filter elements"), 124 tr("Disable elements"), 128 tr("Enable filter"), 129 tr("Hide elements"), 130 null, 125 131 tr("Apply also for children"), 126 132 tr("Inverse filter"), 127 null,128 133 tr("Filter mode") 129 134 }; … … 145 150 } 146 151 }; 147 152 153 filters.addTableModelListener(this); 154 148 155 userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 149 156 … … 160 167 userTable.getColumnModel().getColumn(5).setResizable(false); 161 168 169 userTable.setDefaultRenderer(Boolean.class, new BooleanRenderer()); 170 userTable.setDefaultRenderer(String.class, new StringRenderer()); 171 172 tableChanged(null); 173 162 174 pnl.add(new JScrollPane(userTable), BorderLayout.CENTER); 163 175 … … 187 199 filters.filter(); 188 200 } 201 202 class StringRenderer extends DefaultTableCellRenderer { 203 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 204 Filters model = (Filters)table.getModel(); 205 Component cell = (Component)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 206 cell.setEnabled(model.isCellEnabled(row, column)); 207 return cell; 208 } 209 } 210 211 class BooleanRenderer extends JCheckBox implements TableCellRenderer { 212 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 213 Filters model = (Filters)table.getModel(); 214 setSelected((Boolean)value); 215 setEnabled(model.isCellEnabled(row, column)); 216 setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 217 return this; 218 } 219 } 220 221 public void tableChanged(TableModelEvent e){ 222 setTitle("Filter Hidden:" + filters.hiddenCount + " Disabled:" + filters.disabledCount); 223 } 189 224 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2120 r2145 750 750 if (Main.main.getCurrentDataSet() != null) { 751 751 for (Relation r : Main.main.getCurrentDataSet().relations) { 752 if (!r.isFiltered() && r.isUsable()) {752 if (!r.isFiltered() && !r.incomplete && !r.isDeleted()) { 753 753 for (RelationMember m : r.getMembers()) { 754 754 if (newSelection.contains(m.getMember())) {
Note:
See TracChangeset
for help on using the changeset viewer.