Skip to main content
summaryrefslogtreecommitdiffstats
blob: ccc550bf0b4ff9ec592979e7421b6dfff1c8b10e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*******************************************************************************
 * Copyright (c) 2011 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.display.view.web.components;

import org.eclipse.osee.display.api.search.SearchNavigator;
import org.eclipse.osee.display.api.search.SearchPresenter;
import org.eclipse.osee.display.view.web.HasLogger;
import org.eclipse.osee.display.view.web.HasNavigator;
import org.eclipse.osee.display.view.web.HasPresenter;
import org.eclipse.osee.display.view.web.HasUrl;
import com.vaadin.Application;
import com.vaadin.ui.Component;

/**
 * @author Roberto E. Escobar
 */
public final class ComponentUtility {

   private ComponentUtility() {
      // Utility Class
   }

   public static boolean isAccessible(Component... components) {
      boolean result = true;
      if (components == null) {
         result = false;
      } else {
         for (Component component : components) {
            result &= component != null;
         }
      }
      return result;
   }

   public static SearchNavigator getNavigator(Component component) {
      SearchNavigator navigator = null;
      Application app = component.getApplication();
      if (app instanceof HasNavigator) {
         navigator = ((HasNavigator) app).getNavigator();
      }
      return navigator;
   }

   public static String getUrl(Component component) {
      String url = null;
      Application app = component.getApplication();
      if (app instanceof HasUrl) {
         url = ((HasUrl) app).getUrl();
      }
      return url;
   }

   public static void setUrl(Component component, String url) {
      Application app = component.getApplication();
      if (app instanceof HasUrl) {
         ((HasUrl) app).setUrl(url);
      }
   }

   public static SearchPresenter<?, ?> getPresenter(Component component) {
      SearchPresenter presenter = null;
      Application app = component.getApplication();
      if (app instanceof HasPresenter) {
         presenter = ((HasPresenter) app).getPresenter();
      }
      return presenter;
   }

   public static void logError(String format, Component component, Object... args) {
      Application app = component.getApplication();
      if (app instanceof HasLogger) {
         ((HasLogger) app).logError(format, args);
      }
   }

   public static void logWarn(String format, Component component, Object... args) {
      Application app = component.getApplication();
      if (app instanceof HasLogger) {
         ((HasLogger) app).logWarn(format, args);
      }
   }

   public static void logInfo(String format, Component component, Object... args) {
      Application app = component.getApplication();
      if (app instanceof HasLogger) {
         ((HasLogger) app).logInfo(format, args);
      }
   }

   public static void logDebug(String format, Component component, Object... args) {
      Application app = component.getApplication();
      if (app instanceof HasLogger) {
         ((HasLogger) app).logDebug(format, args);
      }
   }
}

Back to the top