Пример #1
0
  @Override
  public void createPartControl(final Composite parent) {
    parent.setLayout(new GridLayout());
    display = new EpisodesDisplay(parent);
    display.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    makeActions();
    ViewMenus menu = new ViewMenus(getViewSite());

    /*
     * menu.createViewerContextMenu(display.tvEpisodes, activateEpisodeAction,
     * editEpisodeAction, null, removeEpisodeAction);
     */
    menu.createControlContextMenu(
        display.tvEpisodes.getControl(),
        new IMenuPopulator() {
          @Override
          public IAction[] fillMenu() {
            return new IAction[] {
              activateEpisodeAction,
              editEpisodeAction,
              null,
              removeEpisodeAction,
              removeDiagnosesAction
            };
          }
        });

    menu.createToolbar(konsFilterAction, addEpisodeAction, editEpisodeAction);
    GlobalEventDispatcher.addActivationListener(this, getViewSite().getPart());
  }
Пример #2
0
  @Override
  public void createPartControl(final Composite parent) {
    parent.setLayout(new FillLayout());
    form = tk.createForm(parent);
    Composite body = form.getBody();
    body.setLayout(new GridLayout());
    Table table = new Table(body, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.SINGLE);
    TableColumn tc0 = new TableColumn(table, SWT.CENTER);
    tc0.setText(Messages.getString("BestellView.Number")); // $NON-NLS-1$
    tc0.setWidth(40);
    TableColumn tc1 = new TableColumn(table, SWT.LEFT);
    tc1.setText(Messages.getString("BestellView.Article")); // $NON-NLS-1$
    tc1.setWidth(280);
    TableColumn tc2 = new TableColumn(table, SWT.LEFT);
    tc2.setText(Messages.getString("BestellView.Dealer")); // $NON-NLS-1$
    tc2.setWidth(250);
    table.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tv = new TableViewer(table);
    tv.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(final Object inputElement) {
            if (actBestellung != null) {
              return actBestellung.asList().toArray();
            }
            return new Object[0];
          }

          public void dispose() {}

          public void inputChanged(
              final Viewer viewer, final Object oldInput, final Object newInput) {}
        });
    tv.setLabelProvider(new BestellungLabelProvider());
    tv.setSorter(
        new ViewerSorter() {
          @Override
          public int compare(final Viewer viewer, final Object e1, final Object e2) {
            String s1 = ((Item) e1).art.getName();
            String s2 = ((Item) e2).art.getName();
            return s1.compareTo(s2);
          }
        });
    Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
    tv.addDropSupport(
        DND.DROP_COPY,
        types,
        new DropTargetAdapter() {

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

          @Override
          public void drop(final DropTargetEvent event) {
            String drp = (String) event.data;
            String[] dl = drp.split(","); // $NON-NLS-1$
            if (actBestellung == null) {
              InputDialog dlg =
                  new InputDialog(
                      getViewSite().getShell(),
                      Messages.getString("BestellView.CreateNewOrder"), // $NON-NLS-1$
                      Messages.getString("BestellView.EnterOrderTitle"), // $NON-NLS-1$
                      StringTool.leer,
                      null);
              if (dlg.open() == Dialog.OK) {
                setBestellung(new Bestellung(dlg.getValue(), Hub.actUser));
              } else {
                return;
              }
            }
            for (String obj : dl) {
              PersistentObject dropped = Hub.poFactory.createFromString(obj);
              if (dropped instanceof Artikel) {
                actBestellung.addItem((Artikel) dropped, 1);
              }
            }
            tv.refresh();
          }
        });
    makeActions();
    viewmenus = new ViewMenus(getViewSite());
    viewmenus.createToolbar(wizardAction, saveAction, loadAction, printAction, sendAction);
    viewmenus.createMenu(
        wizardAction, saveAction, loadAction, printAction, sendAction, exportClipboardAction);
    viewmenus.createViewerContextMenu(tv, new IAction[] {removeAction, countAction});
    form.getToolBarManager().add(checkInAction);
    form.updateToolBar();
    setBestellung(null);
    tv.setInput(getViewSite());
  }