Jdev go to file extension

When doing EBS development, i found it painful to use JDev with OA extension, it is pretty old version for we are still in EBS 12.1.3 and the corresponding jdev version is 10.1.3, while the latest version of Jdev is 12 for now already, for some reason, i manager to noticed there are some extension we can use to make Jdev more convinent, Go To File Extension is one of this, which popup a window for u and you can choose to open file in current workspace, it is a basic function in eclipse, but not in Jdev.

download go to file extension from
Or oracle extension website:

download extension provide a pretty simple go to file window like this

it is kind of difficult to use, so i update the src code for it(a great developer who leave the src code with it), only a file in it, FileBrowser.java, other thing for this extension is some described XML file, we don't mention those file for now, i will skip what method need to implement for writing a JDev extension, you can look for the detail from 
For this topic, i will just show you the code i update for FileBrowser.java and how to use the extension, here is the step
1.open FileBrowser.java in JDev, i try Eclipse, but everytime i put the class file into the jar file, nothing happen in JDev even when the extension load successfully
2.update the FileBrowser.java to what i will update below
3.compile it and generate classes files, open the go to file Jar file(not the zip file, unzip and you will find the jar file), to directly to the FileBrowser.class, and put all your classes generated in it(here i use same package in JDev editor, so just replace and don't need to update XML in jar file)
4.Close Jdev and put jar file under $JDEV_HOME/jdevbin/jdev/extensions/ and reopen JDEV
5.You should be able to find a 'Go to file Ctrl+Alt-Minus' under 'Search' menu, click it and a more sophisticated popup(may be Ugly for some of u still) will show like the following, you can type any word on the top and the file list will just match what you try to find, it support wildcard * as well, i use a wildcard come from some website to do the work

you can find the SRC code for this extension as

package shay.org.ext;
/*
 * This extension adds a menu option to the Search menu
 * The option "Go To File" provides a list of the files in the currently
 * active project and its sub directories.
 * Choosing a file will open it in the JDeveloper editor.
 *
 * Created by Shay Shmeltzer
 * July 2007
 */

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import java.io.File;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import java.util.Vector;

import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

import oracle.bali.ewt.dialog.JEWTDialog;

import oracle.ide.Addin;
import oracle.ide.Context;
import oracle.ide.Ide;
import oracle.ide.controller.Controller;
import oracle.ide.controller.IdeAction;
import oracle.ide.controller.Menubar;
import oracle.ide.dialogs.OnePageWizardDialogFactory;
import oracle.ide.dialogs.WizardLauncher;
import oracle.ide.editor.EditorManager;
import oracle.ide.help.HelpSystem;
import oracle.ide.keyboard.KeyStrokeContextRegistry;
import oracle.ide.log.LogManager;
import oracle.ide.model.Project;

public final class FileBrowser implements Addin, Controller {
    // Simple Menu item
    public static final int GO_TO_FILE_CMD_ID = 
        Ide.findOrCreateCmdID("GO_TO_FILE_CMD");
    public List<String> projectFiles;

    public boolean handleEvent(IdeAction action, Context context) {
        //logMessage("start handleEvent");
        int cmdId = action.getCommandId();
        String msg = null;
        //populate a list of the files in the active project
        projectFiles = populateFileListForProject(Ide.getActiveProject().getBaseDirectory());

        //create and open the dialog
        if (cmdId == GO_TO_FILE_CMD_ID) {
            Collections.sort(projectFiles);
            JComboBox cb = new JComboBox(new Vector(projectFiles));

            JPanel panel = new JPanel();
            final JList listW = new JList(new Vector(projectFiles));
            JScrollPane scrollPane = new JScrollPane(listW);
            JTextField searchInput = new JTextField();
            searchInput.addKeyListener(new KeyAdapter() {

                        @Override
                        public void keyTyped(KeyEvent e) {
                            // TODO Auto-generated method stub
                            super.keyTyped(e);

                        }

                        @Override
                        public void keyPressed(KeyEvent e) {
                            // TODO Auto-generated method stub
                            super.keyPressed(e);
                            switch (e.getKeyCode()) {
                            case KeyEvent.VK_UP:
                                int selectedIndex = listW.getSelectedIndex();
                                if (selectedIndex > 0) {
                                    listW.setSelectedIndex(selectedIndex - 1);
                                }
                                break;
                            case KeyEvent.VK_DOWN:
                                selectedIndex = listW.getSelectedIndex();
                                if (selectedIndex < 
                                    listW.getModel().getSize()) {
                                    listW.setSelectedIndex(selectedIndex + 1);
                                    listW.ensureIndexIsVisible(selectedIndex + 
                                                               1);
                                }
                                break;
                            }
                        }

                        @Override
                        public void keyReleased(KeyEvent e) {
                            // TODO Auto-generated method stub
                            super.keyReleased(e);
                            int keyCode = e.getKeyCode();
                            if (KeyEvent.VK_UP == keyCode || 
                                KeyEvent.VK_DOWN == keyCode) {

                            } else {
                                JTextField input = (JTextField)e.getSource();
                                String searchText = input.getText();
                                Vector matchList = new Vector();
                                for (int i = 0, length = projectFiles.size(); 
                                     i < length; i++) {
                                    String projfile = projectFiles.get(i);
                                     projfile = projfile.substring(0,projfile.indexOf("#"));
                                    if (Wildcard.equalsOrMatch(projfile.toUpperCase(), 
                                                               (searchText + 
                                                               "*").toUpperCase())) {
                                        matchList.add(projectFiles.get(i));
                                    }
                                }
                                listW.setListData(matchList);
                                listW.revalidate();
                                listW.repaint();
                                
                                if(matchList.size()>0){
                                    listW.setSelectedIndex(0);
                                }
                            }
                        }

                    });
            listW.addMouseListener(new MouseListener(){

                        public void mouseClicked(MouseEvent e) {
                            if(e.getClickCount()==2){
                                String fileFullPath = (String)listW.getSelectedValue();
                                fileFullPath=fileFullPath.substring(fileFullPath.indexOf("#")+2);
                                openFile(fileFullPath);
                            }
                        }

                        public void mousePressed(MouseEvent e) {
                        }

                        public void mouseReleased(MouseEvent e) {
                        }

                        public void mouseEntered(MouseEvent e) {
                        }

                        public void mouseExited(MouseEvent e) {
                        }
                    });
            listW.setSize(500,500);
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            panel.add(searchInput);
            panel.add(scrollPane);
            JEWTDialog dlg = 
                OnePageWizardDialogFactory.createJEWTDialog(panel, null, 
                                                            "Enter File Name");
            dlg.setDefaultButton(JEWTDialog.BUTTON_OK);
            dlg.setOKButtonEnabled(true);

            boolean go = WizardLauncher.runDialog(dlg);
            if (go) {
                String fileFullPath = (String)listW.getSelectedValue();
                fileFullPath=fileFullPath.substring(fileFullPath.indexOf("#")+2);
                openFile(fileFullPath);
            }
        }

        if (msg != null) {
            logMessage(msg);
            Ide.getStatusBar().setText(msg);
            return true;
        }
        return false;
    }
    
    private void openFile(String filePath){
        try {
            //open the specified file
            EditorManager.getEditorManager().openDefaultEditorInFrame(new URL("file:///" +filePath));
        } catch (MalformedURLException e) {
            System.out.println(e);
        }
    }

    private static final void logMessage(String msg) {
        LogManager.getLogManager().showLog();
        LogManager.getLogManager().getMsgPage().log(msg + "\n");
    }

    static boolean enableElementInfo(Context context) {
        return true;
    }

    public boolean update(IdeAction action, Context context) {
        int cmdId = action.getCommandId();

        if (cmdId == GO_TO_FILE_CMD_ID) {
            action.setEnabled(enableElementInfo(context));
            return true;
        }
        return false;
    }

    public void initialize() {
        // Create the Context Menu Item and add it to the Navigator Menu
        Controller ctrlr1 = this;
        JMenuItem mi = 
            doCreateMenuItem(ctrlr1, "Go To File ...", new Integer('O'));
        JMenu jmenu = Menubar.getJMenu("Search");
        jmenu.add(mi);
        KeyStrokeContextRegistry r = Ide.getKeyStrokeContextRegistry();
        r.addAcceleratorDefinitionFile(FileBrowser.class.getClassLoader(), 
                                       "META-INF/accelerators.xml");
    }

    private static JMenuItem doCreateMenuItem(Controller ctrlr, 
                                              String menuLabel, 
                                              Integer mnemonic) {
        // Icon associated with this IdeAction
        Icon icon = null;
        // Category (if any) associated with this IdeAction
        String category = "Search";
        // Name of class which extends oracle.ide.addin.AbstractCommand
        String cmdClass = null;

        // This can be retrieved via IdeAction.find(MY_MENU_COMMAND_ID)
        IdeAction actionTM = // int cmdId,
            // extends oracle.ide.addin.AbstractCommand
            // String name,
            // Category
            // Integer mnemonic,
            // Icon icon,
            // Object data,
            // boolean enabled
            IdeAction.get(GO_TO_FILE_CMD_ID, cmdClass, menuLabel, category, 
                          mnemonic, icon, null, true);

        actionTM.addController(ctrlr);
        JMenuItem menuItem = Ide.getMenubar().createMenuItem(actionTM);
        return menuItem;
    }


    private List populateFileListForProject(String p_dir) {
        File dir = new File(p_dir);
        List justFiles = new ArrayList();
        int filesCounter = 0;

        String[] children = dir.list();
        if (children == null) {
            // Either dir does not exist or is not a directory
        } else {

            for (int i = 0; i < children.length; i++) {
                File as = new File(p_dir + "/" + children[i]);
                if (!as.isDirectory()) {
                    if(!children[i].endsWith(".class")){
                        justFiles.add(children[i] + " # " + as.getAbsolutePath());
                        filesCounter++;    
                    }
                    
                } else {
                    List sub = populateFileListForProject(as.getAbsolutePath());
                    for (int k = 0; k < sub.size(); k++) {
                        justFiles.add(sub.get(k));
                        filesCounter++;
                    }

                }
            }
        }

        return justFiles;
    }


}

package shay.org.ext;

// Copyright (c) 2003-2009, Jodd Team (jodd.org). All Rights Reserved.


/**
 * Checks whether a string matches a given wildcard pattern.
 * Possible patterns allow to match single characters ('?') or any count of
 * characters ('*'). Wildcard characters can be escaped (by an '\').
 * <p>
 * This method uses recursive matching, as in linux or windows. regexp works the same.
 * This method is very fast, comparing to similar implementations.
 */
public class Wildcard {

  /**
   * Checks whether a string matches a given wildcard pattern.
   *
   * @param string  input string
   * @param pattern pattern to match
   * @return      <code>true</code> if string matches the pattern, otherwise <code>false</code>
   */
  public static boolean match(String string, String pattern) {
    return match(string, pattern, 0, 0);
  }

  /**
   * Checks if two strings are equals or if they {@link #match(String, String)}.
   * Useful for cases when matching a lot of equal strings and speed is important.
   */
  public static boolean equalsOrMatch(String string, String pattern) {
    if (string.equals(pattern) == true) {
      return true;
    }
    return match(string, pattern, 0, 0);
  }


  /**
   * Internal matching recursive function.
   */
  private static boolean match(String string, String pattern, int stringStartNdx, int patternStartNdx) {
    int pNdx = patternStartNdx;
    int sNdx = stringStartNdx;
    int pLen = pattern.length();
    if (pLen == 1) {
      if (pattern.charAt(0) == '*') {     // speed-up
        return true;
      }
    }
    int sLen = string.length();
    boolean nextIsNotWildcard = false;

    while (true) {

      // check if end of string and/or pattern occurred
      if ((sNdx >= sLen) == true) {   // end of string still may have pending '*' in pattern
        while ((pNdx < pLen) && (pattern.charAt(pNdx) == '*')) {
          pNdx++;
        }
        return pNdx >= pLen;
      }
      if (pNdx >= pLen) {         // end of pattern, but not end of the string
        return false;
      }
      char p = pattern.charAt(pNdx);    // pattern char

      // perform logic
      if (nextIsNotWildcard == false) {

        if (p == '\\') {
          pNdx++;
          nextIsNotWildcard =  true;
          continue;
        }
        if (p == '?') {
          sNdx++; pNdx++;
          continue;
        }
        if (p == '*') {
          char pnext = 0;           // next pattern char
          if (pNdx + 1 < pLen) {
            pnext = pattern.charAt(pNdx + 1);
          }
          if (pnext == '*') {         // double '*' have the same effect as one '*'
            pNdx++;
            continue;
          }
          int i;
          pNdx++;

          // find recursively if there is any substring from the end of the
          // line that matches the rest of the pattern !!!
          for (i = string.length(); i >= sNdx; i--) {
            if (match(string, pattern, i, pNdx) == true) {
              return true;
            }
          }
          return false;
        }
      } else {
        nextIsNotWildcard = false;
      }

      // check if pattern char and string char are equals
      if (p != string.charAt(sNdx)) {
        return false;
      }

      // everything matches for now, continue
      sNdx++; pNdx++;
    }
  }


  // ---------------------------------------------------------------- utilities

  /**
   * Matches string to at least one pattern.
   * Returns index of matched pattern, or <code>-1</code> otherwise.
   * @see #match(String, String)
   */
  public static int matchOne(String src, String[] patterns) {
    for (int i = 0; i < patterns.length; i++) {
      if (match(src, patterns[i]) == true) {
        return i;
      }
    }
    return -1;
  }

}


i uploaded the final Jar with my src code with it, you can use it directly, and you can try to extend it by yourself if you want

http://yunpan.cn/QIqzc6UZdhPKA

Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值