/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores * CA 94065 USA or visit www.oracle.com if you need additional information or * have any questions. */ package com.sun.lwuit.resources.editor.editors; import com.sun.lwuit.util.EditableResources; import java.io.IOException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; /** * Part of the image border wizard in the theme * * @author Shai Almog */ public class ImageBorderWizardTabbedPane extends javax.swing.JPanel { private ImageBorderCuttingWizard cutting; private ImageBorderWizard design; private ImageBorderAppliesToWizard appliesTo; private boolean generated; /** Creates new form ImageBorderWizardTabbedPane */ public ImageBorderWizardTabbedPane(EditableResources res, String theme) { initComponents(); try { help.setPage(getClass().getResource("/help/9patchHelp.html")); } catch (IOException ex) { ex.printStackTrace(); } design = new ImageBorderWizard(); appliesTo = new ImageBorderAppliesToWizard(res, theme); cutting = new ImageBorderCuttingWizard(res, theme, design, appliesTo); jPanel1.add(java.awt.BorderLayout.CENTER, design); jPanel2.add(java.awt.BorderLayout.CENTER, cutting); jPanel3.add(java.awt.BorderLayout.CENTER, appliesTo); } public void addToAppliesToList(String uiid) { appliesTo.addToList(uiid); } /** 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { generate = new javax.swing.JButton(); close = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); help = new javax.swing.JTextPane(); FormListener formListener = new FormListener(); generate.setText("Generate"); generate.setName("generate"); // NOI18N generate.addActionListener(formListener); close.setText("Close"); close.setName("close"); // NOI18N close.addActionListener(formListener); jTabbedPane1.setName("jTabbedPane1"); // NOI18N jPanel1.setName("jPanel1"); // NOI18N jPanel1.setLayout(new java.awt.BorderLayout()); jTabbedPane1.addTab("Create Image", jPanel1); jPanel2.setName("jPanel2"); // NOI18N jPanel2.setLayout(new java.awt.BorderLayout()); jTabbedPane1.addTab("Cut Image", jPanel2); jPanel3.setName("jPanel3"); // NOI18N jPanel3.setLayout(new java.awt.BorderLayout()); jTabbedPane1.addTab("Apply To", jPanel3); jScrollPane1.setName("jScrollPane1"); // NOI18N help.setContentType("text/html"); help.setEditable(false); help.setName("help"); // NOI18N jScrollPane1.setViewportView(help); jTabbedPane1.addTab("Help", jScrollPane1); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(generate) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(close))) .addContainerGap()) ); layout.linkSize(new java.awt.Component[] {close, generate}, org.jdesktop.layout.GroupLayout.HORIZONTAL); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(generate) .add(close)) .addContainerGap()) ); } // Code for dispatching events from components to event handlers. private class FormListener implements java.awt.event.ActionListener { FormListener() {} public void actionPerformed(java.awt.event.ActionEvent evt) { if (evt.getSource() == generate) { ImageBorderWizardTabbedPane.this.generateActionPerformed(evt); } else if (evt.getSource() == close) { ImageBorderWizardTabbedPane.this.closeActionPerformed(evt); } } }// </editor-fold>//GEN-END:initComponents private void generateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateActionPerformed generated = true; cutting.generate(); }//GEN-LAST:event_generateActionPerformed private void closeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeActionPerformed if(!generated) { if(JOptionPane.showConfirmDialog(this, "Are you sure you want to close the window without generating?", "Are You Sure?", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { return; } } SwingUtilities.windowForComponent(this).dispose(); }//GEN-LAST:event_closeActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton close; private javax.swing.JButton generate; private javax.swing.JTextPane help; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTabbedPane jTabbedPane1; // End of variables declaration//GEN-END:variables }