Package fr.soleil.comete.swing

Examples of fr.soleil.comete.swing.TextField


    public static void main2() {
        DataSourceProducerProvider.pushNewProducer(TangoDataSourceFactory.class);
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());

        final TextField bean = new TextField();

        final StringScalarBox scalarBox = new StringScalarBox();
        panel.add(bean, BorderLayout.CENTER);
        final JLabel focusLabel = new JLabel("grab Focus");
        focusLabel.addMouseListener(new MouseAdapter() {
View Full Code Here


    public static void main2() {
        DataSourceProducerProvider.pushNewProducer(TangoDataSourceFactory.class);
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());

        final TextField bean = new TextField();

        final StringScalarBox scalarBox = new StringScalarBox();
        panel.add(bean, BorderLayout.CENTER);
        final JLabel focusLabel = new JLabel("grab Focus");
        focusLabel.addMouseListener(new MouseAdapter() {
View Full Code Here

     *
     * @return
     */
    public TextField getNumberOfStepsField() {
        if (numberOfStepsField == null) {
            numberOfStepsField = new TextField();
            numberOfStepsField.setText("1");
            numberOfStepsField.setPreferredSize(new Dimension(100, 20));
            setBackgroundStep();
            numberOfStepsField.addKeyListener(new KeyListener() {

View Full Code Here

     *
     * @return fr.esrf.tangoatk.widget.attribute.StringScalarEditor
     */
    private TextField getXWrite() {
        if (xWrite == null) {
            xWrite = new TextField();
            xWrite.setToolTipText(X_INFO);
        }
        return xWrite;
    }
View Full Code Here

     *
     * @return fr.esrf.tangoatk.widget.attribute.StringScalarEditor
     */
    private TextField getYWrite() {
        if (yWrite == null) {
            yWrite = new TextField();
            yWrite.setToolTipText(Y_INFO);
        }
        return yWrite;
    }
View Full Code Here

     *
     * @return fr.esrf.tangoatk.widget.attribute.StringScalarEditor
     */
    private TextField getSigmaWrite() {
        if (sigmaWrite == null) {
            sigmaWrite = new TextField();
            sigmaWrite.setToolTipText(SIGMA_INFO);
        }
        return sigmaWrite;
    }
View Full Code Here

                    double val = Double.parseDouble(entry.getValue());
                    ((WheelSwitch) editorComponent).setNumberValue(val);
                    ((WheelSwitch) editorComponent).setFormatEditable(true);
                    break;
                case STRING:
                    editorComponent = new TextField();
                    ((TextField) editorComponent).setText(entry.getValue());
                    ((TextField) editorComponent).setColumns(50);
                    break;
                case INT:
                    WheelSwitch wheelSwitch = new WheelSwitch();
                    wheelSwitch.setFormat("%+7.0f");
                    double intVal = Double.parseDouble(entry.getValue());
                    wheelSwitch.setFormatEditable(true);
                    if (ParsingUtil.DIMENSION.equals(paramName) && (entryContainer instanceof Actuator)) {
                        wheelSwitch.setFormat("%+1.0f");
                    }
                    if (paramName.startsWith(ParsingUtil.DIMENSION)) {
                        wheelSwitch.setMinValue(0);
                        wheelSwitch.setMinIncluded(true);
                    }
                    wheelSwitch.setNumberValue(intVal);
                    editorComponent = wheelSwitch;
                    break;
                case DOUBLE:
                    editorComponent = new WheelSwitch();
                    double doubleVal = Double.parseDouble(entry.getValue());
                    ((WheelSwitch) editorComponent).setNumberValue(doubleVal);
                    ((WheelSwitch) editorComponent).setFormatEditable(true);
                    break;
                case MATRIX:
                    String valueStr = entry.getValue();
                    String[] valuesStr = valueStr.split("]");
                    List<Integer> values = new ArrayList<Integer>();
                    for (String s : valuesStr) {
                        if (!s.isEmpty()) {
                            s = s.replace("[", "").replace("]", "").trim();
                            Integer i = Integer.parseInt(s);
                            values.add(i);
                        }
                    }
                    if (values.size() == 1) {
                        editorComponent = new WheelSwitch();
                        ((WheelSwitch) editorComponent).setFormat("%+7.0f");
                        Integer iv = values.get(0);
                        ((WheelSwitch) editorComponent).setNumberValue(iv);
                        ((WheelSwitch) editorComponent).setFormatEditable(true);
                        if (ParsingUtil.DIMENSION.equals(paramName) && (entryContainer instanceof Actuator)) {
                            ((WheelSwitch) editorComponent).setFormat("%+1.0f");
                        }
                    } else {
                        String title;
                        Integer minValue;
                        boolean included;
                        if (paramName.startsWith(ParsingUtil.DIMENSION)) {
                            title = "dim ";
                            minValue = 0;
                            included = true;
                        } else {
                            title = paramName;
                            minValue = null;
                            included = false;
                        }
                        editorComponent = new MatrixNumberEditorComponent(values, title, minValue, included);
                        final MatrixNumberEditorComponent matrixEditorComponent = (MatrixNumberEditorComponent) editorComponent;
                        matrixEditorComponent.addBeingEditedListener(new ConfigurationEditionStateListener() {
                            @Override
                            public void setConfigurationBeingEdited(boolean isBeingEdited) {
                                fireEditionStateChanged(isBeingEdited, entry, entryContainer,
                                        matrixEditorComponent.getStringValue(), matrixEditorComponent, labelName,
                                        tabTitle);
                            }
                        });
                    }

                    break;
                case TRAJECTORY:
                    if (entry instanceof TrajectoryEntry) {
                        String location = getErrorLocation(entry, entryContainer);
                        Trajectory trajectory = ((TrajectoryEntry) entry).getTrajectory();
                        if (trajectory instanceof ContinuousTrajectory) {
                            editorComponent = new ContinuousTrajectoryComponent(panelError, errorsMap,
                                    (ContinuousTrajectory) trajectory, location, this, labelName, tabTitle);
                        } else if (trajectory instanceof IntervalStepByStepTrajectory) {
                            editorComponent = new IntervalStepByStepTrajectoryComponent(panelError, errorsMap,
                                    (IntervalStepByStepTrajectory) trajectory, location, this, labelName, tabTitle);
                        } else if (trajectory instanceof TabStepByStepTrajectory) {
                            editorComponent = new TabStepByStepTrajectoryComponent(panelError, errorsMap,
                                    (TabStepByStepTrajectory) trajectory, location, this, labelName, tabTitle);
                        }
                        final ATrajectoryComponent<?> aTrajectoryComponent = (ATrajectoryComponent<?>) editorComponent;
                        aTrajectoryComponent.addBeingEditedListener(new ConfigurationEditionStateListener() {

                            @Override
                            public void setConfigurationBeingEdited(boolean isBeingEdited) {
                                Trajectory traj = aTrajectoryComponent.getTrajectory();
                                fireEditionStateChanged(isBeingEdited, entry, entryContainer,
                                        traj.getStringTrajectory(), aTrajectoryComponent, labelName, tabTitle);
                            }
                        });
                    }
                    break;
                default:
                    break;

            }
        } else if (entry instanceof FakeEntry) {
            Parameter param = ((FakeEntry) entry).getParam();
            description = param.getDescription();
            editorComponent = getEditorComponent(entry, labelName, param, entryContainer, tabTitle);
        }

        // Editor
        if (editorComponent == null && !entry.getKey().equals(ParsingUtil.LEVEL) && customParametersPanel != null
                && plugin != null && plugin.isAcceptCustomParameter()) {
            customParametersPanel.addNewCustomParameter(entry, entryContainer);
        }

        if (editorComponent != null) {
            isEditable = isEditable && ((!entry.isExpert()) || (entry.isExpert() && isExpert));
            editorComponent.setEnabled(isEditable);

            List<Constraint> constraints = entry.getConstraints();

            if (plugin != null) {
                for (Parameter parameter : plugin.getParameters()) {
                    if (parameter.getName().equalsIgnoreCase(entry.getKey()) && parameter.getConstraints() != null) {
                        constraints.addAll(parameter.getConstraints());
                    }
                }
            }

            List<Constraint> nonSatisfiedConstraints = getNonSatisfiedConstraints(entry, entry.getValue(), constraints);

            if (!nonSatisfiedConstraints.isEmpty()) {
                String location = getErrorLocation(entry, entryContainer);
                warnConstraintsAreNotSatisfied(tabTitle, editorComponent, labelName, nonSatisfiedConstraints, location);
            }

            // Listen to edition state change
            if (editorComponent instanceof CheckBox) {
                final CheckBox checkBox = (CheckBox) editorComponent;
                checkBox.addItemListener(new ItemListener() {

                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        Object obj = e.getSource();
                        if (obj instanceof CheckBox) {
                            fireEditionStateChanged(true, entry, entryContainer, checkBox.isSelected() ? "true"
                                    : "false", checkBox, labelName, tabTitle);
                        }

                    }
                });
            } else if (editorComponent instanceof ComboBox) {
                final ComboBox comboBox = (ComboBox) editorComponent;
                comboBox.addItemListener(new ItemListener() {

                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        fireEditionStateChanged(true, entry, entryContainer, (String) comboBox.getSelectedValue(),
                                comboBox, labelName, tabTitle);

                    }
                });
            } else if (editorComponent instanceof MultivaluedListComponent) {
                final MultivaluedListComponent multivaluedListComponent = (MultivaluedListComponent) editorComponent;
                multivaluedListComponent.addBeingEditedListener(new ConfigurationEditionStateListener() {

                    @Override
                    public void setConfigurationBeingEdited(boolean isBeingEdited) {

                        String value = multivaluedListComponent.getValueStr();
                        fireEditionStateChanged(isBeingEdited, entry, entryContainer, value, editorComponent,
                                labelName, tabTitle);

                    }
                });
            } else if (editorComponent instanceof WheelSwitch) {
                final WheelSwitch wheelSwitch = (WheelSwitch) editorComponent;
                wheelSwitch.addWheelSwitchListener(new IWheelSwitchListener() {

                    @Override
                    public void valueChange(WheelSwitchEvent evt) {
                        Object obj = evt.getSource();
                        if (obj instanceof WheelSwitch) {
                            fireEditionStateChanged(true, entry, entryContainer, wheelSwitch.getValue() + "",
                                    wheelSwitch, labelName, tabTitle);
                        }

                    }
                });
            } else if (editorComponent instanceof TextField) {
                final TextField textField = (TextField) editorComponent;
                textField.addTextFieldListener(new ITextFieldListener() {

                    @Override
                    public void textChanged(EventObject e) {

                        fireEditionStateChanged(true, entry, entryContainer, textField.getText(), textField, labelName,
                                tabTitle);

                    }

                    @Override
View Full Code Here

                              }

                          }
                      }
                  }*/
                lEditorComponent = new TextField();
                ((TextField) lEditorComponent).setText(entry.getValue());
                ((TextField) lEditorComponent).setColumns(50);

                break;
            case ENUM:
                lEditorComponent = new ComboBox();
                if (param.getValues() == null || param.getValues().length == 0) {
                    throw new FSParsingException("Plugin parameter " + param.getName()
                            + " must have a values property.", lEditorComponent, labelName);
                }
                for (String s : param.getValues()) {
                    ((ComboBox) lEditorComponent).addItem(s);
                    if (s.equalsIgnoreCase(entry.getValue())) {
                        ((ComboBox) lEditorComponent).setSelectedItem(s);
                    }
                }
                break;
            case NUMBER:
                lEditorComponent = new WheelSwitch();
                double val = Double.parseDouble(entry.getValue());
                if (param.getMinValue() != null && !param.getMinValue().isEmpty()) {
                    double min = Double.parseDouble(param.getMinValue());
                    ((WheelSwitch) lEditorComponent).setMinValue(min);
                }
                if (param.getMaxValue() != null && !param.getMaxValue().isEmpty()) {
                    double max = Double.parseDouble(param.getMaxValue());
                    ((WheelSwitch) lEditorComponent).setMaxValue(max);
                }

                ((WheelSwitch) lEditorComponent).setNumberValue(val);
                if (param.getUnit() != null && !param.getUnit().isEmpty()) {
                    String paramName = param.getName().trim() + " (" + param.getUnit() + ") ";
                    labelName.setText(paramName);
                }
                ((WheelSwitch) lEditorComponent).setFormatEditable(true);

                break;
            case STRING:
                lEditorComponent = new TextField();
                ((TextField) lEditorComponent).setText(entry.getValue());
                ((TextField) lEditorComponent).setColumns(50);

                break;
            case DEV_STATE:
View Full Code Here

     */
    public void addNewCustomParameter(final Entry entry, final EntryContainer actor) {
        Label label = new Label();
        label.setText(entry.getKey());

        TextField textField = new CustomTextField(entry, this, actor);

        textField.setEnabled(isEnabled);

        Button deleteButton = new Button();
        deleteButton.setIcon(Utilities.ICONS.getIcon("flyscan.delete"));
        deleteButton.setOpaque(false);
        deleteButton.setContentAreaFilled(false);
View Full Code Here

     *
     * @return fr.esrf.tangoatk.widget.attribute.StringScalarEditor
     */
    private TextField getXWrite() {
        if (xWrite == null) {
            xWrite = new TextField();
            xWrite.setToolTipText(X_INFO);
            stringBox.setColorEnabled(xWrite, false);
        }
        return xWrite;
    }
View Full Code Here

TOP

Related Classes of fr.soleil.comete.swing.TextField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.