home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / tvbrowser / TvBrowser_1.0.exe / plugins / ProgramInfo.jar / programinfo / ProgramInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-09-19  |  5.7 KB  |  160 lines

  1. package programinfo;
  2.  
  3. import devplugin.Plugin;
  4. import devplugin.PluginInfo;
  5. import devplugin.Program;
  6. import devplugin.ProgramInfoHelper;
  7. import devplugin.SettingsTab;
  8. import devplugin.Version;
  9. import java.awt.Dimension;
  10. import java.awt.Point;
  11. import java.util.ArrayList;
  12. import java.util.Properties;
  13. import java.util.logging.Logger;
  14. import javax.swing.Icon;
  15. import util.ui.Localizer;
  16. import util.ui.UiUtilities;
  17.  
  18. public class ProgramInfo extends Plugin {
  19.    private static final Localizer mLocalizer;
  20.    private static Logger mLog;
  21.    private Point location = null;
  22.    private Dimension size = null;
  23.    private Properties mSettings;
  24.    private static Plugin mInstance;
  25.    public static final String DEFAULT_STYLE_SHEET = "#title {\n  font-size:15px;\n  font-family:Dialog;\n  text-align:center;\n  font-weight:bold;\n}\n\n#time {\n  font-size:9px;\n  font-family:Dialog;\n  text-align:center;\n}\n\n#maininfo {\n  font-size:9px;\n  font-family:Dialog;\n  text-align:right;\n  font-weight:bold;\n}\n\n#info {\n  font-size:9px;\n  font-family:Dialog;\n}\n\n#text {\n  font-size:11px;\n  font-family:Dialog;\n}\n\n#small {\n  font-size:9px;\n  font-family:Dialog;\n}\n";
  26.    // $FF: synthetic field
  27.    static Class class$programinfo$ProgramInfo;
  28.  
  29.    public ProgramInfo() {
  30.       mInstance = this;
  31.    }
  32.  
  33.    public String getContextMenuItemText() {
  34.       return mLocalizer.msg("contextMenuText", "Program information");
  35.    }
  36.  
  37.    public static Plugin getInstance() {
  38.       if (mInstance == null) {
  39.          mLog.severe("mInstance is null");
  40.          mInstance = new ProgramInfo();
  41.       }
  42.  
  43.       return mInstance;
  44.    }
  45.  
  46.    public PluginInfo getInfo() {
  47.       String name = mLocalizer.msg("pluginName", "Program information");
  48.       String desc = mLocalizer.msg("description", "Show information about a program");
  49.       String author = "Martin Oberhauser";
  50.       return new PluginInfo(name, desc, author, new Version(1, 7));
  51.    }
  52.  
  53.    public String getButtonText() {
  54.       return null;
  55.    }
  56.  
  57.    public SettingsTab getSettingsTab() {
  58.       return new ProgramInfoSettingsTab(this.mSettings);
  59.    }
  60.  
  61.    public Properties storeSettings() {
  62.       return this.mSettings;
  63.    }
  64.  
  65.    public void loadSettings(Properties settings) {
  66.       if (settings == null) {
  67.          settings = new Properties();
  68.       }
  69.  
  70.       this.mSettings = settings;
  71.    }
  72.  
  73.    public void execute(Program program) {
  74.       String styleSheet = this.mSettings.getProperty("stylesheet_v1", "#title {\n  font-size:15px;\n  font-family:Dialog;\n  text-align:center;\n  font-weight:bold;\n}\n\n#time {\n  font-size:9px;\n  font-family:Dialog;\n  text-align:center;\n}\n\n#maininfo {\n  font-size:9px;\n  font-family:Dialog;\n  text-align:right;\n  font-weight:bold;\n}\n\n#info {\n  font-size:9px;\n  font-family:Dialog;\n}\n\n#text {\n  font-size:11px;\n  font-family:Dialog;\n}\n\n#small {\n  font-size:9px;\n  font-family:Dialog;\n}\n");
  75.       ProgramInfoDialog dlg = new ProgramInfoDialog(this.getParentFrame(), styleSheet, program, ProgramInfoHelper.mInfoBitArr, ProgramInfoHelper.mInfoIconArr, ProgramInfoHelper.mInfoMsgArr);
  76.       dlg.pack();
  77.       dlg.addComponentListener(new 1(this));
  78.       if (this.size != null) {
  79.          dlg.setSize(this.size);
  80.       }
  81.  
  82.       if (this.location != null) {
  83.          dlg.setLocation(this.location);
  84.          dlg.show();
  85.       } else {
  86.          UiUtilities.centerAndShow(dlg);
  87.          this.size = dlg.getSize();
  88.          this.location = dlg.getLocation();
  89.       }
  90.  
  91.    }
  92.  
  93.    public String getMarkIconName() {
  94.       return "programinfo/Information16.gif";
  95.    }
  96.  
  97.    public String getButtonIconName() {
  98.       return null;
  99.    }
  100.  
  101.    public String getProgramTableIconText() {
  102.       return mLocalizer.msg("programTableIconText", "Movie format");
  103.    }
  104.  
  105.    public Icon[] getProgramTableIcons(Program program) {
  106.       int info = program.getInfo();
  107.       if (info != -1 && info != 0) {
  108.          ArrayList iconList = null;
  109.  
  110.          for(int i = 0; i < ProgramInfoHelper.mInfoBitArr.length; ++i) {
  111.             if (bitSet(info, ProgramInfoHelper.mInfoBitArr[i]) && ProgramInfoHelper.mInfoIconArr[i] != null) {
  112.                if (iconList == null) {
  113.                   iconList = new ArrayList();
  114.                }
  115.  
  116.                iconList.add(ProgramInfoHelper.mInfoIconArr[i]);
  117.             }
  118.          }
  119.  
  120.          if (iconList == null) {
  121.             return null;
  122.          } else {
  123.             Icon[] var5 = new Icon[iconList.size()];
  124.             iconList.toArray(var5);
  125.             return var5;
  126.          }
  127.       } else {
  128.          return null;
  129.       }
  130.    }
  131.  
  132.    static boolean bitSet(int num, int pattern) {
  133.       return (num & pattern) == pattern;
  134.    }
  135.  
  136.    // $FF: synthetic method
  137.    static Class class$(String x0) {
  138.       try {
  139.          return Class.forName(x0);
  140.       } catch (ClassNotFoundException x1) {
  141.          throw new NoClassDefFoundError(x1.getMessage());
  142.       }
  143.    }
  144.  
  145.    // $FF: synthetic method
  146.    static Point access$000(ProgramInfo x0) {
  147.       return x0.location;
  148.    }
  149.  
  150.    // $FF: synthetic method
  151.    static Dimension access$100(ProgramInfo x0) {
  152.       return x0.size;
  153.    }
  154.  
  155.    static {
  156.       mLocalizer = Localizer.getLocalizerFor(class$programinfo$ProgramInfo == null ? (class$programinfo$ProgramInfo = class$("programinfo.ProgramInfo")) : class$programinfo$ProgramInfo);
  157.       mLog = Logger.getLogger((class$programinfo$ProgramInfo == null ? (class$programinfo$ProgramInfo = class$("programinfo.ProgramInfo")) : class$programinfo$ProgramInfo).getName());
  158.    }
  159. }
  160.