Search in sources :

Example 1 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class WbPanel method sendFileToWb.

@Override
public void sendFileToWb(final BaseFileItem fi, boolean clean) {
    if (isVisible() && fi.getId() != null) {
        Whiteboards wbs = wbm.get(roomId);
        String wuid = UUID.randomUUID().toString();
        Whiteboard wb = wbs.get(wbs.getActiveWb());
        switch(fi.getType()) {
            case Folder:
                // do nothing
                break;
            case WmlFile:
                {
                    File f = fi.getFile();
                    if (f.exists() && f.isFile()) {
                        try (BufferedReader br = Files.newBufferedReader(f.toPath())) {
                            final boolean[] updated = { false };
                            JSONArray arr = getArray(new JSONObject(new JSONTokener(br)), o -> {
                                wb.put(o.getString("uid"), o);
                                updated[0] = true;
                                return addFileUrl(rp.getClient(), wbs.getUid(), o, _f -> updateWbSize(wb, _f));
                            });
                            if (updated[0]) {
                                wbm.update(roomId, wb);
                            }
                            sendWbAll(WbAction.setSize, getAddWbJson(wb));
                            sendWbAll(WbAction.load, getObjWbJson(wb.getId(), arr));
                        } catch (Exception e) {
                            log.error("Unexpected error while loading WB", e);
                        }
                    }
                }
                break;
            case PollChart:
                break;
            default:
                {
                    JSONObject file = new JSONObject().put(ATTR_FILE_ID, fi.getId()).put(ATTR_FILE_TYPE, fi.getType().name()).put("count", fi.getCount()).put(ATTR_TYPE, "image").put("left", UPLOAD_WB_LEFT).put("top", UPLOAD_WB_TOP).put("width", fi.getWidth() == null ? DEFAULT_WIDTH : fi.getWidth()).put("height", fi.getHeight() == null ? DEFAULT_HEIGHT : fi.getHeight()).put("uid", wuid).put(ATTR_SLIDE, wb.getSlide());
                    if (FileItem.Type.Video == fi.getType() || FileItem.Type.Recording == fi.getType()) {
                        file.put(ATTR_TYPE, "video");
                        file.put(PARAM_STATUS, new JSONObject().put("paused", true).put("pos", 0.0).put("updated", System.currentTimeMillis()));
                    }
                    final String ruid = wbs.getUid();
                    if (clean) {
                        clearAll(roomId, wb.getId());
                    }
                    wb.put(wuid, file);
                    updateWbSize(wb, fi);
                    wbm.update(roomId, wb);
                    sendWbAll(WbAction.setSize, getAddWbJson(wb));
                    WbWebSocketHelper.sendWbFile(roomId, wb.getId(), ruid, file, fi);
                }
                break;
        }
    }
}
Also used : JSONTokener(com.github.openjson.JSONTokener) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) Arrays(java.util.Arrays) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) Strings(org.apache.directory.api.util.Strings) FileItemDao(org.apache.openmeetings.db.dao.file.FileItemDao) LoggerFactory(org.slf4j.LoggerFactory) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) WbWebSocketHelper.getWbJson(org.apache.openmeetings.web.room.wb.WbWebSocketHelper.getWbJson) PDImageXObject(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) Base64(org.apache.commons.codec.binary.Base64) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) WhiteboardManager(org.apache.openmeetings.web.app.WhiteboardManager) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) JSONArray(com.github.openjson.JSONArray) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Right(org.apache.openmeetings.db.entity.room.Room.Right) ListView(org.apache.wicket.markup.html.list.ListView) ResourceReference(org.apache.wicket.request.resource.ResourceReference) ZoomMode(org.apache.openmeetings.db.dto.room.Whiteboard.ZoomMode) Method(org.apache.wicket.ajax.attributes.AjaxRequestAttributes.Method) NullStringer(org.apache.openmeetings.util.NullStringer) BufferedImage(java.awt.image.BufferedImage) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) ListItem(org.apache.wicket.markup.html.list.ListItem) Set(java.util.Set) UUID(java.util.UUID) Room(org.apache.openmeetings.db.entity.room.Room) List(java.util.List) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) WbWebSocketHelper.getObjWbJson(org.apache.openmeetings.web.room.wb.WbWebSocketHelper.getObjWbJson) Entry(java.util.Map.Entry) LosslessFactory(org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory) PDPage(org.apache.pdfbox.pdmodel.PDPage) JSONTokener(com.github.openjson.JSONTokener) ATTR_TYPE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_TYPE) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NameDialog(org.apache.openmeetings.web.common.NameDialog) HashMap(java.util.HashMap) Deque(java.util.Deque) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PDPageContentStream(org.apache.pdfbox.pdmodel.PDPageContentStream) OmFileHelper(org.apache.openmeetings.util.OmFileHelper) ATTR_FILE_TYPE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_FILE_TYPE) AppendMode(org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode) PARAM_STATUS(org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_STATUS) LinkedList(java.util.LinkedList) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) RoomPanel(org.apache.openmeetings.web.room.RoomPanel) ITEMS_KEY(org.apache.openmeetings.db.dto.room.Whiteboard.ITEMS_KEY) Logger(org.slf4j.Logger) ATTR_CLASS(org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_CLASS) ATTR_SLIDE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_SLIDE) Files(java.nio.file.Files) ATTR_FILE_ID(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_FILE_ID) IOException(java.io.IOException) Client(org.apache.openmeetings.db.entity.basic.Client) AttributeModifier.append(org.apache.wicket.AttributeModifier.append) FileItem(org.apache.openmeetings.db.entity.file.FileItem) JSONObject(com.github.openjson.JSONObject) File(java.io.File) Consumer(java.util.function.Consumer) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle) TreeMap(java.util.TreeMap) BufferedReader(java.io.BufferedReader) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) JSONObject(com.github.openjson.JSONObject) BufferedReader(java.io.BufferedReader) JSONArray(com.github.openjson.JSONArray) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) File(java.io.File) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) IOException(java.io.IOException)

Example 2 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class VideoInfo method newDownloadMenuList.

private List<IMenuItem> newDownloadMenuList() {
    List<IMenuItem> list = new ArrayList<>();
    // mp4
    list.add(new MenuItem(EXTENSION_MP4, JQueryIcon.ARROWTHICKSTOP_1_S) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            BaseFileItem r = rm.getObject();
            return r != null && r.exists(EXTENSION_MP4) && !r.isReadOnly();
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            download.initiate(target);
        }
    });
    return list;
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IMenuItem(com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem) ArrayList(java.util.ArrayList) IMenuItem(com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem) MenuItem(com.googlecode.wicket.jquery.ui.widget.menu.MenuItem)

Example 3 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class RoomForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    RequiredTextField<String> name = new RequiredTextField<>("name");
    name.setLabel(new Model<>(getString("165")));
    add(name);
    add(new // 
    DropDownChoice<>(// 
    "capacity", // 
    DROPDOWN_NUMBER_OF_PARTICIPANTS, new ChoiceRenderer<Long>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Long id) {
            return id;
        }

        @Override
        public String getIdValue(Long id, int index) {
            return "" + id;
        }
    }));
    add(new RoomTypeDropDown("type").setRequired(true).setLabel(Model.of(getString("45"))));
    add(new TextArea<String>("comment"));
    boolean isGroupAdmin = hasGroupAdminLevel(getRights());
    add(new CheckBox("appointment").setEnabled(false));
    add(new CheckBox("ispublic").setEnabled(!isGroupAdmin));
    List<Group> orgList = isGroupAdmin ? groupDao.get(null, getUserId(), 0, Integer.MAX_VALUE, null) : groupDao.get(0, Integer.MAX_VALUE);
    final List<RoomGroup> orgRooms = new ArrayList<>(orgList.size());
    for (Group org : orgList) {
        orgRooms.add(new RoomGroup(org, getModelObject()));
    }
    add(new Select2MultiChoice<>("groups", null, new RestrictiveChoiceProvider<RoomGroup>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(RoomGroup choice) {
            String name = choice.getGroup().getName();
            return name == null ? "" : name;
        }

        @Override
        public String toId(RoomGroup choice) {
            Long id = choice.getGroup().getId();
            return id == null ? null : "" + id;
        }

        @Override
        public void query(String term, int page, Response<RoomGroup> response) {
            response.addAll(orgRooms.stream().filter(rg -> Strings.isEmpty(term) || rg.getGroup().getName().contains(term)).collect(Collectors.toList()));
        }

        @Override
        public RoomGroup fromId(String _id) {
            Long id = Long.valueOf(_id);
            if (!orgList.stream().filter(g -> g.getId().equals(id)).findFirst().isPresent()) {
                // seems to be hacked
                return null;
            }
            Group g = groupDao.get(id);
            return new RoomGroup(g, RoomForm.this.getModelObject());
        }
    }).setLabel(Model.of(getString("828"))).setRequired(isGroupAdmin));
    add(new CheckBox("isDemoRoom"));
    TextField<Integer> demoTime = new TextField<>("demoTime");
    demoTime.setLabel(new Model<>(getString("637")));
    add(demoTime);
    add(new CheckBox("allowUserQuestions"));
    add(new CheckBox("audioOnly"));
    add(new CheckBox("closed"));
    add(new TextField<String>("redirectURL"));
    add(new CheckBox("waitForRecording"));
    add(new CheckBox("allowRecording"));
    add(new CheckBox("chatModerated"));
    add(new Select2MultiChoice<>("hiddenElements", null, new ChoiceProvider<RoomElement>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(RoomElement choice) {
            return choice.name();
        }

        @Override
        public String getIdValue(RoomElement choice) {
            return choice.name();
        }

        @Override
        public void query(String term, int page, Response<RoomElement> response) {
            for (RoomElement r : RoomElement.values()) {
                if (Strings.isEmpty(term) || r.name().contains(term)) {
                    response.add(r);
                }
            }
        }

        @Override
        public Collection<RoomElement> toChoices(Collection<String> ids) {
            Collection<RoomElement> rights = new ArrayList<>(ids.size());
            for (String id : ids) {
                rights.add(RoomElement.valueOf(id));
            }
            return rights;
        }
    }));
    add(new CheckBox("chatOpened"));
    add(new CheckBox("filesOpened"));
    add(new CheckBox("autoVideoSelect"));
    // Moderators
    final Select2Choice<User> moderatorChoice = new Select2Choice<>("moderator2add", moderator2add, new AdminUserChoiceProvider() {

        private static final long serialVersionUID = 1L;

        @Override
        public void query(String term, int page, Response<User> response) {
            response.addAll(userDao.get(term, false, page * PAGE_SIZE, PAGE_SIZE));
            response.setHasMore(PAGE_SIZE == response.getResults().size());
        }

        @Override
        public String getDisplayValue(User choice) {
            Address a = choice.getAddress();
            return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(), a == null ? "" : a.getEmail());
        }
    });
    moderatorChoice.getSettings().setCloseOnSelect(true);
    add(moderatorChoice.add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Room r = RoomForm.this.getModelObject();
            User u = moderator2add.getObject();
            boolean found = false;
            if (u != null) {
                if (r.getModerators() == null) {
                    r.setModerators(new ArrayList<RoomModerator>());
                }
                for (RoomModerator rm : r.getModerators()) {
                    if (rm.getUser().getId().equals(u.getId())) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    RoomModerator rm = new RoomModerator();
                    rm.setRoomId(r.getId());
                    rm.setUser(u);
                    r.getModerators().add(0, rm);
                    moderator2add.setObject(null);
                    target.add(moderatorContainer, moderatorChoice);
                }
            }
        }
    }).setOutputMarkupId(true));
    add(moderatorContainer.add(new ListView<RoomModerator>("moderators") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<RoomModerator> item) {
            RoomModerator moderator = item.getModelObject();
            Label name = new Label("uName", moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname());
            if (moderator.getId() == null) {
                name.add(AttributeModifier.append(ATTR_CLASS, "newItem"));
            }
            item.add(new CheckBox("superModerator", new PropertyModel<Boolean>(moderator, "superModerator"))).add(new Label("userId", "" + moderator.getUser().getId())).add(name).add(new Label("email", moderator.getUser().getAddress().getEmail())).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    RoomForm.this.getModelObject().getModerators().remove(item.getIndex());
                    target.add(moderatorContainer);
                }
            });
        }
    }).setOutputMarkupId(true));
    add(new CheckBox("moderated"));
    // Files
    Form<Void> filesForm = new Form<>("filesForm");
    add(filesForm.add(new Select2MultiChoice<>("files2add", files2add, new ChoiceProvider<BaseFileItem>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(BaseFileItem f) {
            return f.getName();
        }

        @Override
        public String getIdValue(BaseFileItem f) {
            return "" + f.getId();
        }

        @Override
        public void query(String term, int page, Response<BaseFileItem> response) {
            response.addAll(fileDao.getAllRoomFiles(term, page * PAGE_SIZE, PAGE_SIZE, RoomForm.this.getModelObject().getId(), orgList));
            response.setHasMore(PAGE_SIZE == response.getResults().size());
        }

        @Override
        public Collection<BaseFileItem> toChoices(Collection<String> ids) {
            return fileDao.get(ids);
        }
    }).setLabel(Model.of(getString("245")))).add(new TextField<Long>("wbidx", wbIdx) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String[] getInputTypes() {
            return new String[] { "number" };
        }
    }).add(new AjaxButton("addFiles") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            Room r = RoomForm.this.getModelObject();
            if (r.getFiles() == null) {
                r.setFiles(new ArrayList<>());
            }
            for (BaseFileItem f : files2add.getObject()) {
                r.getFiles().add(new RoomFile(r.getId(), f, wbIdx.getObject()));
            }
            target.add(filesContainer, filesForm);
        }

        @Override
        protected String getIcon() {
            return JQueryIcon.PLUSTHICK;
        }
    }).setOutputMarkupId(true));
    add(filesContainer.add(new ListView<RoomFile>("files") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<RoomFile> item) {
            final RoomFile rf = item.getModelObject();
            item.add(new Label("name", new PropertyModel<>(rf.getFile(), "name"))).add(new Label("wbIdx", new PropertyModel<>(rf, "wbIdx"))).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    Room r = RoomForm.this.getModelObject();
                    for (Iterator<RoomFile> iter = r.getFiles().iterator(); iter.hasNext(); ) {
                        RoomFile _rf = iter.next();
                        if (_rf.getFile().getId().equals(rf.getFile().getId())) {
                            iter.remove();
                            break;
                        }
                    }
                    target.add(filesContainer);
                }
            });
        }
    }).setOutputMarkupId(true));
    // Users in this Room
    add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true));
    add(new TextField<String>("confno").setEnabled(false));
    add(pin);
    pin.setEnabled(getModelObject().isSipEnabled());
    add(new TextField<String>("ownerId").setEnabled(false));
    add(new AjaxCheckBox("sipEnabled") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateView(target);
        }
    }.setOutputMarkupId(true));
    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
Also used : Arrays(java.util.Arrays) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) WebSession.getUserId(org.apache.openmeetings.web.app.WebSession.getUserId) FileItemDao(org.apache.openmeetings.db.dao.file.FileItemDao) AdminBaseForm(org.apache.openmeetings.web.admin.AdminBaseForm) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) TextField(org.apache.wicket.markup.html.form.TextField) User(org.apache.openmeetings.db.entity.user.User) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Strings(org.apache.wicket.util.string.Strings) IModel(org.apache.wicket.model.IModel) ChoiceProvider(org.wicketstuff.select2.ChoiceProvider) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) Duration(org.apache.wicket.util.time.Duration) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) Model(org.apache.wicket.model.Model) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) AttributeModifier(org.apache.wicket.AttributeModifier) Collectors(java.util.stream.Collectors) RoomDao(org.apache.openmeetings.db.dao.room.RoomDao) Room(org.apache.openmeetings.db.entity.room.Room) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Response(org.wicketstuff.select2.Response) PAGE_SIZE(org.apache.openmeetings.web.admin.AdminUserChoiceProvider.PAGE_SIZE) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown) List(java.util.List) Group(org.apache.openmeetings.db.entity.user.Group) PropertyModel(org.apache.wicket.model.PropertyModel) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) Form(org.apache.wicket.markup.html.form.Form) AjaxButton(com.googlecode.wicket.jquery.ui.form.button.AjaxButton) UserDao(org.apache.openmeetings.db.dao.user.UserDao) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) CheckBox(org.apache.wicket.markup.html.form.CheckBox) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ArrayList(java.util.ArrayList) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) AuthLevelUtil.hasGroupAdminLevel(org.apache.openmeetings.db.util.AuthLevelUtil.hasGroupAdminLevel) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) Address(org.apache.openmeetings.db.entity.user.Address) CollectionModel(org.apache.wicket.model.util.CollectionModel) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) TextArea(org.apache.wicket.markup.html.form.TextArea) JQueryIcon(com.googlecode.wicket.jquery.ui.JQueryIcon) ATTR_CLASS(org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_CLASS) Application.kickUser(org.apache.openmeetings.web.app.Application.kickUser) Iterator(java.util.Iterator) Select2Choice(org.wicketstuff.select2.Select2Choice) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) Client(org.apache.openmeetings.db.entity.basic.Client) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ClientManager(org.apache.openmeetings.web.app.ClientManager) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebSession.getRights(org.apache.openmeetings.web.app.WebSession.getRights) RoomModerator(org.apache.openmeetings.db.entity.room.RoomModerator) Address(org.apache.openmeetings.db.entity.user.Address) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) AjaxButton(com.googlecode.wicket.jquery.ui.form.button.AjaxButton) TextField(org.apache.wicket.markup.html.form.TextField) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) RoomModerator(org.apache.openmeetings.db.entity.room.RoomModerator) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) ChoiceProvider(org.wicketstuff.select2.ChoiceProvider) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) Collection(java.util.Collection) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) Group(org.apache.openmeetings.db.entity.user.Group) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) User(org.apache.openmeetings.db.entity.user.User) Application.kickUser(org.apache.openmeetings.web.app.Application.kickUser) AdminBaseForm(org.apache.openmeetings.web.admin.AdminBaseForm) Form(org.apache.wicket.markup.html.form.Form) Room(org.apache.openmeetings.db.entity.room.Room) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) Select2Choice(org.wicketstuff.select2.Select2Choice) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) PropertyModel(org.apache.wicket.model.PropertyModel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) Response(org.wicketstuff.select2.Response) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown)

Example 4 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class FileItemTree method newContentComponent.

@Override
protected Component newContentComponent(String id, IModel<BaseFileItem> node) {
    return new Folder<BaseFileItem>(id, this, node) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Component newLabelComponent(String id, final IModel<BaseFileItem> lm) {
            BaseFileItem r = lm.getObject();
            return Type.Folder == r.getType() || r.getId() == null ? new FolderPanel(id, lm, treePanel) : new FileItemPanel(id, lm, treePanel);
        }

        @Override
        protected boolean isSelected() {
            return treePanel.isSelected(getModelObject());
        }

        @Override
        protected boolean isClickable() {
            return FileItemTree.isClickable();
        }

        @Override
        protected void onClick(Optional<AjaxRequestTarget> targetOptional) {
            FileItemTree.this.onClick(targetOptional.get(), getModelObject());
        }

        @Override
        protected MarkupContainer newLinkComponent(String id, IModel<BaseFileItem> model) {
            final BaseFileItem f = getModelObject();
            return new AjaxLink<Void>(id) {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return FileItemTree.isClickable();
                }

                @Override
                public void onClick(AjaxRequestTarget target) {
                    FileItemTree.this.onClick(target, f);
                }

                @Override
                protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                    super.updateAjaxAttributes(attributes);
                    attributes.getDynamicExtraParameters().add(String.format("return {%s: JSON.stringify({%s: attrs.event.shiftKey, %s: attrs.event.ctrlKey})};", PARAM_MOD, PARAM_SHIFT, PARAM_CTRL));
                }
            };
        }

        @Override
        protected String getOtherStyleClass(BaseFileItem r) {
            return getItemStyle(r, false);
        }

        @Override
        protected String getOpenStyleClass() {
            return getItemStyle(getModelObject(), true);
        }

        @Override
        protected String getClosedStyleClass() {
            return getItemStyle(getModelObject(), false);
        }

        @Override
        protected String getSelectedStyleClass() {
            return "ui-state-active";
        }

        @Override
        protected IModel<String> newLabelModel(IModel<BaseFileItem> model) {
            return Model.of(model.getObject().getName());
        }
    };
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) IModel(org.apache.wicket.model.IModel) Optional(java.util.Optional) Folder(org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 5 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class FileTreePanel method deleteAll.

private void deleteAll(AjaxRequestTarget target) {
    for (Entry<String, BaseFileItem> e : selected.entrySet()) {
        BaseFileItem f = e.getValue();
        if (!f.isReadOnly()) {
            delete(f, target);
        }
    }
    updateSelected(target);
    selected.clear();
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem)

Aggregations

BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)18 FileItem (org.apache.openmeetings.db.entity.file.FileItem)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 ArrayList (java.util.ArrayList)6 RoomFile (org.apache.openmeetings.db.entity.room.RoomFile)4 JSONObject (com.github.openjson.JSONObject)3 File (java.io.File)3 List (java.util.List)3 Recording (org.apache.openmeetings.db.entity.record.Recording)3 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)2 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)2 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 FileItemDao (org.apache.openmeetings.db.dao.file.FileItemDao)2 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)2 Client (org.apache.openmeetings.db.entity.basic.Client)2 Room (org.apache.openmeetings.db.entity.room.Room)2