use of org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method showSizeOnDropFeedback.
@Override
protected void showSizeOnDropFeedback(CreateRequest request) {
String typeId = determineTypeIdFromRequest(request);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(typeId);
if (feedbackFactory != null) {
IFigure feedbackFigure = getSizeOnDropFeedback(request);
feedbackFactory.showSizeOnDropFeedback(request, feedbackFigure, getCreationFeedbackOffset(request));
// feedbackFigure.repaint();
} else {
super.showSizeOnDropFeedback(request);
}
}
use of org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method createChangeConstraintCommand.
@Override
protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) {
if (!(child instanceof AbstractBaseEditPart) || !(constraint instanceof Rectangle))
return super.createChangeConstraintCommand(request, child, constraint);
AbstractBaseEditPart part = (AbstractBaseEditPart) child;
AbstractWidgetModel widgetModel = part.getWidgetModel();
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(widgetModel.getTypeID());
Command cmd = null;
if (feedbackFactory != null)
cmd = feedbackFactory.createChangeBoundsCommand(widgetModel, request, (Rectangle) constraint);
if (cmd == null)
cmd = new WidgetSetConstraintCommand(widgetModel, request, (Rectangle) constraint);
List<ConnectionModel> allConnections = new ArrayList<ConnectionModel>(part.getWidgetModel().getSourceConnections());
allConnections.addAll(part.getWidgetModel().getTargetConnections());
if (part.getWidgetModel() instanceof AbstractContainerModel) {
for (AbstractWidgetModel d : ((AbstractContainerModel) part.getWidgetModel()).getAllDescendants()) {
allConnections.addAll(d.getSourceConnections());
allConnections.addAll(d.getTargetConnections());
}
}
if (allConnections.size() > 0) {
CompoundCommand reRouteCmd = new CompoundCommand();
for (ConnectionModel srcConn : allConnections) {
reRouteCmd.add(new SetWidgetPropertyCommand(srcConn, ConnectionModel.PROP_POINTS, new PointList()));
}
cmd = cmd.chain(reRouteCmd);
}
if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) {
Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
if (guidePos != null) {
cmd = chainGuideAttachmentCommand(request, part, cmd, true);
} else if (GuideUtil.getInstance().getGuide(widgetModel, true) != null) {
// SnapToGuides didn't provide a horizontal guide, but
// this part is attached
// to a horizontal guide. Now we check to see if the
// part is attached to
// the guide along the edge being resized. If that is
// the case, we need to
// detach the part from the guide; otherwise, we leave
// it alone.
int alignment = GuideUtil.getInstance().getGuide(widgetModel, true).getAlignment(widgetModel);
int edgeBeingResized = 0;
if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
edgeBeingResized = -1;
} else {
edgeBeingResized = 1;
}
if (alignment == edgeBeingResized) {
cmd = cmd.chain(new ChangeGuideCommand(widgetModel, true));
}
}
}
if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
if (guidePos != null) {
cmd = chainGuideAttachmentCommand(request, part, cmd, false);
} else if (GuideUtil.getInstance().getGuide(widgetModel, false) != null) {
int alignment = GuideUtil.getInstance().getGuide(widgetModel, false).getAlignment(widgetModel);
int edgeBeingResized = 0;
if ((request.getResizeDirection() & PositionConstants.WEST) != 0) {
edgeBeingResized = -1;
} else {
edgeBeingResized = 1;
}
if (alignment == edgeBeingResized) {
cmd = cmd.chain(new ChangeGuideCommand(widgetModel, false));
}
}
}
if (request.getType().equals(REQ_MOVE_CHILDREN) || request.getType().equals(REQ_ALIGN_CHILDREN)) {
cmd = chainGuideAttachmentCommand(request, part, cmd, true);
cmd = chainGuideAttachmentCommand(request, part, cmd, false);
cmd = chainGuideDetachmentCommand(request, part, cmd, true);
cmd = chainGuideDetachmentCommand(request, part, cmd, false);
}
return cmd;
}
use of org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
String typeId = determineTypeIdFromRequest(request);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(typeId);
Command widgetCreateCommand = createWidgetCreateCommand(request);
if (widgetCreateCommand == null)
return null;
if (feedbackFactory != null) {
CompoundCommand compoundCommand = new CompoundCommand();
compoundCommand.add(widgetCreateCommand);
Command initialBoundsCommand = feedbackFactory.createInitialBoundsCommand((AbstractWidgetModel) request.getNewObject(), request, (Rectangle) getConstraintFor(request));
if (initialBoundsCommand != null)
compoundCommand.add(initialBoundsCommand);
return compoundCommand;
} else
return widgetCreateCommand;
}
use of org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method createSizeOnDropFeedback.
/**
* Override to provide custom feedback figure for the given create request.
*
* @param request
* the create request
* @return custom feedback figure
*/
@Override
protected IFigure createSizeOnDropFeedback(final CreateRequest request) {
String typeId = determineTypeIdFromRequest(request);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(typeId);
if (feedbackFactory != null) {
Shape feedbackFigure = feedbackFactory.createSizeOnDropFeedback(request);
if (feedbackFigure != null) {
addFeedback(feedbackFigure);
return feedbackFigure;
}
}
return super.createSizeOnDropFeedback(request);
}
use of org.csstudio.opibuilder.feedback.IGraphicalFeedbackFactory 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);
}
}
Aggregations