Ejemplo n.º 1
0
  /**
   * Create the composite.
   *
   * @param parent The parent reference.
   * @param menuService The menu service reference.
   */
  @PostConstruct
  public void createComposite(Composite parent, EMenuService menuService) {
    final Listener listener = UtilSwt.createAutosizeListener();
    properties = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    properties.setLayout(new FillLayout());
    properties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    properties.setHeaderVisible(true);
    properties.addListener(SWT.Collapse, listener);
    properties.addListener(SWT.Expand, listener);

    final TreeColumn key = new TreeColumn(properties, SWT.LEFT);
    key.setText(Messages.Properties_Key);

    final TreeColumn property = new TreeColumn(properties, SWT.LEFT);
    properties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    property.setText(Messages.Properties_Value);

    addListeners(menuService);
    PropertiesModel.INSTANCE.setTree(properties);

    providersObject =
        checkPropertiesExtensionPoint(
            PropertiesProviderObject.class,
            PropertiesProviderObject.EXTENSION_ID,
            PropertiesProviderObject.EXTENSION_PROPERTIES);
    providersTile =
        checkPropertiesExtensionPoint(
            PropertiesProviderTile.class,
            PropertiesProviderTile.EXTENSION_ID,
            PropertiesProviderTile.EXTENSION_PROPERTIES);
  }
  private Tree createTree(final Composite c, final boolean left) {
    final Tree tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
    final GridData gd_list = new GridData(SWT.FILL, SWT.FILL, true, true);
    tree.setLayoutData(gd_list);
    tree.addListener(SWT.Selection, createTreeSelChangeListener(left));
    tree.addListener(SWT.Selection, this);

    return tree;
  }
Ejemplo n.º 3
0
  private void createFileListArea(Composite parent) {
    Font font = parent.getFont();
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(font);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));

    fileTree = new Tree(composite, SWT.VIRTUAL | SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.minimumHeight = 300;
    gd.minimumWidth = 350;
    fileTree.setLayoutData(gd);
    fileTree.setFont(font);
    fileTree.addListener(
        SWT.SetData,
        new Listener() {
          public void handleEvent(Event event) {
            TreeItem item = (TreeItem) event.item;
            FileInfo info = findFileInfo(item);
            if (info == null) {
              updateItems(item.getParentItem(), false);
            } else {
              fillItem(item, info);
            }
          }
        });
  }
Ejemplo n.º 4
0
 private void fillTree(Composite parent) {
   final HashMap<String, ExampleTab> exampleMap = new HashMap<String, ExampleTab>();
   final BrowserNavigation navigation = RWT.getClient().getService(BrowserNavigation.class);
   for (ExampleTab tab : createExampleTabs()) {
     TreeItem item = new TreeItem(tree, SWT.NONE);
     item.setText(tab.getName());
     item.setData(tab);
     tab.setData(item);
     exampleMap.put(tab.getId(), tab);
   }
   tree.addListener(
       SWT.Selection,
       new Listener() {
         public void handleEvent(Event event) {
           ExampleTab tab = (ExampleTab) event.item.getData();
           selectTab(tab);
           navigation.pushState(tab.getId(), null);
         }
       });
   navigation.addBrowserNavigationListener(
       new BrowserNavigationListener() {
         public void navigated(BrowserNavigationEvent event) {
           ExampleTab tab = exampleMap.get(event.getState());
           if (tab != null) {
             tree.select((TreeItem) tab.getData());
             tree.showSelection();
             selectTab(tab);
           }
         }
       });
   selectTab((ExampleTab) tree.getItem(0).getData());
 }
  public ContactTab(final Composite composite) {
    super(composite, 0);
    this.setLayout(new GridLayout(1, false));

    Composite containerHeaderSession = new Composite(this, SWT.NONE);
    containerHeaderSession.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    containerHeaderSession.setLayout(new GridLayout(2, false));
    final Combo comboSession = new Combo(containerHeaderSession, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboSession.add("分类1");
    comboSession.add("分类2");
    comboSession.add("分类3");
    comboSession.add("分类4");
    comboSession.select(0);
    final Label labelHeader1 = new Label(containerHeaderSession, SWT.NONE);
    labelHeader1.setText("共1人");

    tree =
        new Tree(
            this, /*SWT.CHECK | */
            SWT.VIRTUAL
                | SWT.MULTI
                | SWT.BORDER
                | SWT.FULL_SELECTION
                | SWT.H_SCROLL
                | SWT.V_SCROLL);
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    // tree.setRedraw(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    for (int i = 0; i < titles.length; i++) {
      TreeColumn column = new TreeColumn(tree, SWT.NONE);
      column.setText(titles[i]);
    }
    tree.addTreeListener(
        new TreeAdapter() {
          @Override
          public void treeCollapsed(TreeEvent e) {
            super.treeCollapsed(e);
            expand();
          }

          @Override
          public void treeExpanded(TreeEvent e) {
            super.treeExpanded(e);
            expand();
          }

          private void expand() {
            // System.out.println("expand...");
            isExpanding = true;
            Display.getDefault()
                .timerExec(
                    500,
                    new Runnable() {
                      public void run() {
                        isExpanding = false;
                        // System.out.println("isGroupClick: " + isGroupClick);
                      }
                    });
          }
        });
    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent event) {
            super.mouseDown(event);
          }

          @Override
          public void mouseDoubleClick(MouseEvent event) {
            super.mouseDoubleClick(event);
            Point point = new Point(event.x, event.y);
            TreeItem item = tree.getItem(point);
            // System.out.println("Mouse double click: " + item);
            if (item != null && item.getData() != null && isExpanding == false) {
              ContactInfoDialog dialog =
                  new ContactInfoDialog(getParent().getShell(), ContactInfoComposite.TYPE_EDIT);
              ContactInfo info = (ContactInfo) item.getData();
              dialog.setData(info);
              if (dialog.open() == ContactInfoDialog.OK) {
                AppData.getInstance().getMainWin().refreshContactData(true);
              }
            }
          }
        });
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            if (event.detail == SWT.CHECK) {
              TreeItem item = (TreeItem) event.item;
              boolean checked = item.getChecked();
              UIUtil.checkItems(item, checked);
              UIUtil.checkPath(item.getParentItem(), checked, false);
            } else {
              TreeItem item = (TreeItem) event.item;
              ContactInfo info = null;
              if (item != null && item.getData() != null) {
                info = (ContactInfo) item.getData();
              }
              AppData.getInstance().getMainWin().showDetail(info);
            }
          }
        });

    setupPopupMenu();

    Composite containerHeaderEdit = new Composite(this, SWT.NONE);
    containerHeaderEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    containerHeaderEdit.setLayout(new GridLayout(7, false));

    final Label labelCatalog = new Label(containerHeaderEdit, SWT.PUSH);
    labelCatalog.setText("小类:");
    final Combo comboCatalog = new Combo(containerHeaderEdit, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboCatalog.add("小类1");
    comboCatalog.add("小类2");
    final Label labelSearch = new Label(containerHeaderEdit, SWT.PUSH);
    labelSearch.setText("联系人搜索:");
    final Text textSearch = new Text(containerHeaderEdit, SWT.BORDER);
    textSearch.setLayoutData(new GridData(150, SWT.DEFAULT));

    final Button buttonAdd = new Button(containerHeaderEdit, SWT.PUSH);
    buttonAdd.setText("新增...");
    buttonAdd.setLayoutData(new GridData(100, SWT.DEFAULT));
    buttonAdd.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            AppData.getInstance().getMainWin().addContact();
          }
        });
    final Button buttonImport = new Button(containerHeaderEdit, SWT.PUSH);
    buttonImport.setText("导入...");
    buttonImport.setLayoutData(new GridData(100, SWT.DEFAULT));
    final Button buttonExport = new Button(containerHeaderEdit, SWT.PUSH);
    buttonExport.setText("导出...");
    buttonExport.setLayoutData(new GridData(100, SWT.DEFAULT));

    if (!USE_PACK) {
      for (int i = 0; i < titles.length; i++) {
        if (i == 0) {
          tree.getColumn(i).setWidth(200);
        } else {
          tree.getColumn(i).setWidth(100);
        }
      }
    }
    if (USE_VIRTUAL) {
      tree.addListener(
          SWT.SetData,
          new Listener() {
            @Override
            public void handleEvent(Event event) {
              TreeItem item = (TreeItem) event.item;
              TreeItem parentItem = item.getParentItem();
              String text = null;
              if (parentItem == null) {
                ContactGroupInfo groupInfo = groupInfoList.get(tree.indexOf(item));
                text = groupInfo.getGroupName() + " (共" + groupInfo.getSize() + "人)";
                item.setText(text);
                item.setItemCount(groupInfo.getSize());
                item.setExpanded(true);
              } else {
                ContactGroupInfo groupInfo = groupInfoList.get(tree.indexOf(parentItem));
                ContactInfo info = results.get(groupInfo.getIndex(parentItem.indexOf(item)));
                fillItem(item, info);
              }
              if (USE_PACK) {
                packTable();
              }
            }
          });
    }
    reloadData(false);
  }
Ejemplo n.º 6
0
  // --------------------------------------------------------------------------------
  public void init2() {
    parent.setLayout(new FormLayout());

    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);

    tree = new Tree(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);

    FormData d1 = new FormData();
    d1.top = new FormAttachment(0, 1);
    d1.left = new FormAttachment(0, 1);
    d1.right = new FormAttachment(100, -1);
    d1.bottom = new FormAttachment(100, -1);
    tree.setLayoutData(d1);

    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Data Type");

    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            onSashResize();
          }
        });

    FormData fd_composite1 = new FormData();
    fd_composite1.top = new FormAttachment(0, 1);
    fd_composite1.bottom = new FormAttachment(0, 35);
    fd_composite1.right = new FormAttachment(100, -1);
    fd_composite1.left = new FormAttachment(0, 1);
    editorComposite.setLayoutData(fd_composite1);
    editorComposite.setLayout(new FormLayout());
    Label nameLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_nameLabel = new FormData();
    fd_nameLabel.right = new FormAttachment(0, 66);
    fd_nameLabel.bottom = new FormAttachment(0, 32);
    fd_nameLabel.top = new FormAttachment(0, 12);
    fd_nameLabel.left = new FormAttachment(0, 10);
    nameLabel.setLayoutData(fd_nameLabel);
    nameLabel.setText("Name :");
    Label valueLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_valueLabel = new FormData();
    fd_valueLabel.top = new FormAttachment(nameLabel, 15);
    fd_valueLabel.left = new FormAttachment(0, 10);
    fd_valueLabel.bottom = new FormAttachment(nameLabel, 34, SWT.BOTTOM);
    fd_valueLabel.right = new FormAttachment(nameLabel, 0, SWT.RIGHT);
    valueLabel.setLayoutData(fd_valueLabel);
    valueLabel.setText("Value :");

    valueText =
        new Text(
            editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    valueText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            verifyData();
          }
        });
    valueText.setEnabled(false);
    valueText.setEditable(false);
    FormData fd_valueText = new FormData();
    fd_valueText.top = new FormAttachment(nameLabel, 5);
    fd_valueText.bottom = new FormAttachment(100, -80);
    fd_valueText.right = new FormAttachment(100, -20);
    fd_valueText.left = new FormAttachment(valueLabel, 0, SWT.RIGHT);
    valueText.setLayoutData(fd_valueText);

    updateButton = new Button(editorComposite, SWT.NONE);
    updateButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            onUpdateButtonSelect();
          }
        });
    updateButton.setEnabled(false);
    FormData fd_updateButton = new FormData();
    fd_updateButton.left = new FormAttachment(100, -120);
    fd_updateButton.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    updateButton.setLayoutData(fd_updateButton);
    updateButton.setText("Update");

    typeCombo = new Combo(editorComposite, SWT.READ_ONLY);
    fd_updateButton.top = new FormAttachment(typeCombo, 10);
    typeCombo.setEnabled(false);
    FormData fd_typeList = new FormData();
    fd_typeList.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_typeList.top = new FormAttachment(valueText, 5, SWT.BOTTOM);
    // fd_typeList.bottom = new FormAttachment(valueText, 30, SWT.BOTTOM);
    fd_typeList.right = new FormAttachment(valueText, 170, SWT.LEFT);
    typeCombo.setLayoutData(fd_typeList);

    typeCombo.add("Double");
    typeCombo.add("Integer");
    typeCombo.add("Long");
    typeCombo.add("String");
    typeCombo.add("List (BasicDBList)");
    typeCombo.add("Map (BasicDBObject)");
    typeCombo.add("Date");
    typeCombo.add("ObjectId");
    typeCombo.add("JavaScript code");
    typeCombo.add("Binary data");
    typeCombo.add("Boolean");
    typeCombo.add("Null");
    typeCombo.add("Regular expression");
    typeCombo.add("Symbol");
    typeCombo.add("JavaScript code with scope");
    typeCombo.add("Timestamp");
    typeCombo.add("Min key");
    typeCombo.add("Max key");

    typeCombo.addListener(SWT.Selection, this);

    typeComboIndexMap.put(Double.class, new Integer(0));
    typeComboIndexMap.put(Integer.class, new Integer(1));
    typeComboIndexMap.put(Long.class, new Integer(2));
    typeComboIndexMap.put(String.class, new Integer(3));
    typeComboIndexMap.put(com.mongodb.BasicDBList.class, new Integer(4));
    typeComboIndexMap.put(com.mongodb.BasicDBObject.class, new Integer(5));
    typeComboIndexMap.put(java.util.Date.class, new Integer(6));
    typeComboIndexMap.put(org.bson.types.ObjectId.class, new Integer(7));
    typeComboIndexMap.put(org.bson.types.Code.class, new Integer(8));
    typeComboIndexMap.put(byte[].class, new Integer(9));
    typeComboIndexMap.put(Boolean.class, new Integer(10));
    typeComboIndexMap.put(java.util.regex.Pattern.class, new Integer(12));
    typeComboIndexMap.put(org.bson.types.Symbol.class, new Integer(13));
    typeComboIndexMap.put(org.bson.types.CodeWScope.class, new Integer(14));
    typeComboIndexMap.put(org.bson.types.BSONTimestamp.class, new Integer(15));
    typeComboIndexMap.put(org.bson.types.MinKey.class, new Integer(16));
    typeComboIndexMap.put(org.bson.types.MaxKey.class, new Integer(17));

    Label typeLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_typeLabel = new FormData();
    fd_typeLabel.top = new FormAttachment(typeCombo, 3, SWT.TOP);
    fd_typeLabel.left = new FormAttachment(nameLabel, 0, SWT.LEFT);
    typeLabel.setLayoutData(fd_typeLabel);
    typeLabel.setText("Type :");

    nameText = new Text(editorComposite, SWT.READ_ONLY);
    nameText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
    FormData fd_nameText = new FormData();
    fd_nameText.top = new FormAttachment(nameLabel, -2, SWT.TOP);
    fd_nameText.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_nameText.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    nameText.setLayoutData(fd_nameText);

    MSwtUtil.getTreeColumnWidthFromProperties("documentTree", tree, prop, new int[] {150, 150});

    // listeners
    tree.addListener(SWT.MouseDoubleClick, this);
    tree.addListener(SWT.Selection, this);
    tree.addListener(SWT.KeyDown, this);
    MSwtUtil.addListenerToTreeColumns2(tree, this);

    documentImage = MUtil.getImage(parent.getShell().getDisplay(), "table.png");
    oidImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_star.png");
    intImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_blue.png");
    longImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_red.png");
    doubleImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_orange.png");
    stringImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_green.png");
    dateImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_white.png");
    boolImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_yellow.png");
    listImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_blue.png");
    mapImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_green.png");
    nullImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_black.png");
    jsImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_right.png");

    if (prop.containsKey(DOCUMENT_COMPOSITE_WEIGHT)) {

      (new Thread() {
            public void run() {
              // System.out.println( "e" );
              MSystemUtil.sleep(0);
              // System.out.println( "a" );
              shell
                  .getDisplay()
                  .asyncExec(
                      new Runnable() {
                        public void run() { // ----
                          // debug( "--" + prop.getIntArrayProperty( DOCUMENT_COMPOSITE_WEIGHT )[ 0
                          // ] );
                          sashForm.setWeights(prop.getIntArrayProperty(DOCUMENT_COMPOSITE_WEIGHT));
                        }
                      }); // ----
            }
          })
          .start();

    } else {
      sashForm.setWeights(new int[] {70, 30});
    }
    initializedTime = System.currentTimeMillis();
  }
Ejemplo n.º 7
0
  /*
   * This will set up the tree in the GUI
   */
  public void setupTree(
      Tree tree,
      String topLevelLabel,
      String emptyTopLevelLabel,
      String lowLevelLabel,
      IProject project) {
    // add a double click listener for this tree to interact with source file
    tree.addListener(
        SWT.MouseDoubleClick,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            // retrieve the data that was double clicked
            final Widget widget = event.widget;
            if (widget instanceof Tree) {
              final Tree tree = (Tree) widget;
              final TreeItem item = tree.getItem(new Point(event.x, event.y));
              final Object data = item.getData();
              if (data instanceof ThreadInfo) {
                // now jump to the line in the source code that we want
                final ThreadInfo info = (ThreadInfo) data;
                final IFile file = info.getFile();
                final int line = info.getLine();
                try {
                  GIGUtilities.jumpToLine(file, line);
                } catch (final CoreException e) {
                  StatusManager.getManager()
                      .handle(
                          new Status(
                              IStatus.ERROR, GIGPlugin.PLUGIN_ID, Messages.CORE_EXCEPTION, e));
                }
              } else if (data instanceof TwoThreadInfo) {
                // now jump to the line in the log file that we want
                final TwoThreadInfo twoInfo = (TwoThreadInfo) data;
                final IFile file = twoInfo.getFile();
                final int line = twoInfo.getLine();
                try {
                  GIGUtilities.jumpToLine(file, line);
                } catch (final CoreException e) {
                  StatusManager.getManager()
                      .handle(
                          new Status(
                              IStatus.ERROR, GIGPlugin.PLUGIN_ID, Messages.CORE_EXCEPTION, e));
                }
              }
            }
          }
        });
    // a lot of the time, there is nothing to report
    if (blocks.size() == 0) {
      // report there is nothing by creating a label that says as much
      if (emptyTopLevelLabel != null) {
        final TreeItem topLevel = new TreeItem(tree, SWT.NONE);
        topLevel.setText(emptyTopLevelLabel);
      } else {
        // not even worth reporting the non-existence of this
        return;
      }
    } else {
      // we do have something to report, set it up
      final TreeItem topLevel = new TreeItem(tree, SWT.NONE);
      topLevel.setText(topLevelLabel);

      // sort the blocks, as a map doesn't guarantee sorted
      final Set<Integer> keys = blocks.keySet();
      final int[] keysArray = new int[keys.size()];
      final Iterator<Integer> iter = keys.iterator();
      int j;
      for (int i = 0; i < keysArray.length; i++) {
        j = iter.next();
        keysArray[i] = j;
      }
      Arrays.sort(keysArray);

      for (final int block : keysArray) {
        setupBlockTree(topLevel, blocks.get(block), block, lowLevelLabel, project);
      }
    }
  }
Ejemplo n.º 8
0
  public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Tree tree = new Tree(shell, SWT.FULL_SELECTION | SWT.BORDER);
    tree.setHeaderVisible(true);
    TreeColumn column0 = new TreeColumn(tree, SWT.LEFT);
    column0.setText("Column 0");
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("Column 1");
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Column 2");
    for (int i = 0; i < 9; i++) {
      TreeItem item = new TreeItem(tree, SWT.NONE);
      item.setText("item " + i);
      item.setText(1, "column 1 - " + i);
      item.setText(2, "column 2 - " + i);
      for (int j = 0; j < 9; j++) {
        TreeItem subItem = new TreeItem(item, SWT.NONE);
        subItem.setText("item " + i + " " + j);
        subItem.setText(1, "column 1 - " + i + " " + j);
        subItem.setText(2, "column 2 - " + i + " " + j);
        for (int k = 0; k < 9; k++) {
          TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
          subsubItem.setText("item " + i + " " + j + " " + k);
          subsubItem.setText(1, "column 1 - " + i + " " + j + " " + k);
          subsubItem.setText(2, "column 2 - " + i + " " + j + " " + k);
        }
      }
    }
    column0.pack();
    column1.pack();
    column2.pack();

    Heartbeat =
        new Runnable() {
          @Override
          public void run() {
            if (!Tracking || tree.isDisposed()) return;
            Point cursor = display.getCursorLocation();
            cursor = display.map(null, tree, cursor);
            Scroll(tree, cursor.x, cursor.y);
            display.timerExec(ScrollSpeed, Heartbeat);
          }
        };
    Listener listener =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            switch (event.type) {
              case SWT.MouseEnter:
                Tracking = true;
                display.timerExec(0, Heartbeat);
                break;
              case SWT.MouseExit:
                Tracking = false;
                break;
            }
          }
        };
    tree.addListener(SWT.MouseEnter, listener);
    tree.addListener(SWT.MouseExit, listener);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /** @see com.aptana.ide.core.ui.INavigatorDecorator#addDecorator(org.eclipse.swt.widgets.Tree) */
  public void addDecorator(final Tree tree) {
    if (isDisposed(tree)) {
      return;
    }

    tree.addListener(
        SWT.MeasureItem,
        new Listener() {

          public void handleEvent(Event event) {
            int startWidth = event.width;
            try {
              if (!isDisposed(tree) && event.item instanceof TreeItem) {
                Object data = ((TreeItem) event.item).getData();

                if (data instanceof IContainer) {
                  String lastConnection = getLastSyncConnection((IContainer) data);
                  if (lastConnection != null) {
                    Point stringExtent = event.gc.stringExtent(lastConnection);
                    event.width += DECORATOR.getBounds().width + PADDING + stringExtent.x + PADDING;
                  }
                }
              }
            } catch (Exception e) {
              // Catch all exception so tree painting is never hindered by
              // decoration
              event.width = startWidth;
            } catch (Error e) {
              // Catch all exception so tree painting is never hindered by
              // decoration
              event.width = startWidth;
            }
          }
        });

    tree.addListener(
        SWT.PaintItem,
        new Listener() {

          public void handleEvent(Event event) {
            try {
              if (!isDisposed(tree) && event.item instanceof TreeItem) {
                Object data = ((TreeItem) event.item).getData();

                if (data instanceof IContainer) {
                  String lastConnection = getLastSyncConnection((IContainer) data);
                  if (lastConnection != null) {
                    int x = event.x + event.width + PADDING;
                    int itemHeight = tree.getItemHeight();
                    int imageHeight = DECORATOR.getBounds().height;
                    int y = event.y + (itemHeight - imageHeight) / 2;
                    event.gc.drawImage(DECORATOR, x, y);
                    event.x = x + DECORATOR.getBounds().width;

                    x = event.x + PADDING;

                    Point stringExtent = event.gc.stringExtent(lastConnection);
                    y = event.y + (itemHeight - stringExtent.y) / 2;
                    event.gc.drawString(lastConnection, x, y, true);
                    event.x += stringExtent.x;
                  }
                }
              }
            } catch (Exception e) {
              // Catch all exception so tree painting is never hindered by
              // decoration
            } catch (Error e) {
              // Catch all exception so tree painting is never hindered by
              // decoration
            }
          }
        });
  }
Ejemplo n.º 10
0
  @Override
  public void registeredWith(iVisualElement root) {
    super.registeredWith(root);
    this.root = root;

    this.container = new Composite(ToolBarFolder.currentFolder.getContainer(), SWT.NO_BACKGROUND);

    ToolBarFolder.currentFolder.add("icons/reload.png", container);

    toolbar = new Composite(container, SWT.BACKGROUND);
    Color backgroundColor = ToolBarFolder.currentFolder.firstLineBackground;
    toolbar.setBackground(backgroundColor);

    tree = new Tree(container, 0);
    tree.setBackground(ToolBarFolder.firstLineBackground);
    new GraphNodeToTreeFancy.Pretty(tree, 200);

    GridLayout gl = new GridLayout(1, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    if (Platform.isLinux()) {
      gl.marginLeft = 0;
      gl.marginRight = 0;
      gl.marginTop = 0;
      gl.marginBottom = 0;
      gl.verticalSpacing = 0;
    }

    container.setLayout(gl);
    {
      GridData data = new GridData();
      data.heightHint = 28;
      if (Platform.getOS() == OS.linux) {
        data.heightHint = 38;
      }
      data.widthHint = 1000;
      data.horizontalAlignment = SWT.FILL;
      data.grabExcessHorizontalSpace = true;
      toolbar.setLayoutData(data);
    }
    {
      GridData data = new GridData();
      data.grabExcessVerticalSpace = true;
      data.grabExcessHorizontalSpace = true;
      data.verticalAlignment = SWT.FILL;
      data.horizontalAlignment = SWT.FILL;
      data.verticalIndent = 0;
      data.horizontalIndent = 0;
      tree.setLayoutData(data);
    }

    Link label = new Link(toolbar, SWT.MULTI | SWT.NO_BACKGROUND | SWT.CENTER);
    label.setText("Java class reloading");
    label.setFont(
        new Font(
            Launcher.display,
            label.getFont().getFontData()[0].getName(),
            label.getFont().getFontData()[0].getHeight() + 2,
            SWT.NORMAL));
    label.setBackground(ToolBarFolder.firstLineBackground);

    toolbar.setLayout(new GridLayout(1, true));
    GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true);
    // gd.verticalIndent = 1;
    label.setLayoutData(gd);

    tree.setBackground(ToolBarFolder.background);

    tree.addListener(
        SWT.MouseDown,
        new Listener() {

          @Override
          public void handleEvent(Event arg0) {
            if (Platform.isPopupTrigger(arg0)) {
              TreeItem[] s = tree.getSelection();
              if (s.length == 1) popupFor(s[0], arg0);
            }
          }
        });

    tree.addListener(
        SWT.MouseDoubleClick,
        new Listener() {

          @Override
          public void handleEvent(Event arg0) {
            if (Platform.isPopupTrigger(arg0)) return;

            TreeItem[] s = tree.getSelection();
            if (s.length == 1) doubleClickFor(s[0], arg0);
          }
        });

    for (String s : reloadDomains) {
      Trampoline2.trampoline.reloadingSupport.addDomain(s);
    }
  }
Ejemplo n.º 11
0
  public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Custom gradient selection for Tree");
    shell.setLayout(new FillLayout());
    final Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION);
    tree.setHeaderVisible(false);
    tree.setLinesVisible(false);
    int columnCount = 4;
    for (int i = 0; i < columnCount; i++) {
      TreeColumn column = new TreeColumn(tree, SWT.NONE);
      column.setText("Column " + i);
    }
    int itemCount = 3;
    for (int i = 0; i < itemCount; i++) {
      TreeItem item1 = new TreeItem(tree, SWT.NONE);
      item1.setText("item " + i);
      for (int c = 1; c < columnCount; c++) {
        item1.setText(c, "item [" + i + "-" + c + "]");
      }
      for (int j = 0; j < itemCount; j++) {
        TreeItem item2 = new TreeItem(item1, SWT.NONE);
        item2.setText("item [" + i + " " + j + "]");
        for (int c = 1; c < columnCount; c++) {
          item2.setText(c, "item [" + i + " " + j + "-" + c + "]");
        }
        for (int k = 0; k < itemCount; k++) {
          TreeItem item3 = new TreeItem(item2, SWT.NONE);
          item3.setText("item [" + i + " " + j + " " + k + "]");
          for (int c = 1; c < columnCount; c++) {
            item3.setText(c, "item [" + i + " " + j + " " + k + "-" + c + "]");
          }
        }
      }
    }

    /*
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.
     * Therefore, it is critical for performance that these methods be
     * as efficient as possible.
     */
    tree.addListener(
        SWT.EraseItem,
        new Listener() {
          public void handleEvent(Event event) {
            event.detail &= ~SWT.HOT;
            if ((event.detail & SWT.SELECTED) != 0) {
              GC gc = event.gc;
              Rectangle area = tree.getClientArea();
              /*
               * If you wish to paint the selection beyond the end of
               * last column, you must change the clipping region.
               */
              int columnCount = tree.getColumnCount();
              if (event.index == columnCount - 1 || columnCount == 0) {
                int width = area.x + area.width - event.x;
                if (width > 0) {
                  Region region = new Region();
                  gc.getClipping(region);
                  region.add(event.x, event.y, width, event.height);
                  gc.setClipping(region);
                  region.dispose();
                }
              }
              gc.setAdvanced(true);
              if (gc.getAdvanced()) gc.setAlpha(127);
              Rectangle rect = event.getBounds();
              Color foreground = gc.getForeground();
              Color background = gc.getBackground();
              gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
              gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
              gc.fillGradientRectangle(0, rect.y, 500, rect.height, false);
              // restore colors for subsequent drawing
              gc.setForeground(foreground);
              gc.setBackground(background);
              event.detail &= ~SWT.SELECTED;
            }
          }
        });
    for (int i = 0; i < columnCount; i++) {
      tree.getColumn(i).pack();
    }
    tree.setSelection(tree.getItem(0));
    shell.setSize(500, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 12
0
  public void buildExpressionPanel(Composite parentComp, Map<String, String[]> mapDataSets) {

    Composite comp2 = new Composite(parentComp, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 400;
    comp2.setLayout(layout);
    comp2.setLayoutData(data);

    Group group1 = new Group(comp2, SWT.SHADOW_IN);
    group1.setText("ECL Expression Builder");
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    data = new GridData(GridData.FILL_BOTH);
    group1.setLayout(layout);
    group1.setLayoutData(data);

    Composite compVariable = new Composite(group1, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    data = new GridData();
    data.horizontalSpan = 2;
    compVariable.setLayout(layout);
    compVariable.setLayoutData(data);

    Label lblVariableName = new Label(compVariable, SWT.NONE);
    lblVariableName.setText("Variable Name:");
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    lblVariableName.setLayoutData(gridData);

    /*txtVariableName = new Text(compVariable, SWT.SINGLE | SWT.BORDER );
    gridData = new GridData (GridData.FILL_HORIZONTAL);
    gridData.widthHint = 280;
    txtVariableName.setLayoutData(gridData);*/

    cmbVariableName = new Combo(compVariable, SWT.DROP_DOWN);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 280;
    cmbVariableName.setLayoutData(gridData);

    cmbVariableName.setItems(getCmbListValues()); // Set the Combo Values

    Composite compTreePanel = new Composite(group1, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 3;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    compTreePanel.setLayout(layout);
    compTreePanel.setLayoutData(data);

    Label lblInput = new Label(compTreePanel, SWT.NONE);
    lblInput.setText("Input:");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    lblInput.setLayoutData(gridData);

    Label lblFunctions = new Label(compTreePanel, SWT.NONE);
    lblFunctions.setText("Functions:");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    lblFunctions.setLayoutData(gridData);

    Label lblOperators = new Label(compTreePanel, SWT.NONE);
    lblOperators.setText("Operators:");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    lblOperators.setLayoutData(gridData);

    treeInputDataSet = new Tree(compTreePanel, SWT.SINGLE | SWT.BORDER);

    /*inputTip = new ToolTip(compTreePanel.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION);
       Listener inputList = new Listener(){

    	@Override
    	public void handleEvent(Event event) {
    		// TODO Auto-generated method stub
    		switch (event.type) {
    		case SWT.MouseMove: {
    			inputTip.setVisible(false);
    		}
    			case SWT.MouseHover: {
    				Point coords = new Point(event.x, event.y);
    				TreeItem item = treeInputDataSet.getItem(coords);


    				if(item != null){
    					//System.out.println("Show tool tip " + coords + " " + item.getText());
    					inputTip.setText("Info");
    					inputTip.setMessage(item.getText());
    					inputTip.setVisible(true);
    				}else{
    					//System.out.println("hide tool tip");
    					inputTip.setVisible(false);
    				}
    			}
    		}
    	}};

    	treeInputDataSet.addListener(SWT.MouseHover, inputList);
    	treeInputDataSet.addListener(SWT.MouseMove, inputList);
    */
    // treeInputDataSet.setToolTipText("Select the column from the input dataset");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 100;
    treeInputDataSet.setLayoutData(gridData);
    Utils.fillTree(
        treeInputDataSet, mapDataSets); // Get the values from the HashMap passed as an argument
    treeInputDataSet.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseUp(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDown(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            Tree selectedTree = (Tree) e.widget;
            if (selectedTree.getSelection()[0].getParentItem() != null) {
              String dataField = ((Tree) e.widget).getSelection()[0].getText();
              if (txtExpression.getCaretPosition() > 0) {
                StringBuffer buf = new StringBuffer(txtExpression.getText());
                buf.insert(txtExpression.getCaretPosition(), dataField);
                txtExpression.setText(buf.toString());
              } else {
                StringBuffer buf = new StringBuffer(txtExpression.getText());
                buf.append(dataField);
                txtExpression.setText(buf.toString());
              }
            }
          }
        });

    final Tree treeFunctions = new Tree(compTreePanel, SWT.SINGLE | SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 100;
    treeFunctions.setLayoutData(gridData);
    Map<String, List<String>> mapFunctionValues = Utils.getFunctionValueMap();
    Utils.fillTreeForFunctions(treeFunctions, mapFunctionValues);
    treeFunctions.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseUp(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDown(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            Tree selectedTree = (Tree) e.widget;
            if (selectedTree.getSelection()[0].getParentItem() != null) {
              String dataField = ((Tree) e.widget).getSelection()[0].getText();
              // System.out.println("Text Position:: "+txtExpression.getCaretPosition());
              if (txtExpression.getSelectionText() != null
                  && txtExpression.getSelectionText().length() > 0) {
                String txtToBeReplaced = dataField + "( " + txtExpression.getSelectionText() + " )";
                StringBuffer buf = new StringBuffer(txtExpression.getText());
                buf.replace(
                    txtExpression.getSelection().x,
                    txtExpression.getSelection().y,
                    txtToBeReplaced);
                txtExpression.setText(buf.toString());
              } else if (txtExpression.getCaretPosition() > 0) {
                StringBuffer buf = new StringBuffer(txtExpression.getText());
                buf.insert(txtExpression.getCaretPosition(), dataField + "()");
                txtExpression.setText(buf.toString());
              } else {
                StringBuffer buf = new StringBuffer(txtExpression.getText());
                buf.append(dataField + "()");
                txtExpression.setText(buf.toString());
              }
            }
          }
        });

    final ToolTip functionsTip =
        new ToolTip(compTreePanel.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION);
    BuildHelpIndex bhi = new BuildHelpIndex();

    String indexFile = "plugins/hpcc-common/helpfiles/index.xml";

    URL url = null;
    try {
      URL baseURL = this.getClass().getResource("../../../");

      System.out.println("BaseURL: " + baseURL.getPath());
      if (baseURL != null) {
        url = new URL(baseURL, indexFile);
      } else {
        url = this.getClass().getResource(indexFile);
      }
    } catch (MalformedURLException e) {
      System.out.println("can't find helf files" + e.toString());
    }
    System.out.println("URL: " + url.toString());

    bhi.setUrl(url.toString().replace("%20", " ").replace("file:", ""));
    final HashMap<String, String> helpIndex = bhi.getMap();

    Listener functionsList =
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            // TODO Auto-generated method stub

            switch (event.type) {
              case SWT.MouseExit:
              case SWT.MouseMove:
                {
                  functionsTip.setAutoHide(true);
                  // functionsTip.setVisible(false);
                  break;
                }

              case SWT.MouseHover:
                {
                  break;
                }
              case SWT.KeyDown:
                {
                  if (event.keyCode == SWT.F1) {
                    Point coords = new Point(event.x, event.y);
                    // TreeItem item = treeFunctions.getItem(coords);
                    TreeItem item = treeFunctions.getSelection()[0];
                    Shell tip = new Shell(treeFunctions.getDisplay());
                    System.out.println(event.keyCode);
                    String help = "";
                    String htmlFile = "plugins/hpcc-common/helpfiles/";
                    System.out.println("Item: " + item.getText().replace("STD.", ""));
                    if (helpIndex.containsKey(item.getText().replace("STD.", ""))) {
                      htmlFile += helpIndex.get(item.getText().replace("STD.", ""));
                      // if(Utils.getHelpMap().containsKey(item.getText())){
                      //	help += Utils.getHelpMap().get(item.getText());
                      // }
                    } else {
                      htmlFile += "html/index.html";
                    }
                    Browser browser;
                    try {
                      browser = new Browser(tip, SWT.BALLOON);
                      browser.setBounds(0, 0, 800, 800);
                      // browser.setText(help);
                      // ClassLoader classLoader = getClass().getClassLoader();
                      // System.out.println("PATHbase: " + classLoader.getResource(".").getFile());

                      URL url = null;
                      try {
                        URL baseURL = this.getClass().getResource("../../../");

                        System.out.println("BaseURL: " + baseURL.getPath());
                        if (baseURL != null) {
                          url = new URL(baseURL, htmlFile);
                        } else {
                          url = this.getClass().getResource(htmlFile);
                        }
                      } catch (MalformedURLException e) {
                        System.out.println("can't find helf files" + e.toString());
                      }
                      System.out.println("URL: " + url.toString());
                      browser.setUrl(url.toString());

                      // file:/C:/Program
                      // Files/data-integration/plugins/jobentries/eclproject/../../hpcc-common/eclgui.jar!/org/hpccsystems/mapper/html/bk01apa.html
                    } catch (SWTError e) {
                      System.out.println("Could not instantiate Browser: " + e.getMessage());
                    }

                    tip.pack();
                    tip.open();
                  }
                  break;
                }
            }
          }
        };
    treeFunctions.addListener(SWT.KeyDown, functionsList);
    // treeFunctions.addListener(SWT.MouseHover, functionsList);
    // treeFunctions.addListener(SWT.MouseMove, functionsList);
    // treeFunctions.addListener(SWT.MouseExit, functionsList);

    int style = SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
    final Table tblOperators = new Table(compTreePanel, style);
    gridData = new GridData();
    gridData.heightHint = 100;
    gridData.widthHint = 100;
    tblOperators.setLayoutData(gridData);

    for (int i = getOperatorList().length - 1; i >= 0; i--) {
      TableItem item = new TableItem(tblOperators, SWT.NONE, 0);
      item.setText(getOperatorList()[i]);
    }

    tblOperators.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseUp(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDown(MouseEvent arg0) {
            // Do Nothing
          }

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            String dataField = ((Table) e.widget).getSelection()[0].getText();
            if (txtExpression.getCaretPosition() > 0) {
              StringBuffer buf = new StringBuffer(txtExpression.getText());
              buf.insert(txtExpression.getCaretPosition(), dataField);
              txtExpression.setText(buf.toString());
            } else {
              StringBuffer buf = new StringBuffer(txtExpression.getText());
              buf.append(dataField);
              txtExpression.setText(buf.toString());
            }
          }
        });

    Label lblEclText = new Label(group1, SWT.NONE);
    lblEclText.setText("ECL Text:");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    lblEclText.setLayoutData(gridData);

    txtExpression = new Text(group1, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 2;
    txtExpression.setLayoutData(gridData);

    Composite compButton = new Composite(group1, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 3;
    data = new GridData();
    compButton.setLayout(layout);
    compButton.setLayoutData(data);

    btnSaveExpression = new Button(compButton, SWT.PUSH | SWT.CENTER);
    btnSaveExpression.setText("Save Expression");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 120;
    btnSaveExpression.setLayoutData(gridData);
    btnSaveExpression.addSelectionListener(
        new SelectionAdapter() {
          // Add a record and refresh the view
          public void widgetSelected(SelectionEvent e) {
            int selectionIndex = 0;
            if (tableViewer.getTable().getItemCount() > 0) {
              for (int i = 0; i < tableViewer.getTable().getItemCount(); i++) {
                if (tableViewer.getTable().getItems()[i].getChecked()) {
                  selectionIndex = i;
                }
              }

              /*if(tableViewer.getTable().getItem(selectionIndex).getChecked()){
              	MapperBO objRecord = mapperRecList.getRecord(selectionIndex);
              	//objRecord.setOpVariable(txtVariableName.getText());
              	objRecord.setOpVariable(cmbVariableName.getText());
              	objRecord.setExpression(txtExpression.getText());
              	mapperRecList.removeRecord(selectionIndex);
              	mapperRecList.addRecordAtIndex(selectionIndex, objRecord);
              	//txtVariableName.setText("");

              	cmbVariableName.setText("");
              	txtExpression.setText("");
              	uncheckAll();
              	tableViewer.refresh();
              	tableViewer.getTable().redraw();
              }*/

              selectionIndex = tableViewer.getTable().getSelectionIndex();
              objRecord = mapperRecList.getRecord(selectionIndex);
              objRecord.setOpVariable(cmbVariableName.getText());
              objRecord.setExpression(txtExpression.getText());
              mapperRecList.removeRecord(selectionIndex);
              mapperRecList.addRecordAtIndex(selectionIndex, objRecord);
              cmbVariableName.setText("");
              txtExpression.setText("");
              uncheckAll();
              setOldexpression("");
              setNewExpression("");
              tableViewer.refresh();
              tableViewer.getTable().redraw();
            }
          }
        });

    btnSaveExpression.setEnabled(false);

    btnAddExpression = new Button(compButton, SWT.PUSH | SWT.CENTER);
    btnAddExpression.setText("Add Expression");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 120;
    btnAddExpression.setLayoutData(gridData);
    btnAddExpression.addSelectionListener(
        new SelectionAdapter() {
          // Add a record and refresh the view
          public void widgetSelected(SelectionEvent e) {
            /*if( (txtVariableName.getText()!= null && txtVariableName.getText().trim().length() > 0 )
            		|| (txtExpression.getText()!= null && txtExpression.getText().trim().length() > 0 ) ) {
            	MapperBO record = new MapperBO();
            	record.setOpVariable(txtVariableName.getText());
            	record.setExpression(txtExpression.getText());
            	txtVariableName.setText("");
            	txtExpression.setText("");
            	mapperRecList.addRecord(record);
            	uncheckAll();
            	tableViewer.refresh();
            }*/

            if ((cmbVariableName.getText() != null && cmbVariableName.getText().trim().length() > 0)
                || (txtExpression.getText() != null
                    && txtExpression.getText().trim().length() > 0)) {
              MapperBO record = new MapperBO();
              record.setOpVariable(cmbVariableName.getText());
              record.setExpression(txtExpression.getText());
              cmbVariableName.setText("");
              txtExpression.setText("");
              mapperRecList.addRecord(record);
              uncheckAll();
              setOldexpression("");
              setNewExpression("");
              tableViewer.refresh();
            }
          }
        });

    // Code to Add Cancel Button
    Button btnCancelExpression = new Button(compButton, SWT.PUSH | SWT.CENTER);
    btnCancelExpression.setText("Cancel");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    btnCancelExpression.setLayoutData(gridData);
    btnCancelExpression.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {

            // To check if the expression is modified
            setNewExpression(txtExpression.getText());
            if (hasChanged()) {
              // if(!getOldexpression().equalsIgnoreCase(getNewExpression())) {
              // System.out.println("Old Expression: "+getOldexpression());
              // System.out.println("New Expression: "+getNewExpression());
              int style = 452; // Message Box Style code for SWT.ICON_QUESTION | SWT.YES | SWT.NO |
              // SWT.CANCEL
              MessageBox mb = new MessageBox(tableViewer.getTable().getShell(), style);
              mb.setText("Alert");
              mb.setMessage("You will loose your current changes? Do you wish to continue?");
              int val = mb.open();
              switch (val) { // val contains the constant of the selected button
                case SWT.CANCEL:
                  break;
                case SWT.YES:
                  objRecord = null;
                  cmbVariableName.setText("");
                  txtExpression.setText("");
                  setOldexpression("");
                  setNewExpression("");
                  btnSaveExpression.setEnabled(false);
                  break;
                case SWT.NO:
                  break;
              }
            } else {
              objRecord = null;
              cmbVariableName.setText("");
              txtExpression.setText("");
              btnSaveExpression.setEnabled(false);
              setOldexpression("");
              setNewExpression("");
            }
          }
        });

    /*Composite comp3 = new Composite(parentComp, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = true;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 40;
    comp3.setLayout(layout);
    comp3.setLayoutData(data);

    Button btnOk = new Button(comp3, SWT.PUSH | SWT.CENTER);
    btnOk.setText("Ok");
    gridData = new GridData (GridData.HORIZONTAL_ALIGN_END);
    gridData.widthHint = 80;
    btnOk.setLayoutData(gridData);
    btnOk.addSelectionListener(new SelectionAdapter() {
      		// Add a record and refresh the view
    	public void widgetSelected(SelectionEvent e) {
    		//mapperRecList.addRecord(table.getSelectionIndex());
    	}
    });

    Button btnClose = new Button(comp3, SWT.PUSH | SWT.CENTER);
    btnClose.setText("Cancel");
    gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = 80;
    btnClose.setLayoutData(gridData);*/

  }