示例#1
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testRemoveVerifyListenerUnregistersUntypedEvents() {
    VerifyListener listener = mock(VerifyListener.class);
    text.addVerifyListener(listener);

    text.removeVerifyListener(listener);

    assertFalse(text.isListening(SWT.Verify));
  }
 /**
  * Set the edit mask string on the edit mask control.
  *
  * @param editMask The edit mask string
  */
 public void setMask(String editMask) {
   editMaskParser = new EditMaskParser(editMask);
   text.addVerifyListener(verifyListener);
   text.addFocusListener(focusListener);
   text.addDisposeListener(disposeListener);
   updateTextField.run();
   oldValidText = text.getText();
   oldValidRawText = editMaskParser.getRawResult();
 }
  private void initialize() {
    String filename = StringUtils.defaultString(level.getName());
    GridData gridDataLabel = new GridData();
    gridDataLabel.widthHint = 100;
    gridDataLabel.verticalAlignment = GridData.CENTER;
    gridDataLabel.horizontalAlignment = GridData.END;
    GridData gridDataText = new GridData();
    gridDataText.heightHint = -1;
    gridDataText.widthHint = 150;
    GridLayout gridLayoutMy = new GridLayout();
    gridLayoutMy.numColumns = 2;
    gridLayoutMy.marginWidth = 25;
    gridLayoutMy.verticalSpacing = 5;
    gridLayoutMy.horizontalSpacing = 20;
    gridLayoutMy.marginHeight = 25;
    gridLayoutMy.makeColumnsEqualWidth = false;
    GridData gridDataMy = new GridData();
    gridDataMy.grabExcessHorizontalSpace = true;
    gridDataMy.verticalAlignment = GridData.CENTER;
    gridDataMy.horizontalSpan = 1;
    gridDataMy.horizontalAlignment = GridData.FILL;
    this.setLayoutData(gridDataMy);
    this.setLayout(gridLayoutMy);
    Label labelTitle = new Label(this, SWT.RIGHT);
    labelTitle.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.title"))); // $NON-NLS-1$
    labelTitle.setLayoutData(gridDataLabel);
    textTitle = new Text(this, SWT.BORDER);
    textTitle.setTextLimit(256);
    textTitle.setLayoutData(gridDataText);
    textTitle.setText(StringUtils.defaultString(level.getTitle()));
    Label labelName = new Label(this, SWT.RIGHT);
    labelName.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.name"))); // $NON-NLS-1$
    labelName.setLayoutData(gridDataLabel);
    textName = new Text(this, SWT.BORDER);
    textName.setTextLimit(256);
    textName.setLayoutData(gridDataText);
    textName.setText(filename);
    textName.addVerifyListener(new FileNameVerifier());
    textName.addModifyListener(new ModifyListenerClearErrorMessages(dialogCreator));

    Collection<String> forbiddenNames = new ArrayList<String>();
    Collection<Level> sisters = level.getParent().getSublevels();
    if (CollectionUtils.isNotEmpty(sisters))
      for (Level otherLevel : sisters) forbiddenNames.add(otherLevel.getName());
    if (StringUtils.isNotBlank(filename)) forbiddenNames.remove(filename);
    if (level.getId()
        == APoormansObject
            .UNSET_VALUE) // suggestion of the file name should work just with new  objects
    textTitle.addModifyListener(
          new FilenameSuggestorListener(dialogCreator, textName, forbiddenNames));
  }
  private void createConnectionGroup(final Composite parent) {
    final Group g = createGroup(parent, UIText.RepositorySelectionPage_groupConnection);

    newLabel(g, UIText.RepositorySelectionPage_promptScheme + ":"); // $NON-NLS-1$
    scheme = new Combo(g, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (Protocol p : Protocol.values()) scheme.add(p.getDefaultScheme());
    scheme.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            final int idx = scheme.getSelectionIndex();
            if (idx < 0) {
              setURI(uri.setScheme(null));
              scheme.setToolTipText(EMPTY_STRING);
            } else {
              setURI(uri.setScheme(nullString(scheme.getItem(idx))));
              scheme.setToolTipText(Protocol.values()[idx].getTooltip());
            }
            updateGroups();
          }
        });

    newLabel(g, UIText.RepositorySelectionPage_promptPort + ":"); // $NON-NLS-1$
    portText = new Text(g, SWT.BORDER);
    portText.addVerifyListener(
        new VerifyListener() {
          final Pattern p = Pattern.compile("^(?:[1-9][0-9]*)?$"); // $NON-NLS-1$

          @Override
          public void verifyText(final VerifyEvent e) {
            final String v = portText.getText();
            e.doit = p.matcher(v.substring(0, e.start) + e.text + v.substring(e.end)).matches();
          }
        });
    portText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent e) {
            final String val = nullString(portText.getText());
            if (val == null) setURI(uri.setPort(-1));
            else
              try {
                setURI(uri.setPort(Integer.parseInt(val)));
              } catch (NumberFormatException err) {
                // Ignore it for now.
              }
          }
        });
  }
  private void constructTextWidgets() {
    if (txfValue == null) {
      txfValue = new Text(pnlText, SWT.BORDER);
      txfValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      txfValue.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent theEvent) {
              handleTextChange();
            }
          });

      txfValue.addVerifyListener(
          new VerifyListener() {
            @Override
            public void verifyText(VerifyEvent theEvent) {
              String text = theEvent.text;

              if ((text != null) && (text.length() > 0)) {
                for (int size = text.length(), i = 0; i < size; i++) {
                  if ((validChars != null) && (validChars.indexOf(text.charAt(i)) == -1)) {
                    theEvent.doit = false;
                    break;
                  } else if (!model.isValidValue(text)) {
                    theEvent.doit = false;
                    break;
                  }
                }
              }
            }
          });

      txfValue.addTraverseListener(
          new TraverseListener() {
            @Override
            public void keyTraversed(TraverseEvent theEvent) {
              // stops the enter key from putting in invisible characters
              if (theEvent.detail == SWT.TRAVERSE_RETURN) {
                theEvent.detail = SWT.TRAVERSE_NONE;
                theEvent.doit = true;
              }
            }
          });

      pnlText.pack();
    }
  }
示例#6
0
  public UpperText(final Composite parent, final int style) {
    super(parent, style);
    setLayout(new FillLayout());
    Text text = new Text(this, SWT.MULTI | SWT.V_SCROLL);

    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(final VerifyEvent e) {
            if (e.text.startsWith("1")) {
              e.doit = false;
            } else {
              e.text = e.text.toUpperCase();
            }
          }
        });
  }
    /** 初始化匹配率文本框的监听,只允许输入数字,最大值为100或者101 */
    private void initMatchQtTextListener() {
      value.addVerifyListener(
          new VerifyListener() {

            public void verifyText(VerifyEvent event) {
              if (!value.getText().equals(initValue)) {
                if (event.keyCode == 0 && event.stateMask == 0) { // 文本框得到焦点时

                } else if (Character.isDigit(event.character)
                    || event.character == '\b'
                    || event.keyCode == 127) { // 输入数字,或者按下Backspace、Delete键
                  Text txt = (Text) event.widget;
                  if ("0".equals(txt.getText().trim()) && event.character == '0') {
                    event.doit = false;
                    return;
                  }
                  event.doit = true;
                } else {
                  event.doit = false;
                }
              }
            }
          });

      value.addModifyListener(
          new ModifyListener() {
            final int max = isUEVersion() ? 101 : 100; // 最大值

            public void modifyText(ModifyEvent e) {
              if (!value.getText().equals(initValue) && !value.getText().equals("")) {
                Text txt = (Text) e.widget;
                String text = txt.getText().trim();
                if (text.length() == 2 && text.charAt(0) == '0') {
                  txt.setText(text.charAt(1) + "");
                  txt.setSelection(1);
                } else if (Integer.parseInt(text) > max) {
                  txt.setText("100");
                  txt.setSelection(3);
                }
              }
            }
          });
    }
示例#8
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testAddVerifyListenerRegistersUntypedEvents() {
    text.addVerifyListener(mock(VerifyListener.class));

    assertTrue(text.isListening(SWT.Verify));
  }
示例#9
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testVerifyEvent() {
    VerifyListener verifyListener;
    final java.util.List<TypedEvent> log = new ArrayList<TypedEvent>();
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            log.add(event);
          }
        });
    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            assertEquals('\0', event.character);
            assertEquals(0, event.keyCode);
            log.add(event);
          }
        });

    // VerifyEvent is also sent when setting text to the already set value
    log.clear();
    text.setText("");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());

    // Test verifyListener that prevents (doit=false) change
    text.setText("");
    log.clear();
    verifyListener =
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            event.doit = false;
          }
        };
    text.addVerifyListener(verifyListener);
    text.setText("other");
    assertEquals(1, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals("", text.getText());
    text.removeVerifyListener(verifyListener);

    // Test verifyListener that manipulates text
    text.setText("");
    log.clear();
    verifyListener =
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            event.text = "manipulated";
          }
        };
    text.addVerifyListener(verifyListener);
    text.setText("other");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());
    assertEquals("manipulated", text.getText());
    text.removeVerifyListener(verifyListener);

    // Ensure that VerifyEvent#start and #end denote the positions of the old
    // text and #text denotes the text to be set
    String oldText = "old";
    text.setText(oldText);
    log.clear();
    String newText = oldText + "changed";
    text.setText(newText);
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    VerifyEvent verifyEvent = (VerifyEvent) log.get(0);
    assertEquals(0, verifyEvent.start);
    assertEquals(oldText.length(), verifyEvent.end);
    assertEquals(newText, verifyEvent.text);
    assertEquals(ModifyEvent.class, log.get(1).getClass());

    // Ensure that VerifyEvent gets fired when setEditable was set to false
    text.setText("");
    text.setEditable(false);
    log.clear();
    text.setText("whatever");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());
    text.setEditable(true);

    // Ensure that VerifyEvent#text denotes the text to be set
    // and not the cut by textLimit one
    text.setTextLimit(5);
    String sampleText = "sample_text";
    log.clear();
    text.setText(sampleText);
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    verifyEvent = (VerifyEvent) log.get(0);
    assertEquals(sampleText, verifyEvent.text);
  }
  private void createComp(Composite group) {

    GridLayout layout = new GridLayout(1, false);
    layout.verticalSpacing = 10;
    group.setLayout(layout);

    // TableViewer是通过Table来布局的
    // 制作表格   MULTI可多选  H_SCROLL有水平 滚动条、V_SCROLL有垂直滚动条、BORDER有边框、FULL_SELECTION整行选择
    table = new Table(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL); // 注意此处的设置
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    // 指定Table单元格的宽度和高度
    table.addListener(
        SWT.MeasureItem,
        new Listener() { // 向表格增加一个SWT.MeasureItem监听器,每当需要单元内容的大小的时候就会被调用。
          public void handleEvent(Event event) {
            event.width = table.getGridLineWidth(); // 设置宽度
            event.height =
                (int) Math.floor(event.gc.getFontMetrics().getHeight() * 1.5); // 设置高度为字体高度的1.5倍
          }
        });

    // 表格的视图
    tableViewer = new TableViewer(table);
    // 标题和网格线可见
    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    // 设置填充
    // GridData data = new GridData(SWT.LEFT,SWT.CENTER, true, false);//SWT.FILL, SWT.FILL, true,
    // false  xbm
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 350;
    data.heightHint = 295;
    data.grabExcessHorizontalSpace = true;
    tableViewer.getTable().setLayoutData(data); // 表格的布局

    // 创建表格列的标题
    int width = 1;
    for (int i = 0; i < stationData.getColumnCount(); i++) {
      width = stationData.getColumnWidth(i);
      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setWidth((int) (width * 8));
      column.setText(stationData.getColumnHeads()[i]); // 设置表头
      column.setAlignment(SWT.LEFT); // 对齐方式SWT.LEFT
      if (i == 0) // 站名
      {
        // 列的选择事件  实现排序
        column.addSelectionListener(
            new SelectionAdapter() {
              boolean sortType = true; // sortType记录上一次的排序方式,默认为升序

              public void widgetSelected(SelectionEvent e) {
                sortType = !sortType; // 取反。下一次排序方式要和这一次的相反
                tableViewer.setSorter(new StationSorter(sortType, stationData.columnHeads[0]));
              }
            });
      }
    }

    /*tableLayout.addColumnData(new ColumnWeightData(8, 8, false));//设置列宽为8像素
     TableColumn column_one = new TableColumn(table, SWT.NONE);//SWT.LEFT
     column_one.setText(stationData.COLUMN_HEADINGS[0]);//设置表头
     column_one.setAlignment(SWT.LEFT);//对齐方式SWT.LEFT
     column.setWidth(10);//宽度
    */

    // 设置标题的提供者
    tableViewer.setLabelProvider(new TableLabelProvider());

    // 设置表格视图的内容提供者
    tableViewer.setContentProvider(new TableContentProvider());

    // 设置列的属性.
    tableViewer.setColumnProperties(stationData.columnHeads);

    // 定义每一列的别名
    tableViewer.setColumnProperties(new String[] {"name", "down", "up", "map"});

    // 设置每一列的单元格编辑组件CellEditor
    CellEditor[] celleditors = new CellEditor[5];
    // 文本编辑框
    celleditors[0] = null;
    celleditors[1] = new TextCellEditor(table);
    celleditors[2] = new TextCellEditor(table);
    // CheckboxCellEditor(table) 复选框
    celleditors[3] = new ComboBoxCellEditor(table, StationData.MAPS, SWT.READ_ONLY); // 下拉框

    Text text = (Text) celleditors[1].getControl(); // 设置第down列只能输入数值
    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            // 输入控制键,输入中文,输入字符,输入数字 正整数验证
            Pattern pattern = Pattern.compile("[0-9]\\d*"); // 正则表达式
            Matcher matcher = pattern.matcher(e.text);
            if (matcher.matches()) // 处理数字
            {
              /*if(Integer.parseInt(e.text) != 0)//确保输入的数字不是0
              			e.doit = true;
              		else
              			e.doit = false;
              */
              e.doit = true;
            } else if (e.text.length() > 0) // 字符: 包含中文、空格
            e.doit = false;
            else // 控制键
            e.doit = true;
          }
        });

    Text text1 = (Text) celleditors[2].getControl(); // 设置第up列只能输入数值
    text1.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            String inStr = e.text;
            if (inStr.length() > 0) {
              e.doit = NumberUtils.isDigits(inStr);
            }
          }
        });

    table.addMouseMoveListener(
        new MouseMoveListener() {
          public void mouseMove(MouseEvent e) {
            if (StationData.reloadFlag) {
              getStationInfo();
              openCurrentTable(row);
              StationData.reloadFlag = false;
              // System.out.println("entry");
            }
          }
        });
    /*table.addFocusListener(new FocusListener(){
    public void focusGained(FocusEvent e) {
    	getStationInfo();
    	openCurrentTable(row);
    }
    @Override
    public void focusLost(FocusEvent e) {
    }
      });
         */
    tableViewer.setCellEditors(celleditors);

    // 设置单元的更改器
    tableViewer.setCellModifier(new TableCellModifier());

    tableViewer.addFilter(new TableViewerFilter()); // 过滤器

    // 构造工具条
    Composite buttonComposite = new Composite(group, SWT.NONE);
    buttonComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); // 使工具条居中
    Action actionModify =
        new Action("更新") {
          public void run() {
            // 取得用户所选择的第一行, 若没有选择则为null
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            // 获取选中的第一行数据
            Station station = (Station) selection.getFirstElement();
            if (station != null) {
              if (updateStationInfo(
                  station.getStation_downnumber(),
                  station.getStation_upnumber(),
                  station.getStation_graph(),
                  station.getStation_name())) {
                showMsg("成功更新!");
                // 表格的刷新方法,界面会重新读取数据并显示

                pushCommand();

                tableViewer.refresh(); // false
              } else {
                showMsg("更新失败!");
                // tableViewer.refresh();//false
              }
            } else {
              showMsg("请选取进行更新的行!");
            }
          }
        };

    Action actionDelete =
        new Action("删除") {
          public void run() {
            // 取得用户所选择的第一行, 若没有选择则为null
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            // 获取选中的第一个数据
            Station station = (Station) selection.getFirstElement();
            if (station != null) {
              // 先预先移动到下一行
              Table table = tableViewer.getTable();

              // int i = table.getSelectionIndex(); //取得当前所选行的序号,如没有则返回-1
              // table.setSelection(i + 1); //当前选择行移下一行
              // 确认删除
              MessageBox messageBox =
                  new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_INFORMATION);
              messageBox.setText("提示信息");
              messageBox.setMessage("确定要删除此记录吗?");
              // SWT.YES 是  // SWT.NO 否 // SWT.CANCEL 取消 // SWT.RETRY 重试// SWT.ABORT 放弃// SWT.IGNORE
              // 忽略
              if (messageBox.open() == SWT.YES) {
                if (deleteStationInfo(station.getStation_name())) // 从数据库中删除记录
                {
                  // showMsg("成功删除!");
                  ((List) tableViewer.getInput()).remove(station); // 数据模型的List容器中删除
                  stationData.remove(station.getStation_name());
                  openCurrentTable(row);
                  tableViewer.remove(station); // 从表格界面上删除

                  pushCommand();
                } else showMsg("删除失败!");
              }
            } else {
              showMsg("请选取要删除的纪录!");
            }
          }
        };

    Action actionClear = new Action("清空") { // 清除所显示内容,点击保存后更新库
          public void run() {
            if (clearStationInfo()) {
              showMsg("清空操作成功!");
              stationData.removeAll();
              openCurrentTable(row);

              pushCommand();
            } else showMsg("清空操作失败!");
          }
        };
    Action actionHelp =
        new Action("帮助") {
          public void run() {
            String str = "更新:\n\r" + "先对某行内容进行修改,然后点击更新进行保存\n\r" + "清空:\n\r" + "从库中物理删除所有记录";
            showMsg(str);
          }
        };

    Action nextPage =
        new Action("下一页") {
          public void run() {
            row++;
            if (row > stationData.getTotalPageNum()) {
              row--;
              return;
            }
            openCurrentTable(row);
          }
        };
    Action prevPage =
        new Action("上一页") {
          public void run() {
            row--;
            if (row < 1) {
              row++;
              return;
            }
            openCurrentTable(row);
          }
        };

    Action refresh =
        new Action("刷新") {
          public void run() {
            getStationInfo();
            openCurrentTable(row);
          }
        };

    // 工具条
    ToolBar toolBar = new ToolBar(buttonComposite, SWT.FLAT | SWT.RIGHT); // |SWT.BORDER

    // 工具条管理器
    ToolBarManager manager = new ToolBarManager(toolBar);

    // manager.add(refresh);
    // manager.add(new Separator());

    manager.add(nextPage);
    manager.add(prevPage);

    manager.add(new Separator());

    manager.add(actionModify);
    manager.add(actionDelete);
    manager.add(actionClear);
    manager.add(new Separator());
    manager.add(actionHelp);
    manager.update(true);

    // 选中某行时,改变行的颜色
    table.addListener(
        SWT.EraseItem,
        new Listener() {
          public void handleEvent(Event event) {
            event.detail &= ~SWT.HOT;
            if ((event.detail & SWT.SELECTED) == 0) return;
            int clientWidth = table.getClientArea().width;
            GC gc = event.gc;
            Color oldForeground = gc.getForeground();
            Color oldBackground = gc.getBackground();
            gc.setForeground(red);
            // gc.setBackground(yellow);
            gc.fillGradientRectangle(0, event.y, clientWidth, event.height, false);
            gc.setForeground(oldForeground);
            gc.setBackground(oldBackground);
            event.detail &= ~SWT.SELECTED;
          }
        });

    // 在tableviewer内部为数据记录和tableItem之间的映射创建一个hash表,这样可以加快tableItem的和记录间的查找速度
    // 必须保证存在要显示的数据,否则程序出错。所以这里不能用下面的语句
    // tableViewer.setUseHashlookup(true);//必须在setInput之前加入才有效
    // 从服务器获取数据
    getStationInfo();
    // 通过setInput为table添加了一个list后,只要对这个list里的元素进行添加和删除,
    // table中的数据就会自动添加和删除,当然每次操作后需要调用refresh方法对tableviewer进行刷新。
    // 打开界面所显示的内容
    tableViewer.setInput(stationData.getData()); // 自动输入数据   即将数据显示在表格中
    tableViewer.setItemCount(stationData.PAGE_SIZE); // 设置显示的Item数
  } //// createComp
  /**
   * @param parent
   * @param style
   */
  public SFTPAdvancedOptionsComposite(Composite parent, int style, Listener listener) {
    super(parent, style);
    this.listener = listener;

    setLayout(
        GridLayoutFactory.swtDefaults()
            .numColumns(5)
            .spacing(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                new PixelConverter(this)
                    .convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .create());

    /* row 1 */
    Label label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Compression));

    compressionCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    compressionCombo.add(ISFTPConstants.COMPRESSION_AUTO);
    compressionCombo.add(ISFTPConstants.COMPRESSION_NONE);
    compressionCombo.add(ISFTPConstants.COMPRESSION_ZLIB);
    compressionCombo.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(compressionCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT)
            .create());

    label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .align(SWT.END, SWT.CENTER)
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());

    label = new Label(this, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Port));

    portText = new Text(this, SWT.SINGLE | SWT.RIGHT | SWT.BORDER);
    portText.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                Math.max(
                    new PixelConverter(portText).convertWidthInCharsToPixels(5),
                    portText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x),
                SWT.DEFAULT)
            .create());

    /* row 2 */
    label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Encoding));

    encodingCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    encodingCombo.setItems(Charset.availableCharsets().keySet().toArray(new String[0]));
    encodingCombo.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(encodingCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT)
            .span(4, 1)
            .create());

    /* -- */
    addListeners();
    portText.addVerifyListener(new NumberVerifyListener());
  }
  /** {@inheritDoc} */
  @Override
  protected Control createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    composite.setLayout(gridLayout);

    valueText = new Text(composite, SWT.BORDER | SWT.RIGHT);
    valueText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    valueText.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent e) {
            String oldText = valueText.getText();
            String update = e.text;
            String newText =
                oldText.substring(0, e.start) + update + oldText.substring(e.end, oldText.length());

            // allow blank text
            if (StringUtils.isNotBlank(newText)) {
              // otherwise prove we have a valid double number
              try {
                Double.parseDouble(newText);
              } catch (NumberFormatException exception) {
                e.doit = false;
                return;
              }
            }
          }
        });
    valueText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            if (!modifyMarker) {
              String text = valueText.getText();
              if (!text.isEmpty() && (text.charAt(0) != '-' || text.length() > 1)) {
                long currentSize = getCurrentSize();
                sendPropertyUpdateEvent(currentSize);
              }
            } else {
              modifyMarker = false;
            }
          }
        });

    valueText.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            String text = valueText.getText();
            if (text.isEmpty()) {
              displayValue(getLastCorrectValue());
            }
          }
        });

    unitCombo = new Combo(composite, SWT.BORDER);
    unitCombo.setItems(new String[] {"B", "KB", "MB", "GB"});
    GridData unitGd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
    unitGd.widthHint = 60;
    unitCombo.setLayoutData(unitGd);
    unitCombo.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            long currentSize = getLastCorrectValue();
            int exp = unitCombo.getSelectionIndex();
            displayValue(currentSize, exp);
          };
        });

    displayValue(property.getValue().longValue());

    return composite;
  }
  /**
   * Creates the dialog's contents
   *
   * @param shell the dialog window
   */
  private void createContents(final Shell shell) {

    final Config config = controller.getConfig();

    // Create the ScrolledComposite to scroll horizontally and vertically
    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    // Create the parent Composite container for the three child containers
    Composite container = new Composite(sc, SWT.NONE);
    GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    shell.setLayout(new FillLayout());

    GridData data;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 50;
    data.widthHint = 400;

    // START TOP COMPONENT

    Composite topComp = new Composite(container, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    topComp.setLayout(layout);
    topComp.setLayoutData(data);

    Label blank = new Label(topComp, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 10;
    blank.setLayoutData(data);
    blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    // Show the message
    Label label = new Label(topComp, SWT.NONE);
    label.setText(message);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 30;
    data.widthHint = 370;

    Font f = label.getFont();
    FontData[] farr = f.getFontData();
    FontData fd = farr[0];
    fd.setStyle(SWT.BOLD);
    label.setFont(new Font(Display.getCurrent(), fd));

    label.setLayoutData(data);
    label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    labelSeparator.setLayoutData(data);

    // END TOP COMPONENT

    // START MIDDLE COMPONENT

    Composite restComp = new Composite(container, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    restComp.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    restComp.setLayout(layout);

    // Hide welecome screen
    Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT);
    labelHideWelcomeScreen.setText(
        Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$
    labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK);
    buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN));

    // batch size
    Label labelBatch = new Label(restComp, SWT.RIGHT);
    labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelBatch.setLayoutData(data);

    textBatch = new Text(restComp, SWT.BORDER);
    textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE));
    textBatch.setTextLimit(8);
    textBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 50;
    textBatch.setLayoutData(data);

    // insert Nulls
    Label labelNulls = new Label(restComp, SWT.RIGHT);
    labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelNulls.setLayoutData(data);
    buttonNulls = new Button(restComp, SWT.CHECK);
    buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS));

    // assignment rules
    Label labelRule = new Label(restComp, SWT.RIGHT);
    labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRule.setLayoutData(data);

    textRule = new Text(restComp, SWT.BORDER);
    textRule.setTextLimit(18);
    data = new GridData();
    data.widthHint = 115;
    textRule.setLayoutData(data);
    textRule.setText(config.getString(Config.ASSIGNMENT_RULE));

    // endpoint
    Label labelEndpoint = new Label(restComp, SWT.RIGHT);
    labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEndpoint.setLayoutData(data);

    textEndpoint = new Text(restComp, SWT.BORDER);
    data = new GridData();
    data.widthHint = 250;
    textEndpoint.setLayoutData(data);
    String endpoint = config.getString(Config.ENDPOINT);
    if ("".equals(endpoint)) { // $NON-NLS-1$
      endpoint = defaultServer;
    }

    textEndpoint.setText(endpoint);

    // reset url on login
    Label labelResetUrl = new Label(restComp, SWT.RIGHT);
    labelResetUrl.setText(
        Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelResetUrl.setLayoutData(data);
    buttonResetUrl = new Button(restComp, SWT.CHECK);
    buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN));

    // insert compression
    Label labelCompression = new Label(restComp, SWT.RIGHT);
    labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCompression.setLayoutData(data);
    buttonCompression = new Button(restComp, SWT.CHECK);
    buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION));

    // timeout size
    Label labelTimeout = new Label(restComp, SWT.RIGHT);
    labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTimeout.setLayoutData(data);

    textTimeout = new Text(restComp, SWT.BORDER);
    textTimeout.setTextLimit(4);
    textTimeout.setText(config.getString(Config.TIMEOUT_SECS));
    textTimeout.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textTimeout.setLayoutData(data);

    // extraction batch size
    Label labelQueryBatch = new Label(restComp, SWT.RIGHT);
    labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelQueryBatch.setLayoutData(data);

    textQueryBatch = new Text(restComp, SWT.BORDER);
    textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE));
    textQueryBatch.setTextLimit(4);
    textQueryBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textQueryBatch.setLayoutData(data);

    // enable/disable output of success file for extracts
    Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT);
    labelOutputExtractStatus.setText(
        Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOutputExtractStatus.setLayoutData(data);

    buttonOutputExtractStatus = new Button(restComp, SWT.CHECK);
    buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT));

    // utf-8 for loading
    Label labelReadUTF8 = new Label(restComp, SWT.RIGHT);
    labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelReadUTF8.setLayoutData(data);

    buttonReadUtf8 = new Button(restComp, SWT.CHECK);
    buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8));

    // utf-8 for extraction
    Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT);
    labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelWriteUTF8.setLayoutData(data);

    buttonWriteUtf8 = new Button(restComp, SWT.CHECK);
    buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8));

    // European Dates
    Label labelEuropeanDates = new Label(restComp, SWT.RIGHT);
    labelEuropeanDates.setText(
        Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEuropeanDates.setLayoutData(data);

    buttonEuroDates = new Button(restComp, SWT.CHECK);
    buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES));

    // Field truncation
    Label labelTruncateFields = new Label(restComp, SWT.RIGHT);
    labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTruncateFields.setLayoutData(data);

    buttonTruncateFields = new Button(restComp, SWT.CHECK);
    buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS));

    Label labelCsvCommand = new Label(restComp, SWT.RIGHT);
    labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCsvCommand.setLayoutData(data);
    buttonCsvComma = new Button(restComp, SWT.CHECK);
    buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA));

    Label labelTabCommand = new Label(restComp, SWT.RIGHT);
    labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTabCommand.setLayoutData(data);
    buttonCsvTab = new Button(restComp, SWT.CHECK);
    buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB));

    Label labelOtherCommand = new Label(restComp, SWT.RIGHT);
    labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherCommand.setLayoutData(data);
    buttonCsvOther = new Button(restComp, SWT.CHECK);
    buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER));

    Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT);
    labelOtherDelimiterValue.setText(
        Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherDelimiterValue.setLayoutData(data);
    textSplitterValue = new Text(restComp, SWT.BORDER);
    textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE));
    data = new GridData();
    data.widthHint = 25;
    textSplitterValue.setLayoutData(data);

    // Enable Bulk API Setting
    Label labelUseBulkApi = new Label(restComp, SWT.RIGHT);
    labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelUseBulkApi.setLayoutData(data);

    boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED);
    buttonUseBulkApi = new Button(restComp, SWT.CHECK);
    buttonUseBulkApi.setSelection(useBulkAPI);
    buttonUseBulkApi.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            boolean enabled = buttonUseBulkApi.getSelection();
            // update batch size when this setting changes
            int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled);
            logger.info("Setting batch size to " + newDefaultBatchSize);
            textBatch.setText(String.valueOf(newDefaultBatchSize));
            // make sure the appropriate check boxes are enabled or disabled
            initBulkApiSetting(enabled);
          }
        });

    // Bulk API serial concurrency mode setting
    Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT);
    labelBulkApiSerialMode.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$
    labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK);
    buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiSerialMode.setEnabled(useBulkAPI);

    // Bulk API serial concurrency mode setting
    Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT);
    labelBulkApiZipContent.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$
    labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiZipContent = new Button(restComp, SWT.CHECK);
    buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiZipContent.setEnabled(useBulkAPI);
    // timezone
    textTimezone =
        createTextInput(
            restComp,
            "AdvancedSettingsDialog.timezone",
            Config.TIMEZONE,
            TimeZone.getDefault().getID(),
            200);

    // proxy Host
    Label labelProxyHost = new Label(restComp, SWT.RIGHT);
    labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyHost.setLayoutData(data);

    textProxyHost = new Text(restComp, SWT.BORDER);
    textProxyHost.setText(config.getString(Config.PROXY_HOST));
    data = new GridData();
    data.widthHint = 250;
    textProxyHost.setLayoutData(data);

    // Proxy Port
    Label labelProxyPort = new Label(restComp, SWT.RIGHT);
    labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPort.setLayoutData(data);

    textProxyPort = new Text(restComp, SWT.BORDER);
    textProxyPort.setText(config.getString(Config.PROXY_PORT));
    textProxyPort.setTextLimit(4);
    textProxyPort.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 25;
    textProxyPort.setLayoutData(data);

    // Proxy Username
    Label labelProxyUsername = new Label(restComp, SWT.RIGHT);
    labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyUsername.setLayoutData(data);

    textProxyUsername = new Text(restComp, SWT.BORDER);
    textProxyUsername.setText(config.getString(Config.PROXY_USERNAME));
    data = new GridData();
    data.widthHint = 120;
    textProxyUsername.setLayoutData(data);

    // Proxy Password
    Label labelProxyPassword = new Label(restComp, SWT.RIGHT);
    labelProxyPassword.setText(
        Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPassword.setLayoutData(data);

    textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD);
    textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD));
    data = new GridData();
    data.widthHint = 120;
    textProxyPassword.setLayoutData(data);

    // proxy NTLM domain
    Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT);
    labelProxyNtlmDomain.setText(
        Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyNtlmDomain.setLayoutData(data);

    textProxyNtlmDomain = new Text(restComp, SWT.BORDER);
    textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN));
    data = new GridData();
    data.widthHint = 250;
    textProxyNtlmDomain.setLayoutData(data);

    //////////////////////////////////////////////////
    // Row to start At

    Label blankAgain = new Label(restComp, SWT.NONE);
    data = new GridData();
    data.horizontalSpan = 2;
    blankAgain.setLayoutData(data);

    // Row to start AT
    Label labelLastRow = new Label(restComp, SWT.NONE);

    String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW);
    if (lastBatch.equals("")) { // $NON-NLS-1$
      lastBatch = "0"; // $NON-NLS-1$
    }

    labelLastRow.setText(
        Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$
    data = new GridData();
    data.horizontalSpan = 2;
    labelLastRow.setLayoutData(data);

    Label labelRowToStart = new Label(restComp, SWT.RIGHT);
    labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRowToStart.setLayoutData(data);

    textRowToStart = new Text(restComp, SWT.BORDER);
    textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT));
    data = new GridData();
    data.widthHint = 75;
    textRowToStart.setLayoutData(data);
    textRowToStart.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });

    // now that we've created all the buttons, make sure that buttons dependent on the bulk api
    // setting are enabled or disabled appropriately
    initBulkApiSetting(useBulkAPI);

    // the bottow separator
    Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    labelSeparatorBottom.setLayoutData(data);

    // ok cancel buttons
    new Label(restComp, SWT.NONE);

    // END MIDDLE COMPONENT

    // START BOTTOM COMPONENT

    Composite buttonComp = new Composite(restComp, SWT.NONE);
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    buttonComp.setLayoutData(data);
    buttonComp.setLayout(new GridLayout(2, false));

    // Create the OK button and add a handler
    // so that pressing it will set input
    // to the entered value
    Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$
    ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            Config config = controller.getConfig();

            // set the configValues
            config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection());
            config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection());
            config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText());
            if (!buttonCsvComma.getSelection()
                && !buttonCsvTab.getSelection()
                && (!buttonCsvOther.getSelection()
                    || textSplitterValue.getText() == null
                    || textSplitterValue.getText().length() == 0)) {
              return;
            }
            config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText());
            config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection());
            config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection());
            config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection());

            config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText());
            config.setValue(Config.ENDPOINT, textEndpoint.getText());
            config.setValue(Config.ASSIGNMENT_RULE, textRule.getText());
            config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText());
            config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection());
            config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection());
            config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection());
            config.setValue(Config.TIMEOUT_SECS, textTimeout.getText());
            config.setValue(
                Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection());
            config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection());
            config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection());
            config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection());
            config.setValue(Config.TIMEZONE, textTimezone.getText());
            config.setValue(Config.PROXY_HOST, textProxyHost.getText());
            config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText());
            config.setValue(Config.PROXY_PORT, textProxyPort.getText());
            config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText());
            config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText());
            config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection());
            config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection());
            config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection());

            controller.saveConfig();
            controller.logout();

            input = Labels.getString("UI.ok"); // $NON-NLS-1$
            shell.close();
          }
        });
    data = new GridData();
    data.widthHint = 75;
    ok.setLayoutData(data);

    // Create the cancel button and add a handler
    // so that pressing it will set input to null
    Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            input = null;
            shell.close();
          }
        });

    // END BOTTOM COMPONENT

    data = new GridData();
    data.widthHint = 75;
    cancel.setLayoutData(data);

    // Set the OK button as the default, so
    // user can type input and press Enter
    // to dismiss
    shell.setDefaultButton(ok);

    // Set the child as the scrolled content of the ScrolledComposite
    sc.setContent(container);

    // Set the minimum size
    sc.setMinSize(768, 1024);

    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
  }
示例#14
0
  private void createGroup() {
    try {
      final GridLayout gridLayout_3 = new GridLayout();
      gridLayout_3.verticalSpacing = 10;
      gridLayout_3.marginWidth = 10;
      gridLayout_3.marginTop = 10;
      gridLayout_3.marginRight = 10;
      gridLayout_3.marginLeft = 10;
      gridLayout_3.marginHeight = 10;
      gridLayout_3.marginBottom = 10;
      gridLayout_3.numColumns = 3;

      final Group composite = JOE_G_DetailForm_MainGroup.Control(new Group(this, SWT.NONE));
      composite.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(final DisposeEvent e) {
              if (butApply.isEnabled()) {
                save();
              }
            }
          });
      composite.setLayout(new GridLayout());
      final GridData gridData_6 = new GridData(GridData.FILL, GridData.CENTER, true, true, 3, 1);
      gridData_6.heightHint = 31;
      composite.setLayoutData(gridData_6);

      parameterGroup = JOE_G_DetailForm_ParameterGroup.Control(new Group(composite, SWT.NONE));
      parameterGroup.setEnabled(false);
      //			parameterGroup.setText("Detail Parameter");
      final GridData gridData_3 = new GridData(GridData.FILL, GridData.FILL, true, true);
      gridData_3.heightHint = 239;
      parameterGroup.setLayoutData(gridData_3);
      final GridLayout gridLayout_2 = new GridLayout();
      gridLayout_2.numColumns = 6;
      parameterGroup.setLayout(gridLayout_2);

      @SuppressWarnings("unused")
      final Label nameLabel = JOE_L_Name.Control(new Label(parameterGroup, SWT.NONE));
      //			nameLabel.setText("Name");

      txtName = JOE_T_DetailForm_Name.Control(new Text(parameterGroup, SWT.BORDER));
      //			txtName.addFocusListener(new FocusAdapter() {
      //				public void focusGained(final FocusEvent e) {
      //					txtName.selectAll();
      //				}
      //			});
      txtName.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              if (!txtName.getText().equals("")
                  && (tableParams.getSelectionCount() == 0
                      || (tableParams.getSelectionCount() > 0
                          && !tableParams
                              .getSelection()[0]
                              .getText(0)
                              .equalsIgnoreCase(txtName.getText())))) {
                isEditableParam = true;
                butApplyParam.setEnabled(isEditableParam);
                txtValue.setEnabled(true);
                butText.setEnabled(true);
                paramText.setText("");
                txtParamNote.setEnabled(true);
              } else {
                butText.setEnabled(false);
              }
            }
          });
      txtName.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(final KeyEvent e) {
              if (e.keyCode == SWT.CR && !txtName.getText().equals("")) {
                addParam();
              }
            }
          });
      txtName.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      txtName.setFocus();

      @SuppressWarnings("unused")
      final Label valueLabel = JOE_L_Value.Control(new Label(parameterGroup, SWT.NONE));
      //			valueLabel.setText("Value");

      txtValue = JOE_T_DetailForm_Value.Control(new Text(parameterGroup, SWT.BORDER));
      //			txtValue.addFocusListener(new FocusAdapter() {
      //				public void focusGained(final FocusEvent e) {
      //					txtValue.selectAll();
      //				}
      //			});
      txtValue.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(final KeyEvent e) {
              if (e.keyCode == SWT.CR && !txtName.getText().equals("")) {
                addParam();
              }
            }
          });
      txtValue.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              if (!txtName.getText().equals("")
                  && (tableParams.getSelectionCount() == 0
                      || (tableParams.getSelectionCount() > 0
                          && !tableParams
                              .getSelection()[0]
                              .getText(1)
                              .equalsIgnoreCase(txtValue.getText())))) {
                isEditableParam = true;
                butApplyParam.setEnabled(isEditableParam);
                if (txtValue.getText().trim().length() > 0) butText.setEnabled(false);
                else butText.setEnabled(true);
              }
            }
          });
      txtValue.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

      butText = JOE_B_DetailForm_Text.Control(new Button(parameterGroup, SWT.NONE));
      butText.setEnabled(false);
      butText.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              String ntext = "";
              if (tableParams.getSelectionCount() > 0) {
                TableItem item = tableParams.getSelection()[0];
                ntext = item.getText(2);
              }
              String text =
                  sos.scheduler.editor.app.Utils.showClipboard(ntext, getShell(), true, "");
              if (text != null && !text.trim().equalsIgnoreCase(ntext)) {
                paramText.setText(text);
                txtValue.setText("");
                txtValue.setEnabled(false);
                butText.setEnabled(true);
                addParam();
              } else if (text == null) {
                txtValue.setEnabled(true);
                butText.setEnabled(true);
              } else {
                txtValue.setEnabled(true);
                butText.setEnabled(false);
              }
              butApply.setEnabled(true);
            }
          });
      //			butText.setText("Text");

      butApplyParam = JOE_B_DetailForm_ApplyParam.Control(new Button(parameterGroup, SWT.NONE));
      butApplyParam.setEnabled(isEditableParam);
      butApplyParam.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              addParam();
            }
          });
      final GridData gridData_9 = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
      butApplyParam.setLayoutData(gridData_9);
      //			butApplyParam.setText("Apply");

      tableParams =
          JOE_Tbl_DetailForm_Params.Control(
              new Table(parameterGroup, SWT.FULL_SELECTION | SWT.BORDER));
      tableParams.setEnabled(false);
      tableParams.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              if (tableParams.getSelectionCount() > 0) {
                TableItem item = tableParams.getSelection()[0];
                txtName.setText(item.getText(0));
                // param value ist angegeben
                if (item.getText(1) != null && item.getText(1).trim().length() > 0) {
                  paramText.setText("");
                  txtValue.setText(item.getText(1));
                  txtValue.setEnabled(true);
                  butText.setEnabled(false);
                }
                // param Textknoten ist angegeben
                if (item.getText(2) != null && item.getText(2).trim().length() > 0) {
                  paramText.setText(item.getText(2));
                  txtValue.setText("");
                  txtValue.setEnabled(false);
                  butText.setEnabled(true);
                }
                if (item.getText(1).trim().equals("") && item.getText(2).trim().equals("")) {
                  paramText.setText("");
                  txtValue.setText("");
                  txtValue.setEnabled(true);
                  butText.setEnabled(true);
                }
                txtParamNote.setText(
                    detailListener.getParamNote(item.getText(0), comboLanguage.getText()));
                butRemove.setEnabled(true);
                txtParamNote.setEnabled(true);
                isEditableParam = false;
              } else {
                butRemove.setEnabled(false);
              }
            }
          });
      tableParams.setLinesVisible(true);
      tableParams.setHeaderVisible(true);
      final GridData gridData_4 = new GridData(GridData.FILL, GridData.FILL, true, true, 5, 7);
      tableParams.setLayoutData(gridData_4);

      final TableColumn newColumnTableColumn =
          JOE_TCl_DetailForm_NameColumn.Control(new TableColumn(tableParams, SWT.NONE));
      //			newColumnTableColumn.setText("Name");
      newColumnTableColumn.setWidth(118);
      newColumnTableColumn.addControlListener(
          new ControlAdapter() {
            public void controlResized(final ControlEvent e) {
              w.saveTableColumn("tableParams", newColumnTableColumn);
            }
          });
      w.restoreTableColumn("tableParams", newColumnTableColumn, 118);

      final TableColumn newColumnTableColumn_1 =
          JOE_TCl_DetailForm_ValueColumn.Control(new TableColumn(tableParams, SWT.NONE));
      //			newColumnTableColumn_1.setText("Value");
      newColumnTableColumn_1.setWidth(150);
      newColumnTableColumn_1.addControlListener(
          new ControlAdapter() {
            public void controlResized(final ControlEvent e) {
              w.saveTableColumn("tableParams", newColumnTableColumn_1);
            }
          });
      w.restoreTableColumn("tableParams", newColumnTableColumn_1, 150);

      final TableColumn newColumnTableColumn_2 =
          JOE_TCl_DetailForm_TextColumn.Control(new TableColumn(tableParams, SWT.NONE));
      //			newColumnTableColumn_2.setText("Text");
      newColumnTableColumn_2.setWidth(100);
      newColumnTableColumn_2.addControlListener(
          new ControlAdapter() {
            public void controlResized(final ControlEvent e) {
              w.saveTableColumn("tableParams", newColumnTableColumn_2);
            }
          });
      w.restoreTableColumn("tableParams", newColumnTableColumn_2, 100);

      final Button butNew = JOE_B_DetailForm_New.Control(new Button(parameterGroup, SWT.NONE));
      butNew.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              txtName.setText("");
              txtValue.setText("");
              paramText.setText("");
              txtValue.setEnabled(true);
              paramText.setEnabled(true);
              tableParams.deselectAll();
              txtParamNote.setText("");
            }
          });
      butNew.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      //			butNew.setText("New");

      final Composite composite_2 = JOE_Composite1.Control(new Composite(parameterGroup, SWT.NONE));
      final GridData gridData_2_1 = new GridData(GridData.CENTER, GridData.CENTER, false, false);
      gridData_2_1.heightHint = 67;
      composite_2.setLayoutData(gridData_2_1);
      composite_2.setLayout(new GridLayout());

      butUp = JOE_B_DetailForm_Up.Control(new Button(composite_2, SWT.NONE));
      butUp.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              detailListener.changeUp(tableParams);
            }
          });
      butUp.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      butUp.setImage(ResourceManager.getImageFromResource("/sos/scheduler/editor/icon_up.gif"));

      butDown = JOE_B_DetailForm_Down.Control(new Button(composite_2, SWT.NONE));
      butDown.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              detailListener.changeDown(tableParams);
            }
          });
      butDown.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
      butDown.setImage(ResourceManager.getImageFromResource("/sos/scheduler/editor/icon_down.gif"));

      final Button parameterButton =
          JOE_B_DetailForm_Wizard.Control(new Button(parameterGroup, SWT.NONE));
      parameterButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              startWizzard();
            }
          });

      // parameterButton.setVisible(type != Editor.DETAILS);
      parameterButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      //			parameterButton.setText("Wizard");

      butRemove = JOE_B_DetailForm_Remove.Control(new Button(parameterGroup, SWT.NONE));
      butRemove.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              if (tableParams.getSelectionCount() > 0) {
                detailListener.deleteParameter(tableParams, tableParams.getSelectionIndex());
                txtParamNote.setText("");
                txtName.setText("");
                txtValue.setText("");
                tableParams.deselectAll();
                butRemove.setEnabled(false);
                txtParamNote.setText("");
                isEditableParam = false;
                butApplyParam.setEnabled(isEditableParam);
                butApply.setEnabled(isEditable);
                txtName.setFocus();
                if (gui != null) gui.updateParam();
              }
            }
          });
      final GridData gridData_8 = new GridData(GridData.FILL, GridData.BEGINNING, false, true);
      gridData_8.widthHint = 64;
      gridData_8.minimumWidth = 50;
      butRemove.setLayoutData(gridData_8);
      //			butRemove.setText("Remove");

      final Button butTemp =
          JOE_B_DetailForm_TempDocumentation.Control(new Button(parameterGroup, SWT.NONE));
      butTemp.setLayoutData(new GridData());
      //			butTemp.setText("Documentation");
      butTemp.setVisible(false);

      butApply = JOE_B_DetailForm_ApplyDetails.Control(new Button(parameterGroup, SWT.NONE));
      butApply.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      butApply.setEnabled(isEditable);
      FontData fontDatas[] = butApply.getFont().getFontData();
      FontData data = fontDatas[0];
      butApply.setFont(new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD));
      butApply.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              save();
            }
          });
      //			butApply.setText("Apply Details");

      cancelButton = JOE_B_DetailForm_Cancel.Control(new Button(parameterGroup, SWT.NONE));
      cancelButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      cancelButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              saveWindowPosAndSize();
              if (butApply.getEnabled()) {
                //						int count = MainWindow.message(getShell(),
                // sos.scheduler.editor.app.Messages.getLabel("detailform.close"), SWT.ICON_WARNING
                // | SWT.OK
                int count =
                    MainWindow.message(
                        getShell(), JOE_M_0008.label(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
                if (count != SWT.OK) {
                  return;
                }
              }
              getShell().dispose();
            }
          });
      //			cancelButton.setText("Cancel");

      txtParamNote =
          JOE_T_DetailForm_JobChainNote.Control(
              new Text(
                  parameterGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL));
      txtParamNote.setEnabled(false);
      txtParamNote.addVerifyListener(
          new VerifyListener() {
            public void verifyText(final VerifyEvent e) {
              if (e.keyCode == 8 || e.keyCode == 127) {
                isEditableParam = true;
                butApplyParam.setEnabled(isEditableParam);
              }
            }
          });
      txtParamNote.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              changeParameNote();
            }
          });
      final GridData gridData_5 = new GridData(GridData.FILL, GridData.FILL, true, true, 5, 3);
      gridData_5.heightHint = 73;
      txtParamNote.setLayoutData(gridData_5);

      comboLanguage = JOE_Cbo_DetailForm_Language.Control(new Combo(parameterGroup, SWT.READ_ONLY));
      comboLanguage.setItems(new String[] {"de", "en"});
      final GridData gridData_7 = new GridData(GridData.FILL, GridData.BEGINNING, false, true);
      comboLanguage.setLayoutData(gridData_7);
      comboLanguage.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              txtJobchainNote.setText(detailListener.getNote(comboLanguage.getText()));
              if (tableParams.getSelectionCount() > 0) {
                TableItem item = tableParams.getSelection()[0];
                txtParamNote.setText(
                    detailListener.getParamNote(item.getText(0), comboLanguage.getText()));
              } else if (txtName.getText() != null && txtName.getText().length() > 0) {
                txtParamNote.setText(
                    detailListener.getParamNote(txtName.getText(), comboLanguage.getText()));
              } else if (txtParamNote.getText() != null && txtParamNote.getText().length() > 0) {
                txtParamNote.setText("");
              }
              isEditable = false;
              isEditableParam = false;
              // butApply.setEnabled(isEditable);
              butApplyParam.setEnabled(isEditableParam);
              butRemove.setEnabled(false);
            }
          });
      comboLanguage.select(0);

      butRefreshWizzardNoteParam =
          JOE_B_DetailForm_RefreshWizardNoteParam.Control(new Text(parameterGroup, SWT.CHECK));
      butRefreshWizzardNoteParam.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              refreshTable();
            }
          });
      butRefreshWizzardNoteParam.setVisible(false);
      butRefreshWizzardNoteParam.setLayoutData(new GridData());

      paramText = JOE_T_DetailForm_Param.Control(new Text(parameterGroup, SWT.BORDER));
      paramText.setVisible(false);
      final GridData gridData_14 = new GridData(GridData.CENTER, GridData.BEGINNING, false, false);
      gridData_14.widthHint = 27;
      paramText.setLayoutData(gridData_14);

      jobChainGroup = JOE_G_DetailForm_NoteGroup.Control(new Group(parameterGroup, SWT.NONE));
      jobChainGroup.setEnabled(false);
      //			jobChainGroup.setText("Note");
      final GridLayout gridLayout_1 = new GridLayout();
      gridLayout_1.numColumns = 2;
      jobChainGroup.setLayout(gridLayout_1);
      final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false, 6, 1);
      gridData.horizontalIndent = -1;
      jobChainGroup.setLayoutData(gridData);

      txtJobchainNote =
          JOE_T_DetailForm_JobChainNote.Control(
              new Text(
                  jobChainGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL));
      txtJobchainNote.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              if (detailListener != null) {
                isEditable = true;
                if (gui != null) gui.updateNote();
                detailListener.setNote(txtJobchainNote.getText(), comboLanguage.getText());
                butApply.setEnabled(isEditable);
              }
            }
          });
      final GridData gridData_2 = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 2);
      txtJobchainNote.setLayoutData(gridData_2);

      butXML = JOE_B_DetailForm_XML.Control(new Button(jobChainGroup, SWT.NONE));
      butXML.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      butXML.setEnabled(false);
      butXML.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              try {
                if (dom != null && dom.isChanged()) {
                  //							MainWindow.message("Please save jobchain configuration file before
                  // opening XML Editor.", SWT.ICON_ERROR);
                  MainWindow.message(JOE_M_0020.label(), SWT.ICON_ERROR);
                  return;
                }
                if (dom == null && butApply.isEnabled()) {
                  // ungespeichert
                  //							int c = MainWindow.message("Should the current values be saved?", SWT.YES
                  // | SWT.NO | SWT.ICON_ERROR);
                  int c = MainWindow.message(JOE_M_0021.label(), SWT.YES | SWT.NO | SWT.ICON_ERROR);
                  if (c == SWT.YES) detailListener.save();
                }
                if (type == Editor.JOB_CHAINS) {
                  DetailXMLEditorDialogForm dialog =
                      new DetailXMLEditorDialogForm(
                          detailListener.getConfigurationFilename(),
                          jobChainname,
                          state,
                          _orderId,
                          type,
                          isLifeElement,
                          path);
                  dialog.showXMLEditor();
                  getShell().dispose();
                } else {
                  if (dom != null && dom.getFilename() != null && dom.getFilename().length() > 0) {
                    DetailXMLEditorDialogForm dialog =
                        new DetailXMLEditorDialogForm(dom, type, isLifeElement, path);
                    dialog.setConfigurationData(confListener, tree, parent);
                    dialog.showXMLEditor();
                  } else {
                    //								MainWindow.message("Please save jobchain configuration file before
                    // opening XML Editor.", SWT.ICON_ERROR);
                    MainWindow.message(JOE_M_0020.label(), SWT.ICON_ERROR);
                  }
                }
              } catch (Exception ex) {
                try {
                  //							System.out.println("..error in " + sos.util.SOSClassUtil.getMethodName()
                  // + ": " + ex.getMessage());
                  System.out.println(
                      JOE_M_0010.params(sos.util.SOSClassUtil.getMethodName(), ex.getMessage()));
                  new ErrorLog(JOE_M_0002.params(sos.util.SOSClassUtil.getMethodName()), ex);
                } catch (Exception ee) {
                  // tu nichts
                }
              }
            }
          });
      //			butXML.setText("Open XML");

      butDocumentation =
          JOE_B_DetailForm_Documentation.Control(new Button(jobChainGroup, SWT.NONE));
      butDocumentation.setLayoutData(
          new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
      butDocumentation.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(final SelectionEvent e) {
              String filename = null;
              try {
                if (type == Editor.JOB_CHAINS) {
                  filename = detailListener.getConfigurationFilename();
                } else {
                  if (dom != null) {
                    filename = dom.getFilename();
                  }
                }
                if (filename != null && filename.length() > 0) {
                  File file = new File(filename);
                  if (file.exists()) {
                    // Runtime.getRuntime().exec("cmd /C START iExplore ".concat(filename));
                    Program prog = Program.findProgram("html");
                    if (prog != null) {
                      prog.execute(new File(filename).toURL().toString());
                    } else {
                      String[] split =
                          Options.getBrowserExec(
                              new File(filename).toURL().toString(), Options.getLanguage());
                      Runtime.getRuntime().exec(split);
                    }
                  } else
                    MainWindow.message(JOE_M_0013.params(file.getCanonicalPath()), SWT.ICON_ERROR);
                  //								MainWindow.message("Missing documentation " + file.getCanonicalPath(),
                  // SWT.ICON_ERROR);
                } else MainWindow.message(JOE_M_0012.label(), SWT.ICON_ERROR);
                //							MainWindow.message("Please save jobchain configuration before opening
                // documentation.", SWT.ICON_ERROR);
              } catch (Exception ex) {
                try {
                  //							System.out.println("..could not open file " + filename + " " +
                  // ex.getMessage());
                  System.out.println(
                      JOE_M_0011.params(
                          sos.util.SOSClassUtil.getMethodName(), filename, ex.getMessage()));
                  new ErrorLog(
                      JOE_M_0011.params(
                          sos.util.SOSClassUtil.getMethodName(), filename, ex.getMessage()));
                } catch (Exception ee) {
                  // tu nichts
                }
              }
            }
          });
      //			butDocumentation.setText("Documentation");

      final Label fileLabel =
          JOE_L_DetailForm_JobDocumentation.Control(new Label(parameterGroup, SWT.NONE));
      fileLabel.setLayoutData(new GridData());
      //			fileLabel.setText("Job Documentation: ");

      txtParamsFile = JOE_T_DetailForm_ParamsFile.Control(new Text(parameterGroup, SWT.BORDER));
      //			txtParamsFile.addFocusListener(new FocusAdapter() {
      //				public void focusGained(final FocusEvent e) {
      //					txtParamsFile.selectAll();
      //				}
      //			});
      txtParamsFile.addModifyListener(
          new ModifyListener() {
            public void modifyText(final ModifyEvent e) {
              detailListener.setParamsFileName(txtParamsFile.getText());
              if (gui != null) gui.updateNote();
              butApply.setEnabled(isEditable);
            }
          });
      txtParamsFile.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 4, 1));

      statusBar = JOE_L_DetailForm_ConfigFile.Control(new Label(composite, SWT.BORDER));
      final GridData gridData_11 = new GridData(GridData.FILL, GridData.END, false, false);
      gridData_11.widthHint = 496;
      gridData_11.heightHint = 18;
      statusBar.setLayoutData(gridData_11);
      //			statusBar.setText("Configurations File:");
      setToolTipText();
      if (type == Editor.JOB_CHAINS) setEnabled_(false);
      setVisibility();
    } catch (Exception e) {
      try {
        //				new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + "cause: " +
        // e.toString(), e);
        new ErrorLog(JOE_M_0010.params(sos.util.SOSClassUtil.getMethodName(), e.toString()), e);
      } catch (Exception ee) {
        // tu nichts
      }
    }
  }
示例#15
0
  @Override
  public void createPartControl(Composite parent) {
    //		final boolean canExecute = SecurityFacade.getInstance().canExecute(
    //				SECURITY_ID, false);
    GridLayout grid = new GridLayout();
    grid.numColumns = 5;
    parent.setLayout(grid);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;

    int style =
        SWT.SINGLE
            | SWT.BORDER
            | SWT.H_SCROLL
            | SWT.V_SCROLL
            | SWT.FULL_SELECTION
            | SWT.HIDE_SELECTION;
    Table table = new Table(parent, style);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1);
    table.setLayoutData(gridData);
    messageTable = new MessageTable(table);

    Button butAlarm = new Button(parent, SWT.PUSH);
    butAlarm.setText(Messages.JMSView_SendButton1);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    butAlarm.setLayoutData(gridData);
    butAlarm.setEnabled(true);

    Label alarmTopicLabel = new Label(parent, SWT.NONE);
    alarmTopicLabel.setText(Messages.JMSView_Labels);
    final Text alarmTopic = new Text(parent, SWT.BORDER);
    alarmTopic.setText("ALARM"); // $NON-NLS-1$
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 160;
    alarmTopic.setLayoutData(gridData);

    Label alarmCountLabel = new Label(parent, SWT.NONE);
    alarmCountLabel.setText(Messages.JMSView_Numbers);
    final Text alarmCount = new Text(parent, SWT.BORDER);
    alarmCount.setText("1"); // $NON-NLS-1$
    alarmCount.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            if (e.character == SWT.DEL || e.character == SWT.BS) {
              e.doit = true;
            } else {
              try {
                Integer.parseInt(e.text);
                e.doit = true;
              } catch (NumberFormatException nfe) {
                e.doit = false;
              }
            }
          }
        });
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    alarmCount.setLayoutData(gridData);

    Button butLog = new Button(parent, SWT.PUSH);
    butLog.setText(Messages.JMSView_SendButton2);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    butLog.setLayoutData(gridData);
    butLog.setEnabled(true);

    Label logTopicLabel = new Label(parent, SWT.NONE);
    logTopicLabel.setText(Messages.JMSView_Labels);
    final Text logTopic = new Text(parent, SWT.BORDER);
    logTopic.setText("LOG"); // $NON-NLS-1$
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 160;
    logTopic.setLayoutData(gridData);

    Label logCountLabel = new Label(parent, SWT.NONE);
    logCountLabel.setText(Messages.JMSView_Numbers);
    final Text logCount = new Text(parent, SWT.BORDER);
    logCount.setText("1"); // $NON-NLS-1$
    logCount.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            if (e.character == SWT.DEL || e.character == SWT.BS) {
              e.doit = true;
            } else {
              try {
                Integer.parseInt(e.text);
                e.doit = true;

              } catch (NumberFormatException nfe) {
                e.doit = false;
              }
            }
          }
        });
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    logCount.setLayoutData(gridData);

    butAlarm.addSelectionListener(new SendButtonSelectionListener(alarmTopic, alarmCount));
    butLog.addSelectionListener(new SendButtonSelectionListener(logTopic, logCount));
    JmsSenderPlugin.getDefault()
        .getPluginPreferences()
        .addPropertyChangeListener(propertyChangeListener);

    parent.pack();
  }
示例#16
0
  private Control createText(Composite parent) {
    text = new Text(parent, textStyle);
    text.setTextLimit(7);
    text.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent e) {
            Display.getCurrent()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (text == null || text.isDisposed()) return;

                        if (isAncestorShell(text.getShell(), Display.getCurrent().getActiveShell()))
                          return;
                        textEditingFinished();
                      }
                    });
          }

          public void focusGained(FocusEvent e) {}
        });
    text.addTraverseListener(
        new TraverseListener() {
          public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_ESCAPE) {
              fireCancelEditing();
              e.doit = false;
            } else if (e.detail == SWT.TRAVERSE_RETURN) {
              textEditingFinished();
              e.doit = false;
            }
          }
        });
    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            if (e.keyCode == 27 && e.stateMask == 0) {
              fireCancelEditing();
              e.doit = false;
            } else if (e.keyCode == 13) {
              textEditingFinished();
              e.doit = false;
            } else {
              if (COLOR_NONE_VALUE.equals(e.text)) {
                return;
              }
              char[] charArray = e.text.toCharArray();
              for (char character : charArray) {
                boolean isValid =
                    character == '#'
                        || (character >= 'A' && character <= 'F')
                        || (character >= 'a' && character <= 'f')
                        || (character >= '0' && character <= '9');
                if (!isValid) {
                  e.doit = false;
                  return;
                }
              }
            }
          }
        });
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            if (modifying) return;
            String value = text.getText();
            if ((value == null || value.lastIndexOf('#') != 0) && !COLOR_NONE_VALUE.equals(value)) {
              value = ""; // $NON-NLS-1$
            }
            changeValue("".equals(value) ? null : value); // $NON-NLS-1$
          }
        });
    text.addKeyListener(
        new KeyListener() {
          public void keyReleased(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {
            if (e.character == '\r') {
              textEditingFinished();
              e.doit = false;
            }
          }
        });
    return text;
  }
示例#17
0
  /** Create contents of the dialog. */
  private void createContents() {
    shell = new Shell(getParent(), getStyle());
    shell.setImage(
        ResourceManager.getPluginImage("kr.re.kisti.amga.editor", "icons/elcl16/save.png"));
    shell.setLocation(getParent().getLocation().x + 50, getParent().getLocation().y + 50);
    shell.setSize(400, 245);
    shell.setText("File(xls, txt) Save As...");
    shell.setLayout(new GridLayout(1, false));

    Group grpOutputFormat = new Group(shell, SWT.NONE);
    grpOutputFormat.setText("Output Format");
    grpOutputFormat.setLayout(new GridLayout(3, false));
    GridData gd_grpOutputFormat = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_grpOutputFormat.heightHint = 136;
    grpOutputFormat.setLayoutData(gd_grpOutputFormat);

    combo_type = new Combo(grpOutputFormat, SWT.READ_ONLY);
    combo_type.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            switch (combo_type.getSelectionIndex()) {
              case 0:
                combo_string.setEnabled(false);
                break;
              case 1:
                combo_string.setEnabled(true);
                break;
              default:
                break;
            }
          }
        });
    combo_type.setItems(new String[] {"Excel File", "Delimited Text"});
    GridData gd_combo_type = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    gd_combo_type.widthHint = 253;
    combo_type.setLayoutData(gd_combo_type);
    combo_type.select(0);

    Label lblStringQuoteCharacher = new Label(grpOutputFormat, SWT.NONE);
    lblStringQuoteCharacher.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblStringQuoteCharacher.setText("String quote characher : ");

    combo_string = new Combo(grpOutputFormat, SWT.READ_ONLY);
    combo_string.setEnabled(false);
    combo_string.setItems(new String[] {"Tab", "Space", "Comma"});
    combo_string.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    combo_string.select(0);

    Label lblFileName = new Label(grpOutputFormat, SWT.NONE);
    lblFileName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblFileName.setText("File Name : ");

    text_file = new Text(grpOutputFormat, SWT.BORDER);
    text_file.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            ValuesCheck();
          }
        });
    text_file.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            e.doit = e.text.matches("[\\w]*");
          }
        });
    text_file.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Label lblSavePath = new Label(grpOutputFormat, SWT.NONE);
    lblSavePath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSavePath.setText("Save Path : ");

    text_dir = new Text(grpOutputFormat, SWT.BORDER | SWT.READ_ONLY);
    text_dir.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            ValuesCheck();
          }
        });
    text_dir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button button_browser = new Button(grpOutputFormat, SWT.NONE);
    button_browser.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            //				DirectoryDialog directoryDialog = new DirectoryDialog(shell, SWT.SAVE);
            //				if(text_dir.getText().trim().length() != 0){
            //					directoryDialog.setFilterPath(text_dir.getText());
            //				}
            //
            //				String sPath = directoryDialog.open();
            //				if(sPath != null){
            //					text_dir.setText(sPath);
            //				}
          }
        });
    button_browser.setText("...");
    grpOutputFormat.setTabList(new Control[] {combo_type, combo_string, text_file, button_browser});

    group_btn = new Group(shell, SWT.NONE);
    group_btn.setLayout(null);
    GridData gd_group_btn = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_group_btn.heightHint = 63;
    group_btn.setLayoutData(gd_group_btn);

    Button btn_cancel = new Button(group_btn, SWT.NONE);
    btn_cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shell.close();
          }
        });
    btn_cancel.setBounds(299, 18, 75, 25);
    btn_cancel.setText("&Cancel");

    btn_ok = new Button(group_btn, SWT.NONE);
    btn_ok.setEnabled(false);
    btn_ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {

            try {
              int nCount = 0;
              String sFullPath =
                  text_dir.getText() + System.getProperty("file.separator") + text_file.getText();
              int nTotal = 0;

              switch (combo_type.getSelectionIndex()) {
                case 0:
                  CollectionView navigationView =
                      (CollectionView)
                          PlatformUI.getWorkbench()
                              .getActiveWorkbenchWindow()
                              .getActivePage()
                              .findView(CollectionView.ID);
                  String sCollection = navigationView.SelectTree();

                  // Excel
                  WritableWorkbook myWorkbook =
                      Workbook.createWorkbook(new File(sFullPath + ".xls"));
                  WritableSheet mySheet =
                      myWorkbook.createSheet(sCollection.replaceAll("/", "_"), 0);

                  String sImsi = "";
                  for (int i = 0; i < nColumns; i++) {
                    sImsi = oTotal.get(i);

                    WritableCellFormat ColumnFormat = new WritableCellFormat();
                    ColumnFormat.setAlignment(Alignment.CENTRE);
                    ColumnFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
                    ColumnFormat.setBackground(Colour.GRAY_25);
                    mySheet.setColumnView(i, (sImsi.trim().length() * 2));
                    jxl.write.Label oColumnLabel = new jxl.write.Label(i, 0, sImsi, ColumnFormat);
                    mySheet.addCell(oColumnLabel);
                  }
                  for (int i = 0; i < nColumns; i++) {
                    oTotal.remove(0);
                  }

                  nTotal = (oTotal.size() / nColumns);
                  nCount = 0;
                  for (int nRow = 1; nRow <= nTotal; nRow++) {
                    for (int nCol = 0; nCol < nColumns; nCol++) {
                      jxl.write.Label numberLabels =
                          new jxl.write.Label(nCol, nRow, oTotal.get(nCount++));
                      mySheet.addCell(numberLabels);
                    }
                  }
                  myWorkbook.write();
                  myWorkbook.close();

                  break;
                case 1:
                  // Txt
                  ArrayList<String> oTxt = new ArrayList<String>();
                  int nString = combo_string.getSelectionIndex();
                  String sDelimited = "";

                  switch (nString) {
                    case 0:
                      sDelimited = "\t";
                      break;
                    case 1:
                      sDelimited = " ";
                      break;
                    case 2:
                      sDelimited = ",";
                      break;
                    default:
                      break;
                  }

                  String sContent = "";
                  nCount = 0;
                  nTotal = (oTotal.size() / nColumns);
                  for (int i = 0; i < nTotal; i++) {
                    for (int j = 0; j < nColumns; j++) {
                      sContent = sContent + oTotal.get(nCount++) + sDelimited;
                    }
                    oTxt.add(sContent);
                    sContent = "";
                  }

                  BufferedWriter out = new BufferedWriter(new FileWriter(sFullPath + ".txt"));
                  for (int i = 0; i < oTxt.size(); i++) {
                    out.write(oTxt.get(i));
                    out.newLine();
                  }
                  out.close();

                  break;
                default:
                  break;
              }

              MessageDialog.openInformation(
                  shell,
                  "AMGA_Mangaer",
                  "Success : Files have been saved["
                      + sFullPath
                      + (combo_type.getSelectionIndex() == 0 ? ".xls" : ".txt")
                      + "]");
              shell.close();
            } catch (Exception e1) {
              MessageDialog.openError(shell, "AMGA_Mangaer", e1.getLocalizedMessage());
            }
          }
        });
    btn_ok.setBounds(218, 18, 75, 25);
    btn_ok.setText("&Ok");

    Label lblTotalDataRow = new Label(group_btn, SWT.NONE);
    lblTotalDataRow.setBounds(10, 23, 202, 15);
    lblTotalDataRow.setText("Total data row : " + ((oTotal.size() / nColumns) - 1));
    group_btn.setTabList(new Control[] {btn_ok, btn_cancel});
    shell.setTabList(new Control[] {grpOutputFormat, group_btn});
  }
  private void createRemoteControl(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    group.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    group.setLayoutData(gd);
    group.setText(Messages.getString("GDBJtagDebuggerTab.remoteGroup_Text"));

    useRemote = new Button(group, SWT.CHECK);
    useRemote.setText(Messages.getString("GDBJtagDebuggerTab.useRemote_Text"));
    useRemote.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            useRemoteChanged();
            updateLaunchConfigurationDialog();
          }
        });

    Composite comp = new Composite(group, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    comp.setLayout(layout);

    Label label = new Label(comp, SWT.NONE);
    label.setText(Messages.getString("GDBJtagDebuggerTab.jtagDeviceLabel"));

    jtagDevice = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);

    GDBJtagDeviceContribution[] availableDevices =
        GDBJtagDeviceContributionFactory.getInstance().getGDBJtagDeviceContribution();
    for (int i = 0; i < availableDevices.length; i++) {
      jtagDevice.add(availableDevices[i].getDeviceName());
    }

    jtagDevice.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateDeviceIpPort(jtagDevice.getText());
            scheduleUpdateJob(); // provides much better performance for Text listeners
          }
        });

    remoteConnectionParameters = new Composite(group, SWT.NO_TRIM | SWT.NO_FOCUS);
    remoteConnectParmsLayout = new StackLayout();
    remoteConnectionParameters.setLayout(remoteConnectParmsLayout);

    //
    //  Create entry fields for TCP/IP connections
    //

    {
      remoteTcpipBox = new Composite(remoteConnectionParameters, SWT.NO_TRIM | SWT.NO_FOCUS);
      layout = new GridLayout();
      layout.numColumns = 2;
      remoteTcpipBox.setLayout(layout);
      remoteTcpipBox.setBackground(remoteConnectionParameters.getParent().getBackground());

      label = new Label(remoteTcpipBox, SWT.NONE);
      label.setText(Messages.getString("GDBJtagDebuggerTab.ipAddressLabel")); // $NON-NLS-1$
      ipAddress = new Text(remoteTcpipBox, SWT.BORDER);
      gd = new GridData();
      gd.widthHint = 125;
      ipAddress.setLayoutData(gd);

      label = new Label(remoteTcpipBox, SWT.NONE);
      label.setText(Messages.getString("GDBJtagDebuggerTab.portNumberLabel")); // $NON-NLS-1$
      portNumber = new Text(remoteTcpipBox, SWT.BORDER);
      gd = new GridData();
      gd.widthHint = 125;
      portNumber.setLayoutData(gd);
    }

    //
    //  Create entry fields for other types of connections
    //

    {
      remoteConnectionBox = new Composite(remoteConnectionParameters, SWT.NO_TRIM | SWT.NO_FOCUS);
      layout = new GridLayout();
      layout.numColumns = 2;
      remoteConnectionBox.setLayout(layout);
      remoteConnectionBox.setBackground(remoteConnectionParameters.getParent().getBackground());

      label = new Label(remoteConnectionBox, SWT.NONE);
      label.setText(Messages.getString("GDBJtagDebuggerTab.connectionLabel")); // $NON-NLS-1$
      connection = new Text(remoteConnectionBox, SWT.BORDER);
      gd = new GridData();
      gd.widthHint = 125;
      connection.setLayoutData(gd);
    }

    //
    //  Add watchers for user data entry
    //

    ipAddress.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            scheduleUpdateJob(); // provides much better performance for Text listeners
          }
        });
    portNumber.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character);
          }
        });
    portNumber.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            scheduleUpdateJob(); // provides much better performance for Text listeners
          }
        });

    connection.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            scheduleUpdateJob(); // provides much better performance for Text listeners
          }
        });
  }
示例#19
0
  public ConfigMaker(File configFile) {
    builder = new Builder(configFile);

    display = new Display();
    shell = new Shell(display);
    shell.setText("Negura Server");
    shell.setSize(760, 620);
    stackLayout = new StackLayout();
    shell.setLayout(stackLayout);

    // Page one positioning. ///////////////////////////////////////////////
    p1 = new Composite(shell, SWT.NONE);
    p1.setLayout(new MigLayout("insets 10", "[right][200!][max][100::, fill]"));
    Label newConfigL = Swt.newLabel(p1, "span, align left, wrap 30px", "New configuration");

    Swt.newLabel(p1, null, "Server name:");
    serverNameT = Swt.newText(p1, "w max, wrap", "Negura Server Name");

    Swt.newLabel(p1, null, "Block size:");
    blockSizeC = Swt.newCombo(p1, "w max, wrap 25px", optionsStr, 2);

    Swt.newLabel(p1, null, "Virtual disk blocks:");
    diskBlocksT = Swt.newText(p1, "w max", null);
    Scale diskBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64);

    Swt.newLabel(p1, null, "Virtual disk space:");
    Label diskSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null);

    Swt.newLabel(p1, null, "Minimum user blocks:");
    minBlocksT = Swt.newText(p1, "w max", null);
    Scale minBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64);

    Swt.newLabel(p1, null, "Minimum user space:");
    Label minSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null);

    Swt.newLabel(p1, null, "Port:");
    portT = Swt.newText(p1, "w max, wrap", "5000");

    Swt.newLabel(p1, null, "Check-in time:");
    checkInTimeT = Swt.newText(p1, "w max", "300");
    Swt.newLabel(p1, "wrap", "seconds");

    Swt.newLabel(p1, null, "Thread pool options:");
    threadPoolT =
        Swt.newText(p1, "span, w max, wrap 25px", new ThreadPoolOptions(2, 20, 30000).toString());

    Swt.newLabel(p1, null, "Database URL:");
    databaseUrlT = Swt.newText(p1, "span, w max", "jdbc:postgresql://127.0.0.1:5432/neguradb");

    Swt.newLabel(p1, null, "Database user:"******"w max, wrap", "p");

    Swt.newLabel(p1, null, "Database password:"******"w max, wrap push", "password");

    Button continueB = Swt.newButton(p1, "skip 3", "Continue");

    // Page one options. ///////////////////////////////////////////////////
    titleFont = Swt.getFontWithDifferentHeight(display, newConfigL.getFont(), 16);
    Swt.connectDisposal(shell, titleFont);
    newConfigL.setFont(titleFont);

    Swt.Mod tripleConnector =
        new Swt.Mod() {
          public void modify(Widget to, Widget... from) {
            Label label = (Label) to;
            Combo combo = (Combo) from[0];
            Text text = (Text) from[1];
            int blockSize = optionsInt[combo.getSelectionIndex()];
            long numberOfBlocks = Util.parseLongOrZero(text.getText());
            label.setText(Util.bytesWithUnit(numberOfBlocks * blockSize, 2));
          }
        };

    diskBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER);
    Swt.connectTo(Swt.TEXT_FROM_SCALE, diskBlocksT, diskBlocksS);
    Swt.connectTo(Swt.SCALE_FROM_TEXT, diskBlocksS, diskBlocksT);
    Swt.connectTo(tripleConnector, diskSpaceL, blockSizeC, diskBlocksT);
    diskBlocksT.setText("768");

    minBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER);
    Swt.connectTo(Swt.TEXT_FROM_SCALE, minBlocksT, minBlocksS);
    Swt.connectTo(Swt.SCALE_FROM_TEXT, minBlocksS, minBlocksT);
    Swt.connectTo(tripleConnector, minSpaceL, blockSizeC, minBlocksT);
    minBlocksT.setText("350");

    portT.addVerifyListener(Swt.INTEGER_VERIFIER);
    checkInTimeT.addVerifyListener(Swt.INTEGER_VERIFIER);

    continueB.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            step2();
          }
        });

    // Page two positioning. ///////////////////////////////////////////////
    p2 = new Composite(shell, SWT.NONE);
    p2.setLayout(new MigLayout("insets 10", "[right][grow][100::, fill]"));
    Label newConfig2L = Swt.newLabel(p2, "span, align left, wrap 30px", "New configuration");

    Swt.newLabel(p2, null, "Server key pair:");
    final Text key1T = Swt.newText(p2, "w max", null);
    Button load1B = Swt.newButton(p2, "wrap", "Load");

    Swt.newLabel(p2, null, "Admin key pair:");
    final Text key2T = Swt.newText(p2, "w max", null);
    Button load2B = Swt.newButton(p2, "wrap push", "Load");

    Button genB = Swt.newButton(p2, "align left", "Key pair generator");

    doneB = Swt.newButton(p2, "skip 1", "Done");

    // Page two options. ///////////////////////////////////////////////////
    newConfig2L.setFont(titleFont);
    key1T.setEditable(false);
    key2T.setEditable(false);

    load1B.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            loadKeyPair(key1T, 0);
          }
        });
    load2B.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            loadKeyPair(key2T, 1);
          }
        });
    genB.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            openKeyGeneratorWindow();
          }
        });
    doneB.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            step3();
          }
        });

    stackLayout.topControl = p1;
    shell.layout();
    shell.setDefaultButton(continueB);

    Swt.centerShell(shell);
    shell.open();
  }
示例#20
0
  public NewComposite(Composite parent, int style) {
    super(parent, style);

    setLayout(new GridLayout(2, false));

    GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);

    new Label(this, SWT.NONE).setText("Количество октетов:");
    spinnerOctet = new Spinner(this, SWT.BORDER);
    spinnerOctet.setLayoutData(gd);
    spinnerOctet.setMinimum(2);
    spinnerOctet.setMaximum(8);

    new Label(this, SWT.NONE).setText("Количество ключей:");
    spinnerCount = new Spinner(this, SWT.BORDER);
    spinnerCount.setLayoutData(gd);
    spinnerCount.setMinimum(1);
    spinnerCount.setMaximum(20000);

    new Label(this, SWT.NONE).setText("Настраиваемый октет:");
    textOctet = new Text(this, SWT.BORDER);
    textOctet.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    textOctet.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            int len = event.text.length();
            if (len > 0) {
              int allowed = CUSTOM_OCTET_LENGTH - ((Text) event.widget).getText().length();
              if (len > allowed) {
                event.text = event.text.substring(0, allowed);
              }
              if (!PATTERN_ALPHANUM.matcher(event.text).matches()) {
                event.doit = false;
              } else {
                event.text = event.text.toUpperCase();
              }
            }
          }
        });

    new Label(this, SWT.NONE).setText("Комментарий:");
    textComment = new Text(this, SWT.BORDER);
    textComment.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    new Label(this, SWT.NONE).setText("Начало действия ключа:");
    dtFrom = new DateTime(this, SWT.BORDER | SWT.DATE);
    Calendar calendar = Calendar.getInstance();
    dtFrom.setDate(
        calendar.get(Calendar.YEAR),
        calendar.get(Calendar.MONTH),
        calendar.get(Calendar.DAY_OF_MONTH));

    new Label(this, SWT.NONE).setText("Окончание действия ключа:");
    dtTo = new DateTime(this, SWT.BORDER | SWT.DATE);
    calendar.add(Calendar.YEAR, 1);
    dtTo.setDate(
        calendar.get(Calendar.YEAR),
        calendar.get(Calendar.MONTH),
        calendar.get(Calendar.DAY_OF_MONTH));

    Button button = new Button(this, SWT.PUSH);
    button.setImage(new Image(getShell().getDisplay(), getClass().getResourceAsStream("/new.gif")));
    GridData buttonGridData = new GridData(SWT.NONE, SWT.NONE, false, false, 2, 1);
    button.setLayoutData(buttonGridData);
    button.setText("Создать");
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            generate();
            buttonSave.setEnabled(true);
          }
        });

    tableSet = new SetTable(this, false);
    tableSet.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));

    tableKey = new KeyTable(this);
    GridData gdKeyTable = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gdKeyTable.heightHint = 50;
    tableKey.setLayoutData(gdKeyTable);

    buttonSave = new Button(this, SWT.PUSH);
    buttonSave.setLayoutData(buttonGridData);
    buttonSave.setText("Сохранить");
    buttonSave.setImage(
        new Image(getShell().getDisplay(), getClass().getResourceAsStream("/export.gif")));
    buttonSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            save();
            buttonSave.setEnabled(false);
          }
        });
    buttonSave.setEnabled(false);
  }