Viewing Issue Advanced Details

ID 0003795 Category [DMDirc] *Unsorted Severity minor
Reproducibility always Date Submitted 2010-02-17 21:20 Last Update 2010-03-07 03:22
Reporter Greboid Assigned To Demented-Idiot View Status public
Priority normal Status resolved Resolution fixed
Platform Fixed in Version Target Version 0.6.4
Product Version Product Build
Summary 0003795: Home and End support (top and bottom) for textpane
Description
Home and End support (top and bottom) for textpane
Needs unit test no
Upstream Bug URL

Relationships

Notes

A patchset (1) related to this change has been added to gerrit by Simon Mott

Adds listeners to the TextPane for Control+Home/End and the appropriate
behaviour

Fixes issue 3795

A patchset (2) related to this change has been added to gerrit by Simon Mott

Adds listeners to the TextPane for Control+Home/End and the appropriate
behaviour

Fixes issue 3795
Change-Id: If77f1f08bc8733617d9f1e116dacf21dd9729324
authorSimon Mott <simon@dmdirc.com>2010-03-07 03:02:26 (GMT)
committer Gregory Holmes <greg@dmdirc.com>2010-03-07 03:21:08 (GMT)
commit955061014dadd97cb867f097b7c378c9b6cc5778 (patch) (side-by-side diff)
Adds listeners to the TextPane for Control+Home/End and the appropriate behaviour
Fixes issue 3795 Change-Id: If77f1f08bc8733617d9f1e116dacf21dd9729324 Reviewed-on: http://gerrit.dmdirc.com/973 Reviewed-by: Gregory Holmes <greg@dmdirc.com> Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
-rw-r--r--src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java12
-rw-r--r--src/com/dmdirc/addons/ui_swing/textpane/TextPane.java10
-rw-r--r--src/com/dmdirc/addons/ui_swing/textpane/TextPaneEndAction.java61
-rw-r--r--src/com/dmdirc/addons/ui_swing/textpane/TextPaneHomeAction.java61
4 files changed, 144 insertions, 0 deletions
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
@@ -40,6 +40,8 @@ import com.dmdirc.addons.ui_swing.textpane.LineInfo;
import com.dmdirc.addons.ui_swing.textpane.TextPane;
import com.dmdirc.addons.ui_swing.textpane.TextPanePageDownAction;
import com.dmdirc.addons.ui_swing.textpane.TextPanePageUpAction;
+import com.dmdirc.addons.ui_swing.textpane.TextPaneHomeAction;
+import com.dmdirc.addons.ui_swing.textpane.TextPaneEndAction;
import com.dmdirc.commandparser.PopupManager;
import com.dmdirc.commandparser.PopupMenu;
import com.dmdirc.commandparser.PopupMenuItem;
@@ -537,11 +539,21 @@ public abstract class TextFrame extends JInternalFrame implements Window,
put(KeyStroke.getKeyStroke(KeyEvent.VK_F,
UIUtilities.getCtrlDownMask()), "searchAction");
+ getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
+ UIUtilities.getCtrlDownMask()), "homeAction");
+
+ getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_END,
+ UIUtilities.getCtrlDownMask()), "endAction");
+
getActionMap().put("pageUpAction",
new TextPanePageUpAction(getTextPane()));
getActionMap().put("pageDownAction",
new TextPanePageDownAction(getTextPane()));
getActionMap().put("searchAction", new SearchAction(searchBar));
+ getActionMap().put("homeAction", new TextPaneHomeAction(getTextPane()));
+ getActionMap().put("endAction", new TextPaneEndAction(getTextPane()));
}
/**
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/textpane/TextPane.java
@@ -405,6 +405,16 @@ public final class TextPane extends JComponent implements AdjustmentListener,
scrollModel.setValue(scrollModel.getValue() - 10);
}
+ /** Scrolls to the beginning of the TextPane */
+ public void goToHome() {
+ scrollModel.setValue(0);
+ }
+
+ /** Scrolls to the end of the TextPane */
+ public void goToEnd() {
+ scrollModel.setValue(document.getNumLines());
+ }
+
/** {@inheritDoc}. */
@Override
public void lineAdded(final int line, final int size) {
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/textpane/TextPaneEndAction.java
new file mode 100644
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes,
+ * Simon Mott
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.dmdirc.addons.ui_swing.textpane;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+
+/**
+ * This listener waits to be triggered then scrolls the current active TextPane
+ * to the bottom most line.
+ */
+public class TextPaneEndAction extends AbstractAction {
+
+ /**
+ * A version number for this class. It should be changed whenever the class
+ * structure is changed (or anything else that would prevent serialized
+ * objects being unserialized with the new class).
+ */
+ private static final long serialVersionUID = 1;
+ /** TextPane instance. */
+ private TextPane textpane;
+
+ /**
+ * Instantiates a new action.
+ *
+ * @param textpane Textpane
+ */
+ public TextPaneEndAction(final TextPane textpane) {
+ this.textpane = textpane;
+ }
+
+ /**
+ * {@inheritDoc}.
+ * @param e Action event
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ textpane.goToEnd();
+ }
+} \ No newline at end of file
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/textpane/TextPaneHomeAction.java
new file mode 100644
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes,
+ * Simon Mott
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.dmdirc.addons.ui_swing.textpane;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+
+/**
+ * This listener waits to be triggered then scrolls the current active TextPane
+ * to the top most line.
+ */
+public class TextPaneHomeAction extends AbstractAction {
+
+ /**
+ * A version number for this class. It should be changed whenever the class
+ * structure is changed (or anything else that would prevent serialized
+ * objects being unserialized with the new class).
+ */
+ private static final long serialVersionUID = 1;
+ /** TextPane instance. */
+ private TextPane textpane;
+
+ /**
+ * Instantiates a new action.
+ *
+ * @param textpane Textpane
+ */
+ public TextPaneHomeAction(final TextPane textpane) {
+ this.textpane = textpane;
+ }
+
+ /**
+ * {@inheritDoc}.
+ * @param e Action event
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ textpane.goToHome();
+ }
+} \ No newline at end of file

Issue History

Date Modified Username Field Change
2010-02-17 21:20 Greboid New Issue
2010-02-17 21:20 Greboid Status new => assigned
2010-02-17 21:20 Greboid Assigned To => Greboid
2010-02-28 00:27 Demented-Idiot Assigned To Greboid => Demented-Idiot
2010-03-07 03:03 Version Control Checkin
2010-03-07 03:03 Version Control Note Added: 0010144
2010-03-07 03:03 Version Control Status assigned => fix pending
2010-03-07 03:16 Version Control Checkin
2010-03-07 03:16 Version Control Note Added: 0010148
2010-03-07 03:22 Version Control Checkin
2010-03-07 03:22 Version Control Note Added: 0010150
2010-03-07 03:22 Version Control Status fix pending => resolved
2010-03-07 03:22 Version Control Resolution open => fixed