From cbad9efd802ee2177bf742ef5eb68b6f33276d71 Mon Sep 17 00:00:00 2001 From: Skylar Date: Mon, 31 Aug 2015 17:39:56 -0600 Subject: [PATCH] Add popout preview window --- src/com/netsyms/symat/padview/Controls.form | 15 +- src/com/netsyms/symat/padview/Controls.java | 39 ++++- src/com/netsyms/symat/padview/PopoutView.form | 86 +++++++++++ src/com/netsyms/symat/padview/PopoutView.java | 143 ++++++++++++++++++ src/com/netsyms/symat/padview/pop.png | Bin 0 -> 408 bytes 5 files changed, 275 insertions(+), 8 deletions(-) create mode 100644 src/com/netsyms/symat/padview/PopoutView.form create mode 100644 src/com/netsyms/symat/padview/PopoutView.java create mode 100644 src/com/netsyms/symat/padview/pop.png diff --git a/src/com/netsyms/symat/padview/Controls.form b/src/com/netsyms/symat/padview/Controls.form index 4c41940..a54237d 100644 --- a/src/com/netsyms/symat/padview/Controls.form +++ b/src/com/netsyms/symat/padview/Controls.form @@ -36,7 +36,8 @@ - + + @@ -50,6 +51,7 @@ + @@ -167,5 +169,16 @@ + + + + + + + + + + + diff --git a/src/com/netsyms/symat/padview/Controls.java b/src/com/netsyms/symat/padview/Controls.java index 64286a2..1aa6460 100644 --- a/src/com/netsyms/symat/padview/Controls.java +++ b/src/com/netsyms/symat/padview/Controls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. * @@ -62,7 +62,7 @@ public class Controls extends javax.swing.JPanel { try { File filedata = FileUtils.getFileWithExtension(fc); FileUtils.saveFile(contents, filedata.getAbsolutePath(), true); - GUI.statusLbl.setText("Saved "+filedata.getName()); + GUI.statusLbl.setText("Saved " + filedata.getName()); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Error: Cannot save file: " + ex.getMessage()); @@ -90,6 +90,7 @@ public class Controls extends javax.swing.JPanel { jLabel2 = new javax.swing.JLabel(); previewBtn = new javax.swing.JButton(); delBtn = new javax.swing.JButton(); + expandBtn = new javax.swing.JButton(); jLabel1.setText("My Pads:"); @@ -153,6 +154,14 @@ public class Controls extends javax.swing.JPanel { } }); + expandBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/netsyms/symat/padview/pop.png"))); // NOI18N + expandBtn.setEnabled(false); + expandBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + expandBtnActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -174,7 +183,8 @@ public class Controls extends javax.swing.JPanel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) - .addGap(0, 296, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 286, Short.MAX_VALUE) + .addComponent(expandBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jScrollPane2))) ); layout.setVerticalGroup( @@ -183,7 +193,8 @@ public class Controls extends javax.swing.JPanel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel2) - .addComponent(addBtn)) + .addComponent(addBtn) + .addComponent(expandBtn)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) @@ -219,7 +230,13 @@ public class Controls extends javax.swing.JPanel { } private void updateList() { + int sel = padPane.getSelectedIndex(); padPane.setListData(PadUtils.getPads()); + try { + padPane.setSelectedIndex(sel); + } catch (Exception ex) { + + } } private void padPaneValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_padPaneValueChanged @@ -232,6 +249,7 @@ public class Controls extends javax.swing.JPanel { saveBtn.setEnabled(enable); previewBtn.setEnabled(enable); delBtn.setEnabled(enable); + expandBtn.setEnabled(enable); }//GEN-LAST:event_padPaneValueChanged private void openBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBtnActionPerformed @@ -252,19 +270,26 @@ public class Controls extends javax.swing.JPanel { private void delBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBtnActionPerformed int ans = JOptionPane.showConfirmDialog(this, - "Remove pad from list? It will not be removed from the server.", - "Delete?", - JOptionPane.OK_CANCEL_OPTION); + "Remove pad from list? It will not be removed from the server.", + "Delete?", + JOptionPane.OK_CANCEL_OPTION); if (ans == JOptionPane.OK_OPTION) { PadUtils.delPad(getSelectedPad()); } updateList(); }//GEN-LAST:event_delBtnActionPerformed + private void expandBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_expandBtnActionPerformed + PopoutView pop = new PopoutView(PadUtils.getPad(getSelectedPad()), getSelectedPad()); + pop.setLocationRelativeTo(this); + pop.setVisible(true); + }//GEN-LAST:event_expandBtnActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addBtn; private javax.swing.JButton delBtn; + private javax.swing.JButton expandBtn; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; diff --git a/src/com/netsyms/symat/padview/PopoutView.form b/src/com/netsyms/symat/padview/PopoutView.form new file mode 100644 index 0000000..9c585e3 --- /dev/null +++ b/src/com/netsyms/symat/padview/PopoutView.form @@ -0,0 +1,86 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com/netsyms/symat/padview/PopoutView.java b/src/com/netsyms/symat/padview/PopoutView.java new file mode 100644 index 0000000..1655282 --- /dev/null +++ b/src/com/netsyms/symat/padview/PopoutView.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2015, Skylar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * 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. + * + * 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. + */ +package com.netsyms.symat.padview; + +/** + * + * @author Skylar + */ +public class PopoutView extends javax.swing.JFrame { + + /** + * Creates new form PopoutView + * @param content + * @param title + */ + public PopoutView(String content, String title) { + initComponents(); + textBox.setText(content); + setTitle(getTitle() + title); + if (!PrefStorage.getSetting("wrapLines").equals("")) { + wrapLines.setSelected(true); + wrap(wrapLines.isSelected()); + } + } + + /** + * 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 + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + textBox = new javax.swing.JTextArea(); + closeBtn = new javax.swing.JButton(); + wrapLines = new javax.swing.JCheckBox(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Preview: "); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + textBox.setEditable(false); + textBox.setColumns(1); + textBox.setRows(1); + textBox.setTabSize(4); + jScrollPane1.setViewportView(textBox); + + closeBtn.setText("Close"); + closeBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + closeBtnActionPerformed(evt); + } + }); + + wrapLines.setText("Wrap long lines"); + wrapLines.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + wrapLinesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(layout.createSequentialGroup() + .addComponent(wrapLines) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 242, Short.MAX_VALUE) + .addComponent(closeBtn)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(closeBtn) + .addComponent(wrapLines)) + .addGap(0, 0, 0) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)) + ); + + pack(); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void wrapLinesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wrapLinesActionPerformed + wrap(wrapLines.isSelected()); + }//GEN-LAST:event_wrapLinesActionPerformed + + private void wrap(boolean wrap) { + textBox.setLineWrap(wrap); + textBox.setWrapStyleWord(wrap); + } + + private void save() { + PrefStorage.saveSetting("wrapLines", (wrapLines.isSelected() ? "yes" : "")); + } + + private void closeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBtnActionPerformed + save(); + dispose(); + }//GEN-LAST:event_closeBtnActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + save(); + }//GEN-LAST:event_formWindowClosing + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton closeBtn; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea textBox; + private javax.swing.JCheckBox wrapLines; + // End of variables declaration//GEN-END:variables +} diff --git a/src/com/netsyms/symat/padview/pop.png b/src/com/netsyms/symat/padview/pop.png new file mode 100644 index 0000000000000000000000000000000000000000..86c6dfaa5d62acfdc36066f56be75b1e23f99c1b GIT binary patch literal 408 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf4nJ zF!_Tp9gP2NHH)lih8;@ zhFJ7Yz3i{;k|@IV;l4qyVCD)X zEy^y8f41x0lXJo8ALrToKcDk_k3oNOiNMn>e0>4h4_Lf!@Hg6MB+I5dUCcXoNafoF z%|$KWLkc7=OL+dcRdF!AV*f&uDF^p-c;9)bmiYX}xhz#D<)^E=j%O`uO|N;tn5?+G zQDZf8#Syh@PN#(v&uFDh>io;GpsCp)i2Hh^>0b^l3m03F^{;gGfAuHC)I^lVB(VDL z;QhEIY5%l{1AZS&4X2)%ePs2#ExayAMQ-Y>+t5(G@!I{2Wbb2J(@xG{w>K&~y4_a8 z?V@gn_%@w?KJ{W(*i&;Jh-4+5Wcz!rea3GlVXr6+>vi{&fuYFY>FVdQ&MBb@0EJ?t AQ2+n{ literal 0 HcmV?d00001