예제 #1
0
  public RTQueryPage(TaskRepository taskRepository, IRepositoryQuery query) {
    super("Enter query parameters", taskRepository, query);

    try {
      urls = URLFactory.create(taskRepository.getRepositoryUrl());
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }

    if (query != null) {
      this.titleString = query.getSummary();
      this.queryString = query.getAttribute(RequestTrackerTaskDataHandler.QUERY_ID);
    }
  }
예제 #2
0
 /**
  * @see
  *     org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector#performQuery(org.eclipse.mylyn.tasks.core.TaskRepository,
  *     org.eclipse.mylyn.tasks.core.IRepositoryQuery,
  *     org.eclipse.mylyn.tasks.core.data.TaskDataCollector,
  *     org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession,
  *     org.eclipse.core.runtime.IProgressMonitor)
  */
 public IStatus performQuery(
     TaskRepository repository,
     IRepositoryQuery query,
     TaskDataCollector collector,
     ISynchronizationSession session,
     IProgressMonitor monitor) {
   IStatus status = Status.OK_STATUS;
   GistService service = new GistService(createClient(repository));
   String user = query.getAttribute(IGistQueryConstants.USER);
   try {
     TaskAttributeMapper mapper = dataHandler.getAttributeMapper(repository);
     for (Gist gist : service.getGists(user)) {
       TaskData data = new TaskData(mapper, getConnectorKind(), repository.getUrl(), gist.getId());
       data.setPartial(true);
       dataHandler.fillTaskData(repository, data, gist);
       collector.accept(data);
     }
   } catch (IOException e) {
     status = GitHub.createWrappedStatus(e);
   }
   return status;
 }
  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);
  }
예제 #4
0
 @Override
 void loadQueryParameters(IRepositoryQuery query) {
   String fid = query.getAttribute(ATTR_FILTER_ID);
   filterID = FilterID.valueOf(fid);
 }