01: /*******************************************************************************
02: * Copyright (c) 2005, 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.ui.nls;
11:
12: import java.util.ArrayList;
13: import java.util.Collection;
14: import java.util.Hashtable;
15:
16: import org.eclipse.core.resources.IFile;
17: import org.eclipse.pde.core.plugin.IPluginModelBase;
18:
19: public class ModelChangeTable {
20:
21: private Hashtable fChangeTable = new Hashtable();
22: private int fTotalModelChanges = 0;
23: private ArrayList fPreSelected = new ArrayList();
24:
25: public void addToChangeTable(IPluginModelBase model, IFile file,
26: Object change, boolean selected) {
27: if (change == null)
28: return;
29: ModelChange modelChange;
30: if (fChangeTable.containsKey(model))
31: modelChange = (ModelChange) fChangeTable.get(model);
32: else {
33: modelChange = new ModelChange(model, selected);
34: fChangeTable.put(model, modelChange);
35: fTotalModelChanges += 1;
36: if (selected)
37: fPreSelected.add(modelChange);
38: }
39: modelChange.addChange(file, new ModelChangeElement(modelChange,
40: change));
41: }
42:
43: public Collection getAllModelChanges() {
44: return fChangeTable.values();
45: }
46:
47: public ModelChange getModelChange(IPluginModelBase modelKey) {
48: if (fChangeTable.containsKey(modelKey))
49: return (ModelChange) fChangeTable.get(modelKey);
50: return null;
51: }
52:
53: public Object[] getPreSelected() {
54: return fPreSelected.toArray();
55: }
56:
57: public boolean hasPreSelected() {
58: return fPreSelected.size() > 0;
59: }
60:
61: public boolean isEmpty() {
62: return fChangeTable.size() == 0;
63: }
64: }
|