use of com.serotonin.m2m2.gviews.component.ViewComponent in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method addPointComponentState.
private void addPointComponentState(ViewComponent viewComponent, boolean update, RuntimeManager rtm, Map<String, Object> model, HttpServletRequest request, GraphicalView view, User user, List<ViewComponentState> states, boolean edit, boolean add) {
if (viewComponent.isPointComponent() && (edit || viewComponent.isVisible())) {
PointComponent pointComponent = (PointComponent) viewComponent;
DataPointRT dataPointRT = null;
if (pointComponent.tgetDataPoint() != null)
dataPointRT = rtm.getDataPoint(pointComponent.tgetDataPoint().getId());
ViewComponentState state = preparePointComponentState(pointComponent, update, user, dataPointRT, model, request);
if (!edit) {
if (pointComponent.isSettable()) {
if (view.isEditor(user) || view.isSetter(user))
setChange(pointComponent.tgetDataPoint(), state, dataPointRT, request, model);
}
if (pointComponent.tgetDataPoint() != null)
setChart(pointComponent.tgetDataPoint(), state, request, model);
}
if (add)
states.add(state);
model.clear();
}
}
use of com.serotonin.m2m2.gviews.component.ViewComponent in project ma-modules-public by infiniteautomation.
the class GraphicalViewEditHandler method handleRequest.
@Override
public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws Exception {
GraphicalView view;
User user = Common.getUser(request);
// Fresh hit. Get the id.
String viewIdStr = request.getParameter("viewId");
if (viewIdStr != null) {
// An existing view.
view = new GraphicalViewDao().getView(Integer.parseInt(viewIdStr));
if (view == null)
// Doesn't exist. Redirect back to the views page.
return new RedirectView("/views.shtm");
GraphicalViewsCommon.ensureViewEditPermission(user, view);
if ("true".equals(request.getParameter("copy"))) {
// Make a copy
GraphicalView copy = new GraphicalView();
copy.setId(Common.NEW_ID);
copy.setUserId(user.getId());
copy.setXid(new GraphicalViewDao().generateUniqueXid());
copy.setName(StringUtils.abbreviate(TranslatableMessage.translate(ControllerUtils.getTranslations(request), "common.copyPrefix", view.getName()), 100));
copy.setBackgroundFilename(GraphicalViewsCommon.copyImage(view.getBackgroundFilename()));
for (ViewComponent vc : view.getViewComponents()) copy.addViewComponent(vc);
view = copy;
}
} else {
// A new view.
GraphicalViewsCommon.ensureCanCreate(user);
view = new GraphicalView();
view.setId(Common.NEW_ID);
view.setUserId(user.getId());
view.setXid(new GraphicalViewDao().generateUniqueXid());
}
GraphicalViewsCommon.setUserEditView(user, view);
view.validateViewComponents(false);
model.put("imageSets", Common.imageSets);
model.put("dynamicImages", Common.dynamicImages);
model.put("view", view);
return null;
}
Aggregations