Java Code Examples for org.eclipse.swt.widgets.TreeColumn#getData()

The following examples show how to use org.eclipse.swt.widgets.TreeColumn#getData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected void handleUniqeValuesColumn() {
   TreeColumn treeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn xCol = (XViewerColumn) treeCol.getData();

   TreeItem[] items = xViewer.getTree().getSelection();
   if (items.length == 0) {
      items = xViewer.getTree().getItems();
   }
   if (items.length == 0) {
      XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.no_items.sum")); //$NON-NLS-1$ //$NON-NLS-2$
      return;
   }
   Set<String> values = new HashSet<>();
   for (TreeItem item : items) {
      for (int x = 0; x < xViewer.getTree().getColumnCount(); x++) {
         if (xViewer.getTree().getColumn(x).equals(treeCol)) {
            values.add(((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(item.getData(), x));
         }
      }
   }
   String html = HtmlUtil.simplePage(HtmlUtil.textToHtml(CollectionsUtil.toString("\n", values))); //$NON-NLS-1$
   new HtmlDialog(XViewerText.get("dialog.unique.title"), XViewerText.get("dialog.unique.prompt", xCol.getName()), //$NON-NLS-1$ //$NON-NLS-2$
      html).open();
}
 
Example 2
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected void handleHideColumn() {
   TreeColumn insertTreeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn insertXCol = (XViewerColumn) insertTreeCol.getData();
   //      System.out.println("Hide column " + insertXCol);
   CustomizeData custData = xViewer.getCustomizeMgr().generateCustDataFromTable();
   List<XViewerColumn> xCols = custData.getColumnData().getColumns();
   List<XViewerColumn> newXCols = new ArrayList<>();
   for (XViewerColumn currXCol : xCols) {
      if (currXCol.equals(insertXCol)) {
         currXCol.setShow(false);
      }
      newXCols.add(currXCol);
   }
   custData.getColumnData().setColumns(newXCols);
   xViewer.getCustomizeMgr().loadCustomization(custData);
   xViewer.refresh();
}
 
Example 3
Source File: ViewSelectedCellDataAction.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void run(TreeColumn treeCol, TreeItem treeItem, int columnNum) throws XViewerException, Exception {
   if (treeCol != null) {
      XViewerColumn xCol = (XViewerColumn) treeCol.getData();
      String data = null;

      if (xCol instanceof IXViewerValueColumn) {
         data = ((IXViewerValueColumn) xCol).getColumnText(treeItem.getData(), xCol, columnNum);
      } else {
         data =
            ((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(treeItem.getData(), xCol, columnNum);
      }
      if (data != null && !data.equals("")) { //$NON-NLS-1$
         if (option == Option.View) {
            String html = HtmlUtil.simplePage(HtmlUtil.getPreData(data));
            new HtmlDialog(treeCol.getText() + " " + XViewerText.get("data"), //$NON-NLS-1$//$NON-NLS-2$
               treeCol.getText() + " " + XViewerText.get("data"), html).open(); //$NON-NLS-1$ //$NON-NLS-2$
         } else {
            clipboard.setContents(new Object[] {data}, new Transfer[] {TextTransfer.getInstance()});
         }
      }
   }
}
 
Example 4
Source File: XViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Will be called when Alt-Left-Click is done within table cell
 *
 * @return true if handled
 */
public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
   if (treeColumn.getData() instanceof XViewerColumn) {
      if ((XViewerColumn) treeColumn.getData() instanceof IAltLeftClickProvider) {
         return ((IAltLeftClickProvider) (XViewerColumn) treeColumn.getData()).handleAltLeftClick(treeColumn,
            treeItem);
      }
   }
   return false;
}
 
Example 5
Source File: XViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void handleColumnMultiEdit(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
   if (treeColumn.getData() instanceof XViewerColumn) {
      if ((XViewerColumn) treeColumn.getData() instanceof IMultiColumnEditProvider) {
         ((IMultiColumnEditProvider) (XViewerColumn) treeColumn.getData()).handleColumnMultiEdit(treeColumn,
            treeItems);
      }
   }
}
 
Example 6
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected void handleAddComputedColumn() {
   TreeColumn insertTreeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn insertXCol = (XViewerColumn) insertTreeCol.getData();
   XCheckFilteredTreeDialog dialog = new XCheckFilteredTreeDialog("", //$NON-NLS-1$
      XViewerText.get("dialog.add_column.prompt", insertXCol.getName(), //$NON-NLS-1$
         insertXCol.getId()),
      patternFilter, new ArrayTreeContentProvider(), new XViewerColumnLabelProvider(), new XViewerColumnSorter());
   Collection<XViewerComputedColumn> computedCols = xViewer.getComputedColumns(insertXCol);
   if (computedCols.isEmpty()) {
      XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.no_computed")); //$NON-NLS-1$ //$NON-NLS-2$
      return;
   }
   dialog.setInput(computedCols);
   if (dialog.open() == 0) {
      //         System.out.println("Selected " + dialog.getChecked());
      //         System.out.println("Selected column to add before " + insertXCol);
      CustomizeData custData = xViewer.getCustomizeMgr().generateCustDataFromTable();
      List<XViewerColumn> xCols = custData.getColumnData().getColumns();
      List<XViewerColumn> newXCols = new ArrayList<>();
      for (XViewerColumn currXCol : xCols) {
         if (currXCol.equals(insertXCol)) {
            for (Object obj : dialog.getChecked()) {
               XViewerComputedColumn newComputedXCol = ((XViewerComputedColumn) obj).copy();
               newComputedXCol.setShow(true);
               newComputedXCol.setSourceXViewerColumn(insertXCol);
               newComputedXCol.setXViewer(xViewer);
               newXCols.add(newComputedXCol);
            }
         }
         newXCols.add(currXCol);
      }
      custData.getColumnData().setColumns(newXCols);
      xViewer.getCustomizeMgr().loadCustomization(custData);
      xViewer.refresh();
   }
}
 
Example 7
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected void handleSumColumn() {
   TreeColumn treeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn xCol = (XViewerColumn) treeCol.getData();
   if (!xCol.isSummable()) {
      XViewerLib.popup("Invalid Selection for Sum",
         String.format("Sum not available for column [%s]", xCol.getName()));
      return;
   }

   TreeItem[] items = xViewer.getTree().getSelection();
   if (items.length == 0) {
      items = xViewer.getTree().getItems();
   }
   if (items.length == 0) {
      XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.no_items.sum")); //$NON-NLS-1$ //$NON-NLS-2$
      return;
   }
   List<String> values = new ArrayList<>();
   for (TreeItem item : items) {
      for (int x = 0; x < xViewer.getTree().getColumnCount(); x++) {
         if (xViewer.getTree().getColumn(x).equals(treeCol)) {
            values.add(((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(item.getData(), x));
         }
      }
   }
   XViewerLib.popup(XViewerText.get("menu.sum.prompt"), xCol.sumValues(values)); //$NON-NLS-1$
}
 
Example 8
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected void handleAverageColumn() {
   TreeColumn treeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn xCol = (XViewerColumn) treeCol.getData();
   if (!xCol.isSummable()) {
      XViewerLib.popup("Invalid Selection for Average",
         String.format("Average not available for column [%s]", xCol.getName()));
      return;
   }

   TreeItem[] items = xViewer.getTree().getSelection();
   if (items.length == 0) {
      items = xViewer.getTree().getItems();
   }
   if (items.length == 0) {
      XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.no_items.average")); //$NON-NLS-1$ //$NON-NLS-2$
      return;
   }
   List<String> values = new ArrayList<>();
   for (TreeItem item : items) {
      for (int x = 0; x < xViewer.getTree().getColumnCount(); x++) {
         if (xViewer.getTree().getColumn(x).equals(treeCol)) {
            values.add(((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(item.getData(), x));
         }
      }
   }
   XViewerLib.popup(XViewerText.get("menu.sum.prompt"), xCol.averageValues(values)); //$NON-NLS-1$
}
 
Example 9
Source File: CustomizeManager.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public List<XViewerColumn> getCurrentTableColumnsInOrder() {
   List<XViewerColumn> columns = new ArrayList<>(15);
   for (Integer index : xViewer.getTree().getColumnOrder()) {
      TreeColumn treeCol = xViewer.getTree().getColumn(index);
      XViewerColumn xCol = (XViewerColumn) treeCol.getData();
      columns.add(xCol);
   }
   return columns;
}
 
Example 10
Source File: CustomizeManager.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Return index of XColumn to original column index on creation of table. Since table allows drag re-ordering of
 * columns, this index will provide the map back to the original column index. Used for label providers
 * getColumnText(object, index)
 */
public Map<XViewerColumn, Integer> getCurrentTableColumnsIndex() {
   int[] index = xViewer.getTree().getColumnOrder();
   Map<XViewerColumn, Integer> xColToColumnIndex = new HashMap<>(index.length);
   for (int x = 0; x < index.length; x++) {
      TreeColumn treeCol = xViewer.getTree().getColumn(index[x]);
      XViewerColumn xCol = (XViewerColumn) treeCol.getData();
      xColToColumnIndex.put(xCol, index[x]);
   }
   return xColToColumnIndex;
}
 
Example 11
Source File: CustomizeManager.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public int getColumnNumFromXViewerColumn(XViewerColumn xCol) {
   for (Integer index : xViewer.getTree().getColumnOrder()) {
      TreeColumn treeCol = xViewer.getTree().getColumn(index);
      XViewerColumn treeXCol = (XViewerColumn) treeCol.getData();
      if (xCol.equals(treeXCol)) {
         return index;
      }
   }
   return 0;
}
 
Example 12
Source File: CustomizeManager.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public Pair<XViewerColumn, Integer> getColumnNumFromXViewerColumn(String columnId) {
   if (!xViewer.getTree().isDisposed()) {
      for (Integer index : xViewer.getTree().getColumnOrder()) {
         TreeColumn treeCol = xViewer.getTree().getColumn(index);
         XViewerColumn treeXCol = (XViewerColumn) treeCol.getData();
         if (treeXCol.getId().equals(columnId)) {
            return new Pair<>(treeXCol, index);
         }
      }
   }
   return null;
}