@Override public Action createContextAwareInstance(Lookup actionContext) { return new CreateVectorDataNodeAction(actionContext); }
@Override public void actionPerformed(ActionEvent e) { action.actionPerformed(e); } }
public static VectorDataNode createDefaultVectorDataNode(Product product) { return createDefaultVectorDataNode(product, getDefaultVectorDataNodeName(), "Default vector data container for geometries (automatically created)"); }
public CreateVectorDataNodeAction(Lookup lkp) { super(Bundle.CTL_CreateVectorDataNodeActionText()); this.lkp = lkp; result = this.lkp.lookupResult(ProductNode.class); result.addLookupListener(WeakListeners.create(LookupListener.class, this, result)); putValue(Action.LARGE_ICON_KEY, ImageUtilities.loadImageIcon("org/esa/snap/rcp/icons/NewVectorDataNode16.gif", false)); putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/esa/snap/rcp/icons/NewVectorDataNode24.gif", false)); setEnabled(false); }
@Override public void resultChanged(LookupEvent ev) { ProductNode productNode = SnapApp.getDefault().getSelectedProductNode(SnapApp.SelectionSourceHint.VIEW); setEnabled(productNode != null); }
VectorDataNode vectorDataNode = CreateVectorDataNodeAction.createDefaultVectorDataNode(productSceneView.getProduct()); LayerFilter nodeFilter = VectorDataLayerFilterFactory.createNodeFilter(vectorDataNode); productSceneView.getVectorDataCollectionLayer(true);
private DialogData(ProductNodeGroup<VectorDataNode> vectorGroup) { String defaultPrefix = getDefaultVectorDataNodeName() + "_"; name = defaultPrefix + (numItems++); while (vectorGroup.contains(name)) { name = defaultPrefix + (numItems++); } description = ""; } }
public static VectorDataNode createDefaultVectorDataNode(Product product, String name, String description) { CoordinateReferenceSystem modelCrs = product.getSceneCRS(); SimpleFeatureType type = PlainFeatureFactory.createDefaultFeatureType(modelCrs); VectorDataNode vectorDataNode = new VectorDataNode(name, type); vectorDataNode.setDescription(description); product.getVectorDataGroup().add(vectorDataNode); vectorDataNode.getPlacemarkGroup(); String oldLayerId = selectVectorDataLayer(vectorDataNode); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(new UndoableVectorDataNodeInsertion(product, vectorDataNode, oldLayerId)); } return vectorDataNode; }
@Override void updateState() { final boolean enabled = SnapApp.getDefault().getSelectedProduct(VIEW) != null; action.setEnabled(enabled); setEnabled(enabled); }
@Override public void actionPerformed(ActionEvent e) { ProductNode productNode = SnapApp.getDefault().getSelectedProductNode(SnapApp.SelectionSourceHint.VIEW); if (productNode == null) { return; } Product product = productNode.getProduct(); if (product != null) { DialogData dialogData = new DialogData(product.getVectorDataGroup()); PropertySet propertySet = PropertyContainer.createObjectBacked(dialogData); propertySet.getDescriptor("name").setNotNull(true); propertySet.getDescriptor("name").setNotEmpty(true); propertySet.getDescriptor("name").setValidator(new NameValidator(product)); propertySet.getDescriptor("description").setNotNull(true); final PropertyPane propertyPane = new PropertyPane(propertySet); JPanel panel = propertyPane.createPanel(); panel.setPreferredSize(new Dimension(400, 100)); ModalDialog dialog = new MyModalDialog(propertyPane); dialog.setContent(panel); int i = dialog.show(); if (i == ModalDialog.ID_OK) { createDefaultVectorDataNode(product, dialogData.name, dialogData.description); } } }
private NewVectorDataNodeAction(MaskForm maskForm) { super(maskForm, "icons/NewVectorDataNode24.gif", "newGeometry", "Creates a new mask based on a new geometry container (lines and polygons))"); action = new CreateVectorDataNodeAction(); }