BrightSide Workbench Full Report + Source Code
AbstractUserAction.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2016 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.menu;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.amic.util.string.Strings;
24 
29 @Deprecated
30 public class AbstractUserAction implements IUserAction {
31 
32  protected String id, label, image, link;
33  protected IUserCommand command;
34  protected List<IUserAction> children = new ArrayList<>();
35 
36  @Override
37  public String getId() {
38  return id;
39  }
40 
41  @Override
42  public String getLabel() {
43  return label;
44  }
45 
46  @Override
47  public String getImage() {
48  return image;
49  }
50 
51  @Override
52  public String getLink() {
53  return link == null ? UserCommand.createURL(this) : link;
54  }
55 
56  @Override
57  public boolean isValid() {
58  return !Strings.isBlank(id) &&
59  (!Strings.isBlank(link) || command != null) &&
60  (!Strings.isBlank(label) || !Strings.isBlank(image));
61  }
62 
63  @Override
64  public boolean isCaption() {
65  return Strings.isBlank(link);
66  }
67 
68  @Override
69  public boolean isOnlyLabel() {
70  return Strings.isBlank(image);
71  }
72 
73  @Override
74  public boolean isOnlyImage() {
75  return Strings.isBlank(label);
76  }
77 
78  @Override
79  public void execute() {
80  if(command != null) command.execute(this);
81  }
82 
83  public boolean addChild(IUserAction action) {
84  return children.add(action);
85  }
86 
87 }
static String createURL(IUserAction userAction)
void execute(IUserAction action)