use of org.eclipse.gef.ui.palette.PaletteViewerPreferences in project tdi-studio-se by Talend.
the class TalendPaletteViewer method setupPreferences.
private void setupPreferences() {
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
//$NON-NLS-1$
final String firstTimeRunning = "org.talend.designer.core.ui.editor.palette.TalendPaletteViewer.isFirstTimeRunning";
boolean isFirstTimeRunning = true;
if (preferenceStore != null) {
String value = preferenceStore.getString(firstTimeRunning);
if (StringUtils.isNotEmpty(value)) {
isFirstTimeRunning = Boolean.valueOf(value);
}
}
if (isFirstTimeRunning) {
PaletteViewerPreferences paletteViewerPreferences = this.getPaletteViewerPreferences();
if (paletteViewerPreferences != null) {
paletteViewerPreferences.setAutoCollapseSetting(PaletteViewerPreferences.COLLAPSE_NEVER);
paletteViewerPreferences.getAutoCollapseSetting();
if (preferenceStore != null) {
preferenceStore.setValue(firstTimeRunning, Boolean.FALSE.toString());
try {
InstanceScope.INSTANCE.getNode(DesignerPlugin.ID).flush();
} catch (BackingStoreException e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.eclipse.gef.ui.palette.PaletteViewerPreferences in project archi by archimatetool.
the class AbstractDiagramEditor method configurePaletteViewer.
/**
* Configure the Palette Viewer
*/
protected void configurePaletteViewer(final PaletteViewer viewer) {
PaletteViewerPreferences prefs = viewer.getPaletteViewerPreferences();
// 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();
}
}
});
}
Aggregations