Previous | Next |
DpmSelection.java
DpmSelection provides support for selecting a single item within a portfolio, and for deleting items and copying items to and from the clipboard. An active DPM component always has a current selection even if it is empty.
Create a DpmSelection and establish a data flavor describing the exchange type of selected DPM data. | public class DpmSelection extends ModelSelection { public static DataFlavor dpmFlavor = new DataFlavor(dpm.DpmSelection.class, "dpmFlavor"); |
A selection created by the default constructor is empty. Copied selections specify whatever data is selected by the original selection object. | public DpmSelection( ModelSelectionOwner owner, DpmModel model) { super(owner, model); this.model = model; setEmpty(); } public DpmSelection(DpmSelection copy) { super(copy); model = copy.model; PortRecord p = (PortRecord)copy.getSelectedPortRecord(); if( p != null) selectedPortRecord = (PortRecord)p.clone(); else selectedPortRecord = null; } public Object clone() { return new DpmSelection(this); } |
Methods called to negotiate data types for clipboard operations. A DpmSelection can only transfer a single selected portfolio item. | public synchronized DataFlavor[] getTransferDataFlavors() { DataFlavor[] flavors = { dpmFlavor }; return flavors; } public boolean isDataFlavorSupported(DataFlavor dataFlavor) { return dataFlavor.equals(dpmFlavor); } public synchronized Object getTransferData(DataFlavor dataFlavor) throws IOException, UnsupportedFlavorException { if (dataFlavor.equals(dpmFlavor)) { return selectedPortRecord; } else throw new UnsupportedFlavorException(dataFlavor); } |
Methods called to delete a selection. A portfolio item can only be deleted by selling it off. | public boolean canDelete() { return false; } public Object delete() { return null; } public void undoDelete(Object undoData) { } |
Methods called to handle a paste operation. | public boolean canPasteFrom(Transferable contents) { return false; } public Object pasteFrom(Transferable contents) { return null; } public void undoPaste(Object undoData) { return; } |
Methods called to select all portfolio items or deselect all selected items. A DpmSelection can only specify a single portfolio item. | public void selectAll() { } public void deselectAll() { selectedPortRecord = null; setEmpty(); } |
Methods called to select or deselect a single portfolio record. | public void selectPortRecord(PortRecord portRec) { portRec.setSelected(true); selectedPortRecord = portRec; setNotEmpty(); } public void deselectPortRecord(PortRecord portRec) { portRec.setSelected(false); selectedPortRecord = null; setEmpty(); } |
Access to the currently selected portfolio item. | public PortRecord getSelectedPortRecord() { return selectedPortRecord; } |
Data members | private DpmModel model; private PortRecord selectedPortRecord; } |
Previous | Next |
Copyright ©
Taligent, Inc. 1996 - 1997.
Copyright © IBM Corporation 1996 - 1997.
All Rights Reserved.