01: /*******************************************************************************
02: * Copyright (c) 2006 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.pde.internal.core.text.build;
11:
12: import org.eclipse.jface.text.IDocument;
13: import org.eclipse.osgi.util.NLS;
14: import org.eclipse.pde.core.IModelChangedEvent;
15: import org.eclipse.pde.internal.core.PDECoreMessages;
16: import org.eclipse.pde.internal.core.text.AbstractKeyValueTextChangeListener;
17: import org.eclipse.pde.internal.core.text.IDocumentKey;
18:
19: public class PropertiesTextChangeListener extends
20: AbstractKeyValueTextChangeListener {
21:
22: public PropertiesTextChangeListener(IDocument document) {
23: super (document, false);
24: }
25:
26: public PropertiesTextChangeListener(IDocument document,
27: boolean generateReadableNames) {
28: super (document, generateReadableNames);
29: }
30:
31: public void modelChanged(IModelChangedEvent event) {
32: Object[] objects = event.getChangedObjects();
33: for (int i = 0; i < objects.length; i++) {
34: Object object = objects[i];
35: IDocumentKey key = (IDocumentKey) object;
36: Object op = fOperationTable.remove(key);
37: if (fReadableNames != null)
38: fReadableNames.remove(op);
39: String name = null;
40: switch (event.getChangeType()) {
41: case IModelChangedEvent.REMOVE:
42: if (fReadableNames != null)
43: name = NLS
44: .bind(
45: PDECoreMessages.PropertiesTextChangeListener_editNames_remove,
46: key.getName());
47: deleteKey(key, name);
48: break;
49: default:
50: if (fReadableNames != null)
51: name = NLS
52: .bind(
53: (key.getOffset() == -1 ? PDECoreMessages.PropertiesTextChangeListener_editNames_insert
54: : PDECoreMessages.PropertiesTextChangeListener_editNames_delete),
55: key.getName());
56: modifyKey(key, name);
57: }
58: }
59: }
60:
61: }
|