private TextField<String> addDefinition(String definable, String definition) {
    TableData deleteColumn = new TableData();
    deleteColumn.setWidth("20px");
    deleteColumn.setVerticalAlign(VerticalAlignment.TOP);

    TableData defColumn = new TableData();
    defColumn.setWidth(defColumnWidth);
    defColumn.setVerticalAlign(VerticalAlignment.TOP);

    TableData definitionsColumn = new TableData();
    definitionsColumn.setWidth(definitionsColumnWidth);
    definitionsColumn.setVerticalAlign(VerticalAlignment.TOP);

    final TextField<String> defText = new TextField<String>();
    defText.setValue(definable);
    defText.setWidth(defColumnWidth);

    final TextArea definitionText = new TextArea();
    definitionText.setValue(definition);
    definitionText.setWidth(definitionsColumnWidth);

    fields.put(defText, definitionText);
    final Image image = new Image("images/icon-delete.png");
    image.addClickListener(
        new ClickListener() {

          public void onClick(Widget sender) {
            WindowUtils.confirmAlert(
                "Delete?",
                "Are you sure you want to delete this definition?",
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getText().equalsIgnoreCase("yes")) {
                      remove(defText);
                      remove(definitionText);
                      remove(image);
                      fields.remove(defText);
                    }
                  };
                });
          }
        });

    add(image, deleteColumn);
    add(defText, defColumn);
    add(definitionText, definitionsColumn);

    return defText;
  }
Пример #2
0
  public CommentSection(int width, int height) {
    getFormLayout().setLabelAlign(LabelAlign.TOP);

    commentField = new TextArea();
    commentField.setName("comments");
    commentField.setFieldLabel(I18N.CONSTANTS.comments());
    if (width > 0) {
      getFormLayout().setDefaultWidth(width);
      commentField.setWidth(width);
    }
    if (height > 0) {
      commentField.setHeight(height);
    }
    add(commentField);
  }
  public RightPropertiesPanel() {

    setHeading(Constants.MENU_PROPS);
    setLayout(new FitLayout());

    ToolBar toolBarSelection = new ToolBar();
    LabelToolItem labelComponents = new LabelToolItem("Component:   ");
    toolBarSelection.add(labelComponents);
    labelComponents.setVisible(true);
    setTopComponent(toolBarSelection);

    listComponents = new SimpleComboBox<String>();
    updateFileList("Folders", listComponents);
    listComponents.add(Constants.COMPONENT_SPMANAGERWEB_NAME);
    listComponents.add("Test");
    listComponents.setForceSelection(true);
    listComponents.setEditable(false);
    listComponents.setTriggerAction(ComboBox.TriggerAction.ALL);
    listComponents.setEmptyText("- Choose a component -");
    listComponents.setFieldLabel("Component");
    listComponents.setWidth(200);
    toolBarSelection.add(listComponents);

    listComponents.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            selectedComponent = listComponents.getSimpleValue();
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            updateFileList(selectedComponent, listFiles);
          }
        });

    LabelToolItem labelFiles = new LabelToolItem("    File:   ");
    toolBarSelection.add(labelFiles);
    labelFiles.setVisible(true);

    listFiles = new SimpleComboBox<String>();
    listFiles.setForceSelection(true);
    listFiles.setEditable(false);
    listFiles.setTriggerAction(ComboBox.TriggerAction.ALL);
    listFiles.setEmptyText("-Choose a file-");
    listFiles.setFieldLabel("File");
    listFiles.setAutoWidth(false);
    listFiles.setWidth(250);
    toolBarSelection.add(listFiles);

    listFiles.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            output.clear();
          }
        });

    Button loadButton = new Button("Load");
    toolBarSelection.add(loadButton);

    loadButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            updateFileContent();
          }
        });

    currentOutput = "Select a component and configuration file to display and press \"Load\"";
    output = new TextArea();
    output.addStyleName("demo-TextArea");
    output.setWidth("800px");
    output.setHeight("400px");
    output.setReadOnly(true);
    output.setEmptyText("Select a component and configuration file to display and press \"Load\"");
    output.setVisible(true);
    add(output);
  }