KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > composite > parser > EditableTaskParseStrategy


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.cheatsheets.composite.parser;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.osgi.util.NLS;
16 import org.eclipse.ui.internal.cheatsheets.Messages;
17 import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask;
18 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader;
19 import org.w3c.dom.Node JavaDoc;
20
21 public class EditableTaskParseStrategy implements ITaskParseStrategy {
22     
23     private boolean editableChildErrorReported;
24     
25     public void init() {
26         editableChildErrorReported = false;
27     }
28
29     public boolean parseElementNode(Node JavaDoc childNode, Node JavaDoc parentNode,
30             AbstractTask parentTask, IStatusContainer status) {
31         boolean isElementHandled = true;
32         String JavaDoc nodeName = childNode.getNodeName();
33         if (CompositeCheatSheetParser.isAbstractTask(nodeName)) {
34             if (!editableChildErrorReported ){
35                  editableChildErrorReported = true;
36                  String JavaDoc message = NLS.bind(
37                             Messages.ERROR_EDITABLE_TASK_WITH_CHILDREN,
38                             (new Object JavaDoc[] { parentTask.getName()}));
39                 status.addStatus(IStatus.ERROR, message, null);
40             }
41         } else {
42             isElementHandled = false;
43         }
44         return isElementHandled;
45     }
46
47     public void parsingComplete(AbstractTask parentTask, IStatusContainer status) {
48         if (parentTask.getKind() == null) {
49             String JavaDoc message = NLS.bind(
50                     Messages.ERROR_PARSING_TASK_NO_KIND,
51                     (new Object JavaDoc[] { parentTask.getName()}));
52             status.addStatus(IStatus.ERROR, message, null);
53         } else if (CheatSheetRegistryReader.getInstance().
54                 findTaskEditor(parentTask.getKind()) == null) {
55             String JavaDoc message = NLS.bind(
56                     Messages.ERROR_PARSING_TASK_INVALID_KIND,
57                     (new Object JavaDoc[] { parentTask.getKind(), ICompositeCheatsheetTags.TASK, parentTask.getName()}));
58             status.addStatus(IStatus.ERROR, message, null);
59         }
60     }
61
62 }
63
Popular Tags