KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > environment > gui > GUIRecentFilesList


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.environment.gui.GUIRecentFilesList
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * it is not released as a seperate version.
10  * For AMODA, see http://amoda.berlios.de/.
11  *
12  * This is licensed under the GNU Lesser General Public License (LGPL)
13  * and comes with NO WARRANTY.
14  *
15  * Author: Jens Gulden
16  * Email: amoda@jensgulden.de
17  */

18
19 package de.gulden.framework.amoda.environment.gui;
20
21 import de.gulden.framework.amoda.environment.commandline.*;
22 import de.gulden.framework.amoda.generic.core.GenericRecentFilesList;
23 import java.util.*;
24
25 /**
26  * Class GUIRecentFilesList.
27  *
28  * @author Jens Gulden
29  * @version snapshot-beautyj-1.1
30  */

31 public class GUIRecentFilesList extends GenericRecentFilesList {
32
33     // ------------------------------------------------------------------------
34
// --- field ---
35
// ------------------------------------------------------------------------
36

37     protected int previousMenuEntriesCount = 0;
38
39
40     // ------------------------------------------------------------------------
41
// --- method ---
42
// ------------------------------------------------------------------------
43

44     public void hasBeenChanged() {
45         super.hasBeenChanged();
46         javax.swing.JMenu JavaDoc menu=((GUIApplicationEnvironment)application.getEnvironment()).getFileMenu();
47         java.awt.Component JavaDoc[] components=menu.getMenuComponents();
48         if (previousMenuEntriesCount>0) {
49             for (int i=components.length-1;i>components.length-previousMenuEntriesCount-2;i--) { // remove all including separator
50
menu.remove(components[i]);
51             }
52         }
53         if (size()>0) {
54             menu.addSeparator();
55             for (int i=0;i<size();i++) {
56                 Object JavaDoc entry=this.get(i);
57                 String JavaDoc label=String.valueOf(i+1)+" ";
58                 de.gulden.framework.amoda.generic.behaviour.GenericCommand command=null;
59                 if (entry instanceof java.io.File JavaDoc) {
60                     java.io.File JavaDoc file=(java.io.File JavaDoc)entry;
61                     label+=file.getPath();
62                     command=new de.gulden.framework.amoda.environment.gui.behaviour.CommandOpenRecentFileListEntry(file);
63                 } else if (entry instanceof java.net.URL JavaDoc) {
64                     java.net.URL JavaDoc url=(java.net.URL JavaDoc)entry;
65                     label+=url.toExternalForm();
66                     command=new de.gulden.framework.amoda.environment.gui.behaviour.CommandOpenRecentFileListEntry(url);
67                 }
68                 command.setParent(application);
69                 javax.swing.JMenuItem JavaDoc item=new javax.swing.JMenuItem JavaDoc(label);
70                 item.addActionListener(command);
71                 menu.add(item);
72             }
73             previousMenuEntriesCount=size();
74         }
75     }
76
77 } // end GUIRecentFilesList
78
Popular Tags