private static String createDefaultFileName(ProductMetadataView productMetadataView) { return FileUtils.getFilenameWithoutExtension(productMetadataView.getProduct().getName()) + "_" + productMetadataView.getMetadataElement().getName() + ".txt"; }
@Override public boolean isEnabled() { final ProductMetadataTable metadataTable = getMetadataTable(); return metadataTable.isExpandAllAllowed(); }
public ProductMetadataView openMetadataView(final MetadataElement element) { ProductMetadataView metadataView = new ProductMetadataView(element); openInternalFrame(metadataView); return metadataView; }
metadataView.setCommandUIFactory(visatApp.getCommandUIFactory()); final Icon icon = UIUtils.loadImageIcon("icons/RsMetaData16.gif"); final MetadataElement element = metadataView.getMetadataElement(); metadataFrame = visatApp.createInternalFrame(element.getDisplayName(), icon, metadataView, null,false); final Product product = metadataView.getProduct(); final JInternalFrame internalFrame = metadataFrame; product.addProductNodeListener(new ProductNodeListenerAdapter() {
/** * Returns the currently visible product node. */ @Override public ProductNode getVisibleProductNode() { return getMetadataElement(); }
public ProductMetadataView(MetadataElement metadataElement) { _metadataTable = new ProductMetadataTable(metadataElement); _metadataTable.addMouseListener(new PopupMenuHandler(this)); setLayout(new BorderLayout()); add(new JScrollPane(_metadataTable), BorderLayout.CENTER); expandMenuItem = new JMenuItem(new ExpandAllAction()); collapseMenuItem = new JMenuItem(new CollapseAllAction()); }
private static void collectMetadataView(ViewRef viewRef, ProductManager productManager, ArrayList<ProductNodeView> views) throws Exception { Product product = productManager.getProductByRefNo(viewRef.productRefNo); if (product != null) { String[] productNodeNames = viewRef.productNodeName.split("\\|"); MetadataElement element = product.getMetadataRoot(); for (int i = productNodeNames.length - 1; i >= 0; i--) { if (element == null) { break; } element = element.getElement(productNodeNames[i]); } if (element != null) { ProductMetadataView metadataView = new ProductMetadataView(element); Rectangle bounds = viewRef.bounds; if (bounds != null && !bounds.isEmpty()) { metadataView.setBounds(bounds); } views.add(metadataView); } } else { throw new Exception("Unknown product reference number: " + viewRef.productRefNo); } }
@Override public JPopupMenu createPopupMenu(Component component) { JPopupMenu popupMenu = new JPopupMenu(); if (getCommandUIFactory() != null) { getCommandUIFactory().addContextDependentMenuItems("metadata", popupMenu); } popupMenu.add(expandMenuItem); popupMenu.add(collapseMenuItem); return popupMenu; }
/** * Returns the currently selected product. * * @return the selected product, which can be <code>null</code> */ @Override public Product getSelectedProduct() { if (selectedNode instanceof Product) { return (Product) selectedNode; } else if (selectedNode != null) { return selectedNode.getProduct(); } else if (getSelectedProductSceneView() != null) { return getSelectedProductSceneView().getProduct(); } else if (getSelectedProductMetadataView() != null) { return getSelectedProductMetadataView().getProduct(); } else if (getProductManager().getProductCount() == 1) { return getProductManager().getProduct(0); } else { return null; } }
public Product getProduct() { return getMetadataElement().getProduct(); }
@Override public void actionPerformed(ActionEvent e) { final ProductMetadataTable metadataTable = getMetadataTable(); metadataTable.expandAll(); } }
MetadataElement metadataRoot = metadataView.getProduct().getMetadataRoot(); MetadataElement metadataElement = metadataView.getMetadataElement(); StringBuilder sb = new StringBuilder(metadataElement.getName()); MetadataElement parent = metadataElement.getParentElement();
/** * Finds the (internal) frame for the given meta data element. * <p/> * <p>The content pane of the returned frame is always an instance of <code>ProductMetadataView</code>. * * @param metadataElement the metadata element for which to perform the lookup * @return the internal frame or <code>null</code> if no frame was found */ public JInternalFrame findInternalFrame(final MetadataElement metadataElement) { final JInternalFrame[] frames = getAllInternalFrames(); if (frames == null) { return null; } for (final JInternalFrame frame : frames) { final Container contentPane = frame.getContentPane(); if (contentPane instanceof ProductMetadataView) { final ProductMetadataView view = (ProductMetadataView) contentPane; if (view.getMetadataElement() == metadataElement) { return frame; } } } return null; }
@Override public boolean isEnabled() { final ProductMetadataTable metadataTable = getMetadataTable(); return metadataTable.isExpandAllAllowed(); }
@Override public void actionPerformed(ActionEvent e) { final ProductMetadataTable metadataTable = getMetadataTable(); metadataTable.collapseAll(); } }
private static void expandMetadataTable(CommandEvent event) { ProductNodeView view = VisatApp.getApp().getSelectedProductNodeView(); if (!(view instanceof ProductMetadataView)) { return; } final ProductMetadataView productMetadataView = (ProductMetadataView) view; final ProductMetadataTable metadataTable = productMetadataView.getMetadataTable(); metadataTable.expandAll(); }
private static void collapseMetadataTable() { ProductNodeView view = VisatApp.getApp().getSelectedProductNodeView(); if (!(view instanceof ProductMetadataView)) { return; } final ProductMetadataView productMetadataView = (ProductMetadataView) view; final ProductMetadataTable metadataTable = productMetadataView.getMetadataTable(); metadataTable.collapseAll(); }
/** * Called when a command should update its state. * <p/> * <p> This method can contain some code which analyzes the underlying element and makes a decision whether * this item or group should be made visible/invisible or enabled/disabled etc. * * @param event the command event */ @Override public void updateState(CommandEvent event) { ProductNodeView view = VisatApp.getApp().getSelectedProductNodeView(); boolean expandAllowed = false; if (view instanceof ProductMetadataView) { final ProductMetadataTable metadataTable = ((ProductMetadataView) view).getMetadataTable(); expandAllowed = metadataTable.isExpandAllAllowed(); } setEnabled(expandAllowed); }
/** * Called when a command should update its state. * <p/> * <p> This method can contain some code which analyzes the underlying element and makes a decision whether * this item or group should be made visible/invisible or enabled/disabled etc. * * @param event the command event */ @Override public void updateState(CommandEvent event) { ProductNodeView view = VisatApp.getApp().getSelectedProductNodeView(); boolean expandAllowed = false; if (view instanceof ProductMetadataView) { final ProductMetadataTable metadataTable = ((ProductMetadataView) view).getMetadataTable(); expandAllowed = metadataTable.isExpandAllAllowed(); } setEnabled(expandAllowed); }
final ProductMetadataTable metadataTable = productMetadataView.getMetadataTable();