com.codename1.designer.ImageBorderAppliesToWizard Maven / Gradle / Ivy
/*
* 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.codename1.designer;
import com.codename1.ui.util.EditableResources;
import java.util.Hashtable;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
/**
* Part of the image border wizard in the theme
*
* @author Shai Almog
*/
public class ImageBorderAppliesToWizard extends javax.swing.JPanel {
private EditableResources res;
private String theme;
/** Creates new form ImageBorderAppliesToWizard */
public ImageBorderAppliesToWizard(EditableResources res, String theme) {
this.res = res;
this.theme = theme;
initComponents();
appliesTo.setModel(new DefaultListModel());
}
/** 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() {
jLabel6 = new javax.swing.JLabel();
componentName = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
style = new javax.swing.JComboBox();
jLabel8 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
appliesTo = new javax.swing.JList();
addToList = new javax.swing.JButton();
removeFromList = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
FormListener formListener = new FormListener();
setOpaque(false);
jLabel6.setText("Component");
jLabel6.setName("jLabel6"); // NOI18N
componentName.setEditable(true);
componentName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "Button", "Calendar", "CalendarDay", "CalendarDate", "CalendarNavigation", "CalendarSelectedDay", "CalendarTitle", "CheckBox", "ComboBox", "ComboBoxFocus", "ComboBoxItem", "ComboBoxList", "ComboBoxPopup", "Command", "CommandFocus", "CommandList", "Container", "ContentPane", "Dialog", "DialogBody", "DialogTitle", "Form", "HorizontalScroll", "HorizontalScrollThumb", "HTMLLink", "HTMLMultiComboBoxItem", "HTMLOptgroup", "HTMLOptgroupItem", "HTMLFieldset", "HTMLHR", "Label", "List", "ListRenderer", "ListRendererFocus", "MediaComponent", "Menu", "MonthView", "RadioButton", "Scroll", "ScrollThumb", "SoftButton", "Spinner", "SpinnerRenderer", "TabbedPane", "Table", "TableHeader", "TableCell", "TextArea", "TextField", "Title", "TouchCommand", "Tree", "TreeNode", "VKB", "VKBButton", "VKBSpecialButton", "VKBtooltip", "VKBTextInput" }));
componentName.setName("componentName"); // NOI18N
componentName.setPrototypeDisplayValue("XXXXXXXXXXXXXX");
jLabel7.setText("Style");
jLabel7.setName("jLabel7"); // NOI18N
style.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selected", "Unselected", "Pressed", "Disabled" }));
style.setName("style"); // NOI18N
jLabel8.setText("Applies To");
jLabel8.setName("jLabel8"); // NOI18N
jScrollPane2.setName("jScrollPane2"); // NOI18N
appliesTo.setName("appliesTo"); // NOI18N
jScrollPane2.setViewportView(appliesTo);
addToList.setText("Add");
addToList.setName("addToList"); // NOI18N
addToList.addActionListener(formListener);
removeFromList.setText("Remove");
removeFromList.setName("removeFromList"); // NOI18N
removeFromList.addActionListener(formListener);
jLabel1.setText("Select components, select a style type and add them to the List in order to apply them with the generate button");
jLabel1.setName("jLabel1"); // NOI18N
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(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel6)
.add(jLabel7)
.add(jLabel8))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(componentName, 0, 479, Short.MAX_VALUE)
.add(style, 0, 479, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(addToList)
.add(removeFromList)))))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE))
.addContainerGap())
);
layout.linkSize(new java.awt.Component[] {addToList, removeFromList}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(componentName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel7)
.add(style, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel8)
.add(52, 52, 52))
.add(layout.createSequentialGroup()
.add(addToList)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(removeFromList))
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
.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() == addToList) {
ImageBorderAppliesToWizard.this.addToListActionPerformed(evt);
}
else if (evt.getSource() == removeFromList) {
ImageBorderAppliesToWizard.this.removeFromListActionPerformed(evt);
}
}
}// //GEN-END:initComponents
public void addToList(String uiid) {
((DefaultListModel)appliesTo.getModel()).addElement(uiid);
}
private void addToListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToListActionPerformed
String name = (String)componentName.getSelectedItem();
if(name.length() > 0) {
name += ".";
}
switch(style.getSelectedIndex()) {
case 0:
name += "sel#";
break;
case 2:
name += "press#";
break;
case 3:
name += "dis#";
break;
}
name += "border";
if(!((DefaultListModel)appliesTo.getModel()).contains(name)) {
Hashtable h = res.getTheme(theme);
if(h.contains(name)) {
if(JOptionPane.showConfirmDialog(this,
"A border already exists for this component,\ndo you want to replace it?",
"Already Exists",
JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
}
((DefaultListModel)appliesTo.getModel()).addElement(name);
}
}//GEN-LAST:event_addToListActionPerformed
public JList getAppliesTo() {
return appliesTo;
}
private void removeFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeFromListActionPerformed
if(appliesTo.getSelectedIndex() > -1) {
((DefaultListModel)appliesTo.getModel()).remove(appliesTo.getSelectedIndex());
}
}//GEN-LAST:event_removeFromListActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addToList;
private javax.swing.JList appliesTo;
private javax.swing.JComboBox componentName;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JButton removeFromList;
private javax.swing.JComboBox style;
// End of variables declaration//GEN-END:variables
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy