|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) Punkhorn Software |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Punkhorn Software - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.gef.ui.palette; |
| 12 |
|
| 13 |
import org.eclipse.swt.widgets.Composite; |
| 14 |
import org.eclipse.swt.widgets.Control; |
| 15 |
|
| 16 |
import org.eclipse.ui.IMemento; |
| 17 |
|
| 18 |
import org.eclipse.gef.GraphicalViewer; |
| 19 |
import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; |
| 20 |
|
| 21 |
/** |
| 22 |
* The FlyoutPaletteCompositeBase is a base class for a Composite class which |
| 23 |
* shows a flyout palette alongside another control. The flyout palette |
| 24 |
* auto-hides (thus maximizing space) when not in use, but can also be pinned |
| 25 |
* open if so desired. It will only be visible when the PaletteView is not. |
| 26 |
* |
| 27 |
* <p> |
| 28 |
* A custom palette can be implemented for |
| 29 |
* {@link GraphicalEditorWithFlyoutPalette} by extending this class and |
| 30 |
* overriding the method |
| 31 |
* {@link GraphicalEditorWithFlyoutPalette#createPaletteComposite } to return the |
| 32 |
* custom implementation. |
| 33 |
* |
| 34 |
* @author William Collins punkhornsw@gmail.com |
| 35 |
* @since 3.10 |
| 36 |
*/ |
| 37 |
public class FlyoutPaletteCompositeBase extends Composite { |
| 38 |
|
| 39 |
protected PaletteViewer externalViewer; |
| 40 |
|
| 41 |
protected Control graphicalControl; |
| 42 |
|
| 43 |
public FlyoutPaletteCompositeBase(Composite parent, int style) { |
| 44 |
super(parent, style); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* If an external palette viewer is provided, palette state (that is |
| 49 |
* captured in {@link PaletteViewer#saveState(IMemento)} -- active tool, |
| 50 |
* drawer expansion state, drawer pin state, etc.) will be maintained when |
| 51 |
* switching between the two viewers. Providing an external viewer, although |
| 52 |
* recommended, is optional. |
| 53 |
* |
| 54 |
* @param viewer |
| 55 |
* The palette viewer used in the PaletteView |
| 56 |
*/ |
| 57 |
public void setExternalViewer(PaletteViewer viewer) { |
| 58 |
externalViewer = viewer; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Sets the control along the side of which the palette is to be displayed. |
| 63 |
* The given Control should be a child of this Composite. This method should |
| 64 |
* only be invoked once. |
| 65 |
* |
| 66 |
* @param graphicalViewer |
| 67 |
* the control of the graphical viewer; cannot be |
| 68 |
* <code>null</code> |
| 69 |
*/ |
| 70 |
public void setGraphicalControl(Control graphicalViewer) { |
| 71 |
graphicalControl = graphicalViewer; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* This method hooks a DropTargetListener that collapses the flyout patette |
| 76 |
* when the user drags something from the palette and moves the cursor to |
| 77 |
* the primary viewer's control. If the auto-hide feature of the palette is |
| 78 |
* to work properly when dragging, this method should be called before any |
| 79 |
* other drop target listeners are added to the primary viewer. |
| 80 |
* |
| 81 |
* @param viewer |
| 82 |
* the primary viewer |
| 83 |
*/ |
| 84 |
public void hookDropTargetListener(GraphicalViewer viewer) { |
| 85 |
} |
| 86 |
} |