/**
   * Create the controls for selecting the controls we are going to export.
   *
   * @param workArea
   */
  private void createSettingsControls(Composite workArea) {
    final FormToolkit toolkit = new FormToolkit(workArea.getDisplay());
    workArea.addDisposeListener(e -> toolkit.dispose());
    final ScrolledForm form = toolkit.createScrolledForm(workArea);
    form.setBackground(workArea.getBackground());
    form.getBody().setLayout(new GridLayout());

    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    form.setLayoutData(layoutData);
    final ExpandableComposite expandable =
        toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TWISTIE);
    expandable.setText(IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SettingsGroupName);
    expandable.setBackground(workArea.getBackground());
    expandable.setLayout(new GridLayout());
    expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    expandable.addExpansionListener(
        new IExpansionListener() {

          boolean notExpanded = true;

          @Override
          public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
            if (e.getState() && notExpanded) {
              getShell().setRedraw(false);
              Rectangle shellBounds = getShell().getBounds();
              int entriesToShow = Math.min(4, SettingsTransfer.getSettingsTransfers().length);

              shellBounds.height +=
                  convertHeightInCharsToPixels(entriesToShow) + IDialogConstants.VERTICAL_SPACING;
              getShell().setBounds(shellBounds);
              getShell().setRedraw(true);
              notExpanded = false;
            }
          }

          @Override
          public void expansionStateChanging(ExpansionEvent e) {
            // Nothing to do here

          }
        });

    Composite sectionClient = toolkit.createComposite(expandable);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setBackground(workArea.getBackground());

    if (createButtons(toolkit, sectionClient)) expandable.setExpanded(true);

    expandable.setClient(sectionClient);
  }
  public void createControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.numColumns = 1;
    composite.setLayout(gridLayout);

    if (!inSearchContainer()) {
      createTitleGroup(composite);
    }

    parametersEditor = new ParametersEditor(composite, SWT.NONE);
    GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData1.minimumHeight = 90;
    parametersEditor.setLayoutData(gridData1);

    ExpandableComposite expComposite =
        toolkit.createExpandableComposite(
            composite, ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE);
    expComposite.setFont(parent.getFont());
    GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData_1.heightHint = 150;
    gridData_1.minimumHeight = 150;
    expComposite.setLayoutData(gridData_1);
    expComposite.setBackground(parent.getBackground());
    expComposite.setText(Messages.WebQueryWizardPage_Advanced_Configuration);
    expComposite.addExpansionListener(
        new ExpansionAdapter() {
          @Override
          public void expansionStateChanged(ExpansionEvent e) {
            getControl().getShell().pack();
          }
        });
    toolkit.paintBordersFor(expComposite);

    Composite composite1 = toolkit.createComposite(expComposite, SWT.BORDER);
    composite1.setLayout(new GridLayout(3, false));
    expComposite.setClient(composite1);

    toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_URL_, SWT.NONE);

    queryUrlText = new Text(composite1, SWT.BORDER);
    final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData_2.widthHint = 200;
    queryUrlText.setLayoutData(gridData_2);
    queryUrlText.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent e) {
            webPage = null;
          }
        });
    decorations.add(
        WebContentProposalProvider.createDecoration(queryUrlText, parametersEditor, false));

    Button button = new Button(composite1, SWT.NONE);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    button.setText(Messages.WebQueryWizardPage_Open);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            openBrowser();
          }
        });

    Label queryPatternLabel =
        toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_Pattern_, SWT.NONE);
    queryPatternLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));

    queryPatternText = new Text(composite1, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
    GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
    gridData.widthHint = 200;
    gridData.heightHint = 60;
    queryPatternText.setLayoutData(gridData);
    decorations.add(
        WebContentProposalProvider.createDecoration(queryPatternText, parametersEditor, true));

    Button preview = new Button(composite1, SWT.NONE);
    preview.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    preview.setText(Messages.WebQueryWizardPage_Preview);
    preview.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            webPage = null;
            updatePreview();
          }
        });

    previewTable = new TableViewer(composite1, SWT.BORDER);
    // previewTable = new Table(composite1, SWT.BORDER);
    GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1);
    gridData2.heightHint = 60;

    Table table = previewTable.getTable();
    table.setLayoutData(gridData2);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    TableColumn colId = new TableColumn(table, SWT.NONE);
    colId.setWidth(100);
    colId.setText(Messages.WebQueryWizardPage_Id);

    TableColumn colDescription = new TableColumn(table, SWT.NONE);
    colDescription.setWidth(200);
    colDescription.setText(Messages.WebQueryWizardPage_Description);

    TableColumn colStatus = new TableColumn(table, SWT.NONE);
    colStatus.setText(Messages.WebQueryWizardPage_Status);
    colStatus.setWidth(80);

    TableColumn colType = new TableColumn(table, SWT.NONE);
    colType.setText(Messages.WebQueryWizardPage_Type);
    colType.setWidth(80);

    TableColumn colOwner = new TableColumn(table, SWT.NONE);
    colOwner.setText(Messages.WebQueryWizardPage_Owner);
    colOwner.setWidth(120);

    previewTable.setColumnProperties(
        new String[] {
          "Id", "Description", "Status", "Type", "Owner"
        }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    previewTable.setContentProvider(
        new IStructuredContentProvider() {

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection<?>) {
              return ((Collection<?>) inputElement).toArray();
            }
            return new Object[0];
          }
        });

    previewTable.setLabelProvider(
        new ITableLabelProvider() {

          public String getColumnText(Object element, int columnIndex) {
            TaskMapper task = (TaskMapper) element;
            switch (columnIndex) {
              case 0:
                return task.getTaskData().getTaskId();
              case 1:
                return task.getSummary();
              case 2:
                return task.getCompletionDate() != null
                    ? Messages.WebQueryWizardPage_complete
                    : Messages.WebQueryWizardPage_incomplete;
              case 3:
                return task.getTaskKind();
              case 4:
                return task.getOwner();
            }
            return null;
          }

          public Image getColumnImage(Object element, int columnIndex) {
            return null;
          }

          public void addListener(ILabelProviderListener listener) {}

          public void dispose() {}

          public boolean isLabelProperty(Object element, String property) {
            return false;
          }

          public void removeListener(ILabelProviderListener listener) {}
        });

    setControl(composite);

    LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>();
    Map<String, String> params = new LinkedHashMap<String, String>();
    if (getTaskRepository() != null) {
      queryUrlText.setText(
          addVars(
              vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL)));
      queryPatternText.setText(
          addVars(
              vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP)));

      oldProperties = getTaskRepository().getProperties();
      params.putAll(oldProperties);
    }
    IRepositoryQuery query = getQuery();
    if (query != null) {
      setTitle(query.getSummary());
      queryUrlText.setText(
          addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_TEMPLATE)));
      queryPatternText.setText(
          addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_PATTERN)));
      params.putAll(WebRepositoryConnector.getQueryParams(query));
    }
    parametersEditor.addParams(params, vars);

    Dialog.applyDialogFont(composite);
  }
예제 #3
0
  @Override
  public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new FillLayout());

    tk = UiDesk.getToolkit();
    form = tk.createScrolledForm(main);
    form.getBody().setLayout(new GridLayout(1, true));

    SashForm mainSash = new SashForm(form.getBody(), SWT.VERTICAL);
    mainSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    dauermedikationSection =
        tk.createExpandableComposite(
            mainSash, ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
    dauermedikationSection.setText("Fixmedikation");

    Composite dauermedikationComposite = tk.createComposite(dauermedikationSection);
    dauermedikationSection.setClient(dauermedikationComposite);
    Composite bottomComposite = tk.createComposite(mainSash);

    mainSash.setWeights(new int[] {25, 75});

    // Dauermedikation

    dauermedikationComposite.setLayout(new GridLayout());

    // Label lDauermedikation = tk.createLabel(dauermedikationComposite, "Fixmedikation");
    // lDauermedikation.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    dlDauerMedi = new ProblemFixMediDisplay(dauermedikationComposite, getViewSite());

    bottomComposite.setLayout(new GridLayout());

    SashForm bottomSash = new SashForm(bottomComposite, SWT.HORIZONTAL);
    bottomSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    diagnosenComposite = tk.createComposite(bottomSash);
    Composite konsultationenComposite = tk.createComposite(bottomSash);

    bottomSash.setWeights(new int[] {25, 75});

    diagnosenComposite.setLayout(new GridLayout(1, true));

    Hyperlink hDiagnosen = tk.createHyperlink(diagnosenComposite, "Diagnosen", SWT.NONE);
    hDiagnosen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    hDiagnosen.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            try {
              getViewSite().getPage().showView(DiagnosenView.ID);
            } catch (Exception ex) {
              ExHandler.handle(ex);
              log.error("Fehler beim Starten des Diagnosencodes " + ex.getMessage());
            }
          }
        });

    Table diagnosenTable = tk.createTable(diagnosenComposite, SWT.SINGLE);
    diagnosenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    diagnosenViewer = new TableViewer(diagnosenTable);
    diagnosenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    diagnosenViewer.setContentProvider(
        new IStructuredContentProvider() {
          @Override
          public Object[] getElements(Object inputElement) {
            if (actProblem != null) {
              List<IDiagnose> diagnosen = actProblem.getDiagnosen();
              return diagnosen.toArray();
            }
            return new Object[0];
          }

          @Override
          public void dispose() {
            // nothing to do
          }

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // nothing to do
          }
        });
    diagnosenViewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (!(element instanceof IDiagnose)) {
              return "";
            }

            IDiagnose diagnose = (IDiagnose) element;
            return diagnose.getLabel();
          }
        });
    diagnosenViewer.setInput(this);

    konsultationenComposite.setLayout(new GridLayout(1, true));

    Label lKonsultationen = tk.createLabel(konsultationenComposite, "Konsultationen", SWT.LEFT);
    lKonsultationen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));

    Table konsultationenTable = tk.createTable(konsultationenComposite, SWT.SINGLE);
    konsultationenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    konsultationenViewer = new TableViewer(konsultationenTable);
    konsultationenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    konsultationenViewer.setContentProvider(
        new IStructuredContentProvider() {
          @Override
          public Object[] getElements(Object inputElement) {
            if (actProblem != null) {
              List<Konsultation> konsultationen = actProblem.getKonsultationen();
              return konsultationen.toArray();
            }
            return new Object[0];
          }

          @Override
          public void dispose() {
            // nothing to do
          }

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // nothing to do
          }
        });
    konsultationenViewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (!(element instanceof Konsultation)) {
              return "";
            }

            Konsultation konsultation = (Konsultation) element;
            return konsultation.getLabel();
          }
        });
    konsultationenViewer.setInput(this);

    /* Implementation Drag&Drop */

    final TextTransfer textTransfer = TextTransfer.getInstance();
    Transfer[] types = new Transfer[] {textTransfer};

    // diagnosenComposite
    DropTarget dtarget = new DropTarget(diagnosenComposite, DND.DROP_COPY);
    dtarget.setTransfer(types);
    dtarget.addDropListener(
        new DropTargetListener() {
          @Override
          public void dragEnter(DropTargetEvent event) {
            /* Wir machen nur Copy-Operationen */
            event.detail = DND.DROP_COPY;
          }

          /* Mausbewegungen mit gedrückter Taste sind uns egal */
          @Override
          public void dragLeave(DropTargetEvent event) {
            /* leer */
          }

          @Override
          public void dragOperationChanged(DropTargetEvent event) {
            /* leer */
          }

          @Override
          public void dragOver(DropTargetEvent event) {
            /* leer */
          }

          /* Erst das Loslassen interessiert uns wieder */
          @Override
          public void drop(DropTargetEvent event) {
            String drp = (String) event.data;
            String[] dl = drp.split(",");
            for (String obj : dl) {
              PersistentObject dropped = CoreHub.poFactory.createFromString(obj);
              if (dropped instanceof IDiagnose) {
                IDiagnose diagnose = (IDiagnose) dropped;
                actProblem.addDiagnose(diagnose);

                // tell other viewers that something has changed
                IatrixEventHelper.updateProblem(actProblem);

                // update ourselves
                // TODO: implement ObjectListener
                diagnosenViewer.refresh();
              }
            }
          }

          @Override
          public void dropAccept(DropTargetEvent event) {
            /* leer */
          }
        });

    makeListeners();
    makeActions();
    menus = new ViewMenus(getViewSite());
    menus.createViewerContextMenu(diagnosenViewer, delDiagnoseAction);
    menus.createViewerContextMenu(konsultationenViewer, unassignProblemAction);

    GlobalEventDispatcher.addActivationListener(this, this);
  }