Beispiel #1
0
  @Override
  public Composite createUI(Composite parent) {
    this.display = WorkPart.display();
    Shell shell = new Shell(this.display);
    shell.setSize(50, 100);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    shell.setLayout(gridLayout);
    ProgressBar pb = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE);
    pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label searching = new Label(shell, SWT.NONE);
    searching.setText("Searching...");
    shell.open();
    this.isSearching = true;
    new Thread() {
      public void run() {
        testTm_cz = RetrieveData.testTm_czConnection();
        testTm_lz = RetrieveData.testTm_lzConnection();
        testDeapp = RetrieveData.testDeappConnection();
        root = new TreeNode("Dataset explorer", null, false);
        studyTree = new StudyTree(root);
        topNodeController = new TopNodeController(root, dataType, studyTree);
        root = topNodeController.buildTree();
        topNode = dataType.getStudy().getTopNode();
        isSearching = false;
      }
    }.start();
    this.display = WorkPart.display();
    while (this.isSearching) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    shell.close();
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));
    gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    scroller.setLayout(gd);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite scrolledComposite = new Composite(scroller, SWT.NONE);
    scroller.setContent(scrolledComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 10;
    scrolledComposite.setLayout(layout);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    this.topNode = this.dataType.getStudy().getTopNode();
    if (topNode != null && topNode.compareTo("") != 0) {
      viewer = new TreeViewer(scrolledComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
      viewer.setContentProvider(new StudyContentProvider());
      viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

      viewer.setInput(this.studyTree);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalAlignment = SWT.FILL;
      gridData.verticalAlignment = SWT.FILL;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.heightHint = 300;
      gridData.widthHint = 250;
      this.viewer.getControl().setLayoutData(gridData);
      viewer.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return element.toString();
            }

            @Override
            public Color getBackground(Object element) {
              if (((TreeNode) element).isStudyRoot()) {
                return new Color(Display.getCurrent(), 237, 91, 67);
              }
              if (((TreeNode) element).isLabel()) {
                return new Color(Display.getCurrent(), 212, 212, 212);
              }
              return null;
            }
          });

      securityButton = new Button(scrolledComposite, SWT.CHECK);
      securityButton.setText("Security required");
      securityButton.addListener(
          SWT.Selection,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              security = securityButton.getSelection();
            }
          });

      /*indexesButton=new Button(scrolledComposite, SWT.CHECK);
      indexesButton.setText("Turn off the indexes during loaded (only for large datasets)");
      indexesButton.addListener(SWT.Selection, new Listener(){

      	@Override
      	public void handleEvent(Event event) {
      		indexes=indexesButton.getSelection();
      	}
      })*/ ;
    } else {
      Label label = new Label(scrolledComposite, SWT.NONE);
      label.setText("Please first choose a study node in the description data type");
    }

    Button button = new Button(scrolledComposite, SWT.PUSH);
    button.setText("Load");

    if (topNode != null && topNode.compareTo("") != 0) {
      if (this.testTm_cz && this.testTm_lz && this.testDeapp) {
        button.addListener(SWT.Selection, new LoadGeneExpressionDataListener(this, this.dataType));
        Label dbLabel = new Label(scrolledComposite, SWT.NONE);
        dbLabel.setText("You are connected to database '" + PreferencesHandler.getDb() + "'");
      } else {
        button.setEnabled(false);
        Label warn = new Label(scrolledComposite, SWT.NONE);
        warn.setText("Warning: connection to database is not possible");
      }
    } else {
      button.setEnabled(false);
    }
    scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return composite;
  }