KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > nls > ModelChangeTable


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