Пример #1
0
 protected void doInsert(TestModelChange change) {
   if (fViewer instanceof ListViewer) {
     if (change.getParent() != null && change.getParent().equals(fViewer.getInput())) {
       ((ListViewer) fViewer).add(change.getChildren());
     }
   } else if (fViewer instanceof TableViewer) {
     if (change.getParent() != null && change.getParent().equals(fViewer.getInput())) {
       ((TableViewer) fViewer).add(change.getChildren());
     }
   } else if (fViewer instanceof AbstractTreeViewer) {
     ((AbstractTreeViewer) fViewer).add(change.getParent(), change.getChildren());
   } else if (fViewer instanceof ComboViewer) {
     ((ComboViewer) fViewer).add(change.getChildren());
   } else {
     Assert.isTrue(false, "Unknown kind of viewer");
   }
 }
  public void updateList() {

    //		String[] selection = fileExtList.getSelection();
    //		fileExtList.removeAll();
    //		SortedSet<String> keys = new TreeSet<String>();
    //		keys.addAll(delegateConfigs.keySet());
    //		for (String fileExt : keys) {
    //			fileExtList.add(fileExt);
    //		}
    //		fileExtList.setSelection(selection);

    // does only remember the first selection out of a (possible larger) set of selections
    /*		String selection = "";
    if (fileExtListViewer.getSelection() instanceof IStructuredSelection) {
    	IStructuredSelection structuredSelection = (IStructuredSelection) fileExtListViewer.getSelection();
    	if (structuredSelection.getFirstElement() instanceof String) {
    		selection = (String)structuredSelection.getFirstElement();
    	}
    }*/

    String[] selections = null; // = new String[];

    if (fileExtListViewer.getSelection() instanceof IStructuredSelection) {
      IStructuredSelection structuredSelection =
          (IStructuredSelection) fileExtListViewer.getSelection();
      int amountOfChosenEntries = structuredSelection.toList().size();
      selections = new String[amountOfChosenEntries];
      for (int j = 0; j < amountOfChosenEntries; j++) {
        selections[j] = (String) structuredSelection.toList().get(j);
      }
    }

    fileExtListViewer.setInput(null);
    SortedSet<String> keys = new TreeSet<String>();
    keys.addAll(delegateConfigs.keySet());
    for (String fileExt : keys) {
      fileExtListViewer.add(fileExt);
    }

    if (selections != null) {
      fileExtListViewer.getList().setSelection(selections);
    }
  }
  private void handleZipFile(File f, File uploadDir) throws IOException {
    ZipFile zipFile = new ZipFile(f, "UTF-8", true);
    Enumeration entries = zipFile.getEntries();

    while (entries.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) entries.nextElement();

      InputStream zipin = zipFile.getInputStream(entry);
      File dest = new File(uploadDir, entry.getName());
      OutputStream fileout = new FileOutputStream(dest);
      StreamUtils.copyThenClose(zipin, fileout);

      viewer.add(new UploadItem(zipin, "", dest.getName(), ""));
      if (dest.getName().endsWith("shp")) {
        list.add(dest.toURI().toURL());
      }
    }
    f.delete();
  }
Пример #4
0
  @Override
  public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);

    layout.numColumns = 2;
    Label label1 = new Label(container, SWT.NULL);
    label1.setText("Select Your Agent");
    listViewer = new ListViewer(container);
    list.add("Big Travels");
    list.add("Aviator Travels");
    list.add("BTM Travels");
    list.add("Arihanth Travels");
    list.add("Atlas Travels");
    Object[] list1 = list.toArray();
    listViewer.add(list1);

    Label label2 = new Label(container, SWT.NULL);
    label2.setText("Select travel start date:");
    dateFrom = new DateTime(container, SWT.BORDER | SWT.DATE | SWT.DROP_DOWN);
    listViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            sb = "";
            // sb.append("tatal " + selection.size() + " items selected: ");
            for (java.util.Iterator iterator = selection.iterator(); iterator.hasNext(); ) {
              sb = (String) (iterator.next());
              // sb.replace(0,sb.length(),(String) iterator.next());
              break;
            }

            System.out.println("Your agent is " + sb);
          }
        });
    dateFrom.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {

            // System.out.println ("Calendar date selected (MM/DD/YYYY) = " + (dateFrom.getMonth ()
            // + 1) + "/" + dateFrom.getDay () + "/" + dateFrom.getYear ());
            date.delete(0, date.length());
            date.append((dateFrom.getMonth() + 1));
            date.append("/");
            date.append(dateFrom.getDay());
            date.append("/");
            date.append(dateFrom.getYear());
            // System.out.println("After adding to date "+date);
            // System.out.println ("Date selected (MM/YYYY) = " + (date.getMonth () + 1) + "/" +
            // date.getYear ());

            // System.out.println ("Time selected (HH:MM) = " + time.getHours () + ":" +
            // (time.getMinutes () < 10 ? "0" : "") + time.getMinutes ());

            // dialog.close ();

          }
        });

    // dateFrom.setDate();
    /*L bel label1 = new Label(container, SWT.NULL);
    label1.setText("Travel Name");

    text1 = new Text(container, SWT.BORDER | SWT.SINGLE);
    text1.setText("");
    text1.addKeyListener(new KeyListener() {

      @Override
      public void keyPressed(KeyEvent e) {
      }

      @Override
      public void keyReleased(KeyEvent e) {
        if (!text1.getText().isEmpty()) {
          setPageComplete(true);

        }
      }

    });*/
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    // listViewer.setLayoutData(gd);
    // Required to avoid an error in the system
    setControl(container);
    setPageComplete(false);
  }