📄 reservationaction.java
字号:
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas, Bettina Lademann |
| |
| 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.gui.internal.action;
import java.awt.Component;
import java.awt.Point;
import org.rapla.entities.domain.Reservation;
import org.rapla.entities.dynamictype.DynamicType;
import org.rapla.entities.dynamictype.DynamicTypeAnnotations;
import org.rapla.framework.RaplaContext;
import org.rapla.framework.RaplaException;
import org.rapla.gui.CalendarModel;
import org.rapla.gui.ReservationWizard;
import org.rapla.plugin.RaplaExtensionPoints;
public class ReservationAction extends RaplaObjectAction{
ReservationWizard m_wizard;
public final static int EXCHANGE_ALLOCATABLE = 20;
public final static int NEW_WIZARD = 800;
public ReservationAction(RaplaContext sm,Component parent,Point p) throws RaplaException {
super(sm,parent,p);
raplaType = Reservation.TYPE;
}
public ReservationAction setExchangeAllocatables(Object obj) {
this.type = EXCHANGE_ALLOCATABLE;
putValue(NAME, getString("exchange_allocatables"));
putValue(SMALL_ICON, getIcon("icon.edit"));
changeObject( obj );
return this;
}
public ReservationAction setNew(ReservationWizard wizard) {
super.setNew( Reservation.TYPE);
m_wizard = wizard;
if (m_wizard == null) {
m_wizard = (ReservationWizard) getService( RaplaExtensionPoints.RESERVATION_WIZARD_EXTENSION );
}
if (m_wizard != null)
putValue(NAME, m_wizard.toString());
return this;
}
protected void edit() throws RaplaException {
getReservationController().edit( (Reservation) object );
}
protected boolean canModifiy(Object object) {
if (super.canModify( object) ) {
return true;
}
if ( object instanceof Reservation ) {
return getQuery().canExchangeAllocatables( (Reservation) object) ;
}
return false;
}
public DynamicType guessType() throws RaplaException {
DynamicType type = super.guessType();
if ( type.getAnnotation( DynamicTypeAnnotations.KEY_CLASSIFICATION_TYPE).equals( DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION)) {
return type;
}
return getQuery().getDynamicTypes(DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION)[0];
}
public void changeObject(Object object) {
super.changeObject(object);
if (type == NEW) {
setEnabled( m_wizard != null);
}
}
protected void newEntity() throws RaplaException {
m_wizard.start(parent, (CalendarModel)getService( CalendarModel.ROLE), guessType());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -