Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.

Commit 1c06fa8

Browse files
author
daimor
committed
deleted %NBStudio.Routine.cls
some fixes
1 parent b6254d7 commit 1c06fa8

File tree

13 files changed

+250
-625
lines changed

13 files changed

+250
-625
lines changed

NBStudio.xml

Lines changed: 0 additions & 142 deletions
This file was deleted.

NBStudioCore/src/org/nbstudio/core/CacheFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class CacheFile {
1717

1818
static String name;
19-
static Database db;
19+
public static Database db;
2020

2121
public CacheFile(Database db, String name) {
2222
this.name = name;

NBStudioCore/src/org/nbstudio/core/CacheRoutine.java

Lines changed: 0 additions & 82 deletions
This file was deleted.

NBStudioCore/src/org/nbstudio/core/Connection.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
import com.intersys.objects.CacheDatabase;
99
import com.intersys.objects.CacheException;
1010
import com.intersys.objects.Database;
11+
import java.io.IOException;
12+
import java.io.OutputStream;
13+
import java.io.PrintStream;
1114
import java.io.Serializable;
12-
import java.util.ArrayList;
13-
import java.util.List;
15+
import org.openide.windows.IOProvider;
16+
import org.openide.windows.OutputWriter;
1417

1518
/**
1619
*
1720
* @author daimor
1821
*/
19-
public class Connection implements Serializable {
22+
public final class Connection implements Serializable {
2023

2124
private static final long serialVersionUID = 1L;
2225
public String name;
@@ -33,6 +36,8 @@ public Connection(String name, String address, int port, String namespace) {
3336
}
3437
this.port = port;
3538
this.namespace = namespace;
39+
40+
// this.connection = getAssociatedConnection();
3641
}
3742

3843
public Database getAssociatedConnection() {
@@ -42,6 +47,27 @@ public Database getAssociatedConnection() {
4247
String connString = "jdbc:Cache://" + this.address + ":" + this.port + "/" + this.namespace;
4348
Logger.Log("Try to connect to " + connString);
4449
this.connection = CacheDatabase.getDatabase(connString, "_SYSTEM", "SYS");
50+
51+
OutputStream out = new OutputStream() {
52+
private OutputWriter out = IOProvider.getDefault().getIO("Task", false).getOut();
53+
54+
@Override
55+
public void write(int i) throws IOException {
56+
out.print(String.valueOf((char) i));
57+
}
58+
59+
@Override
60+
public void write(byte[] bytes) throws IOException {
61+
out.print(new String(bytes));
62+
}
63+
64+
@Override
65+
public void write(byte[] bytes, int off, int len) throws IOException {
66+
out.print(new String(bytes, off, len));
67+
}
68+
};
69+
PrintStream cacheOutput = new PrintStream(out, true);
70+
this.connection.setConsoleOutput(cacheOutput);
4571
} catch (CacheException ce) {
4672
ce.printStackTrace();
4773
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package org.nbstudio.core;
6+
7+
import java.awt.event.ActionEvent;
8+
import java.awt.event.ActionListener;
9+
import java.io.File;
10+
import org.openide.awt.ActionID;
11+
import org.openide.awt.ActionReference;
12+
import org.openide.awt.ActionRegistration;
13+
import org.openide.cookies.OpenCookie;
14+
import org.openide.filesystems.FileChooserBuilder;
15+
import org.openide.filesystems.FileUtil;
16+
import org.openide.loaders.DataObject;
17+
import org.openide.loaders.DataObjectNotFoundException;
18+
import org.openide.util.Exceptions;
19+
import org.openide.util.NbBundle.Messages;
20+
21+
/**
22+
*
23+
* @author daimor
24+
*/
25+
@ActionID(category = "File", id = "org.mycore.OpenFileAction")
26+
@ActionRegistration(displayName = "#CTL_OpenFileAction")
27+
@ActionReference(path = "Menu/File", position = 10)
28+
@Messages("CTL_OpenFileAction=Open File")
29+
public class OpenFileAction implements ActionListener {
30+
31+
@Override
32+
public void actionPerformed(ActionEvent e) {
33+
//The default dir to use if no value is stored
34+
File home = new File(System.getProperty("user.home"));
35+
//Now build a file chooser and invoke the dialog in one line of code
36+
//"user-dir" is our unique key
37+
File toAdd = new FileChooserBuilder("user-dir").setTitle("Open File").
38+
setDefaultWorkingDirectory(home).setApproveText("Open").showOpenDialog();
39+
//Result will be null if the user clicked cancel or closed the dialog w/o OK
40+
if (toAdd != null) {
41+
try {
42+
DataObject.find(FileUtil.toFileObject(toAdd)).
43+
getLookup().lookup(OpenCookie.class).open();
44+
} catch (DataObjectNotFoundException ex) {
45+
Exceptions.printStackTrace(ex);
46+
}
47+
}
48+
}
49+
50+
}

NBStudioCore/src/org/nbstudio/core/cls/clsFile.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ public class clsFile extends CacheFile {
4242

4343
public clsFile(Database db, String name) throws CacheException {
4444
super(db, name);
45-
if(ClassDefinition._existsId(db, new Id(name))) {
46-
cls = (ClassDefinition) ClassDefinition._open(db, new Id(name));
45+
try {
46+
if (ClassDefinition._existsId(db, new Id(name))) {
47+
cls = (ClassDefinition) ClassDefinition._open(db, new Id(name));
48+
}
49+
} catch (Exception ex) {
4750
}
4851
}
4952

@@ -74,6 +77,9 @@ public InputStream open() {
7477
final class ClassText extends ByteArrayOutputStream {
7578

7679
public ClassText() throws CacheException {
80+
if (cls == null) {
81+
return;
82+
}
7783
cls._reload();
7884
writeParensValue("Include %s\n\n", cls.getIncludeCode());
7985
writeDescription(cls.getDescription());

0 commit comments

Comments
 (0)