auto-sync
This commit is contained in:
parent
a3d972c406
commit
16d17d5e5f
|
@ -0,0 +1,8 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
public enum KeyStrokeShortcut {
|
||||||
|
PREVIOUS_PAGE,
|
||||||
|
NEXT_PAGE,
|
||||||
|
ZOOM_IN,
|
||||||
|
ZOOM_OUT;
|
||||||
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
package com.rusefi.ui;
|
package com.rusefi.ui;
|
||||||
|
|
||||||
|
import com.rusefi.KeyStrokeShortcut;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,11 +17,13 @@ public class ChartScrollControl {
|
||||||
private final JPanel content = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
private final JPanel content = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||||
private final AtomicInteger index = new AtomicInteger();
|
private final AtomicInteger index = new AtomicInteger();
|
||||||
private static final JLabel info = new JLabel();
|
private static final JLabel info = new JLabel();
|
||||||
|
private ChartRepository.CRListener listener;
|
||||||
|
|
||||||
public ChartScrollControl(final ChartRepository.CRListener listener) {
|
public ChartScrollControl(final ChartRepository.CRListener listener) {
|
||||||
|
|
||||||
content.setBorder(BorderFactory.createLineBorder(Color.red));
|
this.listener = listener;
|
||||||
|
|
||||||
|
content.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
|
|
||||||
setInfoText(index);
|
setInfoText(index);
|
||||||
|
|
||||||
|
@ -27,11 +32,7 @@ public class ChartScrollControl {
|
||||||
prev.addActionListener(new ActionListener() {
|
prev.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (index.intValue() > 0) {
|
previousPage();
|
||||||
index.decrementAndGet();
|
|
||||||
listener.onDigitalChart(ChartRepository.getInstance().getChart(index.get()));
|
|
||||||
setInfoText(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,11 +42,7 @@ public class ChartScrollControl {
|
||||||
next.addActionListener(new ActionListener() {
|
next.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (index.intValue() < ChartRepository.getInstance().getSize() - 1) {
|
nextPage();
|
||||||
index.incrementAndGet();
|
|
||||||
listener.onDigitalChart(ChartRepository.getInstance().getChart(index.get()));
|
|
||||||
setInfoText(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,6 +50,41 @@ public class ChartScrollControl {
|
||||||
content.add(info);
|
content.add(info);
|
||||||
content.add(next);
|
content.add(next);
|
||||||
|
|
||||||
|
bindKeyStrokeActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void previousPage() {
|
||||||
|
if (index.intValue() > 0) {
|
||||||
|
index.decrementAndGet();
|
||||||
|
listener.onDigitalChart(ChartRepository.getInstance().getChart(index.get()));
|
||||||
|
setInfoText(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void nextPage() {
|
||||||
|
if (index.intValue() < ChartRepository.getInstance().getSize() - 1) {
|
||||||
|
index.incrementAndGet();
|
||||||
|
listener.onDigitalChart(ChartRepository.getInstance().getChart(index.get()));
|
||||||
|
setInfoText(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindKeyStrokeActions() {
|
||||||
|
InputMap inputMap = content.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
|
|
||||||
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), KeyStrokeShortcut.PREVIOUS_PAGE);
|
||||||
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), KeyStrokeShortcut.NEXT_PAGE);
|
||||||
|
|
||||||
|
content.getActionMap().put(KeyStrokeShortcut.PREVIOUS_PAGE, new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
previousPage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
content.getActionMap().put(KeyStrokeShortcut.NEXT_PAGE, new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
nextPage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getContent() {
|
public JPanel getContent() {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class LogViewer extends JPanel {
|
||||||
throw new IllegalStateException("Not directory: " + folder);
|
throw new IllegalStateException("Not directory: " + folder);
|
||||||
|
|
||||||
File[] files = folder.listFiles(FILE_FILTER);
|
File[] files = folder.listFiles(FILE_FILTER);
|
||||||
fileList.removeAll();
|
fileListModel.removeAllElements();
|
||||||
for (File file : files)
|
for (File file : files)
|
||||||
fileListModel.addElement(getFileDesc(file));
|
fileListModel.addElement(getFileDesc(file));
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.rusefi.ui;
|
package com.rusefi.ui;
|
||||||
|
|
||||||
import com.irnems.waves.ZoomProvider;
|
import com.irnems.waves.ZoomProvider;
|
||||||
|
import com.rusefi.KeyStrokeShortcut;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 7/7/13
|
* 7/7/13
|
||||||
|
@ -46,7 +48,7 @@ public class ZoomControl extends JPanel {
|
||||||
plus.addActionListener(new ActionListener() {
|
plus.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setValue(value * 1.1);
|
zoomIn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
plus.setToolTipText("Zoom in");
|
plus.setToolTipText("Zoom in");
|
||||||
|
@ -67,11 +69,40 @@ public class ZoomControl extends JPanel {
|
||||||
minus.addActionListener(new ActionListener() {
|
minus.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setValue(value / 1.1);
|
zoomOut();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
minus.setToolTipText("Zoom out");
|
minus.setToolTipText("Zoom out");
|
||||||
add(minus);
|
add(minus);
|
||||||
|
|
||||||
|
bindKeyStrokeActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindKeyStrokeActions() {
|
||||||
|
InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
|
|
||||||
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), KeyStrokeShortcut.ZOOM_IN);
|
||||||
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0), KeyStrokeShortcut.ZOOM_OUT);
|
||||||
|
|
||||||
|
getActionMap().put(KeyStrokeShortcut.ZOOM_IN, new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
zoomIn();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getActionMap().put(KeyStrokeShortcut.ZOOM_OUT, new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
zoomOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void zoomIn() {
|
||||||
|
setValue(value * 1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void zoomOut() {
|
||||||
|
setValue(value / 1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setValue(double value) {
|
private void setValue(double value) {
|
||||||
|
|
Loading…
Reference in New Issue