/** @see IAdaptable#getAdapter(java.lang.Class) */
 public Object getAdapter(Class adapter) {
   if (adapter == EditPart.class && viewer != null)
     return viewer.getEditPartRegistry().get(viewer.getPaletteRoot());
   if (adapter == IFigure.class && viewer != null) {
     Object obj = viewer.getEditPartRegistry().get(viewer.getPaletteRoot());
     if (obj instanceof GraphicalEditPart) return ((GraphicalEditPart) obj).getFigure();
   }
   return null;
 }
Exemplo n.º 2
0
 /**
  * Sets the <code>PaletteViewer</code> for this EditDomain
  *
  * @param palette the PaletteViewer
  */
 public void setPaletteViewer(PaletteViewer palette) {
   if (palette == paletteViewer) return;
   if (paletteViewer != null) paletteViewer.removePaletteListener(paletteListener);
   paletteViewer = palette;
   if (paletteViewer != null) {
     palette.addPaletteListener(paletteListener);
     if (paletteRoot != null) {
       paletteViewer.setPaletteRoot(paletteRoot);
       loadDefaultTool();
     }
   }
 }
Exemplo n.º 3
0
  public void setActiveTool(ToolEntry tool) {
    EditPart part = getFocusEditPart();
    if (part instanceof GraphicalEditPart) {
      IFigure fig = ((GraphicalEditPart) part).getFigure();
      if (fig instanceof Clickable) {
        part.setSelected(EditPart.SELECTED_NONE);
        ((Clickable) fig).getModel().setArmed(false);
        ((Clickable) fig).getModel().setPressed(false);
        ((Clickable) fig).getModel().setSelected(false);
      }
    }
    super.setActiveTool(null);

    if (tool instanceof PaletteItem && !listener.isDragging()) {
      insertIntoEditor((PaletteItem) tool);
    }
  }
 /**
  * @return the palette viewer's control
  * @see Page#getControl()
  */
 public Control getControl() {
   return viewer.getControl();
 }