コード例 #1
0
  /**
   * This helper method puts the step configuration stored in the meta object and puts it into the
   * dialog controls.
   */
  private void populateDialog() {
    wRemoveBlanks.setSelection(meta.isConsecutiveDelimsAsOne());
    if (meta.getSourceFields() != null) {
      for (int i = 0; i < meta.getSourceFields().length; i++) {
        TableItem item = wGroup.table.getItem(i);
        if (meta.getSourceFields()[i] != null) {
          item.setText(1, meta.getSourceFields()[i]);
        }
        if (meta.getSourceDelims()[i] != null) {
          item.setText(2, meta.getSourceDelims()[i]);
        }
        if (meta.getOutputFields()[i] != null) {
          item.setText(3, meta.getOutputFields()[i]);
        }
        if (meta.getOutputDelims()[i] != null) {
          item.setText(4, meta.getOutputDelims()[i]);
        }
      }
    }

    wGroup.setRowNums();
    wGroup.optWidth(true);

    wStepname.selectAll();
    wStepname.setFocus();
  }
コード例 #2
0
 public void valueChanged(ListSelectionEvent event) {
   if (table.getSelectedRow() == -1) textArea.setText(null);
   else {
     TableItem item = table.getTableItemAt(table.getSelectedRow());
     textArea.setText(item.toString());
   }
   textArea.setCaretPosition(0);
 }
コード例 #3
0
 private void newEntry() {
   DataEntryDialog dialog = new DataEntryDialog(shell);
   dialog.setLabels(columnNames);
   String[] data = dialog.open();
   if (data != null) {
     TableItem item = new TableItem(table, SWT.NONE);
     item.setText(data);
     isModified = true;
   }
 }
コード例 #4
0
 private void editEntry(TableItem item) {
   DataEntryDialog dialog = new DataEntryDialog(shell);
   dialog.setLabels(columnNames);
   String[] values = new String[table.getColumnCount()];
   for (int i = 0; i < values.length; i++) {
     values[i] = item.getText(i);
   }
   dialog.setValues(values);
   values = dialog.open();
   if (values != null) {
     item.setText(values);
     isModified = true;
   }
 }
コード例 #5
0
  protected TableItem newOrderedTableItem(Mapping mapping, boolean selected) {
    TableItem[] items = fOrderedTable.getItems();
    int i = 0;
    while (i < items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0)
      i++;

    TableItem item = new TableItem(fOrderedTable, SWT.NULL, i);

    String[] values = new String[] {mapping.getElement(), mapping.getSignature()};
    item.setText(values);
    item.setData(mapping);
    if (selected) fOrderedTable.setSelection(i);

    return item;
  }
コード例 #6
0
  private boolean findMatch(
      String searchString, TableItem item, int column, boolean matchWord, boolean matchCase) {

    String tableText = matchCase ? item.getText(column) : item.getText(column).toLowerCase();
    if (matchWord) {
      if (tableText != null && tableText.equals(searchString)) {
        return true;
      }

    } else {
      if (tableText != null && tableText.indexOf(searchString) != -1) {
        return true;
      }
    }
    return false;
  }
コード例 #7
0
  /** Called when the user confirms the dialog */
  private void ok() {
    // The "stepname" variable will be the return value for the open() method.
    // Setting to step name from the dialog control
    stepname = wStepname.getText();
    // Setting the  settings to the meta object
    meta.setConsecutiveDelimsAsOne(wRemoveBlanks.getSelection());
    int nrfields = wGroup.nrNonEmpty();
    meta.allocate(nrfields);
    for (int i = 0; i < nrfields; i++) {
      TableItem item = wGroup.getNonEmpty(i);
      meta.getSourceFields()[i] = item.getText(1);
      meta.getSourceDelims()[i] = item.getText(2);
      meta.getOutputFields()[i] = item.getText(3);
      meta.getOutputDelims()[i] = item.getText(4);
    }

    // close the SWT dialog window
    dispose();
  }
コード例 #8
0
  protected TableItem newMappingsTableItem(Mapping mapping, boolean selected) {
    TableItem[] items = fMappingsTable.getItems();
    int i = 0;
    while (i < items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0)
      i++;
    TableItem item = new TableItem(fMappingsTable, SWT.NULL, i);
    String idtext = mapping.getIdAttribute();
    String idtype;
    if (idtext.charAt(0) == XMLStructureCreator.ID_TYPE_BODY) {
      idtext = idtext.substring(1, idtext.length());
      idtype = IDTYPE_CHILDBODY;
    } else idtype = IDTYPE_ATTRIBUTE;

    String[] values = new String[] {mapping.getElement(), mapping.getSignature(), idtext, idtype};
    item.setText(values);
    item.setData(mapping);
    if (selected) fMappingsTable.setSelection(i);

    return item;
  }
コード例 #9
0
 private void launchEditor(TableItem item) {
   String theCommand = resUser.getString("Custom_editor");
   theCommand = theCommand.replaceAll("%file%", item.getText(3));
   theCommand = theCommand.replaceAll("%line%", item.getText(1));
   theCommand = theCommand.replace('/', File.separatorChar);
   theCommand = theCommand.replaceAll("%slash%", "/");
   try {
     Runtime.getRuntime().exec(theCommand);
   } catch (IOException e) {
     displayError("Error launching editor: " + e.getMessage());
   }
 }
コード例 #10
0
 protected TableItem newIdMapsTableItem(IdMap idmap, boolean selected) {
   // find index where to insert table entry
   TableItem[] items = fIdMapsTable.getItems();
   int i = 0;
   while (i < items.length && idmap.getName().compareToIgnoreCase(items[i].getText(0)) > 0) i++;
   TableItem item = new TableItem(fIdMapsTable, SWT.NULL, i);
   String[] values =
       new String[] {
         idmap.getName(),
         (idmap.isInternal())
             ? XMLCompareMessages.XMLComparePreference_topTableColumn2internal
             : XMLCompareMessages.XMLComparePreference_topTableColumn2user,
         idmap.getExtension()
       };
   item.setText(values);
   item.setData(idmap);
   if (selected) {
     fIdMapsTable.setSelection(i);
     fIdMapsTable.setFocus();
     selectionChanged();
   }
   return item;
 }
コード例 #11
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final Table table = new Table(shell, SWT.BORDER);
   table.setHeaderVisible(true);
   final TableColumn column1 = new TableColumn(table, SWT.NONE);
   column1.setText("Column 1");
   final TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("Column 2");
   TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"a", "3"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"b", "2"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"c", "1"});
   column1.setWidth(100);
   column2.setWidth(100);
   Listener sortListener =
       e -> {
         TableItem[] items = table.getItems();
         Collator collator = Collator.getInstance(Locale.getDefault());
         TableColumn column = (TableColumn) e.widget;
         int index = column == column1 ? 0 : 1;
         for (int i = 1; i < items.length; i++) {
           String value1 = items[i].getText(index);
           for (int j = 0; j < i; j++) {
             String value2 = items[j].getText(index);
             if (collator.compare(value1, value2) < 0) {
               String[] values = {items[i].getText(0), items[i].getText(1)};
               items[i].dispose();
               TableItem item1 = new TableItem(table, SWT.NONE, j);
               item1.setText(values);
               items = table.getItems();
               break;
             }
           }
         }
         table.setSortColumn(column);
       };
   column1.addListener(SWT.Selection, sortListener);
   column2.addListener(SWT.Selection, sortListener);
   table.setSortColumn(column1);
   table.setSortDirection(SWT.UP);
   shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
コード例 #12
0
    // 当用户对单元格内容进行修改 时,此方法执行. 为某个属性赋值
    public void modify(Object element, String property, Object value) {
      TableItem tableItem = (TableItem) element;
      if (tableItem == null) {
        // tableViewer.update(null, null);
        return;
      }
      Station station = (Station) tableItem.getData();
      if (station == null) {
        // tableViewer.update(null, null);
        return;
      }

      if (property.equals("name")) {
        String name = (String) value;
        station.setStation_name(name);
      } else if (property.equals("down")) {
        String down = (String) value;
        if (down.length() > 0) {
          station.setStation_downnumber(Integer.parseInt(down));
        }
      } else if (property.equals("up")) {
        String up = (String) value;
        if (up.length() > 0) {
          station.setStation_upnumber(Integer.parseInt(up));
        }
      } else if (property.equals("map")) {
        Integer comboIndex = (Integer) value;
        if (comboIndex.intValue() != -1) {
          String mapName = StationData.MAPS[comboIndex.intValue()];
          station.setStation_graph(mapName);
        }
      }

      // System.out.println("Modiy:" + value +"::"+columnIndex);
      /*List list = Arrays.asList(stationData.columnHeads);
       	  int columnIndex = list.indexOf(property);
       	  switch (columnIndex) {
       	  case 0:
       		  String id = (String) value;
       		  if (id.length() > 0) {
       			  station.setStation_id(Integer.parseInt(id));
       		  }
       		  break;
       	  case 1:
       		  String name = (String) value;
       		  if (name.length() > 0) {
       			  station.setStation_name(name);
       		  }
       		  break;

       	  case 2:
       		  String down = (String) value;
       		  if (down.length() > 0) {
       			  station.setStation_downnumber(Integer.parseInt(down));
       		  }
       		  break;
       	  case 3:
       		  String up = (String) value;
       		  if (up.length() > 0) {
       			  station.setStation_upnumber(Integer.parseInt(up));
       		  }
       		  break;
        	case 4:
        	   Integer comboIndex = (Integer) value;
              if(comboIndex.intValue() != -1){
           	  String mapName = StationData.MAPS[comboIndex.intValue()];
        station.setStation_graph(mapName);
       }
       break;
      }
      */
      tableViewer.update(station, null);
    }
コード例 #13
0
  private void openAddressBook() {
    FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);

    fileDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"});
    fileDialog.setFilterNames(
        new String[] {
          resAddressBook.getString("Book_filter_name") + " (*.adr)",
          resAddressBook.getString("All_filter_name") + " (*.*)"
        });
    String name = fileDialog.open();

    if (name == null) return;
    File file = new File(name);
    if (!file.exists()) {
      displayError(
          resAddressBook.getString("File")
              + file.getName()
              + " "
              + resAddressBook.getString("Does_not_exist"));
      return;
    }

    Cursor waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);

    FileReader fileReader = null;
    BufferedReader bufferedReader = null;
    String[] data = new String[0];
    try {
      fileReader = new FileReader(file.getAbsolutePath());
      bufferedReader = new BufferedReader(fileReader);
      String nextLine = bufferedReader.readLine();
      while (nextLine != null) {
        String[] newData = new String[data.length + 1];
        System.arraycopy(data, 0, newData, 0, data.length);
        newData[data.length] = nextLine;
        data = newData;
        nextLine = bufferedReader.readLine();
      }
    } catch (FileNotFoundException e) {
      displayError(resAddressBook.getString("File_not_found") + "\n" + file.getName());
      return;
    } catch (IOException e) {
      displayError(resAddressBook.getString("IO_error_read") + "\n" + file.getName());
      return;
    } finally {

      shell.setCursor(null);

      if (fileReader != null) {
        try {
          fileReader.close();
        } catch (IOException e) {
          displayError(resAddressBook.getString("IO_error_close") + "\n" + file.getName());
          return;
        }
      }
    }

    String[][] tableInfo = new String[data.length][table.getColumnCount()];
    int writeIndex = 0;
    for (int i = 0; i < data.length; i++) {
      String[] line = decodeLine(data[i]);
      if (line != null) tableInfo[writeIndex++] = line;
    }
    if (writeIndex != data.length) {
      String[][] result = new String[writeIndex][table.getColumnCount()];
      System.arraycopy(tableInfo, 0, result, 0, writeIndex);
      tableInfo = result;
    }
    Arrays.sort(tableInfo, new RowComparator(0));

    for (int i = 0; i < tableInfo.length; i++) {
      TableItem item = new TableItem(table, SWT.NONE);
      item.setText(tableInfo[i]);
    }
    shell.setText(resAddressBook.getString("Title_bar") + fileDialog.getFileName());
    isModified = false;
    this.file = file;
  }
コード例 #14
0
  private void openAddressBook(String name) {
    if (name == null) return;
    File file = new File(name);
    if (!file.exists()) {
      displayError(
          resMessages.getString("File")
              + file.getName()
              + " "
              + resMessages.getString("Does_not_exist"));
      return;
    }

    Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);

    FileReader fileReader = null;
    BufferedReader bufferedReader = null;
    String[] data = new String[0];
    try {
      fileReader = new FileReader(file.getAbsolutePath());
      bufferedReader = new BufferedReader(fileReader);
      String nextLine = bufferedReader.readLine();
      while (nextLine != null) {
        String[] newData = new String[data.length + 1];
        System.arraycopy(data, 0, newData, 0, data.length);
        newData[data.length] = nextLine;
        data = newData;
        nextLine = bufferedReader.readLine();
      }
    } catch (FileNotFoundException e) {
      displayError(resMessages.getString("File_not_found") + "\n" + file.getName());
      return;
    } catch (IOException e) {
      displayError(resMessages.getString("IO_error_read") + "\n" + file.getName());
      return;
    } finally {

      shell.setCursor(null);
      waitCursor.dispose();

      if (fileReader != null) {
        try {
          fileReader.close();
        } catch (IOException e) {
          displayError(resMessages.getString("IO_error_close") + "\n" + file.getName());
          return;
        }
      }
    }

    String[][] tableInfo = new String[data.length][table.getColumnCount()];
    for (int i = 0; i < data.length; i++) {
      tableInfo[i] = decodeLine(data[i]);
    }

    Arrays.sort(tableInfo, new RowComparator(0));

    for (int i = 0; i < tableInfo.length; i++) {
      TableItem item = new TableItem(table, SWT.NONE);
      item.setText(tableInfo[i]);
    }
    shell.setText(resMessages.getString("Title_bar") + file.getName());
    isModified = false;
    this.file = file;
  }