001: /**
002: * Copyright 2004 Carlos Silva A.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: */package com.csa.lgantt.view.dialogs;
017:
018: import java.awt.GridBagConstraints;
019: import java.awt.GridBagLayout;
020: import java.awt.event.ActionEvent;
021: import java.awt.event.ActionListener;
022:
023: import javax.swing.JComboBox;
024: import javax.swing.JComponent;
025: import javax.swing.JLabel;
026: import javax.swing.JPanel;
027: import javax.swing.JTextField;
028: import javax.swing.SwingConstants;
029:
030: import com.csa.lgantt.Messages;
031: import com.csa.lgantt.model.Constraint;
032: import com.csa.lgantt.view.adapters.ProjectViewModel;
033:
034: /**
035: * ProjectEditor, edita las caracteristicas de un proyecto:
036: * <ul>
037: * <li> fechad de inicio
038: * </ul>
039: *
040: * <p>$Date: 2006/10/10 05:12:13 $</p>
041: * @version $Revision: 1.2 $
042: * @author {user}
043: */
044: public class ConstraintEditor extends JPanel implements ActionListener {
045:
046: /**
047: *
048: */
049: private static final long serialVersionUID = 3544667395307680562L;
050: JTextField delayEdit;
051: JComboBox modeCombo;
052: ProjectViewModel pvModel;
053: Constraint constraint;
054:
055: protected void addComp(JComponent cmp, GridBagLayout gridbag,
056: GridBagConstraints c) {
057: gridbag.setConstraints(cmp, c);
058: add(cmp);
059: }
060:
061: /**
062: * Constructor for TaskEditor
063: */
064: public ConstraintEditor(Constraint ct) {
065: super ();
066: delayEdit = new JTextField(ct.getHumanReadableDelay(), 4);
067: constraint = ct;
068:
069: modeCombo = new JComboBox();
070: modeCombo.addItem(Messages
071: .getString("ConstraintEditor.mode.end_begin")); //$NON-NLS-1$
072: modeCombo.addItem(Messages
073: .getString("ConstraintEditor.mode.end_end")); //$NON-NLS-1$
074: modeCombo.addItem(Messages
075: .getString("ConstraintEditor.mode.begin_begin")); //$NON-NLS-1$
076: modeCombo.addItem(Messages
077: .getString("ConstraintEditor.mode.begin_end")); //$NON-NLS-1$
078:
079: GridBagLayout gridbag = new GridBagLayout();
080: GridBagConstraints c = new GridBagConstraints();
081: setLayout(gridbag);
082: c.fill = GridBagConstraints.BOTH;
083: c.weightx = 1.0;
084: c.gridwidth = 1;
085: addComp(
086: new JLabel(
087: Messages
088: .getString("ConstraintEditor.delayLabel"), SwingConstants.LEFT), gridbag, c); //$NON-NLS-1$
089: addComp(delayEdit, gridbag, c);
090: c.gridwidth = GridBagConstraints.REMAINDER; //end row
091: addComp(
092: new JLabel(
093: Messages
094: .getString("ConstraintEditor.delayUnits"), SwingConstants.LEFT), gridbag, c); //$NON-NLS-1$
095:
096: c.weightx = 0.0;
097: c.gridwidth = 1;
098: addComp(
099: new JLabel(
100: Messages
101: .getString("ConstraintEditor.modeLabel"), SwingConstants.LEFT), gridbag, c); //$NON-NLS-1$
102: c.gridwidth = GridBagConstraints.REMAINDER; //end row
103: addComp(modeCombo, gridbag, c);
104:
105: modeCombo.addActionListener(this );
106: delayEdit.addActionListener(this );
107: }
108:
109: /**
110: * cambios en los controles.
111: */
112: public void actionPerformed(ActionEvent event) {
113: //System.out.println("actionPerformed "+event.getSource());
114: if (event.getSource() == modeCombo) {
115: byte d = (byte) (modeCombo.getSelectedIndex());
116: constraint.setMode(d);
117: } else if (event.getSource() == delayEdit) {
118: constraint.setHumanReadableDelay(delayEdit.getText());
119: }
120: }
121: }
|