htmlcompactweekviewpage.java

来自「Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI」· Java 代码 · 共 90 行

JAVA
90
字号
/*--------------------------------------------------------------------------*
 | Copyright (C) 2006 Christopher Kohlhaas                                  |
 |                                                                          |
 | This program is free software; you can redistribute it and/or modify     |
 | it under the terms of the GNU General Public License as published by the |
 | Free Software Foundation. A copy of the license has been included with   |
 | these distribution in the COPYING file, if not go to www.fsf.org         |
 |                                                                          |
 | As a special exception, you are granted the permissions to link this     |
 | program with every library, which license fulfills the Open Source       |
 | Definition as published by the Open Source Initiative (OSI).             |
 *--------------------------------------------------------------------------*/
package org.rapla.plugin.compactweekview;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.rapla.components.calendarview.html.AbstractHTMLView;
import org.rapla.components.calendarview.html.HTMLCompactWeekView;
import org.rapla.components.util.xml.XMLWriter;
import org.rapla.entities.domain.Allocatable;
import org.rapla.framework.RaplaContext;
import org.rapla.framework.RaplaException;
import org.rapla.gui.CalendarModel;
import org.rapla.gui.CalendarOptions;
import org.rapla.plugin.abstractcalendar.AbstractHTMLCalendarPage;
import org.rapla.plugin.abstractcalendar.GroupAllocatablesStrategy;
import org.rapla.plugin.abstractcalendar.RaplaBuilder;

public class HTMLCompactWeekViewPage extends AbstractHTMLCalendarPage
{

    public HTMLCompactWeekViewPage( RaplaContext context, CalendarModel calendarModel) throws RaplaException
    {
        super( context,  calendarModel);
    }

    protected AbstractHTMLView createCalendarView() {
        HTMLCompactWeekView weekView = new HTMLCompactWeekView();
        CalendarOptions opt = getCalendarOptions();
        Set excludeDays = opt.getExcludeDays();
        weekView.setExcludeDays( excludeDays );
        return weekView;

    }

    protected RaplaBuilder createBuilder() throws RaplaException {
        RaplaBuilder builder = super.createBuilder();

        builder.setSmallBlocks( true );
        builder.setSplitByAllocatables( true );

        GroupAllocatablesStrategy strategy;
        if ( builder.getAllocatables().size() > 0) {
            strategy = new GroupAllocatablesStrategy( getRaplaLocale().getLocale() );
            strategy.setAllocationGroups( builder.getAllocatables() ) ;
        } else {
            // put all Allocatables in the same group
            strategy = new GroupAllocatablesStrategy( getRaplaLocale().getLocale() ) {
                protected Collection group(List blockList) {
                    ArrayList list = new ArrayList();
                    list.add( blockList );
                    return list;
                }
            };
        }
        strategy.setFixedSlotsEnabled( true );
        builder.setBuildStrategy( strategy );

        List allocatables = builder.getAllocatables();
        String[] slotNames = new String[ allocatables.size() ];
        for (int i = 0; i < slotNames.length; i++ ) {
            Allocatable allocatable = (Allocatable) allocatables.get( i );
            String slotName = allocatable.getName( getRaplaLocale().getLocale() );
            slotNames[i] = XMLWriter.encode( slotName );
        }
        ((HTMLCompactWeekView)view).setSlots( slotNames );
        return builder;
    }

    protected int getIncrementSize() {
        return Calendar.WEEK_OF_YEAR;
    }

}

⌨️ 快捷键说明

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