01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal.provisional.views.markers;
11:
12: import org.eclipse.ui.IMemento;
13: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerField;
14:
15: /**
16: * MarkerState is the object that handles the state of an ExtendedMarkersView.
17: *
18: * @since 3.4
19: *
20: */
21: public class MarkerState {
22:
23: private IMemento memento;
24:
25: /**
26: * Create a new instance of the receiver from the supplied memento.
27: *
28: * @param memento
29: */
30: public MarkerState(IMemento memento) {
31: this .memento = memento;
32: }
33:
34: /**
35: * Return whether or not the receiver was the primary sort field.
36: *
37: * @param markerField
38: * @return
39: */
40: public boolean isPrimarySortField(MarkerField markerField) {
41: // TODO Hook this up to the memento
42: return markerField instanceof MarkerDescriptionAndMessageField;
43: }
44:
45: /**
46: * Return whether or not we are set to the default.
47: * @return
48: */
49: public boolean useDefaults() {
50: return memento == null;
51: }
52:
53: /**
54: * Return the integer value for the tag.
55: * @param tag
56: * @return
57: */
58: public Integer getInteger(String tag) {
59: return memento.getInteger(tag);
60: }
61:
62: /**
63: * Return the String associated with tag.
64: * @param tag
65: * @return String
66: */
67: public String getString(String tag) {
68: return memento.getString(tag);
69: }
70:
71: /**
72: * Return the sort direction stored for the field.
73: * @param field
74: * @return
75: */
76: public int getSortDirection(MarkerField field) {
77: return field.getDefaultDirection();
78: }
79:
80: }
|