/** * Gets the current selection context, if any. * * @return The current selection context, or {@code null} if none exists. * @since BEAM 4.7 */ @Override public SelectionContext getSelectionContext() { return getFigureEditor().getSelectionContext(); }
private FigureEditor getFigureEditor() { final ProductSceneView view = getSelectedProductSceneView(); return view != null ? view.getFigureEditor() : null; }
private static Figure[] getFigures(ProductSceneView view) { if (view == null) { return new Figure[0]; } final FigureCollection figureCollection = view.getFigureEditor().getFigureCollection(); return figureCollection.getFigures(); }
@Override public void actionPerformed(ActionEvent e) { getView().getFigureEditor().setSelection(Selection.EMPTY); } }
@Override public void actionPerformed(ActionEvent e) { getView().getFigureEditor().deleteSelection(); } }
@Override public void actionPerformed(ActionEvent e) { getView().getFigureEditor().selectAll(); } }
@Override public void actionPerformed(ActionEvent e) { Selection selection = getLookup().lookup(Selection.class); if (selection != null && !selection.isEmpty()) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = getView().getFigureEditor().getFigureSelection().createTransferable(false); clipboard.setContents(transferable, selection); getView().getFigureEditor().deleteSelection(); //JOptionPane.showMessage(WindowManager.getDefault().getMainWindow(), "Cut: " + transferable); } } }
@Override public void actionPerformed(ActionEvent e) { Selection selection = getLookup().lookup(Selection.class); if (selection != null && !selection.isEmpty()) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // todo - when we copy, we actually don't clone the SimpleFeature. Then, if we paste, two figures refer // to the same SimpleFeature. Transferable transferable = getView().getFigureEditor().getFigureSelection().createTransferable(true); clipboard.setContents(transferable, selection); //JOptionPane.showMessage(WindowManager.getDefault().getMainWindow(), "Copy: " + transferable); } } }
private void removeViewListener(ProductSceneView view) { if (view != null) { view.getRootLayer().removeListener(pagePanelLL); view.getFigureEditor().removeSelectionChangeListener(pagePanelSCL); } }
private void addViewListener(ProductSceneView view) { if (view != null) { view.getRootLayer().addListener(pagePanelLL); view.getFigureEditor().addSelectionChangeListener(pagePanelSCL); } }
private boolean areFiguresSelected() { final ProductSceneView sceneView = getSelectedProductSceneView(); return sceneView.getFigureEditor().getFigureSelection().isEmpty(); }
private void onSelectionStateChanged() { LOG.fine(String.format(">>> %s#onSelectionStateChanged: selected = %s, interactor = %s%n", getClass().getName(), isSelected(), getInteractor())); ProductSceneView productSceneView = getProductSceneView(); if (productSceneView != null && isSelected()) { Interactor oldInteractor = productSceneView.getFigureEditor().getInteractor(); Interactor newInteractor = getInteractor(); Assert.notNull(newInteractor, "No interactor set on action " + getClass()); if (oldInteractor != newInteractor && oldInteractor.isActive()) { oldInteractor.deactivate(); } if (!newInteractor.isActive()) { newInteractor.activate(); } productSceneView.getFigureEditor().setInteractor(newInteractor); } }
@Override public void componentSelected() { LOG.info(">> componentSelected"); updateSelectedState(); ContextGlobalExtender contextGlobalExtender = Utilities.actionsGlobalContext().lookup(ContextGlobalExtender.class); if (contextGlobalExtender != null) { contextGlobalExtender.put("view", getView()); } setSelection(getView().getFigureEditor().getSelectionContext().getSelection()); getView().getFigureEditor().getSelectionContext().addSelectionChangeListener(this); }
@Override public void componentDeselected() { LOG.info(">> componentDeselected"); updateSelectedState(); getView().getFigureEditor().getSelectionContext().removeSelectionChangeListener(this); setSelection(Selection.EMPTY); ContextGlobalExtender contextGlobalExtender = Utilities.actionsGlobalContext().lookup(ContextGlobalExtender.class); if (contextGlobalExtender != null) { contextGlobalExtender.remove("view"); } }
@Override public void resultChanged(LookupEvent ignored) { updateEnabledState(); if (isEnabled() && isSelected()) { ProductSceneView productSceneView = getProductSceneView(); if (productSceneView != null) { Interactor oldInteractor = productSceneView.getFigureEditor().getInteractor(); Interactor newInteractor = getInteractor(); if (oldInteractor != newInteractor) { oldInteractor.deactivate(); newInteractor.activate(); productSceneView.getFigureEditor().setInteractor(newInteractor); } } } }
public ShapeFigure getCurrentShapeFigure() { FigureSelection figureSelection = getFigureEditor().getFigureSelection(); if (figureSelection.getFigureCount() > 0) { Figure figure = figureSelection.getFigure(0);