Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 1eaab97

Browse files
committed
Windows fixes, new file logging support.
Still doesn't export ffmpeg properly, needs to be tested more.
1 parent a14b030 commit 1eaab97

File tree

15 files changed

+216
-66
lines changed

15 files changed

+216
-66
lines changed

build.xml

+19-14
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,23 @@
193193
</exec>
194194
</target>
195195

196-
<target name="dist-win" depends="clean,resources">
197-
<!-- <fx:deploy-->
198-
<!-- nativeBundles="exe"-->
199-
<!-- outdir="${dist.windows}" outfile="${ant.project.name}">-->
200-
<!-- <fx:application name="${ant.project.name}" mainClass="nodebox.client.Application"-->
201-
<!-- version="${nodebox.version}"/>-->
202-
<!-- <fx:resources refid="dist.fxres"/>-->
203-
<!-- <fx:info title="${ant.project.name}" vendor="EMRG">-->
204-
<!-- <fx:icon href="platform/windows/installer/nodebox.ico"/>-->
205-
<!-- <fx:association description="NodeBox Document" mimetype="application/xml" extension="ndbx"-->
206-
<!-- icon="platform/windows/installer/nodebox.ico"/>-->
207-
<!-- </fx:info>-->
208-
<!-- </fx:deploy>-->
196+
<target name="dist-win" depends="resources" description="Final build on Windows">
197+
<mkdir dir="${dist.windows}" />
198+
<exec executable="jpackage">
199+
<arg line="-i ${dist.unpacked}"/>
200+
<arg line="-d ${dist.windows}"/>
201+
<arg line="-n NodeBox"/>
202+
<arg line="--app-version ${nodebox.version}"/>
203+
<arg line="--main-class nodebox.client.Application"/>
204+
<arg line="--main-jar lib/nodebox.jar"/>
205+
<arg line="--type msi"/>
206+
<arg line="--resource-dir ${dist.res}"/>
207+
<arg line="--icon platform/windows/installer/nodebox.ico"/>
208+
<arg line="--file-associations platform/fa-ndbx.properties"/>
209+
<arg line="--win-menu"/>
210+
<arg line="--win-shortcut"/>
211+
<arg line="--win-upgrade-uuid a3ddd262-9f4c-4e48-a027-5df45387c447"/>
212+
</exec>
209213
</target>
210214

211215

@@ -261,7 +265,8 @@
261265
</copy>
262266
</target>
263267
<target name="bindir" depends="bindir-unix,bindir-win"/>
264-
<target name="run" depends="compile,bindir">
268+
269+
<target name="run" depends="compile,bindir" description="Run the application">
265270
<java classname="nodebox.client.Application" fork="true">
266271
<classpath refid="runtime.classpath"/>
267272
</java>

platform/windows/bin/ffmpeg.exe

60 MB
Binary file not shown.

src/main/java/nodebox/Log.java

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package nodebox;
2+
3+
import nodebox.util.AppDirs;
4+
5+
import java.io.File;
6+
import java.io.IOException;
7+
import java.util.logging.FileHandler;
8+
import java.util.logging.Logger;
9+
import java.util.logging.Level;
10+
import java.util.logging.SimpleFormatter;
11+
12+
public class Log {
13+
private static final Logger LOGGER = java.util.logging.Logger.getGlobal();
14+
15+
static {
16+
try {
17+
// Initialize logging directory
18+
AppDirs.ensureUserLogDir();
19+
File logDir = AppDirs.getUserLogDir();
20+
21+
// Initialize file logging
22+
FileHandler handler = new FileHandler(logDir.getAbsolutePath() + "/nodebox-%u.log");
23+
handler.setFormatter(new SimpleFormatter());
24+
LOGGER.addHandler(handler);
25+
} catch (IOException e) {
26+
e.printStackTrace();
27+
}
28+
}
29+
30+
public static void info(String message) {
31+
LOGGER.log(Level.INFO, message);
32+
}
33+
34+
public static void warn(String message) {
35+
LOGGER.log(Level.WARNING, message);
36+
}
37+
38+
public static void warn(String message, Throwable t) {
39+
LOGGER.log(Level.WARNING, message, t);
40+
}
41+
42+
public static void error(String message) {
43+
LOGGER.log(Level.SEVERE, message);
44+
}
45+
46+
public static void error(String message, Throwable t) {
47+
LOGGER.log(Level.SEVERE, message, t);
48+
}
49+
50+
}

src/main/java/nodebox/client/Application.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package nodebox.client;
2020

21+
import nodebox.Log;
2122
import nodebox.node.NodeLibrary;
2223
import nodebox.node.NodeRepository;
2324
import nodebox.ui.ExceptionDialog;
@@ -32,18 +33,14 @@
3233
import java.awt.*;
3334
import java.awt.desktop.*;
3435
import java.io.File;
35-
import java.io.FileInputStream;
3636
import java.io.IOException;
3737
import java.io.InputStream;
38-
import java.net.URISyntaxException;
3938
import java.net.URL;
4039
import java.util.ArrayList;
4140
import java.util.Collections;
4241
import java.util.List;
4342
import java.util.Properties;
4443
import java.util.concurrent.atomic.AtomicBoolean;
45-
import java.util.logging.Level;
46-
import java.util.logging.Logger;
4744
import java.util.prefs.Preferences;
4845

4946
public class Application implements Host {
@@ -72,7 +69,6 @@ public static Application getInstance() {
7269
private Console console = null;
7370

7471
public static final String NAME = "NodeBox";
75-
private static Logger logger = Logger.getLogger("nodebox.client.Application");
7672

7773
private Application() {
7874
instance = this;
@@ -430,11 +426,11 @@ public NodeBoxDocument openDocument(File file) {
430426
return doc;
431427
}
432428
} catch (IOException e) {
433-
logger.log(Level.WARNING, "The document " + doc.getDocumentFile() + " refers to path with errors", e);
429+
Log.warn("The document " + doc.getDocumentFile() + " refers to path with errors", e);
434430
}
435431
}
436432
} catch (IOException e) {
437-
logger.log(Level.WARNING, "The document " + file + " refers to path with errors", e);
433+
Log.warn("The document " + file + " refers to path with errors", e);
438434
}
439435

440436
try {
@@ -443,7 +439,7 @@ public NodeBoxDocument openDocument(File file) {
443439
NodeBoxMenuBar.addRecentFile(file);
444440
return doc;
445441
} catch (RuntimeException e) {
446-
logger.log(Level.SEVERE, "Error while loading " + file, e);
442+
Log.error("Error while loading " + file, e);
447443
ExceptionDialog d = new ExceptionDialog(null, e);
448444
d.setVisible(true);
449445
return null;
@@ -519,6 +515,7 @@ public Updater getUpdater() {
519515
}
520516

521517
public static void main(String[] args) {
518+
Log.info("Starting NodeBox");
522519
final Application app = new Application();
523520
// Ignore OS X's weird launch parameter.
524521
if (args.length == 1 && !args[0].startsWith("-psn")) {

src/main/java/nodebox/client/ColorWell.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void mouseDragged(MouseEvent e) {
123123
Point pt = e.getPoint();
124124
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(c);
125125
pt = SwingUtilities.convertPoint(c, pt, frame.getContentPane());
126-
MouseEvent newEvent = new MouseEvent(colorPicker, e.getID(), e.getWhen(), e.getModifiers(), (int) pt.getX(), (int) pt.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
126+
MouseEvent newEvent = new MouseEvent(colorPicker, e.getID(), e.getWhen(), e.getModifiersEx(), (int) pt.getX(), (int) pt.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
127127
colorPicker.dispatchEvent(newEvent);
128128
}
129129

src/main/java/nodebox/client/Console.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package nodebox.client;
22

3+
import nodebox.Log;
34
import nodebox.ui.Theme;
45
import org.python.util.PythonInterpreter;
56

@@ -10,8 +11,6 @@
1011
import java.awt.event.*;
1112
import java.io.ByteArrayOutputStream;
1213
import java.util.ArrayList;
13-
import java.util.logging.Level;
14-
import java.util.logging.Logger;
1514

1615
import static com.google.common.base.Preconditions.checkNotNull;
1716

@@ -29,7 +28,6 @@ public class Console extends JFrame implements WindowListener, FocusListener {
2928
ATTRIBUTES_ERROR.addAttribute(StyleConstants.ColorConstants.Foreground, ERROR_COLOR);
3029
}
3130

32-
private static Logger logger = Logger.getLogger("nodebox.client.Console");
3331
private PythonInterpreter interpreter;
3432
private ArrayList<String> history = new ArrayList<String>();
3533
private int historyOffset = 0;
@@ -77,7 +75,7 @@ private void addMessage(String s, AttributeSet attributes) {
7775
try {
7876
messagesDocument.insertString(messagesDocument.getLength(), s, attributes);
7977
} catch (BadLocationException e) {
80-
logger.log(Level.WARNING, "addMessage: bad location (" + s + ")", e);
78+
Log.warn("addMessage: bad location (" + s + ")", e);
8179
}
8280
}
8381

src/main/java/nodebox/client/NodeBoxDocument.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.common.base.Preconditions;
44
import com.google.common.collect.ImmutableList;
55
import com.google.common.collect.ImmutableMap;
6+
import nodebox.Log;
67
import nodebox.client.devicehandler.DeviceHandler;
78
import nodebox.client.devicehandler.DeviceHandlerFactory;
89
import nodebox.function.Function;
@@ -43,7 +44,6 @@
4344
*/
4445
public class NodeBoxDocument extends JFrame implements WindowListener, HandleDelegate {
4546

46-
private static final Logger LOG = Logger.getLogger(NodeBoxDocument.class.getName());
4747
private static final String WINDOW_MODIFIED = "windowModified";
4848
public static String lastFilePath;
4949
public static String lastExportPath;
@@ -146,14 +146,14 @@ public void onSegmentClicked(String fullPath) {
146146
rootPanel.add(animationBar, BorderLayout.SOUTH);
147147

148148
// Zoom in / out shortcuts.
149-
KeyStroke zoomInStroke1 = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() + InputEvent.SHIFT_DOWN_MASK);
150-
KeyStroke zoomInStroke2 = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx());
151-
KeyStroke zoomInStroke3 = KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx());
149+
KeyStroke zoomInStroke1 = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
150+
KeyStroke zoomInStroke2 = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_DOWN_MASK);
151+
KeyStroke zoomInStroke3 = KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.META_DOWN_MASK);
152152
ActionListener zoomInHandler = new ZoomInHandler();
153153
getRootPane().registerKeyboardAction(zoomInHandler, zoomInStroke1, JComponent.WHEN_IN_FOCUSED_WINDOW);
154154
getRootPane().registerKeyboardAction(zoomInHandler, zoomInStroke2, JComponent.WHEN_IN_FOCUSED_WINDOW);
155155
getRootPane().registerKeyboardAction(zoomInHandler, zoomInStroke3, JComponent.WHEN_IN_FOCUSED_WINDOW);
156-
KeyStroke zoomOutStroke = KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx());
156+
KeyStroke zoomOutStroke = KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.META_DOWN_MASK);
157157
getRootPane().registerKeyboardAction(new ZoomOutHandler(), zoomOutStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
158158

159159
setContentPane(rootPanel);
@@ -1093,7 +1093,7 @@ private void createHandleForActiveNode() {
10931093
try {
10941094
handle = (Handle) handleFunction.invoke();
10951095
} catch (Exception e) {
1096-
LOG.log(Level.WARNING, "Error while creating handle for " + activeNode, e);
1096+
Log.warn("Error while creating handle for " + activeNode, e);
10971097
}
10981098
}
10991099

@@ -1510,7 +1510,7 @@ private boolean saveToFile(File file) {
15101510
getNodeLibrary().store(file);
15111511
} catch (IOException e) {
15121512
JOptionPane.showMessageDialog(this, "An error occurred while saving the file.", "NodeBox", JOptionPane.ERROR_MESSAGE);
1513-
LOG.log(Level.SEVERE, "An error occurred while saving the file.", e);
1513+
Log.error("An error occurred while saving the file.", e);
15141514
return false;
15151515
}
15161516
documentChanged = false;
@@ -1699,7 +1699,7 @@ public void run() {
16991699
}
17001700
exportDelegate.exportDone();
17011701
} catch (Exception e) {
1702-
LOG.log(Level.WARNING, "Error while exporting", e);
1702+
Log.warn("Error while exporting", e);
17031703
} finally {
17041704
SwingUtilities.invokeLater(new Runnable() {
17051705
public void run() {

src/main/java/nodebox/client/NodeBoxMenuBar.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.swing.undo.UndoManager;
88
import java.awt.*;
99
import java.awt.event.ActionEvent;
10+
import java.awt.event.InputEvent;
1011
import java.awt.event.KeyEvent;
1112
import java.io.File;
1213
import java.io.IOException;
@@ -249,7 +250,7 @@ public static class OpenExamplesAction extends AbstractAction {
249250

250251
public OpenExamplesAction() {
251252
putValue(NAME, "Open Examples...");
252-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_O, Event.SHIFT_MASK));
253+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_O, InputEvent.SHIFT_DOWN_MASK));
253254
}
254255

255256
public void actionPerformed(ActionEvent e) {
@@ -283,7 +284,7 @@ public void actionPerformed(ActionEvent e) {
283284
public class SaveAsAction extends AbstractDocumentAction {
284285
public SaveAsAction() {
285286
putValue(NAME, "Save As...");
286-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_S, Event.SHIFT_MASK));
287+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK));
287288
}
288289

289290
public void actionPerformed(ActionEvent e) {
@@ -345,7 +346,7 @@ public void actionPerformed(ActionEvent e) {
345346
public class ExportRangeAction extends AbstractDocumentAction {
346347
public ExportRangeAction() {
347348
putValue(NAME, "Export Range...");
348-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_E, Event.SHIFT_MASK));
349+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_E, InputEvent.SHIFT_DOWN_MASK));
349350
}
350351

351352
public void actionPerformed(ActionEvent e) {
@@ -405,7 +406,7 @@ public class RedoAction extends AbstractDocumentAction {
405406

406407
public RedoAction() {
407408
putValue(NAME, redoText);
408-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_Z, Event.SHIFT_MASK));
409+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_Z, InputEvent.SHIFT_DOWN_MASK));
409410
setEnabled(false);
410411
}
411412

@@ -484,7 +485,7 @@ public void actionPerformed(ActionEvent e) {
484485
public class NewNodeAction extends AbstractDocumentAction {
485486
public NewNodeAction() {
486487
putValue(NAME, "Create New Node...");
487-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_N, Event.SHIFT_MASK));
488+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_N, InputEvent.SHIFT_DOWN_MASK));
488489
}
489490

490491
public void actionPerformed(ActionEvent e) {
@@ -506,7 +507,7 @@ public void actionPerformed(ActionEvent e) {
506507
public class PlayPauseAction extends AbstractDocumentAction {
507508
public PlayPauseAction() {
508509
putValue(NAME, "Play/Pause");
509-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_P, Event.META_MASK));
510+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_P, InputEvent.META_DOWN_MASK));
510511
}
511512

512513
@Override
@@ -518,7 +519,7 @@ public void actionPerformed(ActionEvent actionEvent) {
518519
public class RewindAction extends AbstractDocumentAction {
519520
public RewindAction() {
520521
putValue(NAME, "Rewind");
521-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_P, Event.META_MASK | Event.SHIFT_MASK));
522+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_P, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
522523
}
523524

524525
@Override
@@ -530,7 +531,7 @@ public void actionPerformed(ActionEvent actionEvent) {
530531
public class FullScreenAction extends AbstractDocumentAction {
531532
public FullScreenAction() {
532533
putValue(NAME, "Full Screen");
533-
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_F, Event.META_MASK | Event.SHIFT_MASK));
534+
putValue(ACCELERATOR_KEY, Platform.getKeyStroke(KeyEvent.VK_F, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
534535
}
535536

536537
@Override
@@ -555,7 +556,7 @@ public void actionPerformed(ActionEvent actionEvent) {
555556
public class MinimizeAction extends AbstractDocumentAction {
556557
public MinimizeAction() {
557558
putValue(NAME, "Minimize");
558-
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.META_MASK));
559+
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.META_DOWN_MASK));
559560
}
560561

561562
public void actionPerformed(ActionEvent e) {

src/main/java/nodebox/client/PortView.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package nodebox.client;
22

3+
import nodebox.Log;
34
import nodebox.client.port.*;
45
import nodebox.node.Node;
56
import nodebox.node.Port;
@@ -9,16 +10,12 @@
910
import javax.swing.*;
1011
import java.awt.*;
1112
import java.lang.reflect.Constructor;
13+
import java.util.ArrayList;
1214
import java.util.HashMap;
1315
import java.util.Map;
14-
import java.util.logging.Level;
15-
import java.util.logging.Logger;
16-
import java.util.ArrayList;
1716

1817
public class PortView extends JComponent implements PaneView, PortControl.OnValueChangeListener {
1918

20-
private static Logger logger = Logger.getLogger("nodebox.client.PortView");
21-
2219
private static final Map<Port.Widget, Class> CONTROL_MAP;
2320

2421
// At this width, the label background lines out with the pane header divider.
@@ -199,7 +196,7 @@ private PortControl constructControl(Class controlClass, String activeNodePath,
199196
Constructor constructor = controlClass.getConstructor(String.class, Port.class);
200197
return (PortControl) constructor.newInstance(activeNodePath, p);
201198
} catch (Exception e) {
202-
logger.log(Level.SEVERE, "Cannot construct control", e);
199+
Log.error("Cannot construct control", e);
203200
throw new AssertionError("Cannot construct control:" + e);
204201
}
205202
}

0 commit comments

Comments
 (0)