Bug #1342: Show save button in Gantt view when it is disabled
Add new method to ICommand to allow specify when a command is disabled or not. In a disabled command the method doAction is not going to be called when you click in the button. Set ISaveCommand to disabled when user doesn't have permissions to save the order or the order is marked as STORED. FEA: ItEr76S04BugFixing
This commit is contained in:
parent
c1a69c10aa
commit
24c5a2e268
7 changed files with 70 additions and 19 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -62,13 +62,17 @@ class CommandContextualized<T> {
|
|||
result.setImage(command.getImage());
|
||||
result.setTooltiptext(command.getName());
|
||||
}
|
||||
result.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
if (command.isDisabled()) {
|
||||
result.setDisabled(true);
|
||||
} else {
|
||||
result.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
doAction();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
doAction();
|
||||
}
|
||||
});
|
||||
}
|
||||
button = result;
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -46,7 +46,9 @@ import org.zkoss.zk.ui.Component;
|
|||
|
||||
/**
|
||||
* A object that defines several extension points for gantt planner
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public class PlannerConfiguration<T> implements IDisabilityConfiguration {
|
||||
|
||||
|
|
@ -79,6 +81,11 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
|
|||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class NullCommandOnTask<T> implements ICommandOnTask<T> {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -25,7 +25,9 @@ package org.zkoss.ganttz.extensions;
|
|||
/**
|
||||
* An action that can be applied to the planner and it's wanted to be available
|
||||
* to the user <br />
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface ICommand<T> {
|
||||
|
||||
|
|
@ -35,4 +37,6 @@ public interface ICommand<T> {
|
|||
|
||||
public String getImage();
|
||||
|
||||
boolean isDisabled();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -27,7 +27,9 @@ import org.zkoss.ganttz.extensions.ICommand;
|
|||
|
||||
/**
|
||||
* Contract for {@link SaveCommandBuilder} <br />
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface ISaveCommand extends ICommand<TaskElement> {
|
||||
|
||||
|
|
@ -54,4 +56,9 @@ public interface ISaveCommand extends ICommand<TaskElement> {
|
|||
void save(IBeforeSaveActions beforeSaveActions,
|
||||
IAfterSaveActions afterSaveActions) throws ValidationException;
|
||||
|
||||
void setDisabled(boolean disabled);
|
||||
|
||||
@Override
|
||||
boolean isDisabled();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -149,6 +149,7 @@ import org.zkoss.zul.Vbox;
|
|||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
|
|
@ -1006,10 +1007,10 @@ public class OrderPlanningModel implements IOrderPlanningModel {
|
|||
private ISaveCommand setupSaveCommand(
|
||||
PlannerConfiguration<TaskElement> configuration,
|
||||
boolean writingAllowed) {
|
||||
if (!writingAllowed) {
|
||||
return null;
|
||||
}
|
||||
ISaveCommand result = planningState.getSaveCommand();
|
||||
if (!writingAllowed) {
|
||||
result.setDisabled(true);
|
||||
}
|
||||
configuration.addGlobalCommand(result);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1108,6 +1109,11 @@ public class OrderPlanningModel implements IOrderPlanningModel {
|
|||
return "/common/img/ico_back.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -27,7 +27,6 @@ import static org.libreplan.web.I18nHelper._;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
|
@ -106,13 +105,14 @@ import org.zkoss.zul.Messagebox;
|
|||
/**
|
||||
* Builds a command that saves the changes in the taskElements. It can be
|
||||
* considered the final step in the conversation <br />
|
||||
*
|
||||
*
|
||||
* In the save operation it is also kept the consistency of the
|
||||
* LimitingResourceQueueDependencies with the Dependecies between the task of
|
||||
* the planning gantt.
|
||||
*
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Javier Moran Rua <jmoran@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
|
|
@ -215,6 +215,8 @@ public class SaveCommandBuilder {
|
|||
|
||||
private final List<IAfterSaveListener> listeners = new ArrayList<IAfterSaveListener>();
|
||||
|
||||
private boolean disabled = false;
|
||||
|
||||
public SaveCommand(PlanningState planningState,
|
||||
PlannerConfiguration<TaskElement> configuration) {
|
||||
this.state = planningState;
|
||||
|
|
@ -239,6 +241,10 @@ public class SaveCommandBuilder {
|
|||
|
||||
@Override
|
||||
public void doAction(IContext<TaskElement> context) {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
save(null, new IAfterSaveActions() {
|
||||
|
||||
@Override
|
||||
|
|
@ -988,5 +994,16 @@ public class SaveCommandBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -65,6 +65,7 @@ import org.zkoss.zul.Messagebox;
|
|||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
|
|
@ -369,4 +370,9 @@ public class ReassignCommand implements IReassignCommand {
|
|||
return context.getRelativeTo().getDesktop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue