📄 jxplorer.java
字号:
mainViewer = new AttributeDisplay(myProperties, JXplorer.this, resourceLoader);
//String iconDir = JXplorer.getProperty("dir.icons");
mrTree = new SmartTree(this, CBIntText.get("Explore"), resourceLoader);
mrTree.setBackground(new Color(0xF7F9FF));
initialiseTree(mrTree, mainViewer, this);
searchTree = new SmartTree(this, CBIntText.get("Results"), resourceLoader);
searchTree.setBackground(new Color(0xEEFFFF));
initialiseTree(searchTree, mainViewer, this);
schemaTree = new SmartTree(this, CBIntText.get("Schema"), resourceLoader);
schemaTree.setBackground(new Color(0xEEFFEE));
schemaTree.getTree().setEditable(false);
initialiseTree(schemaTree, mainViewer, this);
mainViewer.registerComponents(mainMenu, buttonBar, mrTree.getTree(), mrTree.getPopupTool(), this);
}
public void initialiseTree(SmartTree tree, DataSink viewer, JXplorerEventGenerator gen)
{
if (viewer != null) tree.registerDataSink(viewer);
if (gen != null) tree.registerEventPublisher(gen);
}
/**
* The Status panel is the small (one line) panel at the bottom
* of the browser that reports to users what is happening with
* the browser (e.g. 'connecting', 'disconnected' etc.)
*/
protected void setupStatusDisplay()
{
statusDisplay = new CBPanel();
statusDisplay.makeHeavy();
displayLabel = new JLabel(CBIntText.get("initialising..."));
statusDisplay.addln(displayLabel);
mainPane.add(statusDisplay, BorderLayout.SOUTH);
}
public String getStatus()
{
return displayLabel.getText();
}
/**
* Sets a status message that is displayed on the bottom of
* the screen.
*/
public void setStatus(String s)
{
displayLabel.setText(s);
displayLabel.repaint(); // XXX paintology
}
/**
* saves the old Status message on the status stack
* for later use, and sets status to a new message.
*
* @param newMessage the new status message to set
* (note - this new Message is *not* saved on the stack!)
*/
public void pushStatus(String newMessage)
{
statusStack.push(displayLabel.getText());
setStatus(newMessage);
}
/**
* recalls a status message saved via @pushStatus,
* as well as setting it using @setStatus.
*
* @return the saved status message, in case anyone cares
*/
public String popStatus()
{
String status;
if (statusStack.empty())
status = ""; // sanity check
else
status = (String) statusStack.pop();
setStatus(status);
return status; // in case someone is interested...
}
/**
* Sets up the main work area, below the tool bar,
* which displays the tree/browser panel, and the
* results panel...
*/
protected void setupMainWorkArea()
{
// make sure stuff has been done already is correct...
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
mainPane.add(splitPane, BorderLayout.CENTER);
treeTabPane = new JTabbedPane();
treeTabPane.setMinimumSize(new Dimension(100, 100));
if (isLinux())
treeTabPane.setPreferredSize(new Dimension(265, 100)); //TE: bug 2538.
else
treeTabPane.setPreferredSize(new Dimension(240, 100)); //TE: was 220x100 but increased size to fit icons.
/*
* Initialise the work area scroll panes. Our user defined
* classes will be added to these, and will become magically
* scrollable.
*/
explorePanel = new JScrollPane(mrTree);
resultsPanel = new JScrollPane(searchTree);
schemaPanel = new JScrollPane(schemaTree);
explorePanel.getVerticalScrollBar().setUnitIncrement(16); // ScrollPane's aren't respecting scrollable tree component's getScrollableUnitIncrement() methods; who knows why.
resultsPanel.getVerticalScrollBar().setUnitIncrement(16);
schemaPanel.getVerticalScrollBar().setUnitIncrement(16);
splitPane.add(treeTabPane, JSplitPane.LEFT, 0);
if (JXplorer.getProperty("gui.viewPanel", "true").equals("true"))
{
userViewPanel = new JPanel(new BorderLayout());
userViewPanel.add(mainViewer, BorderLayout.CENTER);
splitPane.add(userViewPanel, JSplitPane.RIGHT, 1);
}
if (mrTree != null) treeTabPane.addTab(mrTree.getName(), new ImageIcon("images" + File.separator + "explore.gif"), explorePanel, "Displays the directory tree, and allows the user to graphically browse the directory."); //TE: sets the tabs up with name, icon, component and tool tip.
if (searchTree != null) treeTabPane.addTab(searchTree.getName(), new ImageIcon("images" + File.separator + "find.gif"), resultsPanel, "Displays the search results, and allows the user to graphically browse these results.");
if (schemaTree != null) treeTabPane.addTab(schemaTree.getName(), new ImageIcon("icons" + File.separator + "schema.gif"), schemaPanel, "Displays the directory schema, and allows the user to graphically browse the schema.");
// nb. Don't add Tab for Admin, this only appears if the user
// successfully establishes at least one admin connection...
/**
* This change listener is intended to listen for tab changes.
* It makes sure the entry is updated in the editor pane so that
* when changing between for example schema and explore, the last
* schema data is not displayed...instead the entry that is selected
* in the explore tab is displayed. (Bug 2243).
*/
treeTabPane.addChangeListener(new ChangeListener()
{
public void stateChanged(ChangeEvent e)
{
Component treePane = treeTabPane.getSelectedComponent();
ButtonRegister br = JXplorer.getButtonRegister();
if (treePane == explorePanel) // Explore.
{
setStatus(CBIntText.get("Connected To ''{0}''", new String[]{url}));
if (br != null && isConnected()) //todo and only if connected!
br.setCommonState(true); //TE: enable buttons.
mrTree.refreshEditorPane();
}
else if (treePane == resultsPanel) // Search.
{
setStatus("Number of search results: " + String.valueOf(searchTree.getNumOfResults()));
searchTree.refreshEditorPane();
}
else if (treePane == schemaPanel) // Schema.
{
setStatus(CBIntText.get("Connected To ''{0}''", new String[]{url}));
if (br != null) //TE: disable buttons.
br.setCommonState(false);
schemaTree.refreshEditorPane();
}
}
});
/* CB removed - use components (above) instead of indices for clarity...
int index = treeTabPane.getSelectedIndex();
switch (index)
{
case 0: //TE: Explore.
{
if (mrTree != null)
mrTree.refreshEditorPane();
break;
}
case 1: //TE: Search.
{
if (searchTree != null)
searchTree.refreshEditorPane();
break;
}
case 2: //TE: Schema.
{
if (schemaTree != null)
schemaTree.refreshEditorPane();
break;
}
}
*/
}
/**
* A vague flag that is set to true if the user hits the connect button,
* false if user hits disconnect button. This is for changing the state
* of the buttons when flicking between tabs.
*
* @return value of connected.
*/
public boolean isConnected()
{
return connected;
}
/**
* A vague flag that is set to true if the user hits the connect button,
* false if user hits disconnect button. This is for changing the state
* of the buttons when flicking between tabs.
*
* @param connected state to set connected to.
*/
public void setConnected(boolean connected)
{
this.connected = connected;
}
/**
* Returns the tree that is currently being directly
* displayed to the user.
*/
public SmartTree getActiveTree()
{
int paneNumber = treeTabPane.getSelectedIndex();
if (paneNumber == treeTabPane.indexOfTab(CBIntText.get("Explore")))
return mrTree;
else if (paneNumber == treeTabPane.indexOfTab(CBIntText.get("Results")))
return searchTree;
else if (paneNumber == treeTabPane.indexOfTab(CBIntText.get("Schema")))
return schemaTree;
// should have returned by now... this line should never be reached!
log.warning("ERROR: Unable to establish active tree - panel = " + paneNumber);
return null;
}
/**
* Make minor additions; the top-right window icon and the
* title bar text.
*/
protected void setupFrills()
{
//this.setIconImage(new ImageIcon(getProperty("dir.images") + "ODlogo.gif").getImage());
this.setIconImage(getImageIcon("ODlogo.gif").getImage());
this.setTitle("JXplorer");
}
/**
* JXplorer utility ftn: load an image from the standard JX images directory.
*
* @param name the file name of the image file within the images directory
* @return the loaded image.
*/
public static ImageIcon getImageIcon(String name)
{
ImageIcon newIcon = new ImageIcon(getProperty("dir.images") + name);
return newIcon;
}
/**
* Initialise the JavaHelp system, pointing it at the right help files.
*/
protected void setupHelp()
{
helpSystem = new CBHelpSystem("JXplorerHelp.hs"); // use default 'JXplorerHelp.hs' help set.
}
/**
* This returns the help system used by JX. Useful to get
* if you need to append some more help stuff.
*
* @return the current JX HelpSystem.
*/
public CBHelpSystem getHelpSystem()
{
return helpSystem;
}
/**
* Closes the application down
*/
public void shutdown()
{
shutdown(null);
}
/**
* Closes the application down, optionally printing out a message
*
* @param msg optional message to be printed out on closing.
*/
public void shutdown(String msg)
{
setProperty("width", String.valueOf(((int) getSize().getWidth())));
setProperty("height", String.valueOf(((int) getSize().getHeight())));
setProperty("xpos", String.valueOf(getX()));
setProperty("ypos", String.valueOf(getY()));
setProperty("last.search.filter", "default"); //TE: sets the last filter property to 'default' (we don't really need to remember the filter after JX exists).
writePropertyFile();
if (msg != null)
log.severe("shutting down\n" + msg);
else
log.warning("shutting down");
System.exit(0);
}
public static void writePropertyFile()
{
CBUtility.writePropertyFile(propertyFile, myProperties, new String("# The property file location defaults to where JXplorer is installed\n" +
"# - this can be over-ridden with the system property 'jxplorer.config'\n" +
"# with a config directory location, or set to user home using the\n" +
"# flag 'user.home' (e.g. -Djxplorer.config='user.home' on the command line).\n"));
}
public String toString()
{
return "JXplorer version " + version;
}
/**
* Before a new connection is made, the old display trees should be cleared.
*/
public void preConnectionSetup()
{
if (mrTree == null) return;
mrTree.clearTree();
mrTree.setRoot(SmartTree.NODATA);
treeTabPane.setSelectedIndex(0);
if (searchTree == null) return;
searchTree.clearTree();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -