Example usage for org.eclipse.jface.viewers IStructuredSelection toList

List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection toList.

Prototype

public List toList();

Source Link

Document

Returns the elements in this selection as a List.

Usage

From source file:eu.esdihumboldt.hale.ui.views.styledmap.StyledMapUtil.java

License:Open Source License

/**
 * Zoom to the selected instances. Does nothing if the selection is empty or
 * contains no {@link Instance}s or {@link InstanceReference}s.
 * //from   w ww  . j a v  a  2s. c  om
 * @param mapKit the map kit
 * @param selection the selection
 */
public static void zoomToSelection(BasicMapKit mapKit, IStructuredSelection selection) {
    BoundingBox bb = null;

    // determine bounding box for each reference and accumulate it
    for (AbstractInstancePainter painter : mapKit.getTilePainters(AbstractInstancePainter.class)) {
        for (Object element : selection.toList()) {
            InstanceReference ref = getReference(element);
            if (ref != null) {
                InstanceWaypoint wp = painter.findWaypoint(ref);
                if (wp != null) {
                    BoundingBox wpBB = wp.getBoundingBox();
                    if (wpBB.checkIntegrity() && !wpBB.isEmpty()) {
                        if (bb == null) {
                            bb = new BoundingBox(wpBB);
                        } else {
                            bb.add(wpBB);
                        }
                    }
                }
            }
        }
    }

    if (bb != null) {
        Set<GeoPosition> positions = new HashSet<GeoPosition>();
        positions.add(new GeoPosition(bb.getMinX(), bb.getMinY(), SelectableWaypoint.COMMON_EPSG));
        positions.add(new GeoPosition(bb.getMaxX(), bb.getMaxY(), SelectableWaypoint.COMMON_EPSG));
        mapKit.zoomToPositions(positions);
    }
}

From source file:eu.geclipse.aws.ec2.ui.actions.AbstractSecurityGroupAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.securityGroupList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;

        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2SecurityGroup) {
                EC2SecurityGroup securityGroup = (EC2SecurityGroup) element;
                this.securityGroupList.add(securityGroup);
            }//ww  w. j av  a  2 s  . c  om
        }
    }
    if ((getEnablementCount() ^ AbstractSecurityGroupAction.ENABLE_FOR_ONE) == 0
            && this.securityGroupList.size() == 1) {
        enable = true;
    } else if ((getEnablementCount() ^ AbstractSecurityGroupAction.ENABLE_FOR_MANY) == 0
            && this.securityGroupList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);

}

From source file:eu.geclipse.aws.ec2.ui.actions.AssociateElasticIPAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.instanceList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2Instance) {
                EC2Instance ec2Instance = (EC2Instance) element;
                this.instanceList.add(ec2Instance);
            }//from   www  . j  a va 2s  . com
        }
    }
    if (this.instanceList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);
}

From source file:eu.geclipse.aws.ec2.ui.actions.CreateConnectionInstance.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.instanceList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2Instance) {
                EC2Instance ec2Instance = (EC2Instance) element;
                this.instanceList.add(ec2Instance);
            }//from w w  w.j a  va 2  s .com
        }
    }
    if (this.instanceList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);

}

From source file:eu.geclipse.aws.ec2.ui.actions.DeleteKeypairAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.keypairList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2Keypair) {
                EC2Keypair ec2Keypair = (EC2Keypair) element;
                this.keypairList.add(ec2Keypair);
            }/*from   w ww.j  a v a2  s .  co  m*/
        }
    }
    if (this.keypairList.size() == 1) {
        enable = true;
    }
    action.setEnabled(enable);
}

From source file:eu.geclipse.aws.ec2.ui.actions.EditAMIAttributesAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.amiList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2AMIImage) {
                EC2AMIImage ami = (EC2AMIImage) element;
                this.amiList.add(ami);
            }/* ww w  .  j  a  v  a2  s .com*/
        }
    }
    if (this.amiList.size() == 1) {
        enable = true;
        extractAWSVoFromGridElement(this.amiList.get(0));
    }
    action.setEnabled(enable);

}

From source file:eu.geclipse.aws.ec2.ui.actions.LaunchAMI.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.amiList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;

        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2AMIImage) {
                EC2AMIImage amiImage = (EC2AMIImage) element;
                this.amiList.add(amiImage);
            }//  w  w  w . ja va 2 s . c  o  m
        }
    }
    if (this.amiList.size() == 1) {
        enable = true;
    }
    action.setEnabled(enable);
}

From source file:eu.geclipse.aws.ec2.ui.actions.RegisterImageAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.connectionElementList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof IGridConnectionElement) {
                IGridConnectionElement connElem = (IGridConnectionElement) element;
                this.connectionElementList.add(connElem);
            }/* w  ww  . j a v a  2  s.c  o  m*/
        }
    }
    if (this.connectionElementList.size() == 1) {
        enable = true;
    }
    action.setEnabled(enable);

}

From source file:eu.geclipse.aws.ec2.ui.actions.ReleaseElasticIPAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    boolean enable = false;
    this.elasticIPList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2ElasticIPAddress) {
                EC2ElasticIPAddress elasticIp = (EC2ElasticIPAddress) element;
                this.elasticIPList.add(elasticIp);
            }// ww w  .  j a v  a  2  s . c  o  m
        }
    }
    if (this.elasticIPList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);
}

From source file:eu.geclipse.aws.s3.ui.actions.DeleteBucketAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    extractAWSVoFromCategory(selection);

    boolean enable = false;
    this.bucketList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof S3BucketStorage) {
                S3BucketStorage bucket = (S3BucketStorage) element;
                this.bucketList.add(bucket);
            }/* w w w  .j  a  v  a 2s. c o  m*/
        }
    }
    if (this.bucketList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);
}