Search in sources :

Example 26 with PaletteDrawer

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);
    }
}
Also used : WidgetDescriptor(org.csstudio.opibuilder.util.WidgetDescriptor) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) IGraphicalFeedbackFactory(org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory) List(java.util.List) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Map(java.util.Map) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Example 27 with PaletteDrawer

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;
    }
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart) DiagramPart(org.jkiss.dbeaver.erd.ui.part.DiagramPart)

Example 28 with PaletteDrawer

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);
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer)

Aggregations

PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)28 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)10 ArrayList (java.util.ArrayList)9 List (java.util.List)6 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)6 TalendPaletteDrawer (org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer)6 SelectionToolEntry (org.eclipse.gef.palette.SelectionToolEntry)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 Iterator (java.util.Iterator)3 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)3 IComponent (org.talend.core.model.components.IComponent)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 TalendCombinedTemplateCreationEntry (org.talend.designer.core.ui.editor.palette.TalendCombinedTemplateCreationEntry)3 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 LinkedList (java.util.LinkedList)2 TreeMap (java.util.TreeMap)2 EditPart (org.eclipse.gef.EditPart)2 ConnectionCreationToolEntry (org.eclipse.gef.palette.ConnectionCreationToolEntry)2