当前位置: 首页>>代码示例>>Java>>正文


Java TaskUtil类代码示例

本文整理汇总了Java中com.intellij.tasks.impl.TaskUtil的典型用法代码示例。如果您正苦于以下问题:Java TaskUtil类的具体用法?Java TaskUtil怎么用?Java TaskUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TaskUtil类属于com.intellij.tasks.impl包,在下文中一共展示了TaskUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findTasks

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@NotNull
@Override
public List<Task> findTasks(@NotNull String query, int max) throws Exception {

  // Unfortunately, both SOAP and XML-RPC interfaces of JIRA don't allow fetching *all* tasks from server, but
  // only filtered by some search term (see http://stackoverflow.com/questions/764282/how-can-jira-soap-api-not-have-this-method).
  // JQL was added in SOAP only since JIRA 4.0 (see method JiraSoapService#getIssuesFromJqlSearch() at
  // https://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/soap/JiraSoapService.html)
  // So due to this limitation and the need to support these old versions of bug tracker (3.0, 4.2) we need the following ugly and hacky
  // solution with extracting issues from RSS feed.

  GetMethod method = new GetMethod(myRepository.getUrl() + RSS_SEARCH_PATH);
  method.setQueryString(new NameValuePair[] {
    new NameValuePair("tempMax", String.valueOf(max)),
    new NameValuePair("assignee", TaskUtil.encodeUrl(myRepository.getUsername())),
    new NameValuePair("reset", "true"),
    new NameValuePair("sorter/field", "updated"),
    new NameValuePair("sorter/order", "DESC"),
    new NameValuePair("pager/start", "0")
  });
  return processRSS(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JiraLegacyApi.java

示例2: update

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@Override
public void update(AnActionEvent event) {
  super.update(event);
  if (event.getPresentation().isEnabled()) {
    TaskManager manager = getTaskManager(event);
    Presentation presentation = event.getPresentation();

    if (manager == null || !manager.isVcsEnabled()) {
      presentation.setText(getTemplatePresentation().getText());
      presentation.setEnabled(false);
    }
    else {
      presentation.setEnabled(true);
      if (manager.getActiveTask().getChangeLists().size() == 0) {
        presentation.setText("Create changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
      }
      else {
        presentation.setText("Add changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateChangelistAction.java

示例3: doREST

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
HttpMethod doREST(String request, boolean post) throws Exception {
  HttpClient client = login(new PostMethod(getUrl() + "/rest/user/login"));
  String uri = getUrl() + request;
  HttpMethod method = post ? new PostMethod(uri) : new GetMethod(uri);
  configureHttpMethod(method);
  int status = client.executeMethod(method);
  if (status == 400) {
    InputStream string = method.getResponseBodyAsStream();
    Element element = new SAXBuilder(false).build(string).getRootElement();
    TaskUtil.prettyFormatXmlToLog(LOG, element);
    if ("error".equals(element.getName())) {
      throw new Exception(element.getText());
    }
  }
  return method;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:YouTrackRepository.java

示例4: Response

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
public Response(@NotNull InputStream stream) throws Exception {
  final Element root = new SAXBuilder().build(stream).getRootElement();
  TaskUtil.prettyFormatXmlToLog(LOG, root);
  @NotNull final Element highlight = root.getChild("highlight");
  //assert highlight != null : "no '/IntelliSense/highlight' element in YouTrack response";
  myHighlightRanges = ContainerUtil.map(highlight.getChildren("range"), new Function<Element, HighlightRange>() {
    @Override
    public HighlightRange fun(Element range) {
      return new HighlightRange(range);
    }
  });

  @NotNull final Element suggest = root.getChild("suggest");
  //assert suggest != null : "no '/IntelliSense/suggest' element in YouTrack response";
  myCompletionItems = ContainerUtil.map(suggest.getChildren("item"), new Function<Element, CompletionItem>() {
    @Override
    public CompletionItem fun(Element item) {
      return new CompletionItem(item);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:YouTrackIntellisense.java

示例5: handleResponse

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@Override
public T handleResponse(HttpResponse response) throws IOException {
  int statusCode = response.getStatusLine().getStatusCode();
  if (!isSuccessful(statusCode)) {
    if (statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound) {
      return null;
    }
    throw RequestFailedException.forStatusCode(statusCode);
  }
  try {
    if (LOG.isDebugEnabled()) {
      String content = getResponseContentAsString(response);
      TaskUtil.prettyFormatJsonToLog(LOG, content);
      return myGson.fromJson(content, myClass);
    }
    else {
      return myGson.fromJson(getResponseContentAsReader(response), myClass);
    }
  }
  catch (JsonSyntaxException e) {
    LOG.warn("Malformed server response", e);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TaskResponseUtil.java

示例6: getRestApiUrl

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
/**
 * Build URL using {@link #getUrl()}, {@link #getRestApiPathPrefix()}} and specified path components.
 * <p/>
 * Individual path components will should not contain leading or trailing slashes. Empty or null components
 * will be omitted. Each components is converted to string using its {@link Object#toString()} method and url encoded, so
 * numeric IDs can be used as well. Returned URL doesn't contain trailing '/', because it's not compatible with some services.
 *
 * @return described URL
 */
@NotNull
public String getRestApiUrl(@NotNull Object... parts) {
  StringBuilder builder = new StringBuilder(getUrl());
  builder.append(getRestApiPathPrefix());
  if (builder.charAt(builder.length() - 1) == '/') {
    builder.deleteCharAt(builder.length() - 1);
  }
  for (Object part : parts) {
    if (part == null || part.equals("")) {
      continue;
    }
    builder.append('/').append(TaskUtil.encodeUrl(String.valueOf(part)));
  }
  return builder.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:NewBaseRepositoryImpl.java

示例7: testSetTimeSpend

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
public void testSetTimeSpend() throws Exception {
  // only REST API 2.0 supports this feature
  myRepository.setUrl(JIRA_5_TEST_SERVER_URL);
  final String issueId = createIssueViaRestApi("BTTTU", "Test issue for time tracking updates (" + SHORT_TIMESTAMP_FORMAT.format(new Date()) + ")");
  final Task task = myRepository.findTask(issueId);
  assertNotNull("Test task not found", task);

  // timestamp as comment
  final String comment = "Timestamp: " + TaskUtil.formatDate(new Date());

  // semi-unique duration as timeSpend
  // should be no longer than 8 hours in total, because it's considered as one full day
  final int minutes = (int)(System.currentTimeMillis() % 240) + 1;
  final String duration = String.format("%dh %dm", minutes / 60, minutes % 60);
  myRepository.updateTimeSpent(new LocalTaskImpl(task), duration, comment);

  final GetMethod request = new GetMethod(myRepository.getRestUrl("issue", task.getId(), "worklog"));
  final String response = myRepository.executeMethod(request);
  final JsonObject object = new Gson().fromJson(response, JsonObject.class);
  final JsonArray worklogs = object.get("worklogs").getAsJsonArray();
  final JsonObject last = worklogs.get(worklogs.size() - 1).getAsJsonObject();

  assertEquals(comment, last.get("comment").getAsString());
  // don't depend on concrete response format: zero hours stripping, zero padding and so on
  assertEquals(minutes * 60, last.get("timeSpentSeconds").getAsInt());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JiraIntegrationTest.java

示例8: getRestApiUrl

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
/**
 * Build URL using {@link #getUrl()}, {@link #getRestApiPathPrefix()}} and specified path components.
 * <p>
 * Individual path components will should not contain leading or trailing slashes. Empty or null components
 * will be omitted. Each components is converted to string using its {@link Object#toString()} method and url encoded, so
 * numeric IDs can be used as well. Returned URL doesn't contain trailing '/', because it's not compatible with some services.
 *
 * @return described URL
 */
@NotNull
public String getRestApiUrl(@NotNull Object... parts)
{
	StringBuilder builder = new StringBuilder(getUrl());
	builder.append(getRestApiPathPrefix());
	if(builder.charAt(builder.length() - 1) == '/')
	{
		builder.deleteCharAt(builder.length() - 1);
	}
	for(Object part : parts)
	{
		if(part == null || part.equals(""))
		{
			continue;
		}
		builder.append('/').append(TaskUtil.encodeUrl(String.valueOf(part)));
	}
	return builder.toString();
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:29,代码来源:NewBaseRepositoryImpl.java

示例9: testDateParsings

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
/**
 * Test ISO8601 date parsing
 */
@Test
public void testDateParsings() throws Exception {
  final Date expected = FORMATTER.parse("2013-08-23 10:11:12.000");
  final Date expectedWithMillis = FORMATTER.parse("2013-08-23 10:11:12.100");
  final Date expectedDateOnly = FORMATTER.parse("2013-08-23 00:00:00.000");
  // JIRA, Redmine and Pivotal
  compareDates(expectedWithMillis, "2013-08-23T14:11:12.100+0400");
  // Trello
  compareDates(expectedWithMillis, "2013-08-23T10:11:12.100Z");
  // Assmbla
  compareDates(expectedWithMillis, "2013-08-23T14:11:12.100+04:00");

  // Formatting variations
  compareDates(expected, "2013/08/23 10:11:12");
  compareDates(expectedDateOnly, "2013-08-23");
  compareDates(expectedWithMillis, "2013-08-23 14:11:12.100123+04");

  // Malformed date
  assertNull(TaskUtil.parseDate("Fri Aug 23 14:11:12 MSK 2013"));
  assertNull(TaskUtil.parseDate("2013:00:23"));
  assertNull(TaskUtil.parseDate("2013/08/23 10:11:12 GMT+04:00"));
  assertNull(TaskUtil.parseDate("2013-08-23+0400"));
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:27,代码来源:DateParsingTest.java

示例10: selectDate

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@Nullable
private Date selectDate(@NotNull Selector selector, @NotNull Object context) throws Exception {
  String s = selectString(selector, context);
  if (s == null) {
    return null;
  }
  return TaskUtil.parseDate(s);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:SelectorBasedResponseHandler.java

示例11: TaskListItem

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
protected TaskListItem(LocalTask task, String separator, boolean temp) {
  myTask = task;
  mySeparator = separator;
  myTemp = temp;
  myText = TaskUtil.getTrimmedSummary(task);
  myIcon = temp ? IconLoader.getTransparentIcon(task.getIcon(), 0.5f) : task.getIcon();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TaskListItem.java

示例12: getElementName

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@Override
public String getElementName(Object element) {
  if (element instanceof TaskPsiElement) {
    return TaskUtil.getTrimmedSummary(((TaskPsiElement)element).getTask());
  }
  else if (element == CREATE_NEW_TASK_ACTION) {
    return CREATE_NEW_TASK_ACTION.getActionText();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GotoTaskAction.java

示例13: testDateParsings

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
/**
 * Test ISO8601 date parsing
 */
@Test
public void testDateParsings() throws Exception {
  final Date expected = FORMATTER.parse("2013-08-23 10:11:12.000");
  final Date expectedWithMillis = FORMATTER.parse("2013-08-23 10:11:12.100");
  final Date expectedDateOnly = FORMATTER.parse("2013-08-23 00:00:00.000");
  // JIRA, Redmine and Pivotal
  compareDates(expectedWithMillis, "2013-08-23T14:11:12.100+0400");
  // Trello
  compareDates(expectedWithMillis, "2013-08-23T10:11:12.100Z");
  // Assmbla
  compareDates(expectedWithMillis, "2013-08-23T14:11:12.100+04:00");

  // Formatting variations
  compareDates(expected, "2013/08/23 10:11:12");
  compareDates(expectedDateOnly, "2013-08-23");
  compareDates(expectedWithMillis, "2013-08-23 14:11:12.100123+04");
  // Possible Redmine date format, notice space before timezone
  compareDates(expected, "2013/08/23 14:11:12 +0400");


  // Malformed date
  assertNull(TaskUtil.parseDate("Fri Aug 23 14:11:12 MSK 2013"));
  assertNull(TaskUtil.parseDate("2013:00:23"));
  assertNull(TaskUtil.parseDate("2013/08/23 10:11:12 GMT+04:00"));
  assertNull(TaskUtil.parseDate("2013-08-23+0400"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:DateParsingTest.java

示例14: executeMethod

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
private String executeMethod(HttpMethod method) throws Exception {
  LOG.debug("URI is " + method.getURI());
  String responseBody;
  try {
    getHttpClient().executeMethod(method);
    Header contentType = method.getResponseHeader("Content-Type");
    if (contentType != null && contentType.getValue().contains("charset")) {
      // ISO-8859-1 if charset wasn't specified in response
      responseBody = StringUtil.notNullize(method.getResponseBodyAsString());
    }
    else {
      InputStream stream = method.getResponseBodyAsStream();
      responseBody = stream == null? "": StreamUtil.readText(stream, "utf-8");
    }
  }
  finally {
    method.releaseConnection();
  }
  switch (getResponseType()) {
    case XML:
      TaskUtil.prettyFormatXmlToLog(LOG, responseBody);
      break;
    case JSON:
      TaskUtil.prettyFormatJsonToLog(LOG, responseBody);
      break;
    default:
      LOG.debug(responseBody);
  }
  LOG.debug("Status code is " + method.getStatusCode());
  if (method.getStatusCode() != HttpStatus.SC_OK) {
    throw new Exception("Request failed with HTTP error: " + method.getStatusText());
  }
  return responseBody;
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:35,代码来源:GenericRepository.java

示例15: handleResponse

import com.intellij.tasks.impl.TaskUtil; //导入依赖的package包/类
@Override
public T handleResponse(HttpResponse response) throws IOException
{
	int statusCode = response.getStatusLine().getStatusCode();
	if(!isSuccessful(statusCode))
	{
		if(statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound)
		{
			return null;
		}
		throw RequestFailedException.forStatusCode(statusCode);
	}
	try
	{
		if(LOG.isDebugEnabled())
		{
			String content = getResponseContentAsString(response);
			TaskUtil.prettyFormatJsonToLog(LOG, content);
			return myGson.fromJson(content, myClass);
		}
		else
		{
			return myGson.fromJson(getResponseContentAsReader(response), myClass);
		}
	}
	catch(JsonSyntaxException e)
	{
		LOG.warn("Malformed server response", e);
		return null;
	}
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:32,代码来源:TaskResponseUtil.java


注:本文中的com.intellij.tasks.impl.TaskUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。