Permalink
Browse files

seems to be working so far

  • Loading branch information...
1 parent e58bcc9 commit 54d5b5e14357a5860553fd024705ab7fb9c23f54 @danja committed Jan 18, 2012
@@ -55,16 +55,8 @@ public ExploreEditDemo() {
treeMouseListener.attach(fileExplorerPane.getTree(), editorPane);
}
- /**
- * @return
- */
private void initEditor() {
editorPane = new SourceEditor();
-// editorScrollPane = new JScrollPane(editorPane);
-//
-// editorPane.setFont(new Font("Monospaced", Font.PLAIN, 12));
-
- // setEditorKit(new ScuteEditorKit("SPARQL"));
jsyntaxpane.DefaultSyntaxKit.initKit();
editorPane.setContentType("text/sparql");
}
@@ -80,10 +72,6 @@ private void initFileExplorer() {
public void centerSplit() {
left.setWeight(0.5);
right.setWeight(0.5);
- // Dimension d = contentPanel.getSize();
- // editorPane.setPreferredSize(new Dimension(d.width/2, d.height));
- // fileExplorerCard.setPreferredSize(new Dimension(d.width/2,
- // d.height));
}
private void initLayout() {
@@ -117,7 +105,6 @@ public static void main(String[] argv) {
UIManager.setLookAndFeel(nf);
} catch (Exception exception) {
// ignore
- exception.printStackTrace();
}
JFrame frame = new JFrame("File Explorer");
@@ -3,18 +3,26 @@
*/
package org.hyperdata.scute.demos;
-import java.awt.BorderLayout;
-import java.awt.Component;
+import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+import javax.swing.UIManager;
import javax.swing.WindowConstants;
-import org.jdesktop.swingx.*;
-import org.jdesktop.swingx.MultiSplitLayout.*;
+import com.nilo.plaf.nimrod.NimRODLookAndFeel;
+import com.nilo.plaf.nimrod.NimRODTheme;
+import org.jdesktop.swingx.JXMultiSplitPane;
+import org.jdesktop.swingx.MultiSplitLayout;
+import org.jdesktop.swingx.MultiSplitLayout.Divider;
+import org.jdesktop.swingx.MultiSplitLayout.Leaf;
+import org.jdesktop.swingx.MultiSplitLayout.Split;
+
+import org.hyperdata.scute.demos.temp.FileTreeMouseListener;
+import org.hyperdata.scute.demos.temp.SourceEditor;
+import org.hyperdata.scute.filemanager.FileExplorerCard;
import org.hyperdata.scute.terminal.Terminal;
//import org.hdesktop.swingx.*;
@@ -23,82 +31,113 @@
/**
* @author danny
- *
+ *
*/
public class JEdwards {
+ private SourceEditor editorPane;
+ private FileExplorerCard fileExplorerPane;
+ private JScrollPane editorScrollPane;
+
private Leaf middle;
private Leaf topLeft;
private Leaf bottomLeft;
private Leaf topRight;
private Leaf bottomRight;
- public JEdwards(){
+ public JEdwards() {
JXMultiSplitPane msp = initPanes();
initTerminals(msp);
-
- JFrame f = new JFrame("JEdwards");
- f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- f.setSize(500, 500);
- f.setLocation(100,100);
- f.getContentPane().add(msp);
- f.setVisible(true);
+ initFileExplorer();
+ initEditor();
+
+ msp.add(fileExplorerPane, "topLeft");
+ msp.add(editorPane.getScrollPane(), "middle");
+
+ FileTreeMouseListener treeMouseListener = new FileTreeMouseListener();
+ treeMouseListener.attach(fileExplorerPane.getTree(), editorPane);
+
+ JFrame f = new JFrame("JEdwards");
+ f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ f.setSize(500, 500);
+ f.setLocation(100, 100);
+ f.getContentPane().add(msp);
+ f.setVisible(true);
}
-
- public void initTerminals(JXMultiSplitPane msp){
+
+ private void initEditor() {
+ editorPane = new SourceEditor();
+ jsyntaxpane.DefaultSyntaxKit.initKit();
+ editorPane.setContentType("text/sparql");
+ }
+
+ /**
+ * @return
+ */
+ private void initFileExplorer() {
+ fileExplorerPane = new FileExplorerCard(System.getProperty("user.home"));
+ fileExplorerPane.setPreferredSize(new Dimension(150, 400));
+ }
+
+ public void initTerminals(JXMultiSplitPane msp) {
Terminal terminal1 = new Terminal();
Terminal terminal2 = new Terminal();
Terminal terminal3 = new Terminal();
-
+
msp.add(new JButton("topLeft"), "topLeft");
msp.add(terminal1.getConsole(), "bottomLeft");
msp.add(terminal2.getConsole(), "topRight");
msp.add(terminal3.getConsole(), "bottomRight");
-
-
terminal1.start();
terminal2.start();
terminal3.start();
}
-
- public static void main(String[] args) {
-
-new JEdwards();
-
- }
-
- public JXMultiSplitPane initPanes(){
+
+ public static void main(String[] args) {
+ try {
+ NimRODTheme nt = new NimRODTheme("./Scute.theme");
+ NimRODLookAndFeel nf = new NimRODLookAndFeel();
+ nf.setCurrentTheme(nt);
+ UIManager.setLookAndFeel(nf);
+ } catch (Exception exception) {
+ // ignore
+ }
+ new JEdwards();
+
+ }
+
+ public JXMultiSplitPane initPanes() {
Split outer = new Split();
outer.setRowLayout(true);
Split left = new Split();
left.setRowLayout(false);
left.setWeight(0.2);
-
+
middle = new Leaf("middle");
middle.setWeight(0.6);
-
+
Split right = new Split();
right.setRowLayout(false);
right.setWeight(0.2);
-
+
outer.setChildren(left, new Divider(), middle, new Divider(), right);
-
+
topLeft = new Leaf("topLeft");
bottomLeft = new Leaf("bottomLeft");
topLeft.setWeight(0.5);
bottomLeft.setWeight(0.5);
-
+
topRight = new Leaf("topRight");
bottomRight = new Leaf("bottomRight");
topRight.setWeight(0.5);
bottomRight.setWeight(0.5);
-
+
left.setChildren(topLeft, new Divider(), bottomLeft);
right.setChildren(topRight, new Divider(), bottomRight);
-
+
// Once the layout is done, the code is easy
JXMultiSplitPane msp = new JXMultiSplitPane();
MultiSplitLayout layout = new MultiSplitLayout(outer);
@@ -40,16 +40,12 @@
public class SourceDemo {
-
public SourceDemo(String syntax) {
- // super(syntax);
- // setFilename("./temp.txt");
-
+ // super(syntax);
+ // setFilename("./temp.txt");
}
-
-
/**
* The main method.
*
@@ -59,31 +55,30 @@ public SourceDemo(String syntax) {
public static void main(String[] args) {
try {
-// UIManager.setLookAndFeel( // is ugly on this machine!!
-// UIManager.getSystemLookAndFeelClassName());
+ // UIManager.setLookAndFeel( // is ugly on this machine!!
+ // UIManager.getSystemLookAndFeelClassName());
// better than default
- // UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
- NimRODTheme nt = new NimRODTheme( "./Scute.theme");
+ // UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
+ NimRODTheme nt = new NimRODTheme("./Scute.theme");
NimRODLookAndFeel nf = new NimRODLookAndFeel();
- nf.setCurrentTheme( nt);
- UIManager.setLookAndFeel( nf);
+ nf.setCurrentTheme(nt);
+ UIManager.setLookAndFeel(nf);
} catch (Exception exception) {
// ignore
- }
-
- // final String filename = "./data/sample2.ttl";
-
- SourceEditor editor = new SourceEditor();
-jsyntaxpane.DefaultSyntaxKit.initKit();
-editor.setContentType("text/sparql");
+ }
+ // final String filename = "./data/sample2.ttl";
+
+ SourceEditor editor = new SourceEditor();
+ jsyntaxpane.DefaultSyntaxKit.initKit();
+ editor.setContentType("text/sparql");
final JFrame frame = new JFrame("Source Demo");
frame.getContentPane().add(editor.getScrollPane());
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- // frame.pack();
+ // frame.pack();
frame.setSize(500, 500);
- frame.setLocation(100,100);
+ frame.setLocation(100, 100);
frame.setVisible(true);
}
}
@@ -4,13 +4,16 @@
package org.hyperdata.scute.demos.temp;
import java.awt.Font;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
import org.hyperdata.scute.filemanager.FileReference;
@@ -37,25 +40,46 @@ public SourceEditor() {
*/
@Override
public void setCurrentFile(File file) {
- System.out.println("setting file "+file);
- String url = "file:///" + file.getAbsolutePath();
- URL newURL = null;
- try {
- newURL = new URL(url);
- } catch (MalformedURLException exception) {
- exception.printStackTrace();
- }
- URL loadedURL = getPage();
- if (loadedURL != null && loadedURL.sameFile(newURL)) {
- return;
- }
- // maybe display "Loading..."
- try {
- setPage(url);
- } catch (IOException exception) {
- exception.printStackTrace();
- }
+// System.out.println("setting file "+file);
+// final String url = "file:///" + file.getAbsolutePath();
+// URL newURL = null;
+// try {
+// newURL = new URL(url);
+// } catch (MalformedURLException exception) {
+// exception.printStackTrace();
+// }
+// URL loadedURL = getPage();
+// if (loadedURL != null && loadedURL.sameFile(newURL)) {
+// return;
+// }
+// // maybe display "Loading..."
+// jsyntaxpane.DefaultSyntaxKit.initKit();
+// setContentType("text/sparql"); // change according to file type
+// setPage(url); // SETPAGE BUGGERS UP SYNTAX HIGHLIGHTING
+
+ try {
+ setText(readFileAsString(file));
+ } catch (IOException exception) {
+ // TODO Auto-generated catch block
+ exception.printStackTrace();
+ }
}
+
+ private static String readFileAsString(File file)
+ throws java.io.IOException{
+ StringBuffer fileData = new StringBuffer(1000);
+ BufferedReader reader = new BufferedReader(
+ new FileReader(file));
+ char[] buf = new char[1024];
+ int numRead=0;
+ while((numRead=reader.read(buf)) != -1){
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
/*
* (non-Javadoc)
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package org.hyperdata.scute.filemanager;
+
+import java.io.File;
+import java.io.FileFilter;
+/**
+ * @author danny
+ *
+ */
+public class DefaultFileFilter implements FileFilter {
+
+ /* (non-Javadoc)
+ * @see java.io.FileFilter#accept(java.io.File)
+ */
+ @Override
+ public boolean accept(File file) {
+ String name = file.getName();
+ if(name.startsWith(".")) return false;
+ return true;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 54d5b5e

Please sign in to comment.