예제 #1
0
 private static String remainingHddSpace() {
   long space = (new File(Messages.getScFolder())).getUsableSpace() / 1024 / 1024 / 1024;
   return new BigDecimal(space).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
 }
예제 #2
0
  public void createPartControl(Composite parent) {
    statusline = getViewSite().getActionBars().getStatusLineManager();
    statusline.setMessage(
        Activator.getImageDescriptor("icons/info.png").createImage(),
        Messages.StatusLine_DropFilesHint);
    makeActions();

    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    Composite content = new Composite(scrolledComposite, SWT.NONE);
    content.setLayout(new GridLayout(1, false));
    scrolledComposite.setContent(content);

    toolBarManager = new ToolBarManager();
    toolBarManager.add(encryptFilesAction);
    toolBarManager.add(newFolderAction);
    toolBarManager.add(new Separator("static"));
    toolBarManager.add(exportSelectionAction);
    toolBarManager.add(renameAction);
    toolBarManager.add(deleteSelectionAction);
    toolBarManager.add(new Separator("static"));
    toolBarManager.add(expandAllAction);
    toolBarManager.add(collapseAllAction);

    ToolBar toolbar = toolBarManager.createControl(content);
    toolbar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));

    // Create the tree viewer as a child of the composite parent
    treeViewer =
        new TreeViewer(
            content, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

    // Anpassungen für TreeTable
    tree = treeViewer.getTree();

    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    treeViewer.getControl().setLayoutData(gridData);

    treeViewer.setUseHashlookup(true);

    /** * Tree table specific code starts ** */
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);

    for (SteadyTableIdentifier identifier : SteadyTableIdentifier.values()) {
      new TreeColumn(tree, SWT.NONE).setText(Messages.getSteadyTableColumnTitle(identifier));
      tree.getColumn(identifier.ordinal()).setWidth(identifier.columnWidth);
    }

    /** * Tree table specific code ends ** */

    // layout the tree viewer below the text field
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    treeViewer.getControl().setLayoutData(gridData);

    treeViewer.setContentProvider(new SteadyTreeTableContentProvider());
    treeViewer.setLabelProvider(new SteadyTreeTableLabelProvider());

    root = getInitialInput();
    treeViewer.setInput(root);
    treeViewer.expandToLevel(1);

    // Drag-Part //////////////////////////////////////////////////////////
    DragSource source = new DragSource(tree, DND.DROP_COPY | DND.DROP_MOVE);
    source.setTransfer(new Transfer[] {TextTransfer.getInstance()});
    source.addDragListener(new TreeDragSourceListener(tree));

    // Drop-Part //////////////////////////////////////////////////////////
    DropTarget dropTarget = new DropTarget(tree, DND.DROP_COPY | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] {TextTransfer.getInstance(), FileTransfer.getInstance()});
    dropTarget.addDropListener(new TreeDropTargetAdapter(treeViewer, root));

    addListeners();
    createContextMenu();
    createFiltersAndSorters();
  }