Working task list implementation

master
skylarmt 9 years ago
parent 61cbfd8508
commit f06f908d7f

@ -17,7 +17,7 @@ package net.apocalypselabs.symat;
public class Debug { public class Debug {
// If output should be on or off // If output should be on or off
public static boolean debug = false; public static boolean debug = true;
/** /**
* Turn debug output on and off. * Turn debug output on and off.

@ -365,7 +365,7 @@ public class Main extends JRibbonFrame {
new IconRibbonBandResizePolicy(appsband.getControlPanel()))); new IconRibbonBandResizePolicy(appsband.getControlPanel())));
RibbonTask hometask = new RibbonTask("Home", coreband, appsband); RibbonTask hometask = new RibbonTask("Home", coreband, appsband);
RibbonTask webtask = new RibbonTask("Web", webband, collabband); RibbonTask webtask = new RibbonTask("Tools", webband, collabband);
loadRibbonMenu(null); loadRibbonMenu(null);
@ -529,6 +529,11 @@ public class Main extends JRibbonFrame {
menu.addMenuEntry(blankbtn); menu.addMenuEntry(blankbtn);
maingui.getRibbon().setApplicationMenu(menu); maingui.getRibbon().setApplicationMenu(menu);
maingui.getRibbon().setApplicationMenuRichTooltip(
new RichTooltip("SyMAT Menu",
"Create files, open documents, "
+ "get help, and change settings")
);
} }
/** /**

@ -9,6 +9,36 @@
<Property name="text" type="java.lang.String" value="File"/> <Property name="text" type="java.lang.String" value="File"/>
</Properties> </Properties>
<SubComponents> <SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="openBtn">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+O"/>
</Property>
<Property name="text" type="java.lang.String" value="Open..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openBtnActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="saveBtn">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Save..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBtnActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Shift+Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Save As..."/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> <MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Sample"/> <Property name="text" type="java.lang.String" value="Sample"/>
@ -19,6 +49,32 @@
</MenuItem> </MenuItem>
</SubComponents> </SubComponents>
</Menu> </Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="insertItem">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+I"/>
</Property>
<Property name="text" type="java.lang.String" value="Insert item"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="insertItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="setTitleBtn">
<Properties>
<Property name="text" type="java.lang.String" value="List title..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setTitleBtnActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents> </SubComponents>
</Menu> </Menu>
</NonVisualComponents> </NonVisualComponents>
@ -28,6 +84,9 @@
<Property name="maximizable" type="boolean" value="true"/> <Property name="maximizable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/> <Property name="resizable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Tasks"/> <Property name="title" type="java.lang.String" value="Tasks"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/tasks.png"/>
</Property>
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>

@ -2,40 +2,40 @@
* CODE LICENSE ===================== * CODE LICENSE =====================
* Copyright (c) 2015, Apocalypse Laboratories * Copyright (c) 2015, Apocalypse Laboratories
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or * this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution. * other materials provided with the distribution.
* *
* 3. Neither the name of the copyright holder nor the names of its contributors * 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without * may be used to endorse or promote products derived from this software without
* specific prior written permission. * specific prior written permission.
* *
* 4. You adhere to the Media License detailed below. If you do not, this license * 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you * is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form. * possess, in source or binary form.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* MEDIA LICENSE ==================== * MEDIA LICENSE ====================
* All images and other graphical files (the "graphics") included with this * All images and other graphical files (the "graphics") included with this
* software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute
* the graphics or any program, source code repository, or other digital storage * the graphics or any program, source code repository, or other digital storage
* media containing them without written permission from Apocalypse Laboratories. * media containing them without written permission from Apocalypse Laboratories.
* This ban on distribution only applies to publicly available systems. * This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that * A password-protected network file share, USB drive, or other storage scheme that
@ -45,7 +45,20 @@
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
import java.awt.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import net.apocalypselabs.symat.components.Task; import net.apocalypselabs.symat.components.Task;
import net.apocalypselabs.symat.components.TaskList;
/** /**
* *
@ -53,13 +66,60 @@ import net.apocalypselabs.symat.components.Task;
*/ */
public class Tasks extends javax.swing.JInternalFrame { public class Tasks extends javax.swing.JInternalFrame {
private String tltitle = "Untitled";
private final JFileChooser fc = new JFileChooser();
/** /**
* Creates new form Tasks * Creates new form Tasks
*/ */
public Tasks() { public Tasks() {
FileFilter filter = new FileNameExtensionFilter("Task List (.sytt)", "sytt");
fc.setFileFilter(filter);
initComponents(); initComponents();
} }
public Tasks(File f) {
this();
try {
openTaskFile(f);
} catch (Exception ex) {
JOptionPane.showInternalMessageDialog(Main.mainPane,
"Cannot open task list: " + ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
Debug.stacktrace(ex);
}
}
private void openTaskFile(File f) throws IOException, ClassNotFoundException {
FileInputStream fin = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fin);
TaskList tl = (TaskList) ois.readObject();
ois.close();
Task[] list = tl.getTasks();
for (Task t : list) {
listPanel.add(t);
}
setTitle(tl.getTitle());
tltitle = tl.getTitle();
redraw();
}
private void saveTasks(File f) throws FileNotFoundException, IOException {
TaskList tl = new TaskList();
for (Component c : listPanel.getComponents()) {
tl.addTask((Task) c);
}
tl.setTitle(tltitle);
FileOutputStream fout = new FileOutputStream(f);
try (ObjectOutputStream oos = new ObjectOutputStream(fout)) {
oos.writeObject(tl);
oos.close();
}
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -73,19 +133,48 @@ public class Tasks extends javax.swing.JInternalFrame {
listPanel = new javax.swing.JPanel(); listPanel = new javax.swing.JPanel();
jMenuBar1 = new javax.swing.JMenuBar(); jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu(); jMenu1 = new javax.swing.JMenu();
openBtn = new javax.swing.JMenuItem();
saveBtn = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
insertItem = new javax.swing.JMenuItem();
setTitleBtn = new javax.swing.JMenuItem();
setClosable(true); setClosable(true);
setIconifiable(true); setIconifiable(true);
setMaximizable(true); setMaximizable(true);
setResizable(true); setResizable(true);
setTitle("Tasks"); setTitle("Tasks");
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/tasks.png"))); // NOI18N
listPanel.setLayout(new javax.swing.BoxLayout(listPanel, javax.swing.BoxLayout.Y_AXIS)); listPanel.setLayout(new javax.swing.BoxLayout(listPanel, javax.swing.BoxLayout.Y_AXIS));
taskList.setViewportView(listPanel); taskList.setViewportView(listPanel);
jMenu1.setText("File"); jMenu1.setText("File");
openBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
openBtn.setText("Open...");
openBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
openBtnActionPerformed(evt);
}
});
jMenu1.add(openBtn);
saveBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
saveBtn.setText("Save...");
saveBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveBtnActionPerformed(evt);
}
});
jMenu1.add(saveBtn);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Save As...");
jMenu1.add(jMenuItem4);
jMenuItem1.setText("Sample"); jMenuItem1.setText("Sample");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() { jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -96,6 +185,27 @@ public class Tasks extends javax.swing.JInternalFrame {
jMenuBar1.add(jMenu1); jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
insertItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
insertItem.setText("Insert item");
insertItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
insertItemActionPerformed(evt);
}
});
jMenu2.add(insertItem);
setTitleBtn.setText("List title...");
setTitleBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
setTitleBtnActionPerformed(evt);
}
});
jMenu2.add(setTitleBtn);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1); setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
@ -121,16 +231,84 @@ public class Tasks extends javax.swing.JInternalFrame {
listPanel.add(t); listPanel.add(t);
t.setVisible(true); t.setVisible(true);
} }
setSize(getWidth() + 1, getHeight()); redraw();
setSize(getWidth() - 1, getHeight());
}//GEN-LAST:event_jMenuItem1ActionPerformed }//GEN-LAST:event_jMenuItem1ActionPerformed
private void insertItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertItemActionPerformed
Task t = new Task(0, "Untitled Task",
"No description");
listPanel.add(t);
t.setVisible(true);
redraw();
}//GEN-LAST:event_insertItemActionPerformed
private void openBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBtnActionPerformed
int result = fc.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
try {
openTaskFile(fc.getSelectedFile());
} catch (IOException ex) {
JOptionPane.showInternalMessageDialog(Main.mainPane,
"Cannot open task list: " + ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
Debug.stacktrace(ex);
} catch (ClassNotFoundException ex) {
JOptionPane.showInternalMessageDialog(Main.mainPane,
"Cannot open task list: " + ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
Debug.stacktrace(ex);
}
}
}//GEN-LAST:event_openBtnActionPerformed
private void setTitleBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setTitleBtnActionPerformed
String res = JOptionPane.showInternalInputDialog(this,
"Task list title:",
"Change Title",
JOptionPane.QUESTION_MESSAGE);
if (res == null) {
return;
}
if (res.equals("")) {
return;
}
setTitle(res);
tltitle = res;
}//GEN-LAST:event_setTitleBtnActionPerformed
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
int result = fc.showSaveDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
try {
saveTasks(fc.getSelectedFile());
} catch (IOException ex) {
JOptionPane.showInternalMessageDialog(Main.mainPane,
"Cannot save task list: " + ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
Debug.stacktrace(ex);
}
}
}//GEN-LAST:event_saveBtnActionPerformed
private void redraw() {
setSize(getWidth() + 1, getHeight());
setSize(getWidth() - 1, getHeight());
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem insertItem;
private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JPanel listPanel; private javax.swing.JPanel listPanel;
private javax.swing.JMenuItem openBtn;
private javax.swing.JMenuItem saveBtn;
private javax.swing.JMenuItem setTitleBtn;
private javax.swing.JScrollPane taskList; private javax.swing.JScrollPane taskList;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -18,27 +25,28 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="statusLabel" min="-2" pref="16" max="-2" attributes="0"/> <Component id="statusLabel" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="taskName" pref="262" max="32767" attributes="0"/> <Component id="taskName" pref="258" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="menuBtn" min="-2" max="-2" attributes="0"/> <Component id="menuBtn" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="taskDesc" max="32767" attributes="0"/> <Component id="taskDesc" max="32767" attributes="0"/>
<Component id="percentDone" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0"> <Component id="menuBtn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="menuBtn" min="-2" max="-2" attributes="0"/> <Component id="statusLabel" alignment="0" pref="32" max="32767" attributes="0"/>
<EmptySpace min="0" pref="7" max="32767" attributes="0"/> <Component id="taskName" alignment="0" max="32767" attributes="0"/>
</Group>
<Component id="taskName" max="32767" attributes="0"/>
<Component id="statusLabel" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="taskDesc" pref="38" max="32767" attributes="0"/> <Component id="percentDone" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="taskDesc" pref="47" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -77,5 +85,10 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JProgressBar" name="percentDone">
<Properties>
<Property name="stringPainted" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

@ -54,16 +54,32 @@ import javax.swing.JOptionPane;
*/ */
public class Task extends javax.swing.JPanel { public class Task extends javax.swing.JPanel {
private boolean taskDone = false; private int percent = 0;
public Task(boolean complete, String name, String desc) { public Task(boolean complete, String name, String desc) {
this((complete ? 100 : 0), name, desc);
}
public Task(int complete, String name, String desc) {
this(); this();
taskDone = complete; percent = complete;
setComplete(complete); setComplete(percent);
taskName.setText(name); taskName.setText(name);
taskDesc.setText(desc); taskDesc.setText(desc);
}
@Override
public String toString() {
return taskName.getText();
} }
public String getDesc() {
return taskDesc.getText();
}
public int getComplete() {
return percent;
}
/** /**
* Creates new form Task * Creates new form Task
*/ */
@ -71,13 +87,16 @@ public class Task extends javax.swing.JPanel {
initComponents(); initComponents();
} }
private void setComplete(boolean b) { private void setComplete(int i) {
percent = i;
statusLabel.setIcon(new ImageIcon( statusLabel.setIcon(new ImageIcon(
getClass().getResource( getClass().getResource(
"/net/apocalypselabs/symat/icons/" "/net/apocalypselabs/symat/icons/"
+ (b ? "green" : "red") + "light.png" + (i == 100 ? "green" : "red") + "light.png"
))); )));
statusLabel.setToolTipText(b ? "Complete" : "Incomplete"); statusLabel.setToolTipText(i == 100 ? "Complete" : "Incomplete");
percentDone.setValue(i);
percentDone.setString(i+"%");
} }
/** /**
@ -93,6 +112,9 @@ public class Task extends javax.swing.JPanel {
taskDesc = new javax.swing.JLabel(); taskDesc = new javax.swing.JLabel();
menuBtn = new javax.swing.JButton(); menuBtn = new javax.swing.JButton();
statusLabel = new javax.swing.JLabel(); statusLabel = new javax.swing.JLabel();
percentDone = new javax.swing.JProgressBar();
setBorder(javax.swing.BorderFactory.createEtchedBorder());
taskName.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(20.0F)); taskName.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(20.0F));
taskName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); taskName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
@ -111,40 +133,44 @@ public class Task extends javax.swing.JPanel {
statusLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/redlight.png"))); // NOI18N statusLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/redlight.png"))); // NOI18N
percentDone.setStringPainted(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) .addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(menuBtn)) .addComponent(menuBtn))
.addComponent(taskDesc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(taskDesc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(percentDone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup() .addComponent(menuBtn)
.addComponent(menuBtn) .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
.addGap(0, 7, Short.MAX_VALUE)) .addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(percentDone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(taskDesc, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)) .addComponent(taskDesc, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
.addGap(0, 0, 0))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void menuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBtnActionPerformed private void menuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBtnActionPerformed
TaskMenu tm = new TaskMenu(taskDone, TaskMenu tm = new TaskMenu(percent,
taskName.getText(), taskName.getText(),
taskDesc.getText()); taskDesc.getText());
JOptionPane.showInternalMessageDialog(this, tm, JOptionPane.showInternalMessageDialog(this, tm,
"Task Options", JOptionPane.PLAIN_MESSAGE); "Task Options", JOptionPane.PLAIN_MESSAGE);
taskDone = tm.isComplete(); percent = tm.getPercent();
setComplete(taskDone); setComplete(percent);
taskName.setText(tm.toString()); taskName.setText(tm.toString());
taskDesc.setText(tm.getDesc()); taskDesc.setText(tm.getDesc());
}//GEN-LAST:event_menuBtnActionPerformed }//GEN-LAST:event_menuBtnActionPerformed
@ -152,6 +178,7 @@ public class Task extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton menuBtn; private javax.swing.JButton menuBtn;
private javax.swing.JProgressBar percentDone;
private javax.swing.JLabel statusLabel; private javax.swing.JLabel statusLabel;
private javax.swing.JLabel taskDesc; private javax.swing.JLabel taskDesc;
private javax.swing.JLabel taskName; private javax.swing.JLabel taskName;

@ -0,0 +1,95 @@
/*
* CODE LICENSE =====================
* Copyright (c) 2015, Apocalypse Laboratories
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* MEDIA LICENSE ====================
* All images and other graphical files (the "graphics") included with this
* software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without written permission from Apocalypse Laboratories.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies
* you permission, that decision is considered final and binding.
*/
package net.apocalypselabs.symat.components;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Container to save tasks.
* @author Skylar
*/
public class TaskList implements Serializable {
private final ArrayList<SingleTask> tasks = new ArrayList<>();
private String title = "Untitled";
public void addTask(Task t) {
SingleTask st = new SingleTask();
st.name = t.toString();
st.desc = t.getDesc();
st.percent = t.getComplete();
tasks.add(st);
}
public Task[] getTasks() {
Task[] a = new Task[tasks.size()];
for (int i = 0; i < tasks.size(); i++) {
a[i] = new Task(
tasks.get(i).percent,
tasks.get(i).name,
tasks.get(i).desc);
}
return a;
}
public void setTitle(String t) {
title = t;
}
public String getTitle() {
return title;
}
public TaskList() {
}
class SingleTask implements Serializable {
public String name = "";
public String desc = "";
public int percent = 0;
}
}

@ -17,39 +17,38 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="nameBox" alignment="0" max="32767" attributes="0"/> <Component id="nameBox" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="completeBox" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
<Component id="jScrollPane1" alignment="0" pref="200" max="32767" attributes="0"/> <Component id="percentSlider" alignment="0" pref="375" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="completeBox" min="-2" max="-2" attributes="0"/> <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="percentSlider" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="nameBox" min="-2" max="-2" attributes="0"/> <Component id="nameBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="107" max="32767" attributes="0"/> <Component id="jScrollPane1" min="-2" pref="115" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JCheckBox" name="completeBox">
<Properties>
<Property name="text" type="java.lang.String" value="Task complete"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="nameBox"> <Component class="javax.swing.JTextField" name="nameBox">
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel1"> <Component class="javax.swing.JLabel" name="jLabel1">
@ -77,5 +76,20 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Percent complete:"/>
</Properties>
</Component>
<Component class="javax.swing.JSlider" name="percentSlider">
<Properties>
<Property name="majorTickSpacing" type="int" value="10"/>
<Property name="minorTickSpacing" type="int" value="5"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="snapToTicks" type="boolean" value="true"/>
<Property name="value" type="int" value="0"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

@ -53,13 +53,13 @@ public class TaskMenu extends javax.swing.JPanel {
/** /**
* Creates new TaskMenu * Creates new TaskMenu
* @param complete If the task is completed. * @param percent Task completion percentage.
* @param name Task name * @param name Task name
* @param desc Task description * @param desc Task description
*/ */
public TaskMenu(boolean complete, String name, String desc) { public TaskMenu(int percent, String name, String desc) {
this(); this();
completeBox.setSelected(complete); percentSlider.setValue(percent);
nameBox.setText(name); nameBox.setText(name);
descBox.setText(desc); descBox.setText(desc);
} }
@ -71,12 +71,8 @@ public class TaskMenu extends javax.swing.JPanel {
initComponents(); initComponents();
} }
/** public int getPercent() {
* Check if the task is marked as done. return percentSlider.getValue();
* @return true if it is.
*/
public boolean isComplete() {
return completeBox.isSelected();
} }
/** /**
@ -105,14 +101,13 @@ public class TaskMenu extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
completeBox = new javax.swing.JCheckBox();
nameBox = new javax.swing.JTextField(); nameBox = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
descBox = new javax.swing.JTextArea(); descBox = new javax.swing.JTextArea();
jLabel3 = new javax.swing.JLabel();
completeBox.setText("Task complete"); percentSlider = new javax.swing.JSlider();
jLabel1.setText("Task Name:"); jLabel1.setText("Task Name:");
@ -122,41 +117,55 @@ public class TaskMenu extends javax.swing.JPanel {
descBox.setRows(5); descBox.setRows(5);
jScrollPane1.setViewportView(descBox); jScrollPane1.setViewportView(descBox);
jLabel3.setText("Percent complete:");
percentSlider.setMajorTickSpacing(10);
percentSlider.setMinorTickSpacing(5);
percentSlider.setPaintLabels(true);
percentSlider.setPaintTicks(true);
percentSlider.setSnapToTicks(true);
percentSlider.setValue(0);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(nameBox) .addComponent(nameBox)
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addComponent(jLabel2)
.addComponent(completeBox) .addComponent(jLabel3)
.addComponent(jLabel2)) .addComponent(jLabel1))
.addGap(0, 0, Short.MAX_VALUE)) .addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE) .addComponent(percentSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(completeBox) .addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(percentSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGap(7, 7, 7)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox completeBox;
private javax.swing.JTextArea descBox; private javax.swing.JTextArea descBox;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField nameBox; private javax.swing.JTextField nameBox;
private javax.swing.JSlider percentSlider;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Loading…
Cancel
Save