View Javadoc

1   /*
2    *  Licensed under the Apache License, Version 2.0 (the "License");
3    *  you may not use this file except in compliance with the License.
4    *  You may obtain a copy of the License at
5    *
6    *      http://www.apache.org/licenses/LICENSE-2.0
7    *
8    *  Unless required by applicable law or agreed to in writing, software
9    *  distributed under the License is distributed on an "AS IS" BASIS,
10   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   *  See the License for the specific language governing permissions and
12   *  limitations under the License.
13   */
14  /*
15   * This file has been modified by Chris Pheby in accordance with Section 4.2
16   * of the Apache Software License
17   */
18  package org.jadira.dependencynavigator.controller;
19  
20  public class Controller {
21  
22      // TODO all resolution over multiple repositories (file/http/workspace)
23      // TODO optional caching for remote repositories?
24      // TODO allow user to load a file for a given dependency from the tree
25      // TODO indicate different repositories in tree
26  
27      private BooleanController checkShowCompile = new BooleanController(true);
28      private BooleanController checkShowTest = new BooleanController(false);
29      private BooleanController checkShowRuntime = new BooleanController(true);
30      private BooleanController checkShowProvided = new BooleanController(true);
31      private BooleanController resolveExclusions = new BooleanController(true);
32  
33      boolean includeScope(String scope) {
34          if ("compile".equalsIgnoreCase(scope) && !checkShowCompile.value) {
35              return false;
36          }
37          if ("test".equalsIgnoreCase(scope) && !checkShowTest.value) {
38              return false;
39          }
40          if ("runtime".equalsIgnoreCase(scope) && !checkShowRuntime.value) {
41              return false;
42          }
43          if ("provided".equalsIgnoreCase(scope) && !checkShowProvided.value) {
44              return false;
45          }
46          return true;
47      }
48  
49      /**
50       * a mutable boolean, used as a lightweight non-swing dependant model
51       */
52      public class BooleanController {
53  
54          private boolean value;
55  
56          private BooleanController(boolean value) {
57              this.value = value;
58          }
59  
60          public boolean getValue() {
61              return value;
62          }
63  
64          public void toggle() {
65              value = !value;
66          }
67  
68      }
69  
70      public BooleanController getCheckShowCompile() {
71          return checkShowCompile;
72      }
73  
74      public BooleanController getCheckShowProvided() {
75          return checkShowProvided;
76      }
77  
78      public BooleanController getCheckShowRuntime() {
79          return checkShowRuntime;
80      }
81  
82      public BooleanController getCheckShowTest() {
83          return checkShowTest;
84      }
85  
86      public BooleanController getResolveExclusions() {
87          return resolveExclusions;
88      }
89  }