/**
   * Sets up tree columns.
   *
   * <p>Conveniently located here to keep column semantics in one place
   *
   * @param tv the tree viewer
   */
  public void configureTreeColumns(final TreeViewer tv) {

    final Tree tree = tv.getTree();

    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setWidth(450);
    c1.setText("Name");

    tree.setHeaderVisible(true);

    tree.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            TreeItem item = tree.getItem(new Point(e.x, e.y));
            if (item != null) {
              boolean expanded = tv.getExpandedState(item.getData());
              if (expanded) {
                tv.collapseToLevel(item.getData(), 1);
              } else {
                tv.expandToLevel(item.getData(), 1);
              }
            }
          }
        });
  }
 /**
  * Add mouse tree listener.
  *
  * @param menuService The menu service reference.
  */
 private void addListeners(EMenuService menuService) {
   properties.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseDoubleClick(MouseEvent e) {
           final TreeItem[] items = properties.getSelection();
           if (items.length > 0) {
             final TreeItem item = items[0];
             if (properties.getData() instanceof Configurer) {
               final Configurer configurer = (Configurer) properties.getData();
               if (updateProperties(item, configurer)) {
                 configurer.save();
               }
             }
           }
         }
       });
   properties.addMenuDetectListener(
       new MenuDetectListener() {
         @Override
         public void menuDetected(MenuDetectEvent menuDetectEvent) {
           properties.getMenu().setVisible(false);
           properties.update();
         }
       });
   menuService.registerContextMenu(properties, MENU_ID);
 }
示例#3
0
  public TreeSources(ApplicationFactory factory, Composite parent) {
    super(parent);

    setLayout(new FillLayout());

    tree = factory.createTree(this, SWT.MULTI);
    tree.setLinesVisible(false);

    createMenu(tree, factory);

    tree.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent arg0) {
            clickMouse = true;
          }
        });

    tree.addTreeListener(
        new TreeAdapter() {
          @SuppressWarnings("unused")
          public void treeCollapsed(TreeEvent arg0) {
            clickMouse = false;
          }

          @SuppressWarnings("unused")
          public void treeExpanded(TreeEvent arg0) {
            clickMouse = false;
          }
        });

    tree.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent event) {
            if (!clickMouse) return;
            clickMouse = false;
            if (tree.getSelectionCount() < 1) return;
            TreeItem selectedItem = tree.getSelection()[0];
            TreeItem parentItem = selectedItem.getParentItem();
            if (parentItem == null) {
              new LoadGroupCategorySource(
                  TreeSources.this, new Worker[0], null, selectedItem.getText());
              creator.selectData(new Worker[0], null, selectedItem.getText());
              return;
            }

            String category = parentItem.getText();
            String name = selectedItem.getText();
            creator.setSource(null, category, name, false);
          }
        });
  }
  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);
  }
  /**
   * Create the main content for this information control.
   *
   * @param parent The parent composite
   * @return The control representing the main content.
   * @since 3.2
   */
  protected Control createDialogArea(Composite parent) {
    setfTreeViewer(createTreeViewer(parent, fTreeStyle));

    final Tree tree = getfTreeViewer().getTree();
    tree.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) // ESC
            dispose();
          }

          public void keyReleased(KeyEvent e) {
            // do nothing
          }
        });

    tree.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            // do nothing
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            gotoSelectedElement();
          }
        });

    tree.addMouseMoveListener(
        new MouseMoveListener() {
          TreeItem fLastItem = null;

          public void mouseMove(MouseEvent e) {
            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              if (o instanceof TreeItem) {
                Rectangle clientArea = tree.getClientArea();
                if (!o.equals(fLastItem)) {
                  fLastItem = (TreeItem) o;
                  tree.setSelection(new TreeItem[] {fLastItem});
                } else if (e.y - clientArea.y < tree.getItemHeight() / 4) {
                  // Scroll up
                  Point p = tree.toDisplay(e.x, e.y);
                  Item item = getfTreeViewer().scrollUp(p.x, p.y);
                  if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] {fLastItem});
                  }
                } else if (clientArea.y + clientArea.height - e.y < tree.getItemHeight() / 4) {
                  // Scroll down
                  Point p = tree.toDisplay(e.x, e.y);
                  Item item = getfTreeViewer().scrollDown(p.x, p.y);
                  if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] {fLastItem});
                  }
                }
              }
            }
          }
        });

    tree.addMouseListener(
        new MouseAdapter() {
          public void mouseUp(MouseEvent e) {

            if (tree.getSelectionCount() < 1) return;

            if (e.button != 1) return;

            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              TreeItem selection = tree.getSelection()[0];
              if (selection.equals(o)) gotoSelectedElement();
            }
          }
        });

    installFilter();

    addDisposeListener(this);
    return getfTreeViewer().getControl();
  }
  /**
   * Create the main content for this information control.
   *
   * @param parent The parent composite
   * @return The control representing the main content.
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    fTreeViewer = createTreeViewer(parent, fTreeStyle);

    DartX.todo();
    //    fCustomFiltersActionGroup = new CustomFiltersActionGroup(getId(),
    //        fTreeViewer);

    final Tree tree = fTreeViewer.getTree();
    tree.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) {
              dispose();
            }
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // do nothing
          }
        });

    tree.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            gotoSelectedElement();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            // do nothing
          }
        });

    tree.addMouseMoveListener(
        new MouseMoveListener() {
          TreeItem fLastItem = null;

          @Override
          public void mouseMove(MouseEvent e) {
            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              if (o instanceof TreeItem) {
                if (!o.equals(fLastItem)) {
                  fLastItem = (TreeItem) o;
                  tree.setSelection(new TreeItem[] {fLastItem});
                }
              }
            }
          }
        });

    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {

            if (tree.getSelectionCount() < 1) {
              return;
            }

            if (e.button != 1) {
              return;
            }

            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              TreeItem selection = tree.getSelection()[0];
              if (selection.equals(o)) {
                gotoSelectedElement();
              }
            }
          }
        });

    installFilter();

    addDisposeListener(this);
    return fTreeViewer.getControl();
  }
  @Override
  public void createPartControl(Composite parent) {
    sashForm = new SashForm(parent, SWT.HORIZONTAL);
    // composite to have control on the xtextEditor control created by super class.
    final Composite leftComposite = new Composite(sashForm, SWT.NONE);
    leftComposite.setLayout(new FillLayout());
    super.createPartControl(leftComposite);
    getSourceViewer()
        .getTextWidget()
        .addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDoubleClick(MouseEvent e) {
                maximizeControl(leftComposite);
              }
            });
    document = getDocument();
    resourceSet =
        document.readOnly(
            new IUnitOfWork<ResourceSet, XtextResource>() {
              public ResourceSet exec(final XtextResource xtextResource) throws Exception {
                return xtextResource.getResourceSet();
              }
            });
    adapterFactory =
        new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

    initializeEditingDomain();

    propertiesViewUpdater = createPropertiesViewUpdater();
    getSelectionProvider().addSelectionChangedListener(propertiesViewUpdater);
    if (getSelectionProvider() instanceof IPostSelectionProvider) {
      ((IPostSelectionProvider) getSelectionProvider())
          .addPostSelectionChangedListener(propertiesViewUpdater);
    }

    final Tree tree = new Tree(sashForm, SWT.MULTI);
    selectionViewer = new TreeViewer(tree);
    setCurrentViewer(selectionViewer);

    selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    selectionViewer.setLabelProvider(
        new DecoratingColumLabelProvider(
            new AdapterFactoryLabelProvider(adapterFactory),
            new DiagnosticDecorator(
                editingDomain,
                selectionViewer,
                EcoreEditorPlugin.getPlugin().getDialogSettings())));
    selectionViewer.setInput(getInputForSelectionViewer(editingDomain));
    selectionViewer.setSelection(
        new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
    selectionViewer.addSelectionChangedListener(propertiesViewUpdater);
    selectionViewer.expandAll();
    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            maximizeControl(tree);
          }
        });

    new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
    new ColumnViewerInformationControlToolTipSupport(
        selectionViewer,
        new DiagnosticDecorator.EditingDomainLocationListener(editingDomain, selectionViewer));
    getSite().setSelectionProvider(this);
    createContextMenuFor(selectionViewer);

    ViewerFilter filter =
        new ViewerFilter() {
          @Override
          public boolean select(Viewer viewer, Object parentElement, Object element) {
            return (!(element instanceof FactoryImpl));
          }
        };
    selectionViewer.addFilter(filter);
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.ui.parts.ContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    pageBook = new PageBook(parent, SWT.NONE);

    outline = getViewer().createControl(pageBook);

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(outline, "com.jaspersoft.studio.doc.view_outline");

    overview = new Canvas(pageBook, SWT.NONE);
    pageBook.showPage(outline);
    configureOutlineViewer();
    hookOutlineViewer();
    setContents(editor.getModel());
    if (outline instanceof Tree) {
      final Tree tree = (Tree) outline;

      tree.addFocusListener(
          new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
              mousePosition.setLocation(-1, -1);
            }

            @Override
            public void focusGained(FocusEvent e) {
              if (enableFocusFix && mousePosition.x != -1) {
                EditPart part = getViewer().findObjectAt(mousePosition);
                if (part != null && part.getModel() instanceof MRoot) {
                  EditPart translatedPart =
                      getViewer().findObjectAt(new Point(mousePosition.x + 10, mousePosition.y));
                  if (translatedPart != null && translatedPart.getModel() != part.getModel()) {
                    TreeItem item = (TreeItem) ((TreeEditPart) translatedPart).getWidget();
                    item.setExpanded(!item.getExpanded());
                    tree.deselectAll();
                    tree.select(item);
                    tree.layout(true);
                  }
                }
              }
            }
          });

      tree.addMouseListener(
          new MouseListener() {

            public void mouseUp(MouseEvent e) {}

            public void mouseDown(MouseEvent e) {}

            public void mouseDoubleClick(MouseEvent e) {
              if (e.getSource() instanceof Tree) {
                Tree t = (Tree) e.getSource();
                TreeItem[] ti = t.getSelection();
                if (ti != null && ti.length > 0) {
                  Object obj = ti[0].getData();
                  if (obj instanceof TreeEditPart && editor instanceof AbstractVisualEditor) {

                    EditPart part =
                        (EditPart)
                            ((AbstractVisualEditor) editor)
                                .getGraphicalViewer()
                                .getEditPartRegistry()
                                .get(((TreeEditPart) obj).getModel());
                    if (part != null) {
                      SelectionRequest request = new SelectionRequest();
                      request.setType(RequestConstants.REQ_OPEN);
                      part.performRequest(request);
                    } else {
                      TreeEditPart atep = (TreeEditPart) obj;
                      if (atep.getModel() instanceof ANode) {
                        EditableFigureEditPart.openEditor(
                            ((ANode) atep.getModel()).getValue(),
                            (IEditorPart) editor,
                            (ANode) atep.getModel());
                      }
                    }
                  }
                }
              }
            }
          });

      // This listener display the tooltip text for the abbreviated nodes names
      tree.addMouseMoveListener(
          new MouseMoveListener() {

            public void mouseMove(MouseEvent e) {
              mousePosition.setLocation(e.x, e.y);
              EditPart part = getViewer().findObjectAt(new Point(e.x, e.y));
              Tree t = (Tree) e.getSource();
              if (part != null && part.getModel() != null && !(part.getModel() instanceof MRoot)) {
                Object model = part.getModel();
                String toolTipText = Misc.nvl(((ANode) model).getToolTip());
                String displayText = Misc.nvl(((ANode) model).getDisplayText());
                String text = "";
                if (!toolTipText.isEmpty() && !toolTipText.equals(displayText))
                  text = toolTipText + "\n";
                text += displayText;
                t.setToolTipText(text);
                return;
              }
              t.setToolTipText(null);
            }
          });
    }
  }
示例#9
0
  @Override
  public void createPartControl(Composite parent) {
    // CREATE CONTROLS
    Composite mainPanel = new Composite(parent, SWT.NONE);
    Control filterPanel = filterPart.createControl(mainPanel, 5, 5);
    Tree tree = new Tree(mainPanel, SWT.FULL_SELECTION | SWT.MULTI);
    filterPanel.setBackground(tree.getBackground());

    viewer = new TreeViewer(tree);
    viewer.setContentProvider(contentProvider);
    ColumnViewerToolTipSupport.enableFor(viewer);

    viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    getViewSite().setSelectionProvider(viewer);

    createActions();

    JpmPreferences jpmPrefs = new JpmPreferences();
    final boolean showJpmOnClick =
        jpmPrefs.getBrowserSelection() != JpmPreferences.PREF_BROWSER_EXTERNAL;

    // LISTENERS
    filterPart.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent event) {
            String filter = (String) event.getNewValue();
            updatedFilter(filter);
          }
        });
    ViewerDropAdapter dropAdapter =
        new ViewerDropAdapter(viewer) {
          @Override
          public boolean validateDrop(Object target, int operation, TransferData transferType) {
            if (canDrop(target, transferType)) return true;

            boolean valid = false;
            if (target instanceof RepositoryPlugin) {
              if (((RepositoryPlugin) target).canWrite()) {

                if (URLTransfer.getInstance().isSupportedType(transferType)) return true;

                if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
                  ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
                  if (selection instanceof IStructuredSelection) {
                    for (Iterator<?> iter = ((IStructuredSelection) selection).iterator();
                        iter.hasNext(); ) {
                      Object element = iter.next();
                      if (element instanceof RepositoryBundle
                          || element instanceof RepositoryBundleVersion) {
                        valid = true;
                        break;
                      }
                      if (element instanceof IFile) {
                        valid = true;
                        break;
                      }
                      if (element instanceof IAdaptable) {
                        IFile file = (IFile) ((IAdaptable) element).getAdapter(IFile.class);
                        if (file != null) {
                          valid = true;
                          break;
                        }
                      }
                    }
                  }
                } else {
                  valid = true;
                }
              }
            }
            return valid;
          }

          @Override
          public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            event.detail = DND.DROP_COPY;
          }

          @Override
          public boolean performDrop(Object data) {
            if (RepositoriesView.this.performDrop(
                getCurrentTarget(), getCurrentEvent().currentDataType)) {
              viewer.refresh(getCurrentTarget(), true);
              return true;
            }

            boolean copied = false;
            if (URLTransfer.getInstance().isSupportedType(getCurrentEvent().currentDataType)) {
              try {
                URL url =
                    new URL(
                        (String)
                            URLTransfer.getInstance()
                                .nativeToJava(getCurrentEvent().currentDataType));
                File tmp = File.createTempFile("dwnl", ".jar");
                IO.copy(url, tmp);
                copied =
                    addFilesToRepository((RepositoryPlugin) getCurrentTarget(), new File[] {tmp});
              } catch (Exception e) {
                return false;
              }
            } else if (data instanceof String[]) {
              String[] paths = (String[]) data;
              File[] files = new File[paths.length];
              for (int i = 0; i < paths.length; i++) {
                files[i] = new File(paths[i]);
              }
              copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            } else if (data instanceof IResource[]) {
              IResource[] resources = (IResource[]) data;
              File[] files = new File[resources.length];
              for (int i = 0; i < resources.length; i++) {
                files[i] = resources[i].getLocation().toFile();
              }
              copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            } else if (data instanceof IStructuredSelection) {
              File[] files = convertSelectionToFiles((IStructuredSelection) data);
              if (files != null && files.length > 0)
                copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            }
            return copied;
          }
        };
    dropAdapter.setFeedbackEnabled(false);
    dropAdapter.setExpandEnabled(false);

    viewer.addDropSupport(
        DND.DROP_COPY | DND.DROP_MOVE,
        new Transfer[] {
          URLTransfer.getInstance(),
          FileTransfer.getInstance(),
          ResourceTransfer.getInstance(),
          LocalSelectionTransfer.getTransfer()
        },
        dropAdapter);
    viewer.addDragSupport(
        DND.DROP_COPY | DND.DROP_MOVE,
        new Transfer[] {LocalSelectionTransfer.getTransfer()},
        new SelectionDragAdapter(viewer));

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            boolean writableRepoSelected = false;
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Object element = selection.getFirstElement();
            if (element instanceof RepositoryPlugin) {
              RepositoryPlugin repo = (RepositoryPlugin) element;
              writableRepoSelected = repo.canWrite();
            }
            addBundlesAction.setEnabled(writableRepoSelected);
          }
        });
    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent ev) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (element instanceof ContinueSearchElement) {
              try {
                getViewSite()
                    .getPage()
                    .showView(
                        Plugin.JPM_BROWSER_VIEW_ID,
                        null,
                        showJpmOnClick ? IWorkbenchPage.VIEW_ACTIVATE : IWorkbenchPage.VIEW_CREATE);
              } catch (PartInitException e) {
                Plugin.getDefault().getLog().log(e.getStatus());
              }
            }
          }
        });
    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
              IStructuredSelection selection = (IStructuredSelection) event.getSelection();
              Object element = selection.getFirstElement();
              if (element instanceof IAdaptable) {
                URI uri = (URI) ((IAdaptable) element).getAdapter(URI.class);
                if (uri != null) {
                  IWorkbenchPage page = getSite().getPage();
                  try {
                    IFileStore fileStore = EFS.getLocalFileSystem().getStore(uri);
                    IDE.openEditorOnFileStore(page, fileStore);
                  } catch (PartInitException e) {
                    logger.logError("Error opening editor for " + uri, e);
                  }
                }
              } else if (element instanceof ContinueSearchElement) {
                ContinueSearchElement searchElement = (ContinueSearchElement) element;
                try {
                  JpmPreferences jpmPrefs = new JpmPreferences();
                  if (jpmPrefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL)
                    getViewSite()
                        .getWorkbenchWindow()
                        .getWorkbench()
                        .getBrowserSupport()
                        .getExternalBrowser()
                        .openURL(new URL("https://www.jpm4j.org/" + searchElement.getFilter()));
                  else
                    getViewSite()
                        .getPage()
                        .showView(Plugin.JPM_BROWSER_VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE);
                } catch (PartInitException e) {
                  Plugin.getDefault().getLog().log(e.getStatus());
                } catch (MalformedURLException e) {
                  // ignore
                }
              }
            }
          }
        });

    createContextMenu();

    // LOAD
    Central.onWorkspaceInit(
        new Function<Workspace, Void>() {
          @Override
          public Void run(Workspace a) {
            final List<RepositoryPlugin> repositories = RepositoryUtils.listRepositories(true);
            SWTConcurrencyUtil.execForControl(
                viewer.getControl(),
                true,
                new Runnable() {
                  @Override
                  public void run() {
                    viewer.setInput(repositories);
                  }
                });
            return null;
          }
        });

    // LAYOUT
    GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    mainPanel.setLayout(layout);

    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    filterPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    // Toolbar
    createActions();
    fillToolBar(getViewSite().getActionBars().getToolBarManager());

    // Register as repository listener
    registration =
        Activator.getDefault()
            .getBundleContext()
            .registerService(RepositoryListenerPlugin.class, this, null);
  }
示例#10
0
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    container.setLayout(new FormLayout());

    treeViewer = new TreeViewer(container, SWT.BORDER);
    final Tree tree_Collection = treeViewer.getTree();

    tree_Collection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            str = treeViewer.getTree().getSelection()[0].getText();
          }
        });
    FormData fd_tree_Collection = new FormData();
    fd_tree_Collection.top = new FormAttachment(0, 3);
    fd_tree_Collection.right = new FormAttachment(100);
    fd_tree_Collection.left = new FormAttachment(0, 3);
    tree_Collection.setLayoutData(fd_tree_Collection);

    tree_Collection.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            TreeItem[] items = treeViewer.getTree().getSelection();
            if (items[0].getExpanded()) {
              items[0].setExpanded(false);
            } else {
              treeViewer.expandToLevel(items[0].getData(), 1);
            }
            if (items[0].getText().equals("/...")) {
              String[] list;

              ExportActionWizard tes = (ExportActionWizard) getWizard();
              list = tes.str.split("/");
              String str = " /";
              for (int i = 1; i < (list.length) - 1; i++) {
                str += list[i] + "/";
              }
              tes.str = str;
              treeViewer.setInput(createDummyModel());
              treeViewer.expandToLevel(2);
            }
          }
        });

    treeViewer.setContentProvider(new CopyViewContentProvider());
    treeViewer.setLabelProvider(new CopyViewLabelProvider());
    treeViewer.setSorter(new NameSorter());

    Composite composite = new Composite(container, SWT.NONE);
    fd_tree_Collection.bottom = new FormAttachment(composite, -1);
    FormData fd_composite = new FormData();
    fd_composite.bottom = new FormAttachment(100, -10);
    fd_composite.top = new FormAttachment(100, -36);
    fd_composite.left = new FormAttachment(0, 14);
    fd_composite.right = new FormAttachment(100);
    composite.setLayoutData(fd_composite);
    composite.setLayout(new GridLayout(2, true));

    btnall = new Button(composite, SWT.RADIO);
    btnall.setSelection(true);
    btnall.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnall.setText("All Entries");

    btnsome = new Button(composite, SWT.RADIO);
    btnsome.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnsome.setText("Some Entries(Query)");

    initTree();
  }
示例#11
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);*/

  }