ItEr40S21ImplantacionAplicacionItEr33S10: ICommandOnTask has a method to know if it's applicable to a task.

This commit is contained in:
Óscar González Fernández 2009-12-22 13:21:49 +01:00
parent 25e3ff9f73
commit 758881b987
10 changed files with 56 additions and 4 deletions

View file

@ -102,6 +102,11 @@ public class DataForPlanner {
return null;
}
@Override
public boolean isApplicableTo(ITaskFundamentalProperties task) {
return true;
}
});
configuration.setDoubleClickCommand(new ICommandOnTask<ITaskFundamentalProperties>() {
@ -123,6 +128,11 @@ public class DataForPlanner {
return null;
}
@Override
public boolean isApplicableTo(ITaskFundamentalProperties task) {
return true;
}
});
return configuration;
}

View file

@ -93,7 +93,8 @@ public class CommandOnTaskContextualized<T> {
}
public boolean accepts(TaskComponent taskComponent) {
return true;
T domainObject = domainObjectFor(taskComponent.getTask());
return commandOnTask.isApplicableTo(domainObject);
}
}

View file

@ -73,6 +73,11 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
return null;
}
@Override
public boolean isApplicableTo(T task) {
return true;
}
}
private IAdapterToTaskFundamentalProperties<T> adapter;

View file

@ -28,4 +28,11 @@ public interface ICommandOnTask<T> {
public void doAction(IContextWithPlannerTask<T> context, T task);
/**
* @param task
* @return <code>true</code> if and only if this command is applicable to
* task
*/
public boolean isApplicableTo(T task);
}

View file

@ -48,7 +48,7 @@ public class ResourceAllocationCommand implements IResourceAllocationCommand {
@Override
public void doAction(IContextWithPlannerTask<TaskElement> context,
TaskElement task) {
if (task instanceof Task) {
if (isApplicableTo(task)) {
this.resourceAllocationController.showWindow((Task) task, context
.getTask(), planningState);
}
@ -72,5 +72,9 @@ public class ResourceAllocationCommand implements IResourceAllocationCommand {
return "/common/img/ico_allocation.png";
}
@Override
public boolean isApplicableTo(TaskElement task) {
return task instanceof Task;
}
}

View file

@ -46,7 +46,7 @@ public class CalendarAllocationCommand implements ICalendarAllocationCommand {
@Override
public void doAction(IContextWithPlannerTask<TaskElement> context,
TaskElement task) {
if (task instanceof Task) {
if (isApplicableTo(task)) {
this.calendarAllocationController.showWindow((Task) task, context
.getTask());
}
@ -68,4 +68,9 @@ public class CalendarAllocationCommand implements ICalendarAllocationCommand {
return "/common/img/ico_calendar.png";
}
@Override
public boolean isApplicableTo(TaskElement task) {
return task instanceof Task;
}
}

View file

@ -104,4 +104,9 @@ public class AddMilestoneCommand implements IAddMilestoneCommand {
return "/common/img/milestone.png";
}
@Override
public boolean isApplicableTo(TaskElement task) {
return true;
}
}

View file

@ -42,7 +42,7 @@ public class DeleteMilestoneCommand implements IDeleteMilestoneCommand {
@Override
public void doAction(IContextWithPlannerTask<TaskElement> context,
TaskElement task) {
if (task instanceof TaskMilestone) {
if (isApplicableTo(task)) {
planningState.removed(task);
context.remove(task);
}
@ -63,4 +63,9 @@ public class DeleteMilestoneCommand implements IDeleteMilestoneCommand {
this.planningState = planningState;
}
@Override
public boolean isApplicableTo(TaskElement task) {
return task instanceof TaskMilestone;
}
}

View file

@ -119,6 +119,11 @@ public class PlanningTabCreator {
public String getIcon() {
return "/common/img/ico_planificador.png";
}
@Override
public boolean isApplicableTo(TaskElement task) {
return true;
}
};
commands.add(scheduleCommand);
companyPlanningController.setAdditional(commands);

View file

@ -84,4 +84,9 @@ public class EditTaskCommand implements IEditTaskCommand {
return "/common/img/ico_editar.png";
}
@Override
public boolean isApplicableTo(TaskElement task) {
return true;
}
}