Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from SeeSharpSoft/master
Release 2.8.1
- Loading branch information
Showing
10 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
...eesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorMouseWheelListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; | ||
|
||
import javax.swing.*; | ||
import java.awt.event.MouseWheelEvent; | ||
import java.awt.event.MouseWheelListener; | ||
|
||
public class CsvTableEditorMouseWheelListener extends CsvTableEditorUtilBase implements MouseWheelListener { | ||
|
||
public static final int SCROLL_FACTOR = 3; | ||
public static final int ZOOM_FACTOR = 3; | ||
|
||
protected static final int SCROLL_FACTOR = 100; | ||
|
||
public CsvTableEditorMouseWheelListener(CsvTableEditorSwing csvTableEditorArg) { | ||
super(csvTableEditorArg); | ||
} | ||
|
||
@Override | ||
public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) { | ||
|
||
if (mouseWheelEvent.isControlDown()) { | ||
int scrolled = mouseWheelEvent.getUnitsToScroll(); | ||
int amount = -(scrolled / SCROLL_FACTOR); | ||
int amount = -(scrolled / ZOOM_FACTOR); | ||
if (amount == 0) { | ||
return; | ||
} | ||
csvTableEditor.changeFontSize(amount); | ||
} else { | ||
JScrollPane scrollPane = csvTableEditor.getTableScrollPane(); | ||
JScrollBar vScrollbar = scrollPane.getVerticalScrollBar(); | ||
vScrollbar.setValue(vScrollbar.getValue() + (int)(SCROLL_FACTOR * mouseWheelEvent.getPreciseWheelRotation())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 27 additions & 8 deletions
35
...arpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorMouseWheelListenerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,48 @@ | ||
package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; | ||
|
||
import net.seesharpsoft.intellij.plugins.csv.editor.table.CsvTableEditor; | ||
import org.mockito.Mockito; | ||
|
||
import javax.swing.*; | ||
import java.awt.event.InputEvent; | ||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseWheelEvent; | ||
|
||
public class CsvTableEditorMouseWheelListenerTest extends CsvTableEditorSwingTestBase { | ||
|
||
public void testWheeledOnCsvTable() { | ||
@Override | ||
protected String getTestFile() { return "AnyFile.csv"; } | ||
|
||
public void testZoomOnCsvTable() { | ||
CsvTableEditorSwing fileEditor = Mockito.spy(this.fileEditor); | ||
|
||
MouseWheelEvent wheelEvent = new MouseWheelEvent(fileEditor.getTable(), | ||
MouseWheelEvent.MOUSE_WHEEL,JComponent.WHEN_FOCUSED, | ||
MouseWheelEvent.CTRL_MASK,0,0,0,false,MouseWheelEvent.WHEEL_UNIT_SCROLL, | ||
3,-1); | ||
|
||
CsvTableEditorMouseWheelListener spiedMouseWheelListener = fileEditor.tableEditorMouseWheelListener; | ||
|
||
int size=fileEditor.getTable().getFont().getSize(); | ||
int size = fileEditor.getTable().getFont().getSize(); | ||
spiedMouseWheelListener.mouseWheelMoved(wheelEvent); | ||
int new_size = fileEditor.getTable().getFont().getSize(); | ||
|
||
assertEquals(size + 1, new_size); | ||
} | ||
|
||
public void testScrollOnCsvTable() { | ||
CsvTableEditorSwing fileEditor = Mockito.spy(this.fileEditor); | ||
|
||
MouseWheelEvent wheelEvent = new MouseWheelEvent(fileEditor.getTable(), | ||
MouseWheelEvent.MOUSE_WHEEL,JComponent.WHEN_FOCUSED, | ||
0,0,0,0,false, MouseWheelEvent.WHEEL_UNIT_SCROLL, | ||
1,1); | ||
|
||
CsvTableEditorMouseWheelListener spiedMouseWheelListener = fileEditor.tableEditorMouseWheelListener; | ||
|
||
int scrollValue = fileEditor.getTableScrollPane().getVerticalScrollBar().getValue(); | ||
assertEquals(0, scrollValue); | ||
spiedMouseWheelListener.mouseWheelMoved(wheelEvent); | ||
int new_size=fileEditor.getTable().getFont().getSize(); | ||
scrollValue = fileEditor.getTableScrollPane().getVerticalScrollBar().getValue(); | ||
|
||
assertTrue(new_size == size + 1); | ||
// 90 is max in this case | ||
assertEquals(90, scrollValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters