Search in sources :

Example 1 with Options

use of com.googlecode.wicket.jquery.core.Options in project webanno by webanno.

the class TextFeatureEditor method createFieldComboBox.

private AbstractTextComponent createFieldComboBox() {
    AbstractTextComponent field;
    if (getModelObject().feature.getTagset() != null) {
        field = new StyledComboBox<Tag>("value", PropertyModel.of(getModel(), "tagset")) {

            private static final long serialVersionUID = -1735694425658462932L;

            @Override
            protected void onInitialize() {
                super.onInitialize();
                // Ensure proper order of the initializing JS header items: first combo box
                // behavior (in super.onInitialize()), then tooltip.
                Options options = new Options(DescriptionTooltipBehavior.makeTooltipOptions());
                options.set("content", FUNCTION_FOR_TOOLTIP);
                add(new TooltipBehavior("#" + getMarkupId() + "_listbox *[title]", options) {

                    private static final long serialVersionUID = 1854141593969780149L;

                    @Override
                    protected String $() {
                        // with a slight delay hoping that all is set up after 1 second.
                        return "try {setTimeout(function () { " + super.$() + " }, 1000); } catch (err) {}; ";
                    }
                });
            }

            @Override
            protected void onConfigure() {
                super.onConfigure();
                // Trigger a re-loading of the tagset from the server as constraints may have
                // changed the ordering
                AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
                if (target != null) {
                    LOG.trace("onInitialize() requesting datasource re-reading");
                    target.appendJavaScript(String.format("var $w = %s; if ($w) { $w.dataSource.read(); }", KendoUIBehavior.widget(this, ComboBoxBehavior.METHOD)));
                }
            }
        };
    } else {
        field = new TextField<String>("value");
    }
    // Ensure that markup IDs of feature editor focus components remain constant across
    // refreshes of the feature editor panel. This is required to restore the focus.
    field.setOutputMarkupId(true);
    field.setMarkupId(ID_PREFIX + getModelObject().feature.getId());
    return field;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Options(com.googlecode.wicket.jquery.core.Options) TooltipBehavior(com.googlecode.wicket.jquery.ui.widget.tooltip.TooltipBehavior) DescriptionTooltipBehavior(de.tudarmstadt.ukp.clarin.webanno.support.DescriptionTooltipBehavior) Tag(de.tudarmstadt.ukp.clarin.webanno.model.Tag) AbstractTextComponent(org.apache.wicket.markup.html.form.AbstractTextComponent)

Example 2 with Options

use of com.googlecode.wicket.jquery.core.Options in project openmeetings by apache.

the class RoomSidebar method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    final NameDialog addFolder = new NameDialog("addFolder", getString("712")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            roomFiles.createFolder(target, getModelObject());
        }
    };
    final Form<?> form = new Form<>("form");
    ConfirmableBorderDialog confirmTrash = new ConfirmableBorderDialog("confirm-trash", getString("80"), getString("713"), form);
    roomFiles = new RoomFilePanel("tree", room, addFolder, confirmTrash);
    add(selfRights, userList.add(updateUsers()).setOutputMarkupId(true), fileTab.setVisible(!room.isInterview()), roomFiles.setVisible(!room.isInterview()));
    add(addFolder, settings, userCount.setOutputMarkupId(true));
    add(toggleRight, toggleActivity, roomAction, avSettings);
    add(confirmKick = new ConfirmableAjaxBorder("confirm-kick", getString("603"), getString("605")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            kickUser(kickedClient);
        }
    });
    add(form.add(confirmTrash), upload = new UploadDialog("upload", room, roomFiles));
    updateShowFiles(null);
    add(new JQueryUIBehavior("#room-sidebar-tabs", "tabs", new Options("activate", "function(event, ui) {Room.setSize();}")));
    add(activities = new ActivitiesPanel("activities", room));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) NameDialog(org.apache.openmeetings.web.common.NameDialog) Options(com.googlecode.wicket.jquery.core.Options) ActivitiesPanel(org.apache.openmeetings.web.room.activities.ActivitiesPanel) Form(org.apache.wicket.markup.html.form.Form) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) JQueryUIBehavior(com.googlecode.wicket.jquery.ui.JQueryUIBehavior) ConfirmableBorderDialog(org.apache.openmeetings.web.common.ConfirmableAjaxBorder.ConfirmableBorderDialog)

Example 3 with Options

use of com.googlecode.wicket.jquery.core.Options in project openmeetings by apache.

the class SettingsPanel method onInitialize.

@Override
protected void onInitialize() {
    List<ITab> tabs = new ArrayList<>();
    tabs.add(new AjaxTab(Model.of(getString("1170"))) {

        private static final long serialVersionUID = 1L;

        UserProfilePanel profilePanel = null;

        @Override
        protected WebMarkupContainer getLazyPanel(String panelId) {
            if (profilePanel == null) {
                profilePanel = new UserProfilePanel(panelId, getUserId());
                profilePanel.setOutputMarkupId(true);
            }
            return profilePanel;
        }

        @Override
        public boolean load(AjaxRequestTarget target) {
            if (profilePanel != null) {
                profilePanel.setDefaultModelObject(userDao.get(getUserId()));
                target.add(profilePanel);
            }
            return super.load(target);
        }
    });
    tabs.add(new AjaxTab(Model.of(getString("1188"))) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer getLazyPanel(String panelId) {
            return new MessagesContactsPanel(panelId);
        }
    });
    tabs.add(new AbstractTab(Model.of(getString("1171"))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer getPanel(String panelId) {
            return new ProfilePanel(panelId);
        }
    });
    tabs.add(new AbstractTab(Model.of(getString("1172"))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer getPanel(String panelId) {
            return new UserSearchPanel(panelId);
        }
    });
    tabs.add(new AbstractTab(Model.of(getString("1548"))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer getPanel(String panelId) {
            return new WidgetsPanel(panelId);
        }
    });
    add(new TabbedPanel("tabs", tabs, new Options("active", active)).setActiveTab(active));
    super.onInitialize();
}
Also used : Options(com.googlecode.wicket.jquery.core.Options) ArrayList(java.util.ArrayList) TabbedPanel(com.googlecode.wicket.jquery.ui.widget.tabs.TabbedPanel) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxTab(com.googlecode.wicket.jquery.ui.widget.tabs.AjaxTab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab)

Example 4 with Options

use of com.googlecode.wicket.jquery.core.Options in project webanno by webanno.

the class DescriptionTooltipBehavior method makeTooltipOptions.

public static Options makeTooltipOptions() {
    Options options = new Options();
    options.set("position", "{ my: 'center bottom', at: 'center top', of: '.page-footer' }");
    options.set("show", false);
    options.set("hide", false);
    return options;
}
Also used : Options(com.googlecode.wicket.jquery.core.Options)

Example 5 with Options

use of com.googlecode.wicket.jquery.core.Options in project openmeetings by apache.

the class CalendarPanel method onInitialize.

@Override
protected void onInitialize() {
    final Form<Date> form = new Form<>("form");
    add(form);
    dialog = new AppointmentDialog("appointment", this, new CompoundPropertyModel<>(getDefault()));
    add(dialog);
    boolean isRtl = isRtl();
    Options options = new Options();
    options.set("isRTL", isRtl);
    options.set("header", isRtl ? "{left: 'agendaDay,agendaWeek,month', center: 'title', right: 'today nextYear,next,prev,prevYear'}" : "{left: 'prevYear,prev,next,nextYear today', center: 'title', right: 'month,agendaWeek,agendaDay'}");
    options.set("allDaySlot", false);
    options.set("axisFormat", Options.asString("H(:mm)"));
    options.set("defaultEventMinutes", 60);
    options.set("timeFormat", Options.asString("H(:mm)"));
    options.set("buttonText", new JSONObject().put("month", getString("801")).put("week", getString("800")).put("day", getString("799")).put("today", getString("1555")).toString());
    JSONArray monthes = new JSONArray();
    JSONArray shortMonthes = new JSONArray();
    JSONArray days = new JSONArray();
    JSONArray shortDays = new JSONArray();
    // first week day must be Sunday
    days.put(0, getString("466"));
    shortDays.put(0, getString("459"));
    for (int i = 0; i < 12; i++) {
        monthes.put(i, getString(String.valueOf(469 + i)));
        shortMonthes.put(i, getString(String.valueOf(1556 + i)));
        if (i + 1 < 7) {
            days.put(i + 1, getString(String.valueOf(460 + i)));
            shortDays.put(i + 1, getString(String.valueOf(453 + i)));
        }
    }
    options.set("monthNames", monthes.toString());
    options.set("monthNamesShort", shortMonthes.toString());
    options.set("dayNames", days.toString());
    options.set("dayNamesShort", shortDays.toString());
    options.set("firstDay", cfgDao.getInt(CONFIG_CALENDAR_FIRST_DAY, 0));
    calendar = new Calendar("calendar", new AppointmentModel(), options) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onInitialize() {
            super.onInitialize();
            add(new CalendarFunctionsBehavior(getMarkupId()));
        }

        @Override
        public boolean isSelectable() {
            return true;
        }

        @Override
        public boolean isDayClickEnabled() {
            return true;
        }

        @Override
        public boolean isEventClickEnabled() {
            return true;
        }

        @Override
        public boolean isEventDropEnabled() {
            return true;
        }

        @Override
        public boolean isEventResizeEnabled() {
            return true;
        }

        // no need to override onDayClick
        @Override
        public void onSelect(AjaxRequestTarget target, CalendarView view, LocalDateTime start, LocalDateTime end, boolean allDay) {
            Appointment a = getDefault();
            LocalDateTime s = start, e = end;
            if (CalendarView.month == view) {
                LocalDateTime now = ZonedDateTime.now(getZoneId()).toLocalDateTime();
                s = start.withHour(now.getHour()).withMinute(now.getMinute());
                e = s.plus(1, ChronoUnit.HOURS);
            }
            a.setStart(getDate(s));
            a.setEnd(getDate(e));
            dialog.setModelObjectWithAjaxTarget(a, target);
            dialog.open(target);
        }

        @Override
        public void onEventClick(AjaxRequestTarget target, CalendarView view, int eventId) {
            Appointment a = apptDao.get((long) eventId);
            dialog.setModelObjectWithAjaxTarget(a, target);
            dialog.open(target);
        }

        @Override
        public void onEventDrop(AjaxRequestTarget target, int eventId, long delta, boolean allDay) {
            Appointment a = apptDao.get((long) eventId);
            if (!AppointmentDialog.isOwner(a)) {
                return;
            }
            java.util.Calendar cal = WebSession.getCalendar();
            cal.setTime(a.getStart());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setStart(cal.getTime());
            cal.setTime(a.getEnd());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setEnd(cal.getTime());
            apptDao.update(a, getUserId());
            if (a.getCalendar() != null) {
                updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a);
            }
        }

        @Override
        public void onEventResize(AjaxRequestTarget target, int eventId, long delta) {
            Appointment a = apptDao.get((long) eventId);
            if (!AppointmentDialog.isOwner(a)) {
                return;
            }
            java.util.Calendar cal = WebSession.getCalendar();
            cal.setTime(a.getEnd());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setEnd(cal.getTime());
            apptDao.update(a, getUserId());
            if (a.getCalendar() != null) {
                updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a);
            }
        }
    };
    form.add(calendar);
    populateGoogleCalendars();
    add(refreshTimer);
    add(syncTimer);
    calendarDialog = new CalendarDialog("calendarDialog", this, new CompoundPropertyModel<>(getDefaultCalendar()));
    add(calendarDialog);
    calendarListContainer.setOutputMarkupId(true);
    calendarListContainer.add(new ListView<OmCalendar>("items", new LoadableDetachableModel<List<OmCalendar>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<OmCalendar> load() {
            List<OmCalendar> cals = new ArrayList<>(apptManager.getCalendars(getUserId()));
            cals.addAll(apptManager.getGoogleCalendars(getUserId()));
            return cals;
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<OmCalendar> item) {
            item.setOutputMarkupId(true);
            final OmCalendar cal = item.getModelObject();
            item.add(new Button("item", new PropertyModel<String>(cal, "title")).add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    calendarDialog.open(target, CalendarDialog.DIALOG_TYPE.UPDATE_CALENDAR, cal);
                    target.add(calendarDialog);
                }
            }));
        }
    });
    add(new Button("syncCalendarButton").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            syncCalendar(target);
        }
    }));
    add(new Button("submitCalendar").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            calendarDialog.open(target, CalendarDialog.DIALOG_TYPE.UPDATE_CALENDAR, getDefaultCalendar());
            target.add(calendarDialog);
        }
    }));
    add(calendarListContainer);
    super.onInitialize();
}
Also used : LocalDateTime(java.time.LocalDateTime) Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Options(com.googlecode.wicket.jquery.core.Options) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) Button(com.googlecode.wicket.jquery.ui.form.button.Button) OmCalendar(org.apache.openmeetings.db.entity.calendar.OmCalendar) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) CalendarView(com.googlecode.wicket.jquery.ui.calendar.CalendarView) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) OmCalendar(org.apache.openmeetings.db.entity.calendar.OmCalendar) Calendar(com.googlecode.wicket.jquery.ui.calendar.Calendar) GoogleCalendar(com.googlecode.wicket.jquery.ui.calendar.EventSource.GoogleCalendar) JSONArray(com.github.openjson.JSONArray) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) Date(java.util.Date) CalendarWebHelper.getDate(org.apache.openmeetings.web.util.CalendarWebHelper.getDate) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) JSONObject(com.github.openjson.JSONObject) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel)

Aggregations

Options (com.googlecode.wicket.jquery.core.Options)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 ArrayList (java.util.ArrayList)2 Form (org.apache.wicket.markup.html.form.Form)2 JSONArray (com.github.openjson.JSONArray)1 JSONObject (com.github.openjson.JSONObject)1 JQueryUIBehavior (com.googlecode.wicket.jquery.ui.JQueryUIBehavior)1 Calendar (com.googlecode.wicket.jquery.ui.calendar.Calendar)1 CalendarView (com.googlecode.wicket.jquery.ui.calendar.CalendarView)1 GoogleCalendar (com.googlecode.wicket.jquery.ui.calendar.EventSource.GoogleCalendar)1 Button (com.googlecode.wicket.jquery.ui.form.button.Button)1 AjaxTab (com.googlecode.wicket.jquery.ui.widget.tabs.AjaxTab)1 TabbedPanel (com.googlecode.wicket.jquery.ui.widget.tabs.TabbedPanel)1 TooltipBehavior (com.googlecode.wicket.jquery.ui.widget.tooltip.TooltipBehavior)1 KendoFeedbackPanel (com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel)1 Tag (de.tudarmstadt.ukp.clarin.webanno.model.Tag)1 DescriptionTooltipBehavior (de.tudarmstadt.ukp.clarin.webanno.support.DescriptionTooltipBehavior)1 LocalDateTime (java.time.LocalDateTime)1 Date (java.util.Date)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1