📄 textattributespanel.java
字号:
{ // change the code type CodeExpression.Code newCode = (CodeExpression.Code)code.getSelectedItem(); return Variable.withCode(value, newCode); } /** * Apply any changes the user has made through the Panel. * @return true if any changes committed to database, false otherwise */ public synchronized boolean applyChanges() { if (varKey == null) return false; boolean changed = false; // see if code changed CodeExpression.Code newCode = (CodeExpression.Code)code.getSelectedItem(); if (newCode != initialCode) changed = true; // see if units changed TextDescriptor.Unit newUnit = (TextDescriptor.Unit)units.getSelectedItem(); if (newUnit != initialUnit) changed = true; // see if show style changed - check if DispPos changed Object newDisp = show.getSelectedItem(); if (newDisp != initialDispPos) changed = true; int newDispIndex = -1; if (newDisp != displaynone) newDispIndex = ((TextDescriptor.DispPos)newDisp).getIndex(); if (td != null) { // nothing changed on current var/td, return if (!changed) return false; } new ChangeText( owner, varKey, newCode, newUnit.getIndex(), newDispIndex ); initialCode = newCode; initialUnit = newUnit; initialDispPos = newDisp; return true; } // populate show combo box. If includeNoneChoice is true, include // the "None" option in the combo box. Note that it is a String, while // all the other objects are TextDescriptor.DispPos objects. private void populateShowComboBox(boolean includeNoneChoice) { show.removeAllItems(); // populate show style dialog box if (includeNoneChoice) show.addItem(displaynone); for (Iterator<TextDescriptor.DispPos> it = TextDescriptor.DispPos.getShowStyles(); it.hasNext(); ) { show.addItem(it.next()); } } private static class ChangeText extends Job { private ElectricObject owner; private Variable.Key varKey; private CodeExpression.Code code; private int unit; private int dispPos; private ChangeText( ElectricObject owner, Variable.Key varKey, CodeExpression.Code code, int unit, int dispPos) { super("Modify Text Attribute", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.owner = owner; this.varKey = varKey; this.code = code; this.unit = unit; this.dispPos = dispPos; startJob(); } public boolean doIt() throws JobException { // change the code type if (owner.isParam(varKey)) { if (owner instanceof Cell) { Cell cell = (Cell)owner; cell.getCellGroup().updateParam((Variable.AttrKey)varKey, cell.getParameter(varKey).withCode(code).getObject()); } else if (owner instanceof NodeInst) { NodeInst ni = (NodeInst)owner; ni.addParameter(ni.getParameter(varKey).withCode(code)); } } else { owner.updateVarCode(varKey, code); } TextDescriptor td = owner.getTextDescriptor(varKey); if (td == null) return false; // change the units td = td.withUnit(TextDescriptor.Unit.getUnitAt(unit)); // change the show style Variable var = owner.getParameterOrVariable(varKey); if (dispPos < 0) { // var should not be null if (var != null) td = td.withDisplay(false); } else { if (var != null) td = td.withDisplay(true); td = td.withDispPart(TextDescriptor.DispPos.getShowStylesAt(dispPos)); } owner.setTextDescriptor(varKey, td); return true; } } /** 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; jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); code = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); units = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); show = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); attrInfo1 = new javax.swing.JLabel(); attrInfo2 = new javax.swing.JLabel(); attrInfo3 = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel1.setLayout(new java.awt.GridBagLayout()); jLabel1.setText("Code:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4); jPanel1.add(jLabel1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.1; jPanel1.add(code, gridBagConstraints); jLabel2.setText("Units:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4); jPanel1.add(jLabel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.1; jPanel1.add(units, gridBagConstraints); jLabel3.setText("Show:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4); jPanel1.add(jLabel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.1; jPanel1.add(show, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); add(jPanel1, gridBagConstraints); jPanel2.setLayout(new java.awt.GridBagLayout()); attrInfo1.setText("Attributes created on a cell are"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel2.add(attrInfo1, gridBagConstraints); attrInfo2.setText("inherited by instances of that cell"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel2.add(attrInfo2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel2.add(attrInfo3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 10, 4, 4); add(jPanel2, gridBagConstraints); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel attrInfo1; private javax.swing.JLabel attrInfo2; private javax.swing.JLabel attrInfo3; private javax.swing.JComboBox code; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JComboBox show; private javax.swing.JComboBox units; // End of variables declaration//GEN-END:variables}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -