⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a_cmslistexplorerdialog.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            isColumnVisible(CmsUserSettings.FILELIST_DATE_EXPIRED));
        metadata.getColumnDefinition(LIST_COLUMN_STATE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_STATE));
        metadata.getColumnDefinition(LIST_COLUMN_LOCKEDBY).setVisible(
            isColumnVisible(CmsUserSettings.FILELIST_LOCKEDBY));
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart()
     */
    protected String defaultActionHtmlStart() {

        StringBuffer result = new StringBuffer(2048);
        result.append(htmlStart(null));
        result.append(getList().listJs(getLocale()));
        result.append(CmsListExplorerColumn.getExplorerStyleDef());
        result.append(bodyStart("dialog", null));
        result.append(dialogStart());
        result.append(dialogContentStart(getParamTitle()));
        return result.toString();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#executeSelectPage()
     */
    protected void executeSelectPage() {

        super.executeSelectPage();
        getSettings().setExplorerPage(getList().getCurrentPage());
    }

    /**
     * Returns a list of list items from a list of resources.<p>
     * 
     * @param resources a list of {@link CmsResource} objects
     * 
     * @return a list of {@link CmsListItem} objects
     */
    protected List getListItemsFromResources(List resources) {

        List ret = new ArrayList();
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_PROCESS_PROJECT_VIEW_START_1, new Integer(resources.size())));
        }
        CmsResourceUtil resUtil = getResourceUtil();
        applyColumnVisibilities();
        // get content
        Iterator itRes = resources.iterator();
        while (itRes.hasNext()) {
            CmsResource resource = (CmsResource)itRes.next();
            if (!resource.getRootPath().startsWith(getJsp().getRequestContext().getSiteRoot())
                && !resource.getRootPath().startsWith(CmsWorkplace.VFS_PATH_SYSTEM)) {
                continue;
            }
            resUtil.setResource(resource);
            CmsListItem item = getList().newItem(resource.getResourceId().toString());
            item.set(LIST_COLUMN_NAME, getCms().getSitePath(resource));
            item.set(LIST_COLUMN_TITLE, resUtil.getTitle());
            item.set(LIST_COLUMN_TYPE, resUtil.getResourceTypeName());
            item.set(LIST_COLUMN_SIZE, resUtil.getSizeString());
            item.set(LIST_COLUMN_PERMISSIONS, resUtil.getPermissions());
            item.set(LIST_COLUMN_DATELASTMOD, new Date(resource.getDateLastModified()));
            item.set(LIST_COLUMN_USERLASTMOD, resUtil.getUserLastModified());
            item.set(LIST_COLUMN_DATECREATE, new Date(resource.getDateCreated()));
            item.set(LIST_COLUMN_USERCREATE, resUtil.getUserCreated());
            item.set(LIST_COLUMN_DATEREL, new Date(resource.getDateReleased()));
            item.set(LIST_COLUMN_DATEEXP, new Date(resource.getDateExpired()));
            item.set(LIST_COLUMN_STATE, resUtil.getStateName());
            item.set(LIST_COLUMN_LOCKEDBY, resUtil.getLockedByName());
            ret.add(item);
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_PROCESS_PROJECT_VIEW_END_1, new Integer(ret.size())));
        }
        return ret;
    }

    /**
     * Returns the project to use as reference.<p>
     * 
     * @return the project to use as reference
     */
    protected CmsProject getProject() {

        return getCms().getRequestContext().currentProject();
    }

    /**
     * Returns the list of resources to show in the explorer view.<p>
     * 
     * @return a list of {@link org.opencms.file.CmsResource} objects
     */
    protected List getResources() {

        List ret = new ArrayList(getList().getContent().size());
        Iterator it = getList().getContent().iterator();
        while (it.hasNext()) {
            CmsListItem item = (CmsListItem)it.next();
            try {
                ret.add(getCms().readResource((String)item.get(LIST_COLUMN_NAME)));
            } catch (CmsException e) {
                // ignore
            }
        }
        return ret;
    }

    /**
     * Returns the visibility flag for a given column.<p>
     * 
     * The default behaviour is to show the same columns as the explorer view,
     * but this can be overwritten.<p>
     * 
     * @param colFlag some {@link CmsUserSettings#FILELIST_TITLE} like value 
     *              indentifying the column to get the visibility flag for
     *  
     * @return the visibility flag for the given column
     */
    protected boolean isColumnVisible(int colFlag) {

        if (m_colVisibilities.get(new Integer(colFlag)) instanceof Boolean) {
            return ((Boolean)m_colVisibilities.get(new Integer(colFlag))).booleanValue();
        }
        return false;
    }

    /**
     * Adds the standard explorer view columns to the list.<p>
     * 
     * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setColumns(CmsListMetadata metadata) {

        setColumnVisibilities();

        // position 1: icon
        CmsListColumnDefinition typeIconCol = new CmsListColumnDefinition(LIST_COLUMN_TYPEICON);
        typeIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_0));
        typeIconCol.setHelpText(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_HELP_0));
        typeIconCol.setWidth("20");
        typeIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        typeIconCol.setListItemComparator(new CmsListItemActionIconComparator());

        // add resource icon action
        CmsListDirectAction resourceTypeIconAction = new CmsListResourceTypeIconAction(LIST_ACTION_TYPEICON, this);
        resourceTypeIconAction.setEnabled(false);
        typeIconCol.addDirectAction(resourceTypeIconAction);
        metadata.addColumn(typeIconCol);

        // position 2: lock icon
        CmsListColumnDefinition lockIconCol = new CmsListColumnDefinition(LIST_COLUMN_LOCKICON);
        lockIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_LOCK_0));
        lockIconCol.setWidth("20");
        lockIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        lockIconCol.setListItemComparator(new CmsListItemActionIconComparator());

        // add lock icon action
        CmsListDirectAction resourceLockIconAction = new CmsListResourceLockAction(LIST_ACTION_LOCKICON, this);
        resourceLockIconAction.setEnabled(false);
        lockIconCol.addDirectAction(resourceLockIconAction);
        metadata.addColumn(lockIconCol);

        // position 3: project state icon, resource is inside or outside current project        
        CmsListColumnDefinition projStateIconCol = new CmsListColumnDefinition(LIST_COLUMN_PROJSTATEICON);
        projStateIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_PROJSTATE_0));
        projStateIconCol.setWidth("20");

        // add resource icon action
        CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(
            LIST_ACTION_PROJSTATEICON,
            this);
        resourceProjStateAction.setEnabled(false);
        projStateIconCol.addDirectAction(resourceProjStateAction);
        metadata.addColumn(projStateIconCol);

        // position 4: name
        CmsListColumnDefinition nameCol = new CmsListExplorerColumn(LIST_COLUMN_NAME);
        nameCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));

        // add resource open action
        CmsListDefaultAction resourceOpenDefAction = new CmsListOpenResourceAction(
            LIST_DEFACTION_OPEN,
            getCms(),
            LIST_COLUMN_NAME);
        resourceOpenDefAction.setEnabled(true);
        nameCol.addDefaultAction(resourceOpenDefAction);
        metadata.addColumn(nameCol);

        // position 5: title
        CmsListColumnDefinition titleCol = new CmsListExplorerColumn(LIST_COLUMN_TITLE);
        titleCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_TITLE_0));
        metadata.addColumn(titleCol);

        // position 6: resource type
        CmsListColumnDefinition typeCol = new CmsListExplorerColumn(LIST_COLUMN_TYPE);
        typeCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_TYPE_0));
        metadata.addColumn(typeCol);

        // position 7: size
        CmsListColumnDefinition sizeCol = new CmsListExplorerColumn(LIST_COLUMN_SIZE);
        sizeCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_SIZE_0));
        metadata.addColumn(sizeCol);

        // position 8: permissions
        CmsListColumnDefinition permissionsCol = new CmsListExplorerColumn(LIST_COLUMN_PERMISSIONS);
        permissionsCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_PERMISSIONS_0));
        metadata.addColumn(permissionsCol);

        // position 9: date of last modification
        CmsListColumnDefinition dateLastModCol = new CmsListExplorerColumn(LIST_COLUMN_DATELASTMOD);
        dateLastModCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_DATELASTMODIFIED_0));
        dateLastModCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
        metadata.addColumn(dateLastModCol);

        // position 10: user who last modified the resource
        CmsListColumnDefinition userLastModCol = new CmsListExplorerColumn(LIST_COLUMN_USERLASTMOD);
        userLastModCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_USERLASTMODIFIED_0));
        metadata.addColumn(userLastModCol);

        // position 11: date of creation
        CmsListColumnDefinition dateCreateCol = new CmsListExplorerColumn(LIST_COLUMN_DATECREATE);
        dateCreateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_DATECREATED_0));
        dateCreateCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
        metadata.addColumn(dateCreateCol);

        // position 12: user who created the resource
        CmsListColumnDefinition userCreateCol = new CmsListExplorerColumn(LIST_COLUMN_USERCREATE);
        userCreateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_USERCREATED_0));
        metadata.addColumn(userCreateCol);

        // position 13: date of release
        CmsListColumnDefinition dateReleaseCol = new CmsListExplorerColumn(LIST_COLUMN_DATEREL);
        dateReleaseCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_DATERELEASED_0));
        dateReleaseCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter(CmsResource.DATE_RELEASED_DEFAULT));
        metadata.addColumn(dateReleaseCol);

        // position 14: date of expiration
        CmsListColumnDefinition dateExpirationCol = new CmsListExplorerColumn(LIST_COLUMN_DATEEXP);
        dateExpirationCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_DATEEXPIRED_0));
        dateExpirationCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter(CmsResource.DATE_EXPIRED_DEFAULT));
        metadata.addColumn(dateExpirationCol);

        // position 15: state (changed, unchanged, new, deleted)
        CmsListColumnDefinition stateCol = new CmsListExplorerColumn(LIST_COLUMN_STATE);
        stateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_STATE_0));
        metadata.addColumn(stateCol);

        // position 16: locked by
        CmsListColumnDefinition lockedByCol = new CmsListExplorerColumn(LIST_COLUMN_LOCKEDBY);
        lockedByCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_LOCKEDBY_0));
        metadata.addColumn(lockedByCol);
    }

    /**
     * Sets the default column visibility flags from the user preferences.<p>
     */
    protected void setColumnVisibilities() {

        m_colVisibilities = new HashMap(16);
        // set explorer configurable column visibilities
        int preferences = new CmsUserSettings(getCms()).getExplorerSettings();
        setColumnVisibility(CmsUserSettings.FILELIST_TITLE, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_TYPE, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_SIZE, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_PERMISSIONS, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_DATE_LASTMODIFIED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_USER_LASTMODIFIED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_DATE_CREATED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_USER_CREATED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_DATE_RELEASED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_DATE_EXPIRED, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_STATE, preferences);
        setColumnVisibility(CmsUserSettings.FILELIST_LOCKEDBY, preferences);
        // set explorer no configurable column visibilities
        m_colVisibilities.put(new Integer(LIST_COLUMN_TYPEICON.hashCode()), Boolean.TRUE);
        m_colVisibilities.put(new Integer(LIST_COLUMN_LOCKICON.hashCode()), Boolean.TRUE);
        m_colVisibilities.put(new Integer(LIST_COLUMN_PROJSTATEICON.hashCode()), Boolean.TRUE);
        m_colVisibilities.put(new Integer(LIST_COLUMN_NAME.hashCode()), Boolean.TRUE);
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setIndependentActions(CmsListMetadata metadata) {

        metadata.addIndependentAction(CmsListIndependentAction.getDefaultExplorerSwitchAction());
    }

    /**
     * Sets the given column visibility flag from the given preferences.<p>
     * 
     * @param colFlag the flag that identifies the column to set the flag for
     * @param prefs the user preferences
     */
    private void setColumnVisibility(int colFlag, int prefs) {

        Integer key = new Integer(colFlag);
        Boolean value = new Boolean((prefs & colFlag) > 0);
        m_colVisibilities.put(key, value);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -