use of org.kie.workbench.common.stunner.core.definition.shape.Glyph in project kie-wb-common by kiegroup.
the class ServiceTaskShapeDefTest method testGetGlyph.
@Test
public void testGetGlyph() {
Glyph expected = mock(Glyph.class);
when(iconDataGlyphGenerator.apply(eq(WID_ICON_DATA))).thenReturn(expected);
Glyph glyph = tested.getGlyph(ServiceTask.class, DEF_ID);
assertEquals(expected, glyph);
}
use of org.kie.workbench.common.stunner.core.definition.shape.Glyph in project kie-wb-common by kiegroup.
the class BPMNPaletteDefinitionBuilder method createPaletteServiceTasksCategory.
private void createPaletteServiceTasksCategory(final DefaultPaletteDefinition paletteDefinition, final Consumer<DefaultPaletteDefinition> callback) {
final ExpandedPaletteDefinitionBuilder.ItemMessageProvider categoryMessageProvider = paletteDefinitionBuilder.getCategoryMessageProvider();
final Function<String, Glyph> categoryGlyphProvider = paletteDefinitionBuilder.getCategoryGlyphProvider();
final Collection<WorkItemDefinition> workItemDefinitions = workItemDefinitionRegistry.get().items();
if (!workItemDefinitions.isEmpty()) {
final String serviceTasksTitle = categoryMessageProvider.getTitle(BPMNCategories.SERVICE_TASKS);
final String serviceTasksDesc = categoryMessageProvider.getDescription(BPMNCategories.SERVICE_TASKS);
final DefaultPaletteCategory workItemsCategory = new CategoryBuilder().setItemId(BPMNCategories.SERVICE_TASKS).setTitle(serviceTasksTitle).setDescription(serviceTasksDesc).setTooltip(serviceTasksTitle).setGlyph(categoryGlyphProvider.apply(BPMNCategories.SERVICE_TASKS)).build();
int i = 0;
for (final WorkItemDefinition workItemDefinition : workItemDefinitions) {
final ServiceTask serviceTask = serviceTaskBuilder.apply(workItemDefinition);
final DefinitionAdapter<Object> adapter = definitionManager.adapters().registry().getDefinitionAdapter(serviceTask.getClass());
final String category = adapter.getCategory(serviceTask);
DefaultPaletteGroup subcategoryGroup = null;
final Optional<DefaultPaletteItem> subcategoryGroupOp = workItemsCategory.getItems().stream().filter(item -> category.equals(item.getId())).findFirst();
if (!subcategoryGroupOp.isPresent()) {
subcategoryGroup = new GroupBuilder().setItemId(category).setTitle(category).setDescription(category).build();
workItemsCategory.getItems().add(subcategoryGroup);
} else {
subcategoryGroup = (DefaultPaletteGroup) subcategoryGroupOp.get();
}
final String defId = adapter.getId(serviceTask);
final String title = adapter.getTitle(serviceTask);
final String description = adapter.getDescription(serviceTask);
final DefaultPaletteItem item = new ItemBuilder().setItemId(defId).setDefinitionId(defId).setTitle(title).setDescription(description).build();
subcategoryGroup.getItems().add(item);
// Link the first work item definition found to the work item's palette category.
if (0 == i) {
workItemsCategory.setDefinitionId(defId);
}
i++;
}
paletteDefinition.getItems().add(workItemsCategory);
}
callback.accept(paletteDefinition);
}
use of org.kie.workbench.common.stunner.core.definition.shape.Glyph in project kie-wb-common by kiegroup.
the class AbstractShapeFactory method getGlyph.
@Override
public Glyph getGlyph(final String definitionId) {
final Glyph glyph = getGlyphFor(definitionId);
if (ShapeGlyph.class.equals(glyph.getClass())) {
final ShapeGlyph shapeGlyph = (ShapeGlyph) glyph;
shapeGlyph.setDefinitionId(definitionId);
shapeGlyph.setFactorySupplier(() -> this);
}
return glyph;
}
use of org.kie.workbench.common.stunner.core.definition.shape.Glyph in project kie-wb-common by kiegroup.
the class AbstractActionsToolboxView method addButton.
@Override
public V addButton(Glyph glyph, String title, Consumer<MouseClickEvent> clickEventConsumer) {
final ButtonItem button = toolboxFactory.buttons().button(renderGlyph(glyph, getGlyphSize())).decorate(createDecorator()).tooltip(tooltip.createItem(title)).onMouseEnter(event -> onMouseEnter()).onMouseExit(event -> onMouseExit()).onClick(event -> clickEventConsumer.accept(new MouseClickEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY())));
addButton(button);
return cast();
}
use of org.kie.workbench.common.stunner.core.definition.shape.Glyph in project kie-wb-common by kiegroup.
the class BS3PaletteWidgetViewImpl method showDragProxy.
@Override
public void showDragProxy(String itemId, double x, double y, double width, double height) {
final Glyph glyph = presenter.getShapeGlyph(itemId);
itemDragProxy = shapeGlyphDragHandler.show(new ShapeGlyphDragHandler.Item() {
@Override
public Glyph getShape() {
return glyph;
}
@Override
public int getWidth() {
return (int) width;
}
@Override
public int getHeight() {
return (int) height;
}
}, (int) x, (int) y, new DragProxyCallback() {
@Override
public void onStart(int x, int y) {
presenter.onDragStart(itemId, x, y);
}
@Override
public void onMove(int x, int y) {
presenter.onDragProxyMove(itemId, (double) x, (double) y);
}
@Override
public void onComplete(int x, int y) {
presenter.onDragProxyComplete(itemId, (double) x, (double) y);
}
});
}
Aggregations