25 |
* |
* |
26 |
* Contributors: |
* Contributors: |
27 |
* Martin O. J. Schmitz - initial API and implementation |
* Martin O. J. Schmitz - initial API and implementation |
28 |
* Stefan A. Krüger - additional utility classes |
* Stefan A. Tzeggai - additional utility classes |
29 |
******************************************************************************/ |
******************************************************************************/ |
30 |
/* |
/* |
31 |
* SearchMapDialog.java |
* SearchMapDialog.java |
37 |
|
|
38 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
39 |
import java.awt.Cursor; |
import java.awt.Cursor; |
|
import java.awt.FlowLayout; |
|
40 |
import java.awt.Point; |
import java.awt.Point; |
41 |
import java.awt.Window; |
import java.awt.Window; |
42 |
import java.awt.event.KeyAdapter; |
import java.awt.event.KeyAdapter; |
54 |
import javax.swing.ListSelectionModel; |
import javax.swing.ListSelectionModel; |
55 |
import javax.swing.SwingWorker; |
import javax.swing.SwingWorker; |
56 |
|
|
57 |
|
import net.miginfocom.swing.MigLayout; |
58 |
|
|
59 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
|
import org.geotools.gui.swing.ExceptionMonitor; |
|
|
import org.geotools.gui.swing.JMapPane; |
|
60 |
|
|
61 |
|
import schmitzm.geotools.gui.SelectableXMapPane; |
62 |
|
import schmitzm.swing.ExceptionDialog; |
63 |
import schmitzm.swing.SortableJTable; |
import schmitzm.swing.SortableJTable; |
64 |
import schmitzm.swing.SwingUtil; |
import schmitzm.swing.SwingUtil; |
65 |
|
|
83 |
searchTextField.setText(text); |
searchTextField.setText(text); |
84 |
} |
} |
85 |
|
|
86 |
private final JMapPane mapPane; |
private final SelectableXMapPane mapPane; |
87 |
|
|
88 |
/** |
/** |
89 |
* The dialog will be relative to the {@link JMapPane}s parent |
* The dialog will be relative to the {@link SelectableXMapPane}s parent |
90 |
* {@link Window}. |
* {@link Window}. |
91 |
* |
* |
92 |
* @param parent |
* @param parent |
95 |
* @param windowTitle |
* @param windowTitle |
96 |
* A title to be used for the dialog. |
* A title to be used for the dialog. |
97 |
*/ |
*/ |
98 |
public SearchMapDialog(LabelSearch labelSearch, JMapPane mapPane, |
public SearchMapDialog(LabelSearch labelSearch, SelectableXMapPane mapPane, |
99 |
final String windowTitle) { |
final String windowTitle) { |
100 |
super(SwingUtil.getParentWindow(mapPane), windowTitle); |
super(SwingUtil.getParentWindow(mapPane), windowTitle); |
101 |
this.labelSearch = labelSearch; |
this.labelSearch = labelSearch; |
126 |
|
|
127 |
private void initialize() { |
private void initialize() { |
128 |
|
|
129 |
JPanel cp = new JPanel(new BorderLayout()); |
JPanel cp = new JPanel(new MigLayout("wrap 1","[grow]","[][][grow]")); |
130 |
|
|
131 |
JLabel label = new JLabel(LabelSearch.R("SearchMapDialog.searchString.Label")); |
JLabel label = new JLabel(LabelSearch.R("SearchMapDialog.searchString.Label")); |
132 |
label.setLabelFor(searchTextField); |
label.setLabelFor(searchTextField); |
133 |
searchTextField.setToolTipText(LabelSearch.R("SearchMapDialog.searchString.tt")); |
searchTextField.setToolTipText(LabelSearch.R("SearchMapDialog.searchString.tt")); |
|
|
|
134 |
searchTextField.addKeyListener(keyListenerStartSearch); |
searchTextField.addKeyListener(keyListenerStartSearch); |
|
|
|
135 |
// Pressing ESC disposes the Dialog |
// Pressing ESC disposes the Dialog |
136 |
searchTextField.addKeyListener(keyEscDispose); |
searchTextField.addKeyListener(keyEscDispose); |
137 |
|
cp.add(label, "split 2"); |
138 |
|
cp.add(searchTextField); |
139 |
|
|
140 |
|
cp.add(new JLabel(LabelSearch.R("SearchMapDialog.Explanation"))); |
141 |
|
|
142 |
|
cp.add(scrollPane); |
143 |
|
|
|
JPanel upper = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
|
upper.add(label); |
|
|
upper.add(searchTextField); |
|
|
|
|
|
cp.add(upper, BorderLayout.NORTH); |
|
|
|
|
|
SwingUtil.setPreferredHeight(scrollPane, 0); |
|
|
SwingUtil.setMaximumHeight(scrollPane, 0); |
|
144 |
cp.add(scrollPane, BorderLayout.SOUTH); |
cp.add(scrollPane, BorderLayout.SOUTH); |
145 |
|
|
146 |
cp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
cp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
157 |
} |
} |
158 |
|
|
159 |
/** |
/** |
160 |
* Performes a search on the {@link JMapPane}'s labels and outputs the |
* Performes a search on the {@link SelectableXMapPane}'s labels and outputs the |
161 |
* possible numerouse results. |
* possible numerouse results. |
162 |
* |
* |
163 |
* @param text |
* @param text |
185 |
showMultipleResults(get()); |
showMultipleResults(get()); |
186 |
} catch (InterruptedException e) { |
} catch (InterruptedException e) { |
187 |
LOGGER.error(e); |
LOGGER.error(e); |
188 |
ExceptionMonitor.show(SearchMapDialog.this, e); |
ExceptionDialog.show(SearchMapDialog.this, e); |
189 |
} catch (ExecutionException e) { |
} catch (ExecutionException e) { |
190 |
LOGGER.error(e); |
LOGGER.error(e); |
191 |
ExceptionMonitor.show(SearchMapDialog.this, e); |
ExceptionDialog.show(SearchMapDialog.this, e); |
192 |
} |
} |
193 |
} |
} |
194 |
}; |
}; |