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

📄 abstractraplablock.java

📁 Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI
💻 JAVA
字号:
/*--------------------------------------------------------------------------*
 | Copyright (C) 2006 Gereon Fassbender, 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.abstractcalendar;

import java.util.Date;
import java.util.List;

import org.rapla.components.util.DateTools;
import org.rapla.components.xmlbundle.I18nBundle;
import org.rapla.entities.Named;
import org.rapla.entities.domain.Allocatable;
import org.rapla.entities.domain.Appointment;
import org.rapla.entities.domain.Reservation;
import org.rapla.framework.RaplaLocale;


public abstract class AbstractRaplaBlock
{
    RaplaBuilder.RaplaBlockContext m_context;
    Date m_start;
    Date m_end;
    RaplaLocale m_raplaLocale;

    AbstractRaplaBlock() {

    }

    void contextualize(RaplaBuilder.RaplaBlockContext context) {
        m_context = context;
        m_raplaLocale = getBuildContext().getRaplaLocale();
    }

    public String getName(Named named) {
        return named.getName(m_raplaLocale.getLocale());
    }

    public Date getStart()  {
        return m_start;
    }

    public Date getEnd() {
        return m_end;
    }
    
    protected I18nBundle getI18n() {
        return getBuildContext().getI18n();
    }

    void setStart(Date start) {
        m_start = start;
    }

    void setEnd(Date end) {
        m_end = end;
    }

    public Appointment getAppointment() {
        return getContext().getAppointment();
    }

    public Reservation getReservation()  {
        return getAppointment().getReservation();
    }

    RaplaBuilder.RaplaBlockContext getContext() {
        return m_context;
    }

    RaplaBuilder.BuildContext getBuildContext() {
        return getContext().getBuildContext();
    }

    public boolean isMovable() {
        return getContext().isMovable() && !isException();
    }

    public boolean startsAndEndsOnSameDay() {
        return DateTools.isSameDay(
                getAppointment().getStart().getTime()
                ,getAppointment().getEnd().getTime() -1
        )
                ;
    }

    String[] getColorsAsHex() {
        List allocatables = getContext().getColoredAllocatables();
        if (allocatables.size() ==0 ) {
            String color = RaplaBuilder.getColorForClassifiable( getReservation() );
            if ( color == null) {
                color = getBuildContext().lookupColorString(null);
            }
            return new String[] {color};
        }
        String[] results = new String[allocatables.size()];
        for (int i=0;i<allocatables.size();i++) {
            results[i] = getBuildContext().lookupColorString((Allocatable) allocatables.get(i));
        }
        return results;
    }

    String getTimeString() {
        RaplaLocale loc = getBuildContext().getRaplaLocale();
        String timeString = null;
        if ( getBuildContext().isTimeVisible()) {
            timeString = "";
            // Don't show startTime if its 00:00
            /* TODO nicht sinnvoll auch 0:00 als Start und Endzeit anzuzeigen?*/
            if ( !DateTools.isMidnight(getStart())) {
                timeString = loc.formatTime( getStart() );
            }
            if ( !DateTools.isMidnight(getEnd().getTime() + 1))  {
                timeString = timeString + " - ";
                timeString = timeString + loc.formatTime( getEnd());
           }
        }
        return timeString;
    }

    public boolean isException() {
        return getAppointment().getRepeating() != null && getAppointment().getRepeating().isException(getStart().getTime());
    }

    public boolean isStartResizable() {
        return startsAndEndsOnSameDay() && !isException();
    }

    public boolean isEndResizable() {
        return startsAndEndsOnSameDay() && !isException();
    }

}







⌨️ 快捷键说明

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