Integrate task lists with Ribbon open/save and single instance handler
This commit is contained in:
parent
e524e59da9
commit
ac497ec61d
@ -70,10 +70,13 @@ import java.util.GregorianCalendar;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.ListModel;
|
import javax.swing.ListModel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import org.pushingpixels.flamingo.api.ribbon.*;
|
import org.pushingpixels.flamingo.api.ribbon.*;
|
||||||
import org.pushingpixels.flamingo.api.ribbon.resize.*;
|
import org.pushingpixels.flamingo.api.ribbon.resize.*;
|
||||||
import org.pushingpixels.flamingo.api.common.*;
|
import org.pushingpixels.flamingo.api.common.*;
|
||||||
@ -179,10 +182,16 @@ public class Main extends JRibbonFrame {
|
|||||||
// Open initial windows
|
// Open initial windows
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
if (!argfile.equals("")) {
|
if (!argfile.equals("")) {
|
||||||
Editor ed = new Editor();
|
if (argfile.endsWith(".sytt")) {
|
||||||
loadFrame(ed);
|
Tasks tt = new Tasks(new File(argfile));
|
||||||
ed.openFileFromName(argfile);
|
loadFrame(tt);
|
||||||
argfile = "";
|
argfile = "";
|
||||||
|
} else {
|
||||||
|
Editor ed = new Editor();
|
||||||
|
loadFrame(ed);
|
||||||
|
ed.openFileFromName(argfile);
|
||||||
|
argfile = "";
|
||||||
|
}
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
boolean licValid = false;
|
boolean licValid = false;
|
||||||
@ -381,9 +390,6 @@ public class Main extends JRibbonFrame {
|
|||||||
|
|
||||||
public static ResizableIcon getTinyRibbonIcon(String name) {
|
public static ResizableIcon getTinyRibbonIcon(String name) {
|
||||||
int d = 32;
|
int d = 32;
|
||||||
if (name.endsWith("icon")) {
|
|
||||||
d = 24;
|
|
||||||
}
|
|
||||||
return ImageWrapperResizableIcon.getIcon(
|
return ImageWrapperResizableIcon.getIcon(
|
||||||
Main.class.getResource("icons/" + name + ".png"),
|
Main.class.getResource("icons/" + name + ".png"),
|
||||||
new Dimension(d, d));
|
new Dimension(d, d));
|
||||||
@ -467,6 +473,17 @@ public class Main extends JRibbonFrame {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
JCommandButton.CommandButtonKind.ACTION_ONLY);
|
JCommandButton.CommandButtonKind.ACTION_ONLY);
|
||||||
|
RibbonApplicationMenuEntrySecondary newtaskbtn
|
||||||
|
= new RibbonApplicationMenuEntrySecondary(
|
||||||
|
getTinyRibbonIcon("taskicon"),
|
||||||
|
"Task List",
|
||||||
|
new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
loadFrame(new Tasks());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
JCommandButton.CommandButtonKind.ACTION_ONLY);
|
||||||
RibbonApplicationMenuEntryPrimary newbtn
|
RibbonApplicationMenuEntryPrimary newbtn
|
||||||
= new RibbonApplicationMenuEntryPrimary(
|
= new RibbonApplicationMenuEntryPrimary(
|
||||||
getRibbonIcon("newfile"),
|
getRibbonIcon("newfile"),
|
||||||
@ -479,7 +496,32 @@ public class Main extends JRibbonFrame {
|
|||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
loadFrame(new Editor(1337));
|
JFileChooser fc = new JFileChooser();
|
||||||
|
FileFilter script
|
||||||
|
= new FileNameExtensionFilter("Script"
|
||||||
|
+ "(syjs, sypy, js, py)",
|
||||||
|
"syjs", "sypy", "js", "py");
|
||||||
|
FileFilter all
|
||||||
|
= new FileNameExtensionFilter("SyMAT File"
|
||||||
|
+ "(syjs, sypy, js, py, sytt)",
|
||||||
|
"syjs", "sypy", "js", "py", "sytt");
|
||||||
|
FileFilter tasklist =
|
||||||
|
new FileNameExtensionFilter("Task List (sytt)",
|
||||||
|
"sytt");
|
||||||
|
fc.setFileFilter(all);
|
||||||
|
fc.addChoosableFileFilter(script);
|
||||||
|
fc.addChoosableFileFilter(tasklist);
|
||||||
|
int result = fc.showOpenDialog(maingui);
|
||||||
|
if (result == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File f = fc.getSelectedFile();
|
||||||
|
if (f.getName().endsWith(".sytt")) {
|
||||||
|
loadFrame(new Tasks(f));
|
||||||
|
} else {
|
||||||
|
Editor ed = new Editor();
|
||||||
|
ed.openFileFromName(f.getAbsolutePath());
|
||||||
|
loadFrame(ed);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
|
JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
|
||||||
@ -494,7 +536,8 @@ public class Main extends JRibbonFrame {
|
|||||||
} else {
|
} else {
|
||||||
openbtn.addSecondaryMenuGroup("Recent Files", recent);
|
openbtn.addSecondaryMenuGroup("Recent Files", recent);
|
||||||
}
|
}
|
||||||
newbtn.addSecondaryMenuGroup("New Script", newjsbtn, newpybtn);
|
newbtn.addSecondaryMenuGroup("Code File", newjsbtn, newpybtn);
|
||||||
|
newbtn.addSecondaryMenuGroup("Other", newtaskbtn);
|
||||||
|
|
||||||
RibbonApplicationMenuEntryFooter displaybtn
|
RibbonApplicationMenuEntryFooter displaybtn
|
||||||
= new RibbonApplicationMenuEntryFooter(
|
= new RibbonApplicationMenuEntryFooter(
|
||||||
@ -532,7 +575,7 @@ public class Main extends JRibbonFrame {
|
|||||||
maingui.getRibbon().setApplicationMenuRichTooltip(
|
maingui.getRibbon().setApplicationMenuRichTooltip(
|
||||||
new RichTooltip("SyMAT Menu",
|
new RichTooltip("SyMAT Menu",
|
||||||
"Create files, open documents, "
|
"Create files, open documents, "
|
||||||
+ "get help, and change settings")
|
+ "get help, and change settings")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
package net.apocalypselabs.symat;
|
package net.apocalypselabs.symat;
|
||||||
|
|
||||||
import fi.iki.elonen.NanoHTTPD;
|
import fi.iki.elonen.NanoHTTPD;
|
||||||
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,9 +65,14 @@ public class SingleInstanceServer extends NanoHTTPD {
|
|||||||
String msg = "OK";
|
String msg = "OK";
|
||||||
Map<String, String> parms = session.getParms();
|
Map<String, String> parms = session.getParms();
|
||||||
if (parms.get("arg") != null) {
|
if (parms.get("arg") != null) {
|
||||||
Editor ed = new Editor();
|
if (parms.get("arg").endsWith(".sytt")) {
|
||||||
Main.loadFrame(ed);
|
Tasks tt = new Tasks(new File(parms.get("arg")));
|
||||||
ed.openFileFromName(parms.get("arg"));
|
Main.loadFrame(tt);
|
||||||
|
} else {
|
||||||
|
Editor ed = new Editor();
|
||||||
|
Main.loadFrame(ed);
|
||||||
|
ed.openFileFromName(parms.get("arg"));
|
||||||
|
}
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -287,7 +287,7 @@ public class Tasks extends javax.swing.JInternalFrame {
|
|||||||
}
|
}
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
if (result == JFileChooser.APPROVE_OPTION) {
|
||||||
try {
|
try {
|
||||||
saveTasks(fc.getSelectedFile());
|
saveTasks(FileUtils.getFileWithExtension(fc));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showInternalMessageDialog(Main.mainPane,
|
JOptionPane.showInternalMessageDialog(Main.mainPane,
|
||||||
"Cannot save task list: " + ex.getMessage(),
|
"Cannot save task list: " + ex.getMessage(),
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 620 B |
Binary file not shown.
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 654 B |
BIN
src/net/apocalypselabs/symat/icons/taskicon.png
Normal file
BIN
src/net/apocalypselabs/symat/icons/taskicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 477 B |
Loading…
x
Reference in New Issue
Block a user