/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: DXFTab.java * * Copyright (c) 2004 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) 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 for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */ package com.sun.electric.tool.user.dialogs.options; import com.sun.electric.database.text.Setting; import com.sun.electric.database.text.TextUtils; import com.sun.electric.technology.technologies.Artwork; import com.sun.electric.tool.io.IOTool; import com.sun.electric.tool.user.dialogs.EDialog; import com.sun.electric.tool.user.dialogs.PreferencesFrame; import javax.swing.JPanel; /** * Class to handle the "DXF" tab of the Preferences dialog. */ public class DXFTab extends PreferencePanel { private TextUtils.UnitScale [] scales; private Setting artworkDXFLayerSetting = Artwork.tech().findLayer("Graphics").getDXFLayerSetting(); private Setting dxfScaleSetting = IOTool.getDXFScaleSetting(); /** Creates new form DXFTab */ public DXFTab(PreferencesFrame parent, boolean modal) { super(parent, modal); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(dxfLayerName); } /** return the JPanel to use for the user preferences. */ public JPanel getUserPreferencesPanel() { return preferences; } /** return the JPanel to use for the project preferences part of this tab. */ public JPanel getProjectPreferencesPanel() { return projectSettings; } /** return the name of this preferences tab. */ public String getName() { return "DXF"; } /** * Method called at the start of the dialog. * Caches current values and displays them in the DXF tab. */ public void init() { // user preferences dxfInputFlattensHierarchy.setSelected(IOTool.isDXFInputFlattensHierarchy()); dxfInputReadsAllLayers.setSelected(IOTool.isDXFInputReadsAllLayers()); // project preferences dxfLayerName.setText(getString(artworkDXFLayerSetting)); // initialize the scale popup scales = TextUtils.UnitScale.getUnitScales(); for(int i=0; i<scales.length; i++) dxfScale.addItem(scales[i].getName() + "Meter"); dxfScale.setSelectedItem(TextUtils.UnitScale.findFromIndex(getInt(dxfScaleSetting)).getName() + "Meter"); } /** * Method called when the "OK" panel is hit. * Updates any changed fields in the DXF tab. */ public void term() { // user preferences boolean currentValue = dxfInputFlattensHierarchy.isSelected(); if (currentValue != IOTool.isDXFInputFlattensHierarchy()) IOTool.setDXFInputFlattensHierarchy(currentValue); currentValue = dxfInputReadsAllLayers.isSelected(); if (currentValue != IOTool.isDXFInputReadsAllLayers()) IOTool.setDXFInputReadsAllLayers(currentValue); // project preferences setString(artworkDXFLayerSetting, dxfLayerName.getText()); setInt(dxfScaleSetting, scales[dxfScale.getSelectedIndex()].getIndex()); } /** * Method called when the factory reset is requested. */ public void reset() { // user preferences if (IOTool.isFactoryDXFInputFlattensHierarchy() != IOTool.isDXFInputFlattensHierarchy()) IOTool.setDXFInputFlattensHierarchy(IOTool.isFactoryDXFInputFlattensHierarchy()); if (IOTool.isFactoryDXFInputReadsAllLayers() != IOTool.isDXFInputReadsAllLayers()) IOTool.setDXFInputReadsAllLayers(IOTool.isFactoryDXFInputReadsAllLayers()); } /** 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. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; preferences = new javax.swing.JPanel(); dxfInputReadsAllLayers = new javax.swing.JCheckBox(); dxfInputFlattensHierarchy = new javax.swing.JCheckBox(); projectSettings = new javax.swing.JPanel(); dxfLayerName = new javax.swing.JTextField(); jLabel17 = new javax.swing.JLabel(); dxfScale = new javax.swing.JComboBox(); header = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jSeparator1 = new javax.swing.JSeparator(); jLabel2 = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); getContentPane().setLayout(new java.awt.GridBagLayout()); setTitle("IO Options"); setName(""); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); preferences.setLayout(new java.awt.GridBagLayout()); dxfInputReadsAllLayers.setText("Input reads all layers"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); preferences.add(dxfInputReadsAllLayers, gridBagConstraints); dxfInputFlattensHierarchy.setText("Input flattens hierarchy"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); preferences.add(dxfInputFlattensHierarchy, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; getContentPane().add(preferences, gridBagConstraints); projectSettings.setLayout(new java.awt.GridBagLayout()); dxfLayerName.setColumns(8); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); projectSettings.add(dxfLayerName, gridBagConstraints); jLabel17.setText("DXF Scale:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); projectSettings.add(jLabel17, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); projectSettings.add(dxfScale, gridBagConstraints); header.setText("DXF Input will accpt all of these layers:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 2, 4); projectSettings.add(header, gridBagConstraints); jLabel1.setText("DXF Output will use the first layer in the list"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); projectSettings.add(jLabel1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0); projectSettings.add(jSeparator1, gridBagConstraints); jLabel2.setText(" (separate layer names with a comma)"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 10, 2, 4); projectSettings.add(jLabel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; getContentPane().add(projectSettings, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; getContentPane().add(jSeparator2, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt)//GEN-FIRST:event_closeDialog { setVisible(false); dispose(); }//GEN-LAST:event_closeDialog // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox dxfInputFlattensHierarchy; private javax.swing.JCheckBox dxfInputReadsAllLayers; private javax.swing.JTextField dxfLayerName; private javax.swing.JComboBox dxfScale; private javax.swing.JLabel header; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel2; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JPanel preferences; private javax.swing.JPanel projectSettings; // End of variables declaration//GEN-END:variables }