Search in sources :

Example 1 with Range

use of org.eclipse.scout.rt.platform.util.Range in project scout.rt by eclipse.

the class AbstractPlanner method initConfig.

protected void initConfig() {
    m_listenerList = new EventListenerList();
    m_activityMapUIFacade = createUIFacade();
    // 
    setLabel(getConfiguredLabel());
    setAvailableDisplayModes(getConfiguredAvailableDisplayModes());
    setDisplayMode(getConfiguredDisplayMode());
    setDisplayModeOptions(new HashMap<Integer, DisplayModeOptions>());
    initDisplayModeOptions();
    setHeaderVisible(getConfiguredHeaderVisible());
    setSelectionMode(getConfiguredSelectionMode());
    setActivitySelectable(getConfiguredActivitySelectable());
    setMinimumActivityDuration(getConfiguredMinimumActivityDuration());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menus.addOrdered(menu);
    }
    m_contributionHolder = new ContributionComposite(this);
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    menus.addAllOrdered(contributedMenus);
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contributing menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    IPlannerContextMenu contextMenu = new PlannerContextMenu(this, menus.getOrderedList());
    setContextMenu(contextMenu);
    // local property observer
    addPlannerListener(new PlannerAdapter() {

        @Override
        @SuppressWarnings("unchecked")
        public void plannerChanged(PlannerEvent e) {
            if (e.getType() == PlannerEvent.TYPE_RESOURCES_SELECTED) {
                List<Resource<RI>> resources = (List<Resource<RI>>) e.getResources();
                try {
                    interceptResourcesSelected(resources);
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            }
        }
    });
    addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        @SuppressWarnings("unchecked")
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals(PROP_DISPLAY_MODE)) {
                try {
                    interceptDisplayModeChanged((int) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_VIEW_RANGE)) {
                try {
                    interceptViewRangeChanged((Range) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_SELECTION_RANGE)) {
                try {
                    interceptSelectionRangeChanged((Range) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_SELECTED_ACTIVITY)) {
                Activity<RI, AI> cell = (Activity<RI, AI>) e.getNewValue();
                if (cell != null) {
                    try {
                        interceptActivitySelected(cell);
                    } catch (Exception t) {
                        BEANS.get(ExceptionHandler.class).handle(t);
                    }
                }
            }
        }
    });
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ExceptionHandler(org.eclipse.scout.rt.platform.exception.ExceptionHandler) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) ArrayList(java.util.ArrayList) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) PropertyChangeEvent(java.beans.PropertyChangeEvent) IPlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) Range(org.eclipse.scout.rt.platform.util.Range) PlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.PlannerContextMenu) IPlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu)

Example 2 with Range

use of org.eclipse.scout.rt.platform.util.Range in project scout.rt by eclipse.

the class JsonPlanner method initJsonProperties.

@Override
protected void initJsonProperties(PLANNER model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_LABEL, model) {

        @Override
        protected String modelValue() {
            return getModel().getLabel();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_AVAILABLE_DISPLAY_MODES, model) {

        @Override
        protected Set<Integer> modelValue() {
            return getModel().getAvailableDisplayModes();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_DISPLAY_MODE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDisplayMode();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_DISPLAY_MODE_OPTIONS, model) {

        @Override
        protected Map<Integer, DisplayModeOptions> modelValue() {
            return getModel().getDisplayModeOptions();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            JSONObject options = new JSONObject();
            for (Entry<Integer, DisplayModeOptions> option : ((Map<Integer, DisplayModeOptions>) value).entrySet()) {
                options.put(String.valueOf(option.getKey()), MainJsonObjectFactory.get().createJsonObject(option.getValue()).toJson());
            }
            return options;
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_VIEW_RANGE, model) {

        @Override
        protected Range<Date> modelValue() {
            return getModel().getViewRange();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return new JsonDateRange((Range<Date>) value).toJson();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_HEADER_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isHeaderVisible();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_SELECTION_RANGE, model) {

        @Override
        protected Range<Date> modelValue() {
            return getModel().getSelectionRange();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return new JsonDateRange((Range<Date>) value).toJson();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_SELECTED_ACTIVITY, model) {

        @Override
        protected Activity<?, ?> modelValue() {
            return getModel().getSelectedActivity();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            Activity<?, ?> activityCell = (Activity<?, ?>) value;
            return new P_GetOrCreateCellIdProvider().getId(activityCell);
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_SELECTION_MODE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getSelectionMode();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_ACTIVITY_SELECTABLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isActivitySelectable();
        }
    });
}
Also used : Set(java.util.Set) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) DisplayModeOptions(org.eclipse.scout.rt.client.ui.basic.planner.DisplayModeOptions) Activity(org.eclipse.scout.rt.client.ui.basic.planner.Activity) Range(org.eclipse.scout.rt.platform.util.Range) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) Date(java.util.Date) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate) Entry(java.util.Map.Entry) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Range

use of org.eclipse.scout.rt.platform.util.Range in project scout.rt by eclipse.

the class JsonPlanner method extractSelectionRange.

protected Range<Date> extractSelectionRange(JSONObject data) {
    JSONObject selectionRange = data.optJSONObject("selectionRange");
    Date fromDate = toJavaDate(selectionRange, "from");
    Date toDate = toJavaDate(selectionRange, "to");
    return new Range<Date>(fromDate, toDate);
}
Also used : JSONObject(org.json.JSONObject) Range(org.eclipse.scout.rt.platform.util.Range) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) Date(java.util.Date) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate)

Example 4 with Range

use of org.eclipse.scout.rt.platform.util.Range in project scout.rt by eclipse.

the class JsonCalendar method extractViewRange.

protected Range<Date> extractViewRange(JSONObject data) {
    JSONObject viewRange = data.optJSONObject("viewRange");
    Date fromDate = toJavaDate(viewRange, "from");
    Date toDate = toJavaDate(viewRange, "to");
    return new Range<Date>(fromDate, toDate);
}
Also used : JSONObject(org.json.JSONObject) Range(org.eclipse.scout.rt.platform.util.Range) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) Date(java.util.Date) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate)

Example 5 with Range

use of org.eclipse.scout.rt.platform.util.Range in project scout.rt by eclipse.

the class JsonPlanner method extractViewRange.

protected Range<Date> extractViewRange(JSONObject data) {
    JSONObject range = data.optJSONObject("viewRange");
    Date fromDate = toJavaDate(range, "from");
    Date toDate = toJavaDate(range, "to");
    return new Range<Date>(fromDate, toDate);
}
Also used : JSONObject(org.json.JSONObject) Range(org.eclipse.scout.rt.platform.util.Range) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) Date(java.util.Date) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate)

Aggregations

Range (org.eclipse.scout.rt.platform.util.Range)6 Date (java.util.Date)5 JsonDate (org.eclipse.scout.rt.ui.html.json.JsonDate)5 JsonDateRange (org.eclipse.scout.rt.ui.html.json.JsonDateRange)5 JSONObject (org.json.JSONObject)5 Set (java.util.Set)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 IPlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu)1 PlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.PlannerContextMenu)1 CalendarComponent (org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent)1 Activity (org.eclipse.scout.rt.client.ui.basic.planner.Activity)1 DisplayModeOptions (org.eclipse.scout.rt.client.ui.basic.planner.DisplayModeOptions)1 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)1