Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2013-07-29 20:01:19 +04:00
15 changed files with 211 additions and 73 deletions
@@ -935,6 +935,7 @@
<option name="MATCHED_BRACE_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="ff8647" />
<option name="BACKGROUND" value="3b514d" />
</value>
</option>
<option name="MESSAGE_ARGUMENT">
@@ -90,12 +90,11 @@ public class LogConsolePreferences extends LogFilterRegistrar {
fireStateChanged();
}
public boolean isApplicable(@NotNull String text, String prevType, boolean checkStandartFilters) {
public boolean isApplicable(@NotNull String text, String prevType, boolean checkStandardFilters) {
for (LogFilter filter : myRegisteredLogFilters.keySet()) {
if (myRegisteredLogFilters.get(filter).booleanValue() && !filter.isAcceptable(text)) return false;
}
if (checkStandartFilters) {
if (checkStandardFilters) {
final String type = getType(text);
boolean selfTyped = false;
if (type != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,10 +55,12 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.ColorUtil;
import com.intellij.util.Alarm;
import com.intellij.util.Processor;
import com.intellij.util.containers.WeakHashMap;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -413,7 +415,11 @@ public class BraceHighlightingHandler {
if (myProject.isDisposed() || myEditor.isDisposed()) return;
Color color = attributes.getBackgroundColor();
if (color == null) return;
color = color.darker();
if (UIUtil.isUnderDarcula()) {
color = ColorUtil.shift(color, 1.1d);
} else {
color = color.darker();
}
lineMarkFragment(startLine, endLine, color);
}
};
@@ -30,7 +30,7 @@ import java.util.List;
*/
public class DefaultLogFilterModel extends LogFilterModel {
private final Project myProject;
private boolean myCheckStandartFilters = true;
private boolean myCheckStandardFilters = true;
private String myPrevType = null;
public DefaultLogFilterModel(Project project) {
@@ -42,11 +42,11 @@ public class DefaultLogFilterModel extends LogFilterModel {
}
public boolean isCheckStandartFilters() {
return myCheckStandartFilters;
return myCheckStandardFilters;
}
public void setCheckStandartFilters(boolean checkStandartFilters) {
myCheckStandartFilters = checkStandartFilters;
public void setCheckStandartFilters(boolean checkStandardFilters) {
myCheckStandardFilters = checkStandardFilters;
}
@Override
@@ -68,7 +68,7 @@ public class DefaultLogFilterModel extends LogFilterModel {
@Override
public boolean isApplicable(String line) {
if (!super.isApplicable(line)) return false;
return getPreferences().isApplicable(line, myPrevType, myCheckStandartFilters);
return getPreferences().isApplicable(line, myPrevType, myCheckStandardFilters);
}
@Override
@@ -78,70 +78,70 @@ public class DefaultLogFilterModel extends LogFilterModel {
@Override
public List<LogFilter> getLogFilters() {
LogConsolePreferences prefs = getPreferences();
LogConsolePreferences preferences = getPreferences();
final ArrayList<LogFilter> filters = new ArrayList<LogFilter>();
if (myCheckStandartFilters) {
addStandartFilters(filters, prefs);
if (myCheckStandardFilters) {
addStandardFilters(filters, preferences);
}
filters.addAll(prefs.getRegisteredLogFilters());
filters.addAll(preferences.getRegisteredLogFilters());
return filters;
}
private void addStandartFilters(ArrayList<LogFilter> filters, final LogConsolePreferences prefs) {
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.all"), prefs) {
private void addStandardFilters(ArrayList<LogFilter> filters, final LogConsolePreferences preferences) {
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.all"), preferences) {
@Override
public void selectFilter() {
prefs.FILTER_ERRORS = false;
prefs.FILTER_INFO = false;
prefs.FILTER_WARNINGS = false;
prefs.FILTER_DEBUG = false;
preferences.FILTER_ERRORS = false;
preferences.FILTER_INFO = false;
preferences.FILTER_WARNINGS = false;
preferences.FILTER_DEBUG = false;
}
@Override
public boolean isSelected() {
return !prefs.FILTER_ERRORS && !prefs.FILTER_INFO && !prefs.FILTER_WARNINGS && !prefs.FILTER_DEBUG;
return !preferences.FILTER_ERRORS && !preferences.FILTER_INFO && !preferences.FILTER_WARNINGS && !preferences.FILTER_DEBUG;
}
});
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors.warnings.and.infos"), prefs) {
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors.warnings.and.infos"), preferences) {
@Override
public void selectFilter() {
prefs.FILTER_ERRORS = false;
prefs.FILTER_INFO = false;
prefs.FILTER_WARNINGS = false;
prefs.FILTER_DEBUG = true;
preferences.FILTER_ERRORS = false;
preferences.FILTER_INFO = false;
preferences.FILTER_WARNINGS = false;
preferences.FILTER_DEBUG = true;
}
@Override
public boolean isSelected() {
return !prefs.FILTER_ERRORS && !prefs.FILTER_INFO && !prefs.FILTER_WARNINGS && prefs.FILTER_DEBUG;
return !preferences.FILTER_ERRORS && !preferences.FILTER_INFO && !preferences.FILTER_WARNINGS && preferences.FILTER_DEBUG;
}
});
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors.and.warnings"), prefs) {
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors.and.warnings"), preferences) {
@Override
public void selectFilter() {
prefs.FILTER_ERRORS = false;
prefs.FILTER_INFO = true;
prefs.FILTER_WARNINGS = false;
prefs.FILTER_DEBUG = true;
preferences.FILTER_ERRORS = false;
preferences.FILTER_INFO = true;
preferences.FILTER_WARNINGS = false;
preferences.FILTER_DEBUG = true;
}
@Override
public boolean isSelected() {
return !prefs.FILTER_ERRORS && prefs.FILTER_INFO && !prefs.FILTER_WARNINGS && prefs.FILTER_DEBUG;
return !preferences.FILTER_ERRORS && preferences.FILTER_INFO && !preferences.FILTER_WARNINGS && preferences.FILTER_DEBUG;
}
});
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors"), prefs) {
filters.add(new MyFilter(DiagnosticBundle.message("log.console.filter.show.errors"), preferences) {
@Override
public void selectFilter() {
prefs.FILTER_ERRORS = false;
prefs.FILTER_INFO = true;
prefs.FILTER_WARNINGS = true;
prefs.FILTER_DEBUG = true;
preferences.FILTER_ERRORS = false;
preferences.FILTER_INFO = true;
preferences.FILTER_WARNINGS = true;
preferences.FILTER_DEBUG = true;
}
@Override
public boolean isSelected() {
return !prefs.FILTER_ERRORS && prefs.FILTER_INFO && prefs.FILTER_WARNINGS && prefs.FILTER_DEBUG;
return !preferences.FILTER_ERRORS && preferences.FILTER_INFO && preferences.FILTER_WARNINGS && preferences.FILTER_DEBUG;
}
});
}
@@ -171,16 +171,16 @@ public class DefaultLogFilterModel extends LogFilterModel {
}
private abstract class MyFilter extends IndependentLogFilter {
private final LogConsolePreferences myPrefs;
private final LogConsolePreferences myPreferences;
protected MyFilter(String name, LogConsolePreferences prefs) {
protected MyFilter(String name, LogConsolePreferences preferences) {
super(name);
myPrefs = prefs;
myPreferences = preferences;
}
@Override
public boolean isAcceptable(String line) {
return myPrefs.isApplicable(line, myPrevType, myCheckStandartFilters);
return myPreferences.isApplicable(line, myPrevType, myCheckStandardFilters);
}
}
}
@@ -50,6 +50,7 @@ import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.IOException;
@@ -156,7 +157,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
myFilter.setSelectedItem(customFilter != null ? customFilter : "");
new AnAction() {
{
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK)),
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK)),
LogConsoleBase.this);
}
@@ -75,13 +75,13 @@ public abstract class LogConsoleImpl extends LogConsoleBase {
inputStream.skip(skippedContents);
}
}
catch (FileNotFoundException e) {
catch (FileNotFoundException ignored) {
if (FileUtil.createIfDoesntExist(file)) {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
}
}
}
catch (Throwable e) {
catch (Throwable ignored) {
reader = null;
}
return reader;
@@ -212,7 +212,7 @@ public class GithubShareAction extends DumbAwareAction {
}
// check access to private repos (network)
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserInfo(auth);
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserDetailed(auth);
githubInfoRef.set(new GithubInfo(auth, userInfo, names));
}
catch (IOException e) {
@@ -232,7 +232,7 @@ public class GithubUtil {
}
private static void testConnection(@NotNull GithubAuthData auth, @Nullable String login) throws IOException {
GithubUserDetailed user = GithubApiUtil.getCurrentUserInfo(auth);
GithubUserDetailed user = GithubApiUtil.getCurrentUserDetailed(auth);
if (login != null && !login.equalsIgnoreCase(user.getLogin())) {
throw new GithubAuthenticationException("Wrong login");
}
@@ -33,10 +33,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.*;
/**
* @author Kirill Likhodedov
@@ -404,7 +401,13 @@ public class GithubApiUtil {
}
@NotNull
public static GithubUserDetailed getCurrentUserInfo(@NotNull GithubAuthData auth) throws IOException {
public static GithubUser getCurrentUser(@NotNull GithubAuthData auth) throws IOException {
JsonElement result = getRequest(auth, "/user");
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUser.class);
}
@NotNull
public static GithubUserDetailed getCurrentUserDetailed(@NotNull GithubAuthData auth) throws IOException {
JsonElement result = getRequest(auth, "/user");
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUserDetailed.class);
}
@@ -479,18 +482,16 @@ public class GithubApiUtil {
}
@NotNull
public static List<GithubIssue> getIssues(@NotNull GithubAuthData auth,
@NotNull String user,
@NotNull String repo,
@Nullable String query) throws IOException {
public static List<GithubIssue> getIssuesAssigned(@NotNull GithubAuthData auth,
@NotNull String user,
@NotNull String repo,
@Nullable String assigned) throws IOException {
String path;
boolean noQuery = StringUtil.isEmpty(query);
if (!noQuery) {
query = URLEncoder.encode(query, "UTF-8");
path = "/legacy/issues/search/" + user + "/" + repo + "/open/" + query + "?per_page=100";
if (StringUtil.isEmptyOrSpaces(assigned)) {
path = "/repos/" + user + "/" + repo + "/issues?per_page=100";
}
else {
path = "/repos/" + user + "/" + repo + "/issues?per_page=100";
path = "/repos/" + user + "/" + repo + "/issues?assignee=" + assigned + "&per_page=100";
}
PagedRequest<GithubIssue, GithubIssueRaw> request =
@@ -499,6 +500,20 @@ public class GithubApiUtil {
return request.getAll();
}
@NotNull
public static List<GithubIssue> getIssuesQueried(@NotNull GithubAuthData auth,
@NotNull String user,
@NotNull String repo,
@Nullable String query) throws IOException {
query = URLEncoder.encode("@" + user + "/" + repo + " " + query, "UTF-8");
String path = "/search/issues/?q=" + query;
JsonElement result = getRequest(auth, path);
return createDataFromRaw(fromJson(result, GithubIssuesSearchResultRaw.class), GithubIssuesSearchResult.class).getIssues();
}
@NotNull
public static GithubIssue getIssue(@NotNull GithubAuthData auth, @NotNull String user, @NotNull String repo, @NotNull String id)
throws IOException {
@@ -570,4 +585,4 @@ public class GithubApiUtil {
return request.getAll();
}
}
}
@@ -0,0 +1,37 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.github.api;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author Aleksey Pivovarov
*/
@SuppressWarnings("UnusedDeclaration")
public class GithubIssuesSearchResult {
@NotNull private List<GithubIssue> issues;
public GithubIssuesSearchResult(@NotNull List<GithubIssue> issues) {
this.issues = issues;
}
@NotNull
public List<GithubIssue> getIssues() {
return issues;
}
}
@@ -0,0 +1,50 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.github.api;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author Aleksey Pivovarov
*/
@SuppressWarnings("UnusedDeclaration")
public class GithubIssuesSearchResultRaw implements DataConstructor {
List<GithubIssueRaw> items;
@NotNull
GithubIssuesSearchResult createIssueSearchResult() {
List<GithubIssue> issues = new ArrayList<GithubIssue>();
for (GithubIssueRaw raw : items) {
issues.add(raw.createIssue());
}
return new GithubIssuesSearchResult(issues);
}
@SuppressWarnings("unchecked")
@NotNull
@Override
public <T> T create(@NotNull Class<T> resultClass) {
if (resultClass.isAssignableFrom(GithubIssuesSearchResult.class)) {
return (T)createIssueSearchResult();
}
throw new ClassCastException(this.getClass().getName() + ": bad class type: " + resultClass.getName());
}
}
@@ -39,6 +39,7 @@ public class GithubRepository extends BaseRepositoryImpl {
private Pattern myPattern = Pattern.compile("($^)");
private String myRepoAuthor = "";
private String myRepoName = "";
private String myUser = "";
private String myToken = "";
{
@@ -85,7 +86,16 @@ public class GithubRepository extends BaseRepositoryImpl {
@NotNull
private Task[] getIssues(@Nullable String query) throws Exception {
List<GithubIssue> issues = GithubApiUtil.getIssues(getAuthData(), getRepoAuthor(), getRepoName(), query);
List<GithubIssue> issues;
if (StringUtil.isEmptyOrSpaces(query)) {
if (StringUtil.isEmptyOrSpaces(myUser)) {
myUser = GithubApiUtil.getCurrentUser(getAuthData()).getLogin();
}
issues = GithubApiUtil.getIssuesAssigned(getAuthData(), getRepoAuthor(), getRepoName(), myUser);
}
else {
issues = GithubApiUtil.getIssuesQueried(getAuthData(), getRepoAuthor(), getRepoName(), query);
}
return ContainerUtil.map2Array(issues, Task.class, new Function<GithubIssue, Task>() {
@Override
@@ -223,6 +233,14 @@ public class GithubRepository extends BaseRepositoryImpl {
myRepoAuthor = repoAuthor;
}
public String getUser() {
return myUser;
}
public void setUser(String user) {
myUser = user;
}
@Transient
public String getToken() {
return myToken;
@@ -22,6 +22,7 @@ import com.intellij.execution.configurations.RunProfile;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.LibraryUtil;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -36,6 +37,7 @@ import org.jetbrains.plugins.groovy.util.GroovyUtils;
import org.jetbrains.plugins.groovy.util.LibrariesUtil;
import java.io.File;
import java.util.List;
import static com.intellij.util.containers.ContainerUtil.ar;
@@ -129,7 +131,6 @@ public class GantRunner extends GroovyScriptRunner {
final File[] groovyJars = GroovyConfigUtils.getGroovyAllJars(gantHome + "/lib/");
if (groovyJars.length > 0) {
params.getClassPath().add(groovyJars[0].getAbsolutePath());
return;
}
if (module == null) {
@@ -141,17 +142,20 @@ public class GantRunner extends GroovyScriptRunner {
File[] libJars = GroovyUtils.getFilesInDirectoryByPattern(groovyHome + "/lib/", ".*\\.jar");
if (libJars.length > 0) {
params.getClassPath().addAllFiles(libJars);
return;
}
}
List<VirtualFile> classpath = params.getClassPath().getRootDirs();
String[] characteristicClasses = ar(
LibrariesUtil.SOME_GROOVY_CLASS, "org.apache.tools.ant.BuildException",
"org.apache.tools.ant.launch.AntMain", "org.apache.commons.cli.ParseException");
LibrariesUtil.SOME_GROOVY_CLASS, "org.apache.tools.ant.BuildException", "org.apache.tools.ant.launch.AntMain",
"org.apache.commons.cli.ParseException");
for (String someClass : characteristicClasses) {
VirtualFile jar = LibrariesUtil.findJarWithClass(module, someClass);
if (jar != null) {
params.getClassPath().add(jar);
if (!LibraryUtil.isClassAvailableInLibrary(classpath, someClass)) {
VirtualFile jar = LibrariesUtil.findJarWithClass(module, someClass);
if (jar != null) {
params.getClassPath().add(jar);
}
}
}
}
@@ -20,6 +20,7 @@ import com.intellij.tasks.*;
import com.intellij.tasks.jira.model.JiraComment;
import com.intellij.tasks.jira.model.JiraIssue;
import com.intellij.tasks.jira.model.JiraIssueType;
import com.intellij.tasks.jira.model.JiraStatus;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import icons.TasksIcons;
@@ -100,7 +101,8 @@ class JiraTask extends Task {
@Override
public TaskState getState() {
switch (Integer.parseInt(myJiraIssue.getId())) {
JiraStatus status = myJiraIssue.getStatus();
switch (Integer.parseInt(status.getId())) {
case 1:
return TaskState.OPEN;
case 3:
@@ -32,7 +32,7 @@ public class JiraIssue {
*/
public static final String REQUIRED_RESPONSE_FIELDS = "id,key,summary,description," +
"created,updated,duedate,resolutiondate" +
"assignee,reporter,issuetype,comment";
"assignee,reporter,issuetype,comment,status";
private String id;
private String key;
@@ -109,6 +109,10 @@ public class JiraIssue {
return fields.comment == null ? ContainerUtil.<JiraComment>emptyList() : fields.comment.getComments();
}
public JiraStatus getStatus() {
return fields.status;
}
public static class Fields {
private String summary;
private String description;
@@ -122,5 +126,6 @@ public class JiraIssue {
private JiraUser reporter;
private JiraIssueType issuetype;
private JiraStatus status;
}
}