Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f908677e7fff31430ff6fda456e30c990b6838d2 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
 * 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:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.internal.cdo.view;

import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.view.CDOView;

import org.eclipse.net4j.util.properties.DefaultPropertyTester;
import org.eclipse.net4j.util.properties.IProperties;
import org.eclipse.net4j.util.properties.Properties;
import org.eclipse.net4j.util.properties.Property;

/**
 * @author Eike Stepper
 */
public class ViewProperties extends Properties<CDOView>
{
  public static final IProperties<CDOView> INSTANCE = new ViewProperties();

  private static final String CATEGORY_VIEW = "View"; //$NON-NLS-1$

  private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$

  private ViewProperties()
  {
    super(CDOView.class);

    add(new Property<CDOView>("open", //$NON-NLS-1$
        "Open", "Whether this view is open or not.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return !view.isClosed();
      }
    });

    add(new Property<CDOView>("viewID", //$NON-NLS-1$
        "ID", "The ID of this view.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getViewID();
      }
    });

    add(new Property<CDOView>("branchName") //$NON-NLS-1$
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getBranch().getName();
      }
    });

    add(new Property<CDOView>("branch", //$NON-NLS-1$
        "Branch", "The branch of this view.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getBranch().getPathName();
      }
    });

    add(new Property<CDOView>("timeStamp", //$NON-NLS-1$
        "Time Stamp", "The time stamp of this view.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return CDOCommonUtil.formatTimeStamp(view.getTimeStamp());
      }
    });

    add(new Property<CDOView>("lastUpdateTime", //$NON-NLS-1$
        "Last Update", "The time stamp of the last passive update.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return CDOCommonUtil.formatTimeStamp(view.getLastUpdateTime());
      }
    });

    add(new Property<CDOView>("readOnly", //$NON-NLS-1$
        "Read-Only", "Whether this view is read-only or not.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.isReadOnly();
      }
    });

    add(new Property<CDOView>("dirty", //$NON-NLS-1$
        "Dirty", "Whether this view is dirty or not.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.isDirty();
      }
    });

    add(new Property<CDOView>("durable", //$NON-NLS-1$
        "Durable", "Whether this view is durable or not.", CATEGORY_VIEW)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getDurableLockingID() != null;
      }
    });

    add(new Property<CDOView>("sessionID", //$NON-NLS-1$
        "Session ID", "The ID of the session of this view.", CATEGORY_SESSION)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getSession().getSessionID();
      }
    });

    add(new Property<CDOView>("userID", //$NON-NLS-1$
        "User ID", "The user ID of the session of this view.", CATEGORY_SESSION)
    {
      @Override
      protected Object eval(CDOView view)
      {
        return view.getSession().getUserID();
      }
    });
  }

  /**
   *
   */
  public static void main(String[] args)
  {
    new Tester().dumpContributionMarkup();
  }

  /**
   * @author Eike Stepper
   */
  public static final class Tester extends DefaultPropertyTester<CDOView>
  {
    public static final String NAMESPACE = "org.eclipse.emf.cdo.view";

    public Tester()
    {
      super(NAMESPACE, INSTANCE);
    }
  }
}

Back to the top