KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > text > bundle > BundleTextChangeListener


1 /*******************************************************************************
2  * Copyright (c) 2005, 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 package org.eclipse.pde.internal.core.text.bundle;
12
13 import org.eclipse.jface.text.IDocument;
14 import org.eclipse.pde.core.IModelChangedEvent;
15 import org.eclipse.pde.internal.core.text.AbstractKeyValueTextChangeListener;
16
17 public class BundleTextChangeListener extends AbstractKeyValueTextChangeListener {
18
19     public BundleTextChangeListener(IDocument document) {
20         super(document);
21     }
22
23     public void modelChanged(IModelChangedEvent event) {
24         Object JavaDoc[] objects = event.getChangedObjects();
25         for (int i = 0; i < objects.length; i++) {
26             Object JavaDoc object = objects[i];
27             if (object instanceof PDEManifestElement)
28                 object = ((PDEManifestElement)object).getHeader();
29             else if (object instanceof PackageFriend)
30                 object = ((PackageFriend)object).getHeader();
31             
32             if (object instanceof ManifestHeader) {
33                 ManifestHeader header = (ManifestHeader)object;
34                 fOperationTable.remove(header);
35                 
36                 if (header.getValue() == null || header.getValue().trim().length() == 0) {
37                     deleteKey(header);
38                 } else {
39                     modifyKey(header);
40                 }
41             }
42         }
43     }
44
45 }
46
Popular Tags