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.
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