⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resourcespanel.java

📁 Memoranda( 从前以jNotes2而闻名) 是一个日志管理和个人项目管理工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), true, false);            resourcesTable.tableChanged();        }    }    void removeResB_actionPerformed(ActionEvent e) {        int[] toRemove = resourcesTable.getSelectedRows();        String msg = "";        if (toRemove.length == 1)            msg =                Local.getString("Remove the shortcut to resource")                    + "\n'"                    + resourcesTable.getModel().getValueAt(toRemove[0], 0)                    + "'";        else            msg = Local.getString("Remove") + " " + toRemove.length + " " + Local.getString("shortcuts");        msg +=            "\n"            + Local.getString("Are you sure?");        int n =            JOptionPane.showConfirmDialog(                App.getFrame(),                msg,                Local.getString("Remove resource"),                JOptionPane.YES_NO_OPTION);        if (n != JOptionPane.YES_OPTION)            return;        for (int i = 0; i < toRemove.length; i++) {        	        		CurrentProject.getResourcesList().removeResource(                        ((Resource) resourcesTable.getModel().getValueAt(toRemove[i], ResourcesTable._RESOURCE)).getPath());        }        resourcesTable.tableChanged();    }    MimeType addResourceType(String fpath) {        ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));        Dimension dlgSize = new Dimension(420, 300);        dlg.setSize(dlgSize);        Dimension frmSize = App.getFrame().getSize();        Point loc = App.getFrame().getLocation();        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);        dlg.ext = MimeTypesList.getExtension(fpath);        dlg.setVisible(true);        if (dlg.CANCELLED)            return null;        int ix = dlg.getTypesList().getSelectedIndex();        MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];        mt.addExtension(MimeTypesList.getExtension(fpath));        CurrentStorage.get().storeMimeTypesList();        return mt;    }    boolean checkApp(MimeType mt) {        String appId = mt.getAppId();        AppList appList = MimeTypesList.getAppList();        File d;        if (appId == null) {            appId = Util.generateId();            d = new File("/");        }        else {            File exe = new File(appList.getFindPath(appId) + "/" + appList.getExec(appId));            if (exe.isFile())                return true;            d = new File(exe.getParent());            while (!d.exists())                d = new File(d.getParent());        }        SetAppDialog dlg =            new SetAppDialog(                App.getFrame(),                Local.getString(Local.getString("Select the application to open files of type")+" '" + mt.getLabel() + "'"));        Dimension dlgSize = new Dimension(420, 300);        dlg.setSize(dlgSize);        Dimension frmSize = App.getFrame().getSize();        Point loc = App.getFrame().getLocation();        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);        dlg.setDirectory(d);        dlg.appPanel.argumentsField.setText("$1");        dlg.setVisible(true);        if (dlg.CANCELLED)            return false;        File f = new File(dlg.appPanel.applicationField.getText());        appList.addOrReplaceApp(            appId,            f.getParent().replace('\\', '/'),            f.getName().replace('\\', '/'),            dlg.appPanel.argumentsField.getText());        mt.setApp(appId);        /*appList.setFindPath(appId, chooser.getSelectedFile().getParent().replace('\\','/'));        appList.setExec(appId, chooser.getSelectedFile().getName().replace('\\','/'));*/        CurrentStorage.get().storeMimeTypesList();        return true;    }        void runApp(String fpath) {        MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);        if (mt.getMimeTypeId().equals("__UNKNOWN")) {            mt = addResourceType(fpath);            if (mt == null)                return;        }        if (!checkApp(mt))            return;        String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);        if (command == null)            return;        /*DEBUG*/        System.out.println("Run: " + command[0]);        try {            Runtime.getRuntime().exec(command);        }        catch (Exception ex) {            new ExceptionDialog(ex, "Failed to run an external application <br><code>"                    +command[0]+"</code>", "Check the application path and command line parameters for this resource type " +                    		"(File-&gt;Preferences-&gt;Resource types).");        }    }    void runBrowser(String url) {        Util.runBrowser(url);    }    class PopupListener extends MouseAdapter {        public void mouseClicked(MouseEvent e) {            if ((e.getClickCount() == 2) && (resourcesTable.getSelectedRow() > -1)) {                String path = (String) resourcesTable.getValueAt(resourcesTable.getSelectedRow(), 3);                if (path.length() >0)                    runApp(path);                else                    runBrowser((String) resourcesTable.getValueAt(resourcesTable.getSelectedRow(), 0));            }            //editTaskB_actionPerformed(null);        }                public void mousePressed(MouseEvent e) {                    maybeShowPopup(e);                }                public void mouseReleased(MouseEvent e) {                    maybeShowPopup(e);                }                private void maybeShowPopup(MouseEvent e) {                    if (e.isPopupTrigger()) {                        resPPMenu.show(e.getComponent(), e.getX(), e.getY());                    }                }    }    void refreshB_actionPerformed(ActionEvent e) {        resourcesTable.tableChanged();    }  void ppRun_actionPerformed(ActionEvent e) {    String path = (String) resourcesTable.getValueAt(resourcesTable.getSelectedRow(), 3);                if (path.length() >0)                    runApp(path);                else                    runBrowser((String) resourcesTable.getValueAt(resourcesTable.getSelectedRow(), 0));  }  void ppRemoveRes_actionPerformed(ActionEvent e) {    removeResB_actionPerformed(e);  }  void ppNewRes_actionPerformed(ActionEvent e) {    newResB_actionPerformed(e);  }  void ppRefresh_actionPerformed(ActionEvent e) {     resourcesTable.tableChanged();  }    /**   * Copy a file to the directory of the current project   * @param srcStr The path of the source file.   * @param destStr The destination path.   * @return The new path of the file.   */  String copyFileToProjectDir(String srcStr) {	  	  String JN_DOCPATH = Util.getEnvDir();	    	  	  String baseName;	  int i = srcStr.lastIndexOf( File.separator );		if ( i != -1 ) {			baseName = srcStr.substring(i+1);		} else			baseName = srcStr;			  String destStr = JN_DOCPATH + CurrentProject.get().getID() 	  				   + File.separator + "_projectFiles" + File.separator + baseName;	  	  File f = new File(JN_DOCPATH + CurrentProject.get().getID() + File.separator + "_projectFiles");	  if (!f.exists()) {		  f.mkdirs();	  }	  	  System.out.println("[DEBUG] Copy file from: "+srcStr+" to: "+destStr);	  	  try {         FileInputStream in = new FileInputStream(srcStr);         FileOutputStream out = new FileOutputStream(destStr);         byte[] buf = new byte[4096];         int len;         while ((len = in.read(buf)) > 0) {           out.write(buf, 0, len);         }         out.close();         in.close();       } 	   catch (IOException e) {         System.err.println(e.toString());       }		       return destStr;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -