use of org.eclipse.gef.palette.PaletteDrawer in project yamcs-studio by yamcs.
the class OPIEditorPaletteFactory method createPaletteContents.
private static void createPaletteContents(PaletteRoot palette) {
Map<String, List<String>> categoriesMap = WidgetsService.getInstance().getAllCategoriesMap();
String[] hiddenWidgets = PreferencesHelper.getHiddenWidgets();
List<String> hiddenWidgetsList = null;
if (hiddenWidgets != null)
hiddenWidgetsList = Arrays.asList(hiddenWidgets);
for (final Map.Entry<String, List<String>> entry : categoriesMap.entrySet()) {
PaletteDrawer categoryDrawer = new PaletteDrawer(entry.getKey());
for (String typeId : entry.getValue()) {
if (hiddenWidgetsList != null && hiddenWidgetsList.indexOf(typeId) >= 0)
continue;
WidgetDescriptor widgetDescriptor = WidgetsService.getInstance().getWidgetDescriptor(typeId);
ImageDescriptor icon = CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(widgetDescriptor.getPluginId(), widgetDescriptor.getIconPath());
CombinedTemplateCreationEntry widgetEntry = new CombinedTemplateCreationEntry(widgetDescriptor.getName(), widgetDescriptor.getDescription(), new WidgetCreationFactory(widgetDescriptor), icon, icon);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(widgetDescriptor.getTypeID());
if (feedbackFactory != null && feedbackFactory.getCreationTool() != null) {
widgetEntry.setToolClass(feedbackFactory.getCreationTool());
}
categoryDrawer.add(widgetEntry);
}
palette.add(categoryDrawer);
}
}
use of org.eclipse.gef.palette.PaletteDrawer in project dbeaver by serge-rider.
the class ERDGraphicalViewer method setContents.
@Override
public void setContents(EditPart editpart) {
loadContents = true;
try {
super.setContents(editpart);
// Reset palette contents
if (editpart instanceof DiagramPart) {
List<DBSEntity> tables = new ArrayList<>();
for (Object child : editpart.getChildren()) {
if (child instanceof EntityPart) {
tables.add(((EntityPart) child).getEntity().getObject());
}
}
tables.sort(DBUtils.nameComparator());
Map<PaletteDrawer, List<ToolEntryTable>> toolMap = new LinkedHashMap<>();
for (DBSEntity table : tables) {
DBPDataSourceContainer container = table.getDataSource().getContainer();
PaletteDrawer drawer = getContainerPaletteDrawer(container);
if (drawer != null) {
List<ToolEntryTable> tools = toolMap.get(drawer);
if (tools == null) {
tools = new ArrayList<>(tables.size());
toolMap.put(drawer, tools);
}
tools.add(new ToolEntryTable(table));
}
}
for (Map.Entry<PaletteDrawer, List<ToolEntryTable>> entry : toolMap.entrySet()) {
entry.getKey().setChildren(entry.getValue());
}
// editor.getPaletteContents().setChildren(tools);
}
} finally {
loadContents = false;
}
}
use of org.eclipse.gef.palette.PaletteDrawer in project dbeaver by serge-rider.
the class ERDGraphicalViewer method releaseContainer.
private void releaseContainer(DBPDataSourceContainer container) {
PaletteDrawer drawer = getContainerPaletteDrawer(container);
if (drawer != null) {
editor.getPaletteRoot().remove(drawer);
}
container.getRegistry().removeDataSourceListener(this);
container.release(editor);
}
Aggregations