Permalink
Browse files

refactored toolbar

  • Loading branch information...
danja committed Mar 11, 2011
1 parent d622f5a commit b7bf28f5a5480d7a37742417c54c19ab30cce1f9
View
@@ -0,0 +1,17 @@
+ 100 files 200 files 300 files 400 files 500 files 505 text files.
+classified 505 filesDuplicate file check 505 files (464 known unique)Unique: 100 files Unique: 200 files Unique: 300 files Unique: 400 files 484 unique files.
+Counting: 100Counting: 200Counting: 300Counting: 400 61 files ignored.
+
+http://cloc.sourceforge.net v 1.09 T=10.0 s (42.5 files/s, 10093.9 lines/s)
+-------------------------------------------------------------------------------
+Language files blank comment code scale 3rd gen. equiv
+-------------------------------------------------------------------------------
+HTML 249 9154 3996 69603 x 1.90 = 132245.70
+Java 160 2642 6494 8236 x 1.36 = 11200.96
+CSS 4 86 59 297 x 1.00 = 297.00
+XML 5 59 102 168 x 1.90 = 319.20
+Bourne Shell 6 8 9 24 x 3.81 = 91.44
+Haskell 1 0 0 2 x 2.11 = 4.22
+-------------------------------------------------------------------------------
+SUM: 425 11949 10660 78330 x 1.84 = 144158.52
+-------------------------------------------------------------------------------
View
@@ -1,4 +1,4 @@
SELECT DISTINCT * WHERE {
?s ?p ?o
}
-LIMIT 10
+LIMIT 10zxc
View
@@ -1,13 +1,7 @@
-# Turtle Syntax (autogenerated - leave this line intact)
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
-<http://purl.org/stuff/brian>
- <http://xmlns.com/foaf/0.1/knows>
- <http://purl.org/stuff/andy> .
+SELECT DISTINCT * WHERE {
-<http://purl.org/stuff/carl>
- <http://xmlns.com/foaf/0.1/name>
- "carl" .
-
-<http://purl.org/stuff/andy>
- <http://xmlns.com/foaf/0.1/knows>
- <http://purl.org/stuff/brian> .
+ <http://dbpedia.org/resource/Neptune> a ?object .
+ ?object rdfs:label ?label .
+}
@@ -1,5 +1,8 @@
HIDE toolbars if not needed (a la gnome bars?)
+spellchecker for RDF terms?
+http://www.javaworld.com/javaworld/jw-02-2001/jw-0216-ternary.html?page=1
+http://jstomp.sourceforge.net/comboBox/search.html
null any previous runner on Run
@@ -21,6 +21,7 @@
import org.hyperdata.scute.cards.Card;
import org.hyperdata.scute.cards.CardsPanel;
import org.hyperdata.scute.main.Config;
+import org.hyperdata.scute.main.ScratchPad;
import org.hyperdata.scute.main.Scute;
import org.hyperdata.scute.rdf.ModelContainer;
import org.hyperdata.scute.source.TextContainer;
@@ -40,6 +41,8 @@
/** The text saver. */
private TextSaver textSaver;
+ private TextSaver scratchTextSaver;
+ private TextContainer scratchTextContainer;
/** The model timer. */
private final Timer timer = new Timer();
@@ -87,7 +90,7 @@ public void activityOccurred(EventObject object) {
*/
@Override
public void focusGained(FocusEvent event) {
-
+ // scratchTextSaver - maybe..?
textSaver.save(); // save the old one
reschedule(); // start over
}
@@ -104,6 +107,10 @@ public void reschedule() {
if (textSaver != null) {
textSaver.cancel();
}
+ if (scratchTextSaver != null) {
+ scratchTextSaver.cancel();
+ }
+
timer.purge(); // clean queue
modelSaver = new ModelSaver(workingModelContainer);
@@ -113,6 +120,10 @@ public void reschedule() {
textSaver = new TextSaver(currentTextContainer);
timer.schedule(textSaver, Config.self.getTextSaveDelay());
}
+
+ scratchTextSaver = new TextSaver(scratchTextContainer);
+ timer.schedule(scratchTextSaver, Config.self.getTextSaveDelay());
+
}
/*
@@ -178,6 +189,10 @@ private void finishUp() {
textSaver.cancel();
textSaver.save();
}
+ if (scratchTextSaver != null) {
+ scratchTextSaver.cancel();
+ scratchTextSaver.save();
+ }
Config.self.setSync(true);
Config.self.saveNow();
}
@@ -215,4 +230,11 @@ public void stateChanged(ChangeEvent event) {
}
}
+ /**
+ * @param scratchPad
+ */
+ public void setScratchTextContainer(TextContainer textContainer) {
+ scratchTextContainer = textContainer;
+ }
+
}
@@ -8,6 +8,7 @@
import javax.swing.JPanel;
+import org.hyperdata.scute.source.EditorPane;
import org.hyperdata.scute.source.TextContainer;
@@ -19,6 +20,7 @@
// this is a bit yucky, will do for now
private TextContainer textContainer = null;
+// private EditorPane editorPane = null;
private boolean textCard = false;
// JPanel's constructors
@@ -64,4 +66,11 @@ public boolean isTextCard() {
return textCard;
}
+// public EditorPane getEditorPane() {
+// return this.editorPane;
+// }
+//
+// public void setEditorPane(EditorPane editorPane) {
+// this.editorPane = editorPane;
+// }
}
@@ -6,12 +6,18 @@
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.event.UndoableEditListener;
+import javax.swing.text.Document;
import javax.swing.undo.UndoManager;
import org.jdesktop.swingx.JXErrorPane;
@@ -36,62 +42,127 @@
/** UndoManager that we add edits to. */
public UndoManager undoManager = new UndoManager();
- public EditorToolbar(Frame frame, JEditorPane findPane, EditorPane zoomPane) {
+ private JButton undoButton;
- undoHandler = new UndoHandler(zoomPane);
- zoomPane.getDocument().addUndoableEditListener(undoHandler);
+ private JButton redoButton;
- Action undoAction = zoomPane.getUndoAction();
- JButton undoButton = new JButton(undoAction);
+ private JButton findButton;
+
+ private JButton zoomIn;
+
+ private JButton zoomOut;
+
+ private Frame frame = null;
+
+ private Map<Document, UndoHandler> undoHandlerMap = new HashMap<Document, UndoHandler>();
+
+ private PropertyChangeListener undoActionChangeListener;
+ private PropertyChangeListener redoActionChangeListener;
+
+ public EditorToolbar(Frame frame) {
+ this.frame = frame;
+ init();
+ }
+
+ private void init() {
+ undoButton = new JButton();
undoButton.setIcon(GeneralIcons.undoIcon);
- undoAction.addPropertyChangeListener(new ActionChangedListener(undoButton));
undoButton.setHideActionText(true);
undoButton.setToolTipText("Undo edit");
+ undoActionChangeListener = new ActionChangedListener(undoButton);
add(undoButton);
- Action redoAction = zoomPane.getRedoAction();
- JButton redoButton = new JButton(redoAction);
- redoAction.addPropertyChangeListener(new ActionChangedListener(redoButton));
+ redoButton = new JButton();
redoButton.setIcon(GeneralIcons.redoIcon);
redoButton.setHideActionText(true);
redoButton.setToolTipText("Redo edit");
+ redoActionChangeListener = new ActionChangedListener(redoButton);
add(redoButton);
- Action findAction = new FindAction(frame, findPane);
- JButton findButton = new JButton(findAction);
+ findButton = new JButton();
findButton.setIcon(GeneralIcons.findIcon);
findButton.setHideActionText(true);
findButton.setToolTipText("Find in text..");
add(findButton);
- ZoomAction zoomInAction = new ZoomAction(zoomPane, "+", 1.1);
- JButton zoomIn = new JButton(zoomInAction);
+ zoomIn = new JButton();
zoomIn.setIcon(GeneralIcons.zoomInIcon);
zoomIn.setHideActionText(true);
zoomIn.setToolTipText("Zoom in");
add(zoomIn);
- ZoomAction zoomOutAction = new ZoomAction(zoomPane, "-", 1 / 1.1);
- JButton zoomOut = new JButton(zoomOutAction);
+ zoomOut = new JButton();
zoomOut.setIcon(GeneralIcons.zoomOutIcon);
zoomOut.setHideActionText(true);
zoomOut.setToolTipText("Zoom out");
add(zoomOut);
-
-// JButton exceptionButton = new JButton("X");
-// exceptionButton.addActionListener(new ActionListener(){
-//
-// @Override
-// public void actionPerformed(ActionEvent e) {
-// try {
-// throw new ClassNotFoundException("original message");
-// } catch (Exception exception) {
-//
-// Log.exception(exception);
-// }
-//
-// }});
-//
-// add(exceptionButton);
+ }
+
+ private void refreshButtons() {
+ undoButton.setIcon(GeneralIcons.undoIcon);
+ undoButton.setHideActionText(true);
+ undoButton.setToolTipText("Undo edit");
+
+ redoButton.setIcon(GeneralIcons.redoIcon);
+ redoButton.setHideActionText(true);
+ redoButton.setToolTipText("Redo edit");
+
+ findButton.setIcon(GeneralIcons.findIcon);
+ findButton.setHideActionText(true);
+ findButton.setToolTipText("Find in text..");
+
+ zoomIn.setIcon(GeneralIcons.zoomInIcon);
+ zoomIn.setHideActionText(true);
+ zoomIn.setToolTipText("Zoom in");
+
+ zoomOut.setIcon(GeneralIcons.zoomOutIcon);
+ zoomOut.setHideActionText(true);
+ zoomOut.setToolTipText("Zoom out");
+ }
+
+ /**
+ * @param source
+ */
+ public void setEditorPane(EditorPane targetPane) {
+
+ Document doc = targetPane.getDocument();
+ if (undoHandlerMap.get(doc) == null) {
+ undoHandler = new UndoHandler(targetPane);
+ doc.addUndoableEditListener(undoHandler);
+ }
+
+ Action undoAction = targetPane.getUndoAction();
+ undoButton.setAction(undoAction);
+ undoAction.addPropertyChangeListener(undoActionChangeListener);
+
+ Action redoAction = targetPane.getRedoAction();
+ redoButton.setAction(redoAction);
+ redoAction.addPropertyChangeListener(redoActionChangeListener);
+
+ Action findAction = new FindAction(frame, targetPane);
+ findButton.setAction(findAction);
+
+ ZoomAction zoomInAction = new ZoomAction(targetPane, "+", 1.1);
+ zoomIn.setAction(zoomInAction);
+
+ ZoomAction zoomOutAction = new ZoomAction(targetPane, "-", 1 / 1.1);
+ zoomOut.setAction(zoomOutAction);
+ refreshButtons(); // a pain, but seems necessary
+ }
+
+ public void findOnly() {
+ undoButton.setEnabled(false);
+ redoButton.setEnabled(false);
+ findButton.setEnabled(true);
+ zoomIn.setEnabled(false);
+ zoomOut.setEnabled(false);
+ }
+
+ public void enableAll() {
+ undoButton.setEnabled(true);
+ redoButton.setEnabled(true);
+ findButton.setEnabled(true);
+ zoomIn.setEnabled(true);
+ zoomOut.setEnabled(true);
}
}
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.hyperdata.scute.main;
+
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+
+import javax.swing.JEditorPane;
+
+import org.hyperdata.scute.editortools.EditorToolbar;
+import org.hyperdata.scute.source.EditorPane;
+
+/**
+ * @author danny
+ *
+ */
+public class FocusMonitor implements FocusListener {
+
+ private EditorToolbar editorToolbar;
+
+ public void setEditorToolbar(EditorToolbar editorToolbar){
+ this.editorToolbar = editorToolbar;
+ }
+ /* (non-Javadoc)
+ * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
+ */
+ @Override
+ public void focusGained(FocusEvent event) {
+ Object source = event.getSource();
+ if(source instanceof EditorPane){
+ editorToolbar.enableAll();
+ editorToolbar.setEditorPane((EditorPane)source);
+ editorToolbar.setVisible(true);
+ } else {
+ editorToolbar.setVisible(false);
+ }
+ System.out.println("FOCUS="+event.getSource());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
+ */
+ @Override
+ public void focusLost(FocusEvent e) {
+ // ignore
+ }
+
+}
Oops, something went wrong.

0 comments on commit b7bf28f

Please sign in to comment.