Search in sources :

Example 1 with WidgetDescriptor

use of org.csstudio.opibuilder.util.WidgetDescriptor in project yamcs-studio by yamcs.

the class WidgetTreeEditpart method getImage.

@Override
protected Image getImage() {
    if (getWidgetModel() instanceof DisplayModel)
        return super.getImage();
    String typeID = getWidgetModel().getTypeID();
    WidgetDescriptor widgetDescriptor = WidgetsService.getInstance().getWidgetDescriptor(typeID);
    Image image = CustomMediaFactory.getInstance().getImageFromPlugin(widgetDescriptor.getPluginId(), widgetDescriptor.getIconPath());
    return image;
}
Also used : DisplayModel(org.csstudio.opibuilder.model.DisplayModel) WidgetDescriptor(org.csstudio.opibuilder.util.WidgetDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 2 with WidgetDescriptor

use of org.csstudio.opibuilder.util.WidgetDescriptor 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)

Aggregations

WidgetDescriptor (org.csstudio.opibuilder.util.WidgetDescriptor)2 List (java.util.List)1 Map (java.util.Map)1 IGraphicalFeedbackFactory (org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)1 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Image (org.eclipse.swt.graphics.Image)1