use of org.eclipse.gef.dnd.TemplateTransferDragSourceListener in project dbeaver by dbeaver.
the class ERDPaletteViewerProvider method configurePaletteViewer.
@Override
protected void configurePaletteViewer(PaletteViewer viewer) {
super.configurePaletteViewer(viewer);
viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer));
}
use of org.eclipse.gef.dnd.TemplateTransferDragSourceListener in project archi by archimatetool.
the class AbstractDiagramEditor method configurePaletteViewer.
/**
* Configure the Palette Viewer
*/
protected void configurePaletteViewer(final PaletteViewer viewer) {
PaletteViewerPreferences prefs = viewer.getPaletteViewerPreferences();
// Don't use large icons
prefs.setUseLargeIcons(PaletteViewerPreferences.LAYOUT_ICONS, false);
prefs.setUseLargeIcons(PaletteViewerPreferences.LAYOUT_COLUMNS, false);
prefs.setUseLargeIcons(PaletteViewerPreferences.LAYOUT_DETAILS, false);
prefs.setUseLargeIcons(PaletteViewerPreferences.LAYOUT_LIST, false);
// First time use so set to icons layout
if (!InternalGEFPlugin.getDefault().getPreferenceStore().getBoolean("com.archimatetool.paletteSet")) {
// $NON-NLS-1$
// $NON-NLS-1$
InternalGEFPlugin.getDefault().getPreferenceStore().setValue("com.archimatetool.paletteSet", true);
prefs.setLayoutSetting(PaletteViewerPreferences.LAYOUT_ICONS);
prefs.setCurrentUseLargeIcons(false);
}
// Register as drag source to drag onto the canvas
viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer));
/*
* Tool Changed
*/
viewer.addPaletteListener(new PaletteListener() {
@Override
public void activeToolChanged(PaletteViewer palette, ToolEntry toolEntry) {
CreationFactory factory = (CreationFactory) toolEntry.getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY);
if (factory != null) {
ComponentSelectionManager.INSTANCE.fireSelectionEvent(toolEntry, factory.getObjectType());
}
}
});
/*
* Mouse Hover
*/
viewer.getControl().addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseHover(MouseEvent e) {
ToolEntry toolEntry = findToolEntryAt(viewer, new Point(e.x, e.y));
if (toolEntry != null) {
CreationFactory factory = (CreationFactory) toolEntry.getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY);
if (factory != null) {
ComponentSelectionManager.INSTANCE.fireSelectionEvent(toolEntry, factory.getObjectType());
}
}
}
});
viewer.getControl().addMouseListener(new MouseAdapter() {
/*
* If Shift key is pressed set Tool Entry to unload or not
*/
@Override
public void mouseDown(MouseEvent e) {
ToolEntry toolEntry = findToolEntryAt(viewer, new Point(e.x, e.y));
if (toolEntry != null) {
boolean shiftKey = (e.stateMask & SWT.SHIFT) != 0;
toolEntry.setToolProperty(AbstractTool.PROPERTY_UNLOAD_WHEN_FINISHED, !shiftKey);
}
}
/*
* Double-click on Format Painter
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
ToolEntry toolEntry = findToolEntryAt(viewer, new Point(e.x, e.y));
if (toolEntry instanceof FormatPainterToolEntry) {
FormatPainterInfo.INSTANCE.reset();
}
}
});
}
use of org.eclipse.gef.dnd.TemplateTransferDragSourceListener in project yamcs-studio by yamcs.
the class OPIEditor method createPaletteViewerProvider.
@Override
protected PaletteViewerProvider createPaletteViewerProvider() {
return new PaletteViewerProvider(getEditDomain()) {
@Override
protected void configurePaletteViewer(PaletteViewer viewer) {
super.configurePaletteViewer(viewer);
// create a drag source listener for this palette viewer
// together with an appropriate transfer drop target listener, this will enable
// model element creation by dragging a CombinatedTemplateCreationEntries
// from the palette into the editor
// @see ShapesEditor#createTransferDropTargetListener()
viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer));
}
};
}
Aggregations