Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Wednesday, March 02, 2005

Re: [jump-users] flash selected row

Hi Erwan -

BeanShell to the rescue!

1. Select some features using the Select Tool.
2. Click View > BeanShell to open the BeanShell window.
3. Paste the code below into the BeanShell window using [Ctrl]+V, then
press Enter. Presto! The rows are selected in the attribute table. In
fact, it even works if there are multiple task windows and multiple
attribute tables!

{
void visitDescendants(container, visitor) {
children = new ArrayList();
children.addAll(Arrays.asList(container.getComponents()));
if (container instanceof Window) {
children.addAll(Arrays.asList(container.getOwnedWindows()));
}
for (child : children) {
if (visitor.yield(child) == Boolean.TRUE) {
return;
}
if (child instanceof Container) {
if (visitDescendants(child, visitor) == Boolean.TRUE) {
return;
}
}
}
}
selectedFeatures = new HashSet();
layerViewPanelVisitor = new Block(){
public Object yield(Object child) {
import com.vividsolutions.jump.workbench.ui.LayerViewPanel;
if (child instanceof LayerViewPanel) {
selectedFeatures.addAll(child.getSelectionManager()
.getFeaturesWithSelectedItems());
}
return Boolean.FALSE;
}
};
visitDescendants(wc.getWorkbench().getFrame(), layerViewPanelVisitor);
void select(table) {
import com.vividsolutions.jump.workbench.ui.LayerTableModel;
if (!(table.getModel() instanceof LayerTableModel)) {
return;
}
table.clearSelection();
for (int i = 0; i < table.getModel().getRowCount(); i++) {
if (selectedFeatures.contains(table.getModel().getFeature(i))) {
table.addRowSelectionInterval(i, i);
}
}
}
tableVisitor = new Block(){
public Object yield(Object child) {
if (child instanceof JTable) {
select(child);
}
return Boolean.FALSE;
}
};
visitDescendants(wc.getWorkbench().getFrame(), tableVisitor);
}

On Wed, 02 Mar 2005 20:39:38 +0100, BOCHER wrote:
> Hi all,
>
> When I select a feature polygon or linestring in task, I'd like the row
> to be select ("flash-selected-row") in the attributs table. Do you know
> a simple way to do it ?
>
> Cheers
>
> R1.

0 Comments:

Post a Comment

<< Home