001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.examples.propertysheet;
011:
012: import org.eclipse.core.runtime.IAdaptable;
013: import org.eclipse.swt.graphics.RGB;
014: import org.eclipse.ui.texteditor.IDocumentProvider;
015:
016: /**
017: * This class is an example of the implementation of a simple parser.
018: */
019: public class UserFileParser {
020: /**
021: * Return the fabricated result for this example.
022: *
023: */
024: private static IAdaptable getFabricatedResult() {
025: // returns fabricated input.
026: GroupElement root = new GroupElement(MessageUtil
027: .getString("Everybody"), null); //$NON-NLS-1$
028: GroupElement userGroup = root.createSubGroup(MessageUtil
029: .getString("Company_Inc")); //$NON-NLS-1$
030: GroupElement ottGroup = userGroup.createSubGroup(MessageUtil
031: .getString("Waterloo_Lab")); //$NON-NLS-1$
032: userGroup.createSubGroup(MessageUtil.getString("Toronto_Lab")); //$NON-NLS-1$
033: userGroup.createSubGroup(MessageUtil.getString("Hamilton_Lab")); //$NON-NLS-1$
034: userGroup.createSubGroup(MessageUtil.getString("London_Lab")); //$NON-NLS-1$
035: userGroup.createSubGroup(MessageUtil.getString("Grimsby_Lab")); //$NON-NLS-1$
036: GroupElement uiTeam = ottGroup.createSubGroup(MessageUtil
037: .getString("Team1")); //$NON-NLS-1$
038: //
039: UserElement user1 = uiTeam.createUser("richard"); //$NON-NLS-1$
040: user1.setFullName(new Name(MessageUtil
041: .getString("Richard_Zokol"))); //$NON-NLS-1$
042: user1.setEmailAddress(new EmailAddress(MessageUtil
043: .getString("rzokol@company.com"))); //$NON-NLS-1$
044: user1.setPhoneNumber("x789"); //$NON-NLS-1$
045: user1
046: .setAddress(new Address(
047: new StreetAddress(232, MessageUtil
048: .getString("Champlain")), MessageUtil.getString("Hull"), new Integer(5), MessageUtil.getString("A1B2C3"))); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
049: user1.setBirthday(new Birthday(18, 1, 1981));
050: user1.setCoop(new Boolean(true));
051: user1.setHairColor(new RGB(0, 0, 0));
052: user1.setEyeColor(new RGB(0, 0, 0));
053: //
054: UserElement user2 = uiTeam.createUser("george"); //$NON-NLS-1$
055: user2.setFullName(new Name(MessageUtil
056: .getString("George_Knudson"))); //$NON-NLS-1$
057: user2.setEmailAddress(new EmailAddress(MessageUtil
058: .getString("gknudson@company.com"))); //$NON-NLS-1$
059: user2.setPhoneNumber("x678"); //$NON-NLS-1$
060: user2
061: .setAddress(new Address(
062: new StreetAddress(),
063: MessageUtil.getString("Toronto"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
064: user2.setBirthday(new Birthday(7, 5, 1978));
065: user2.setCoop(new Boolean(true));
066: user2.setHairColor(new RGB(0, 0, 0));
067: user2.setEyeColor(new RGB(0, 0, 0));
068:
069: //
070: UserElement user3 = uiTeam.createUser("arnold"); //$NON-NLS-1$
071: user3.setFullName(new Name(MessageUtil
072: .getString("Arnold_Palmer"))); //$NON-NLS-1$
073: user3.setEmailAddress(new EmailAddress(MessageUtil
074: .getString("apalmer@company.com"))); //$NON-NLS-1$
075: user3.setPhoneNumber("x567"); //$NON-NLS-1$
076: user3
077: .setAddress(new Address(
078: new StreetAddress(),
079: MessageUtil.getString("Ottawa"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
080: user3.setBirthday(new Birthday(11, 23, 1962));
081: user3.setHairColor(new RGB(0, 0, 0));
082: user3.setEyeColor(new RGB(0, 0, 0));
083:
084: //
085: UserElement user4 = uiTeam.createUser("lee"); //$NON-NLS-1$
086: user4
087: .setFullName(new Name(MessageUtil
088: .getString("Lee_Trevino"))); //$NON-NLS-1$
089: user4.setEmailAddress(new EmailAddress(MessageUtil
090: .getString("ltrevino@company.com"))); //$NON-NLS-1$
091: user4.setPhoneNumber("x456"); //$NON-NLS-1$
092: user4
093: .setAddress(new Address(
094: new StreetAddress(),
095: MessageUtil.getString("Ottawa"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
096: //
097: UserElement user5 = uiTeam.createUser("tiger"); //$NON-NLS-1$
098: user5
099: .setFullName(new Name(MessageUtil
100: .getString("Tiger_Woods"))); //$NON-NLS-1$
101: user5.setEmailAddress(new EmailAddress(MessageUtil
102: .getString("twoods@company.com"))); //$NON-NLS-1$
103: user5.setPhoneNumber("x345"); //$NON-NLS-1$
104: user5
105: .setAddress(new Address(
106: new StreetAddress(),
107: MessageUtil.getString("Ottawa"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
108: //
109: UserElement user6 = uiTeam.createUser("jack"); //$NON-NLS-1$
110: user6.setFullName(new Name(MessageUtil
111: .getString("Jack_Nicklaus"))); //$NON-NLS-1$
112: user6.setEmailAddress(new EmailAddress(MessageUtil
113: .getString("jnicklaus@company.com"))); //$NON-NLS-1$
114: user6.setPhoneNumber("x234 "); //$NON-NLS-1$
115: user6
116: .setAddress(new Address(
117: new StreetAddress(),
118: MessageUtil.getString("Ottawa"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
119: //
120: UserElement greg = uiTeam.createUser("weslock"); //$NON-NLS-1$
121: greg.setFullName(new Name(MessageUtil.getString("Weslock"))); //$NON-NLS-1$
122: greg.setEmailAddress(new EmailAddress(MessageUtil
123: .getString("weslock@company.com"))); //$NON-NLS-1$
124: greg.setPhoneNumber("x123"); //$NON-NLS-1$
125: greg
126: .setAddress(new Address(
127: new StreetAddress(),
128: MessageUtil.getString("Ottawa"), new Integer(4), MessageUtil.getString("A1B2C3"))); //$NON-NLS-2$ //$NON-NLS-1$
129:
130: return root;
131: }
132:
133: /**
134: * Parse the input given by the argument. For this example we do no parsing and return
135: * a fabricated result.
136: *
137: */
138: public IAdaptable parse(IDocumentProvider documentProvider) {
139:
140: return getFabricatedResult();
141: }
142: }
|