mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 19:09:03 +00:00
Implemented zoom control keyboard shortcuts
- Added a `CTRL + +` to zoom in - Added a `CTRL + -` to zoom out - Added a `CTRL + 0` to reset zoom - Minor refactor in classes names (removed "2" appended to GUI's classes name)
This commit is contained in:
parent
15aaf95dcd
commit
b5e9171558
@ -46,7 +46,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.Month;
|
|
||||||
import java.time.format.TextStyle;
|
import java.time.format.TextStyle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -70,7 +69,7 @@ import net.sourceforge.plantuml.security.SecurityUtils;
|
|||||||
import net.sourceforge.plantuml.sprite.SpriteGrayLevel;
|
import net.sourceforge.plantuml.sprite.SpriteGrayLevel;
|
||||||
import net.sourceforge.plantuml.sprite.SpriteUtils;
|
import net.sourceforge.plantuml.sprite.SpriteUtils;
|
||||||
import net.sourceforge.plantuml.stats.StatsUtils;
|
import net.sourceforge.plantuml.stats.StatsUtils;
|
||||||
import net.sourceforge.plantuml.swing.MainWindow2;
|
import net.sourceforge.plantuml.swing.MainWindow;
|
||||||
import net.sourceforge.plantuml.syntax.LanguageDescriptor;
|
import net.sourceforge.plantuml.syntax.LanguageDescriptor;
|
||||||
import net.sourceforge.plantuml.utils.Cypher;
|
import net.sourceforge.plantuml.utils.Cypher;
|
||||||
import net.sourceforge.plantuml.version.Version;
|
import net.sourceforge.plantuml.version.Version;
|
||||||
@ -171,7 +170,7 @@ public class Run {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
new MainWindow2(option, dir);
|
new MainWindow(option, dir);
|
||||||
} catch (java.awt.HeadlessException e) {
|
} catch (java.awt.HeadlessException e) {
|
||||||
System.err.println("There is an issue with your server. You will find some tips here:");
|
System.err.println("There is an issue with your server. You will find some tips here:");
|
||||||
System.err.println("https://forum.plantuml.net/3399/problem-with-x11-and-headless-exception");
|
System.err.println("https://forum.plantuml.net/3399/problem-with-x11-and-headless-exception");
|
||||||
|
@ -35,38 +35,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.swing;
|
package net.sourceforge.plantuml.swing;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseMotionAdapter;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollBar;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.ListModel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.WindowConstants;
|
|
||||||
|
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
import net.sourceforge.plantuml.ImageSelection;
|
import net.sourceforge.plantuml.ImageSelection;
|
||||||
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
||||||
@ -75,15 +43,25 @@ import net.sourceforge.plantuml.security.SFile;
|
|||||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
import net.sourceforge.plantuml.version.PSystemVersion;
|
import net.sourceforge.plantuml.version.PSystemVersion;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
|
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
|
||||||
|
|
||||||
class ImageWindow2 extends JFrame {
|
class ImageWindow extends JFrame {
|
||||||
|
|
||||||
private final static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class);
|
private final static Preferences prefs = Preferences.userNodeForPackage(ImageWindow.class);
|
||||||
private final static String KEY_ZOOM_FIT = "zoomfit";
|
private final static String KEY_ZOOM_FIT = "zoomfit";
|
||||||
private final static String KEY_WIDTH_FIT = "widthfit";
|
private final static String KEY_WIDTH_FIT = "widthfit";
|
||||||
|
|
||||||
private SimpleLine2 simpleLine2;
|
private SimpleLine simpleLine;
|
||||||
private final JScrollPane scrollPane;
|
private final JScrollPane scrollPane;
|
||||||
private final JButton next = new JButton("Next");
|
private final JButton next = new JButton("Next");
|
||||||
private final JButton copy = new JButton("Copy");
|
private final JButton copy = new JButton("Copy");
|
||||||
@ -92,7 +70,7 @@ class ImageWindow2 extends JFrame {
|
|||||||
private final JCheckBox widthFitButt = new JCheckBox("Width fit");
|
private final JCheckBox widthFitButt = new JCheckBox("Width fit");
|
||||||
private final JButton zoomMore = new JButton("+");
|
private final JButton zoomMore = new JButton("+");
|
||||||
private final JButton zoomLess = new JButton("-");
|
private final JButton zoomLess = new JButton("-");
|
||||||
private final MainWindow2 main;
|
private final MainWindow main;
|
||||||
|
|
||||||
private final ListModel listModel;
|
private final ListModel listModel;
|
||||||
private int index;
|
private int index;
|
||||||
@ -106,10 +84,10 @@ class ImageWindow2 extends JFrame {
|
|||||||
|
|
||||||
private int startX, startY;
|
private int startX, startY;
|
||||||
|
|
||||||
public ImageWindow2(SimpleLine2 simpleLine, final MainWindow2 main, ListModel listModel, int index) {
|
public ImageWindow(SimpleLine simpleLine, final MainWindow main, ListModel listModel, int index) {
|
||||||
super(simpleLine.toString());
|
super(simpleLine.toString());
|
||||||
setIconImage(PSystemVersion.getPlantumlSmallIcon2());
|
setIconImage(PSystemVersion.getPlantumlSmallIcon2());
|
||||||
this.simpleLine2 = simpleLine;
|
this.simpleLine = simpleLine;
|
||||||
this.listModel = listModel;
|
this.listModel = listModel;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.main = main;
|
this.main = main;
|
||||||
@ -180,7 +158,7 @@ class ImageWindow2 extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
super.windowClosing(e);
|
super.windowClosing(e);
|
||||||
main.closing(ImageWindow2.this);
|
main.closing(ImageWindow.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -205,7 +183,16 @@ class ImageWindow2 extends JFrame {
|
|||||||
this.setFocusable(true);
|
this.setFocusable(true);
|
||||||
this.addKeyListener(new KeyAdapter() {
|
this.addKeyListener(new KeyAdapter() {
|
||||||
public void keyPressed(KeyEvent evt) {
|
public void keyPressed(KeyEvent evt) {
|
||||||
if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_RIGHT) {
|
if (evt.isControlDown() && (evt.getKeyCode() == KeyEvent.VK_PLUS || evt.getKeyCode() == KeyEvent.VK_ADD)) {
|
||||||
|
zoomFactor++;
|
||||||
|
refreshImage(false);
|
||||||
|
} else if (evt.isControlDown() && (evt.getKeyCode() == KeyEvent.VK_MINUS || evt.getKeyCode() == KeyEvent.VK_SUBTRACT)) {
|
||||||
|
zoomFactor--;
|
||||||
|
refreshImage(false);
|
||||||
|
} else if (evt.isControlDown() && (evt.getKeyCode() == KeyEvent.VK_0 || evt.getKeyCode() == KeyEvent.VK_NUMPAD0)) {
|
||||||
|
zoomFactor = 0;
|
||||||
|
refreshImage(false);
|
||||||
|
} else if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||||
next();
|
next();
|
||||||
} else if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_LEFT) {
|
} else if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||||
previous();
|
previous();
|
||||||
@ -229,7 +216,6 @@ class ImageWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next() {
|
private void next() {
|
||||||
@ -285,22 +271,22 @@ class ImageWindow2 extends JFrame {
|
|||||||
if (index > listModel.getSize() - 1) {
|
if (index > listModel.getSize() - 1) {
|
||||||
index = listModel.getSize() - 1;
|
index = listModel.getSize() - 1;
|
||||||
}
|
}
|
||||||
simpleLine2 = (SimpleLine2) listModel.getElementAt(index);
|
simpleLine = (SimpleLine) listModel.getElementAt(index);
|
||||||
setTitle(simpleLine2.toString());
|
setTitle(simpleLine.toString());
|
||||||
refreshImage(false);
|
refreshImage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSimpleLine() {
|
private void refreshSimpleLine() {
|
||||||
for (SimpleLine2 line : main.getCurrentDirectoryListing2()) {
|
for (SimpleLine line : main.getCurrentDirectoryListing2()) {
|
||||||
if (line.getFile().equals(simpleLine2.getFile())) {
|
if (line.getFile().equals(simpleLine.getFile())) {
|
||||||
simpleLine2 = line;
|
simpleLine = line;
|
||||||
setTitle(simpleLine2.toString());
|
setTitle(simpleLine.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScrollablePicture buildScrollablePicture() {
|
private ScrollablePicture buildScrollablePicture() {
|
||||||
final GeneratedImage generatedImage = simpleLine2.getGeneratedImage();
|
final GeneratedImage generatedImage = simpleLine.getGeneratedImage();
|
||||||
if (generatedImage == null) {
|
if (generatedImage == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -333,7 +319,7 @@ class ImageWindow2 extends JFrame {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ImageIcon imageIcon = new ImageIcon(image, simpleLine2.toString());
|
final ImageIcon imageIcon = new ImageIcon(image, simpleLine.toString());
|
||||||
final ScrollablePicture scrollablePicture = new ScrollablePicture(imageIcon, 1);
|
final ScrollablePicture scrollablePicture = new ScrollablePicture(imageIcon, 1);
|
||||||
|
|
||||||
scrollablePicture.addMouseListener(new MouseAdapter() {
|
scrollablePicture.addMouseListener(new MouseAdapter() {
|
||||||
@ -376,7 +362,7 @@ class ImageWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copy() {
|
private void copy() {
|
||||||
final GeneratedImage generatedImage = simpleLine2.getGeneratedImage();
|
final GeneratedImage generatedImage = simpleLine.getGeneratedImage();
|
||||||
if (generatedImage == null) {
|
if (generatedImage == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -386,8 +372,8 @@ class ImageWindow2 extends JFrame {
|
|||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null);
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleLine2 getSimpleLine() {
|
public SimpleLine getSimpleLine() {
|
||||||
return simpleLine2;
|
return simpleLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int v1;
|
private int v1;
|
||||||
@ -416,7 +402,7 @@ class ImageWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isError() {
|
private boolean isError() {
|
||||||
return simpleLine2.getGeneratedImage() != null && simpleLine2.getGeneratedImage().lineErrorRaw() != -1;
|
return simpleLine.getGeneratedImage() != null && simpleLine.getGeneratedImage().lineErrorRaw() != -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -35,59 +35,30 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.swing;
|
package net.sourceforge.plantuml.swing;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
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.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.ListModel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.Timer;
|
|
||||||
import javax.swing.border.CompoundBorder;
|
|
||||||
|
|
||||||
import net.sourceforge.plantuml.DirWatcher2;
|
import net.sourceforge.plantuml.DirWatcher2;
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
import net.sourceforge.plantuml.Log;
|
import net.sourceforge.plantuml.Log;
|
||||||
import net.sourceforge.plantuml.Option;
|
import net.sourceforge.plantuml.Option;
|
||||||
import net.sourceforge.plantuml.version.PSystemVersion;
|
import net.sourceforge.plantuml.version.PSystemVersion;
|
||||||
|
|
||||||
public class MainWindow2 extends JFrame {
|
import javax.swing.Timer;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
final private static Preferences prefs = Preferences.userNodeForPackage(MainWindow2.class);
|
public class MainWindow extends JFrame {
|
||||||
|
|
||||||
|
final private static Preferences prefs = Preferences.userNodeForPackage(MainWindow.class);
|
||||||
final private static String KEY_DIR = "cur";
|
final private static String KEY_DIR = "cur";
|
||||||
final private static String KEY_PATTERN = "pat";
|
final private static String KEY_PATTERN = "pat";
|
||||||
|
|
||||||
@ -97,8 +68,8 @@ public class MainWindow2 extends JFrame {
|
|||||||
private final JTextField extensions = new JTextField();
|
private final JTextField extensions = new JTextField();
|
||||||
private final int period = 300;
|
private final int period = 300;
|
||||||
|
|
||||||
final private List<SimpleLine2> currentDirectoryListing2 = new ArrayList<>();
|
final private List<SimpleLine> currentDirectoryListing2 = new ArrayList<>();
|
||||||
final private Set<ImageWindow2> openWindows2 = new HashSet<>();
|
final private Set<ImageWindow> openWindows2 = new HashSet<>();
|
||||||
final private Option option;
|
final private Option option;
|
||||||
|
|
||||||
private DirWatcher2 dirWatcher;
|
private DirWatcher2 dirWatcher;
|
||||||
@ -155,7 +126,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
return Option.getPattern();
|
return Option.getPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow2(Option option, File arg) {
|
public MainWindow(Option option, File arg) {
|
||||||
super(getDirectory(arg).getAbsolutePath());
|
super(getDirectory(arg).getAbsolutePath());
|
||||||
System.setProperty("PLANTUML_SECURITY_PROFILE", "UNSECURE");
|
System.setProperty("PLANTUML_SECURITY_PROFILE", "UNSECURE");
|
||||||
final File dir = getDirectory(arg);
|
final File dir = getDirectory(arg);
|
||||||
@ -190,7 +161,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
try {
|
try {
|
||||||
if (e.getClickCount() == 2) {
|
if (e.getClickCount() == 2) {
|
||||||
final int index = jList1.locationToIndex(e.getPoint());
|
final int index = jList1.locationToIndex(e.getPoint());
|
||||||
doubleClick((SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index);
|
doubleClick((SimpleLine) jList1.getModel().getElementAt(index), jList1.getModel(), index);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
@ -209,7 +180,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
final int index = jList1.getSelectedIndex();
|
final int index = jList1.getSelectedIndex();
|
||||||
doubleClick((SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index);
|
doubleClick((SimpleLine) jList1.getModel().getElementAt(index), jList1.getModel(), index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,8 +286,8 @@ public class MainWindow2 extends JFrame {
|
|||||||
jList1.setVisible(true);
|
jList1.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doubleClick(SimpleLine2 simpleLine, ListModel listModel, int index) {
|
private void doubleClick(SimpleLine simpleLine, ListModel listModel, int index) {
|
||||||
for (ImageWindow2 win : openWindows2) {
|
for (ImageWindow win : openWindows2) {
|
||||||
if (win.getSimpleLine().equals(simpleLine)) {
|
if (win.getSimpleLine().equals(simpleLine)) {
|
||||||
win.setVisible(true);
|
win.setVisible(true);
|
||||||
win.setExtendedState(Frame.NORMAL);
|
win.setExtendedState(Frame.NORMAL);
|
||||||
@ -324,7 +295,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (simpleLine.getGeneratedImage() != null) {
|
if (simpleLine.getGeneratedImage() != null) {
|
||||||
openWindows2.add(new ImageWindow2(simpleLine, this, listModel, index));
|
openWindows2.add(new ImageWindow(simpleLine, this, listModel, index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,19 +327,19 @@ public class MainWindow2 extends JFrame {
|
|||||||
final File file = ent.getKey();
|
final File file = ent.getKey();
|
||||||
removeAllThatUseThisFile(file);
|
removeAllThatUseThisFile(file);
|
||||||
final Future<List<GeneratedImage>> future = ent.getValue();
|
final Future<List<GeneratedImage>> future = ent.getValue();
|
||||||
final SimpleLine2 simpleLine = SimpleLine2.fromFuture(file, future);
|
final SimpleLine simpleLine = SimpleLine.fromFuture(file, future);
|
||||||
currentDirectoryListing2.add(simpleLine);
|
currentDirectoryListing2.add(simpleLine);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SimpleLine2 line : new ArrayList<>(currentDirectoryListing2)) {
|
for (SimpleLine line : new ArrayList<>(currentDirectoryListing2)) {
|
||||||
if (line.pendingAndFinished()) {
|
if (line.pendingAndFinished()) {
|
||||||
currentDirectoryListing2.remove(line);
|
currentDirectoryListing2.remove(line);
|
||||||
changed = true;
|
changed = true;
|
||||||
final Future<List<GeneratedImage>> future = line.getFuture();
|
final Future<List<GeneratedImage>> future = line.getFuture();
|
||||||
for (GeneratedImage im : future.get()) {
|
for (GeneratedImage im : future.get()) {
|
||||||
mayRefreshImageWindow(im.getPngFile());
|
mayRefreshImageWindow(im.getPngFile());
|
||||||
final SimpleLine2 simpleLine = SimpleLine2.fromGeneratedImage(line.getFile(), im);
|
final SimpleLine simpleLine = SimpleLine.fromGeneratedImage(line.getFile(), im);
|
||||||
currentDirectoryListing2.add(simpleLine);
|
currentDirectoryListing2.add(simpleLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,8 +349,8 @@ public class MainWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeAllThatUseThisFile(File file) {
|
private void removeAllThatUseThisFile(File file) {
|
||||||
for (final Iterator<SimpleLine2> it = currentDirectoryListing2.iterator(); it.hasNext();) {
|
for (final Iterator<SimpleLine> it = currentDirectoryListing2.iterator(); it.hasNext();) {
|
||||||
final SimpleLine2 line = it.next();
|
final SimpleLine line = it.next();
|
||||||
if (line.getFile().equals(file)) {
|
if (line.getFile().equals(file)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
@ -387,7 +358,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mayRefreshImageWindow(File pngFile) {
|
private void mayRefreshImageWindow(File pngFile) {
|
||||||
for (ImageWindow2 win : openWindows2) {
|
for (ImageWindow win : openWindows2) {
|
||||||
if (win.getSimpleLine().getGeneratedImage() == null) {
|
if (win.getSimpleLine().getGeneratedImage() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -398,14 +369,14 @@ public class MainWindow2 extends JFrame {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closing(ImageWindow2 imageWindow) {
|
public void closing(ImageWindow imageWindow) {
|
||||||
final boolean ok = openWindows2.remove(imageWindow);
|
final boolean ok = openWindows2.remove(imageWindow);
|
||||||
if (ok == false) {
|
if (ok == false) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SimpleLine2> getCurrentDirectoryListing2() {
|
public List<SimpleLine> getCurrentDirectoryListing2() {
|
||||||
return Collections.unmodifiableList(currentDirectoryListing2);
|
return Collections.unmodifiableList(currentDirectoryListing2);
|
||||||
}
|
}
|
||||||
|
|
@ -41,21 +41,21 @@ import java.util.concurrent.Future;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
|
|
||||||
class SimpleLine2 implements Comparable<SimpleLine2> {
|
class SimpleLine implements Comparable<SimpleLine> {
|
||||||
|
|
||||||
private final File file;
|
private final File file;
|
||||||
private final GeneratedImage generatedImage;
|
private final GeneratedImage generatedImage;
|
||||||
private final Future<List<GeneratedImage>> future;
|
private final Future<List<GeneratedImage>> future;
|
||||||
|
|
||||||
public static SimpleLine2 fromFuture(File file, Future<List<GeneratedImage>> future) {
|
public static SimpleLine fromFuture(File file, Future<List<GeneratedImage>> future) {
|
||||||
return new SimpleLine2(file, null, future);
|
return new SimpleLine(file, null, future);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleLine2 fromGeneratedImage(File file, GeneratedImage generatedImage) {
|
public static SimpleLine fromGeneratedImage(File file, GeneratedImage generatedImage) {
|
||||||
return new SimpleLine2(file, generatedImage, null);
|
return new SimpleLine(file, generatedImage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SimpleLine2(File file, GeneratedImage generatedImage, Future<List<GeneratedImage>> future) {
|
private SimpleLine(File file, GeneratedImage generatedImage, Future<List<GeneratedImage>> future) {
|
||||||
this.generatedImage = generatedImage;
|
this.generatedImage = generatedImage;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.future = future;
|
this.future = future;
|
||||||
@ -84,7 +84,7 @@ class SimpleLine2 implements Comparable<SimpleLine2> {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(SimpleLine2 other) {
|
public int compareTo(SimpleLine other) {
|
||||||
return toString().compareTo(other.toString());
|
return toString().compareTo(other.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user