1 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 31 public class GUIRecentFilesList extends GenericRecentFilesList { 32 33 37 protected int previousMenuEntriesCount = 0; 38 39 40 44 public void hasBeenChanged() { 45 super.hasBeenChanged(); 46 javax.swing.JMenu menu=((GUIApplicationEnvironment)application.getEnvironment()).getFileMenu(); 47 java.awt.Component [] components=menu.getMenuComponents(); 48 if (previousMenuEntriesCount>0) { 49 for (int i=components.length-1;i>components.length-previousMenuEntriesCount-2;i--) { menu.remove(components[i]); 51 } 52 } 53 if (size()>0) { 54 menu.addSeparator(); 55 for (int i=0;i<size();i++) { 56 Object entry=this.get(i); 57 String label=String.valueOf(i+1)+" "; 58 de.gulden.framework.amoda.generic.behaviour.GenericCommand command=null; 59 if (entry instanceof java.io.File ) { 60 java.io.File file=(java.io.File )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 ) { 64 java.net.URL url=(java.net.URL )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 item=new javax.swing.JMenuItem (label); 70 item.addActionListener(command); 71 menu.add(item); 72 } 73 previousMenuEntriesCount=size(); 74 } 75 } 76 77 } | Popular Tags |