Search in sources :

Example 16 with BaseFileItem

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

the class DownloadMenuItem method onClick.

@Override
public void onClick(AjaxRequestTarget target) {
    BaseFileItem fi = tree.getLastSelected();
    File f = ext == null && (Type.Image == fi.getType() || Type.Presentation == fi.getType()) ? fi.getOriginal() : fi.getFile(ext);
    if (f != null && f.exists()) {
        tree.dwnldFile = f;
        tree.downloader.initiate(target);
    }
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) File(java.io.File)

Example 17 with BaseFileItem

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

the class FileTreePanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    download.setDefaultModelObject(newDownloadMenuList());
    Droppable<BaseFileItem> trashToolbar = new Droppable<BaseFileItem>("trash-toolbar") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("hoverClass", Options.asString("ui-state-hover trash-toolbar-hover"));
            behavior.setOption("accept", Options.asString(".recorditem, .fileitem"));
        }

        @Override
        public JQueryBehavior newWidgetBehavior(String selector) {
            return new DroppableBehavior(selector, this) {

                private static final long serialVersionUID = 1L;

                @Override
                protected JQueryAjaxBehavior newOnDropAjaxBehavior(IJQueryAjaxAware source) {
                    return new OnDropAjaxBehavior(source) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public CharSequence getCallbackFunctionBody(CallbackParameter... parameters) {
                            String dialogId = UUID.randomUUID().toString();
                            String statement = "var $drop = $(this);";
                            statement += "$('body').append('<div id=" + dialogId + ">" + getString("713") + "</div>');";
                            statement += "$( '#" + dialogId + "' ).dialog({ title: '" + escapeEcmaScript(getString("80")) + "', classes: {'ui-dialog-titlebar': 'ui-corner-all no-close'}, buttons: [";
                            statement += "	{ text: '" + escapeEcmaScript(getString("54")) + "', click: function() { $drop.append(ui.draggable); $(this).dialog('close'); " + super.getCallbackFunctionBody(parameters) + " } },";
                            statement += "	{ text: '" + escapeEcmaScript(getString("lbl.cancel")) + "', click: function() { $(this).dialog('close'); } } ";
                            statement += "],";
                            statement += "close: function(event, ui) { $(this).dialog('destroy').remove(); }";
                            statement += "});";
                            return statement;
                        }
                    };
                }
            };
        }

        @Override
        public void onDrop(AjaxRequestTarget target, Component component) {
            Object o = component.getDefaultModelObject();
            if (o instanceof BaseFileItem) {
                BaseFileItem f = (BaseFileItem) o;
                if (isSelected(f)) {
                    deleteAll(target);
                } else {
                    delete(f, target);
                }
            }
        }
    };
    form.add(trashToolbar);
    trashToolbar.add(getUpload());
    trashToolbar.add(createDir);
    trashToolbar.add(new WebMarkupContainer("refresh").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            update(target);
        }
    }));
    trashToolbar.add(trashBorder = new ConfirmableAjaxBorder("trash", getString("80"), getString("713"), trashConfirm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isClickable() {
            return !readOnly && !selected.isEmpty();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            deleteAll(target);
        }
    });
    form.add(trees.add(tree).setOutputMarkupId(true));
    updateSizes();
    form.add(sizes.add(new Label("homeSize", homeSize), new Label("publicSize", publicSize)).setOutputMarkupId(true));
    form.add(errorsDialog);
    setReadOnly(false, null);
}
Also used : JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) Label(org.apache.wicket.markup.html.basic.Label) CallbackParameter(org.apache.wicket.ajax.attributes.CallbackParameter) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IJQueryAjaxAware(com.googlecode.wicket.jquery.core.ajax.IJQueryAjaxAware) Component(org.apache.wicket.Component) DroppableBehavior(com.googlecode.wicket.jquery.ui.interaction.droppable.DroppableBehavior)

Example 18 with BaseFileItem

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

the class OmTreeProvider method refreshRoots.

public void refreshRoots(boolean all) {
    List<BaseFileItem> fRoot = new ArrayList<>(), rRoot = new ArrayList<>();
    if (all && roomId != null) {
        BaseFileItem r = createRoot(Application.getString("706"), FILES_MY, false);
        r.setOwnerId(getUserId());
        fRoot.add(r);
    }
    if (roomId != null) {
        BaseFileItem r = createRoot(Application.getString("707"), FILES_ROOM, false);
        r.setRoomId(roomId);
        fRoot.add(r);
    }
    if (all) {
        {
            BaseFileItem r = createRoot(Application.getString("860"), RECORDINGS_MY, true);
            r.setOwnerId(getUserId());
            rRoot.add(r);
        }
        {
            BaseFileItem r = createRoot(PUBLIC, RECORDINGS_PUBLIC, true);
            rRoot.add(r);
        }
    }
    for (GroupUser gu : userDao.get(getUserId()).getGroupUsers()) {
        Group g = gu.getGroup();
        boolean readOnly = g.isRestricted() && !hasAdminLevel(getRights()) && !gu.isModerator();
        if (all) {
            BaseFileItem r = createRoot(String.format("%s (%s)", GROUP_REC, g.getName()), String.format(RECORDINGS_GROUP, g.getId()), true);
            r.setReadOnly(readOnly);
            r.setGroupId(g.getId());
            rRoot.add(r);
        }
        BaseFileItem r = createRoot(String.format("%s (%s)", GROUP_FILE, g.getName()), String.format(FILES_GROUP, g.getId()), false);
        r.setGroupId(g.getId());
        // group videos are read-only in recordings tree
        r.setReadOnly(roomId == null || readOnly);
        fRoot.add(r);
    }
    roots.clear();
    if (roomId == null) {
        roots.addAll(rRoot);
        roots.addAll(fRoot);
    } else {
        roots.addAll(fRoot);
        roots.addAll(rRoot);
    }
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Group(org.apache.openmeetings.db.entity.user.Group) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) ArrayList(java.util.ArrayList)

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