📄 wizardsequence.java
字号:
public void setReservation(Reservation reservation) throws RaplaException {
classificationField.mapFrom(reservation);
}
public ActionMap getActionMap() {
ActionMap map = createActionMap();
map.get(PREV).setEnabled(false);
map.get(NEXT).putValue(Action.NAME, getString("reservation_wizard.appointment_menu"));
map.get(NEXT).putValue(Action.SMALL_ICON, getIcon("icon.arrow_right"));
map.get(FINISH).setEnabled(false);
return map;
}
public String getHelp() {
return getString("reservation_wizard.panel1");
}
public String getDefaultAction() {
return NEXT;
}
public boolean checkReservation() {
try {
classificationField.mapTo(reservation);
} catch (RaplaException ex) {
showException(ex,getComponent());
return false;
}
String newName = getName( reservation );
if (newName.length() ==0) {
showWarning(getString("error.no_reservation_name"), getComponent());
return false;
}
// We must clear all appointments because the period has been changed);
if (period != null && !period.equals(periodSelection.getSelectedItem())) {
panel2.removeAllAppointments();
}
period = (Period) periodSelection.getSelectedItem();
if (period == null) {
showWarning(getString("error.no_period_found"), getComponent());
return false;
}
return true;
}
public JComponent getComponent() {
return content;
}
}
class ReservationAllocation
implements
WizardPanel
{
JPanel content = new JPanel();
AppointmentSelection appointmentSelection;
AllocatableSelection allocatableSelection;
public ReservationAllocation() throws RaplaException {
appointmentSelection = new AppointmentSelection(getContext());
allocatableSelection = new AllocatableSelection(getContext());
content.setLayout(new BorderLayout());
content.add(appointmentSelection.getComponent(),BorderLayout.NORTH);
content.add(allocatableSelection.getComponent(),BorderLayout.CENTER);
Border emptyBorder = new EmptyLineBorder();
appointmentSelection.getComponent().setBorder(BorderFactory.createTitledBorder(emptyBorder, getString("enter_appointments")));
allocatableSelection.getComponent().setBorder(BorderFactory.createTitledBorder(emptyBorder, getString("select_persons_and_resources")));
}
public void setReservation(Reservation reservation) throws RaplaException {
allocatableSelection.setReservation(reservation);
appointmentSelection.setReservation(reservation);
appointmentSelection.addAppointmentListener(allocatableSelection);
}
public void refresh(ModificationEvent evt) throws RaplaException {
allocatableSelection.refresh(evt);
}
public void newAppointment(Date start,Date end) throws RaplaException {
appointmentSelection.newAppointment(start,end);
}
public void removeAllAppointments() {
appointmentSelection.removeAllAppointments();
}
public String getHelp() {
return getString("reservation_wizard.panel2");
}
public String getDefaultAction() {
return FINISH;
}
public ActionMap getActionMap() {
ActionMap map = createActionMap();
map.get(NEXT).putValue(Action.NAME, getString("reservation_wizard.search_free_appointment"));
map.get(NEXT).putValue(Action.SMALL_ICON,getIcon("icon.calendar"));
return map;
}
public Collection getAllocatables() {
return allocatableSelection.getMarkedAllocatables();
}
public JComponent getComponent() {
return content;
}
}
class ReservationWeekview
implements
WizardPanel
,ViewListener
{
JPanel content = new JPanel();
SwingWeekView wv= new SwingWeekView();
RaplaBuilder builder;
Date start= null;
Date end = null;
Action nextAction;
public ReservationWeekview() throws RaplaException {
builder = new SwingRaplaBuilder(getContext());
content.setLayout(new BorderLayout());
content.add(wv,BorderLayout.CENTER);
CalendarOptions opt = getCalendarOptions();
wv.setTimeZone( DateTools.getTimeZone());
wv.setExcludeDays( opt.getExcludeDays() );
wv.setWorktime( opt.getWorktimeStart(), opt.getWorktimeEnd());
wv.addBuilder(builder);
//wv.setDateVisible(false);
wv.addCalendarViewListener(this);
}
public void setAllocatables(Collection markedAllocatables) throws RaplaException {
Iterator it = markedAllocatables.iterator();
StringBuffer buf = new StringBuffer();
int i=0;
while (it.hasNext()) {
if (i>0)
buf.append(", ");
buf.append( getName( (Allocatable)it.next() ) );
i++;
}
String title = getI18n().format("list.format",period.getName(),buf.toString());
content.setBorder(BorderFactory.createTitledBorder(title));
wv.setToDate(period.getStart());
Collection otherReservations =
Arrays.asList(getQuery().getReservations(null
,wv.getStartDate()
,wv.getEndDate()
,null)
);
Collection reservations = new ArrayList(otherReservations);
reservations.add(reservation);
builder.selectAllocatables(markedAllocatables);
builder.selectReservations(reservations);
}
public void build() {
wv.rebuild();
wv.scrollToStart();
}
public JComponent getComponent() {
return content;
}
public String getHelp() {
return getString("reservation_wizard.panel3");
}
public ActionMap getActionMap() {
ActionMap map = createActionMap();
nextAction = map.get(NEXT);
nextAction.putValue(Action.NAME, getString("reservation_wizard.add_appointment"));
nextAction.putValue(Action.SMALL_ICON, getIcon("icon.new"));
nextAction.setEnabled(false);
map.get(FINISH).setEnabled(false);
return map;
}
public Date getStart() {
return start;
}
public String getDefaultAction() {
return FINISH;
}
public Date getEnd() {
return end;
}
// Implementation of the weekview listener
public void selectionChanged(Date start,Date end) {
this.start = start;
this.end = end;
nextAction.setEnabled( start != null && end != null );
}
public void selectionPopup(Component component,Point p,Date start,Date end, int slotNr) {
}
public void blockPopup(Block block,Point p) {
}
public void blockEdit(Block block,Point p) {
}
public void moved(Block block,Point p,Date newStart) {
}
public void resized(Block block,Point p,Date newStart, Date newEnd) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -