Working task list implementation

master
skylarmt 9 years ago
parent 61cbfd8508
commit f06f908d7f

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

@ -365,7 +365,7 @@ public class Main extends JRibbonFrame {
new IconRibbonBandResizePolicy(appsband.getControlPanel())));
RibbonTask hometask = new RibbonTask("Home", coreband, appsband);
RibbonTask webtask = new RibbonTask("Web", webband, collabband);
RibbonTask webtask = new RibbonTask("Tools", webband, collabband);
loadRibbonMenu(null);
@ -529,6 +529,11 @@ public class Main extends JRibbonFrame {
menu.addMenuEntry(blankbtn);
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"/>
</Properties>
<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">
<Properties>
<Property name="text" type="java.lang.String" value="Sample"/>
@ -19,6 +49,32 @@
</MenuItem>
</SubComponents>
</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>
</Menu>
</NonVisualComponents>
@ -28,6 +84,9 @@
<Property name="maximizable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/>
<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>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>

@ -2,40 +2,40 @@
* 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
*
* 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,
*
* 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
*
* 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
*
* 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
* 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
* 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
@ -45,7 +45,20 @@
*/
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.TaskList;
/**
*
@ -53,13 +66,60 @@ import net.apocalypselabs.symat.components.Task;
*/
public class Tasks extends javax.swing.JInternalFrame {
private String tltitle = "Untitled";
private final JFileChooser fc = new JFileChooser();
/**
* Creates new form Tasks
*/
public Tasks() {
FileFilter filter = new FileNameExtensionFilter("Task List (.sytt)", "sytt");
fc.setFileFilter(filter);
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.
* 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();
jMenuBar1 = new javax.swing.JMenuBar();
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();
jMenu2 = new javax.swing.JMenu();
insertItem = new javax.swing.JMenuItem();
setTitleBtn = new javax.swing.JMenuItem();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
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));
taskList.setViewportView(listPanel);
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.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -96,6 +185,27 @@ public class Tasks extends javax.swing.JInternalFrame {
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);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
@ -121,16 +231,84 @@ public class Tasks extends javax.swing.JInternalFrame {
listPanel.add(t);
t.setVisible(true);
}
setSize(getWidth() + 1, getHeight());
setSize(getWidth() - 1, getHeight());
redraw();
}//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
private javax.swing.JMenuItem insertItem;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem4;
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;
// End of variables declaration//GEN-END:variables
}

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<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>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -18,27 +25,28 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="statusLabel" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="taskName" pref="262" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="taskName" pref="258" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="menuBtn" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="taskDesc" max="32767" attributes="0"/>
<Component id="percentDone" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="menuBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="7" max="32767" attributes="0"/>
</Group>
<Component id="taskName" max="32767" attributes="0"/>
<Component id="statusLabel" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="menuBtn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="statusLabel" alignment="0" pref="32" max="32767" attributes="0"/>
<Component id="taskName" alignment="0" max="32767" attributes="0"/>
</Group>
<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>
</DimensionLayout>
@ -77,5 +85,10 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JProgressBar" name="percentDone">
<Properties>
<Property name="stringPainted" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

@ -54,16 +54,32 @@ import javax.swing.JOptionPane;
*/
public class Task extends javax.swing.JPanel {
private boolean taskDone = false;
private int percent = 0;
public Task(boolean complete, String name, String desc) {
this((complete ? 100 : 0), name, desc);
}
public Task(int complete, String name, String desc) {
this();
taskDone = complete;
setComplete(complete);
percent = complete;
setComplete(percent);
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
*/
@ -71,13 +87,16 @@ public class Task extends javax.swing.JPanel {
initComponents();
}
private void setComplete(boolean b) {
private void setComplete(int i) {
percent = i;
statusLabel.setIcon(new ImageIcon(
getClass().getResource(
"/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();
menuBtn = new javax.swing.JButton();
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.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
percentDone.setStringPainted(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.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)
.addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(menuBtn))
.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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(menuBtn)
.addGap(0, 7, Short.MAX_VALUE))
.addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(menuBtn)
.addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 32, 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(percentDone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.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
private void menuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBtnActionPerformed
TaskMenu tm = new TaskMenu(taskDone,
TaskMenu tm = new TaskMenu(percent,
taskName.getText(),
taskDesc.getText());
JOptionPane.showInternalMessageDialog(this, tm,
"Task Options", JOptionPane.PLAIN_MESSAGE);
taskDone = tm.isComplete();
setComplete(taskDone);
percent = tm.getPercent();
setComplete(percent);
taskName.setText(tm.toString());
taskDesc.setText(tm.getDesc());
}//GEN-LAST:event_menuBtnActionPerformed
@ -152,6 +178,7 @@ public class Task extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton menuBtn;
private javax.swing.JProgressBar percentDone;
private javax.swing.JLabel statusLabel;
private javax.swing.JLabel taskDesc;
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">
<Group type="103" groupAlignment="0" 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="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="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" alignment="0" pref="200" max="32767" attributes="0"/>
<Component id="percentSlider" alignment="0" pref="375" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="completeBox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" 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"/>
<EmptySpace 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"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="107" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="115" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<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>
<Component class="javax.swing.JLabel" name="jLabel1">
@ -77,5 +76,20 @@
</Component>
</SubComponents>
</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>
</Form>

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Loading…
Cancel
Save