mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68253 Issue trackers integration. Added possibility to login anonymously.
This commit is contained in:
@@ -36,6 +36,7 @@ public abstract class TaskRepositoryType<T extends TaskRepository> {
|
||||
protected static final int NO_FEATURES = 0;
|
||||
|
||||
public static final int BASIC_HTTP_AUTHORIZATION = 0x0001;
|
||||
public static final int LOGIN_ANONYMOUSLY = 0x0002;
|
||||
|
||||
@NotNull
|
||||
public abstract String getName();
|
||||
@@ -50,7 +51,7 @@ public abstract class TaskRepositoryType<T extends TaskRepository> {
|
||||
|
||||
public abstract Class<T> getRepositoryClass();
|
||||
|
||||
public boolean isSupported(int feature) {
|
||||
public final boolean isSupported(int feature) {
|
||||
return (getFeatures() & feature) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="76b0" layout-manager="GridLayoutManager" row-count="8" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="76b0" layout-manager="GridLayoutManager" row-count="9" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<tabbedpane title="General"/>
|
||||
@@ -25,7 +25,7 @@
|
||||
<children>
|
||||
<vspacer id="10875">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="fec04" class="com.intellij.ui.components.JBLabel" binding="myUrlLabel">
|
||||
@@ -46,45 +46,9 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="22736" class="com.intellij.ui.components.JBLabel" binding="myUsernameLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="63a48"/>
|
||||
<text value="User&name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="63a48" class="javax.swing.JTextField" binding="myUserNameText">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="70c27" class="com.intellij.ui.components.JBLabel" binding="myPasswordLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="3f5c3"/>
|
||||
<text value="&Password:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3f5c3" class="javax.swing.JPasswordField" binding="myPasswordText">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="235e5" binding="myCustomPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -92,7 +56,7 @@
|
||||
</grid>
|
||||
<component id="1e777" class="com.intellij.ui.components.JBCheckBox" binding="myUseProxy">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
@@ -101,7 +65,7 @@
|
||||
</component>
|
||||
<component id="39542" class="javax.swing.JButton" binding="myProxySettingsButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Proxy settings..."/>
|
||||
@@ -109,7 +73,7 @@
|
||||
</component>
|
||||
<component id="d86a3" class="javax.swing.JCheckBox" binding="myUseHTTPAuthentication">
|
||||
<constraints>
|
||||
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Use HTTP authentication"/>
|
||||
@@ -117,12 +81,12 @@
|
||||
</component>
|
||||
<hspacer id="122ff">
|
||||
<constraints>
|
||||
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="8aba0" class="javax.swing.JButton" binding="myTestButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="7" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Test"/>
|
||||
@@ -136,6 +100,50 @@
|
||||
<text value="&Share URL"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="93b1c" class="com.intellij.ui.components.JBCheckBox" binding="myLoginAnonymouslyJBCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Login Anonymously"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="22736" class="com.intellij.ui.components.JBLabel" binding="myUsernameLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="63a48"/>
|
||||
<text value="User&name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="63a48" class="javax.swing.JTextField" binding="myUserNameText">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="70c27" class="com.intellij.ui.components.JBLabel" binding="myPasswordLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="3f5c3"/>
|
||||
<text value="&Password:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3f5c3" class="javax.swing.JPasswordField" binding="myPasswordText">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="3d7e" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
|
||||
@@ -64,6 +64,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
private JBCheckBox myAddCommitMessage;
|
||||
private JBLabel myComment;
|
||||
private JPanel myEditorPanel;
|
||||
protected JBCheckBox myLoginAnonymouslyJBCheckBox;
|
||||
|
||||
private boolean myApplying;
|
||||
protected final T myRepository;
|
||||
@@ -98,6 +99,15 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
myUseHTTPAuthentication.setSelected(repository.isUseHttpAuthentication());
|
||||
myUseHTTPAuthentication.setVisible(repository.getRepositoryType().isSupported(TaskRepositoryType.BASIC_HTTP_AUTHORIZATION));
|
||||
|
||||
myLoginAnonymouslyJBCheckBox.setVisible(repository.getRepositoryType().isSupported(TaskRepositoryType.LOGIN_ANONYMOUSLY));
|
||||
myLoginAnonymouslyJBCheckBox.setSelected(repository.isLoginAnonymously());
|
||||
myLoginAnonymouslyJBCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
loginAnonymouslyChanged(!myLoginAnonymouslyJBCheckBox.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
myAddCommitMessage.setSelected(repository.isShouldFormatCommitMessage());
|
||||
myDocument = EditorFactory.getInstance().createDocument(repository.getCommitMessageFormat());
|
||||
myEditor = EditorFactory.getInstance().createEditor(myDocument);
|
||||
@@ -119,6 +129,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
installListener(myShareURL);
|
||||
installListener(myUseProxy);
|
||||
installListener(myUseHTTPAuthentication);
|
||||
installListener(myLoginAnonymouslyJBCheckBox);
|
||||
|
||||
enableButtons();
|
||||
|
||||
@@ -128,6 +139,14 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
}
|
||||
|
||||
setAnchor(myUseProxy);
|
||||
loginAnonymouslyChanged(!myLoginAnonymouslyJBCheckBox.isSelected());
|
||||
}
|
||||
|
||||
protected void loginAnonymouslyChanged(boolean enabled) {
|
||||
myUsernameLabel.setEnabled(enabled);
|
||||
myUserNameText.setEnabled(enabled);
|
||||
myPasswordLabel.setEnabled(enabled);
|
||||
myPasswordText.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -210,6 +229,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
myRepository.setShared(myShareURL.isSelected());
|
||||
myRepository.setUseProxy(myUseProxy.isSelected());
|
||||
myRepository.setUseHttpAuthentication(myUseHTTPAuthentication.isSelected());
|
||||
myRepository.setLoginAnonymously(myLoginAnonymouslyJBCheckBox.isSelected());
|
||||
|
||||
myRepository.setShouldFormatCommitMessage(myAddCommitMessage.isSelected());
|
||||
myRepository.setCommitMessageFormat(myDocument.getText());
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.tasks.impl;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.PasswordUtil;
|
||||
import com.intellij.tasks.TaskRepository;
|
||||
import com.intellij.tasks.TaskRepositoryType;
|
||||
@@ -34,6 +35,7 @@ public abstract class BaseRepository extends TaskRepository {
|
||||
protected String myPassword = "";
|
||||
protected boolean myUseProxy;
|
||||
protected boolean myUseHttpAuthentication;
|
||||
protected boolean myLoginAnonymously;
|
||||
|
||||
public BaseRepository(TaskRepositoryType type) {
|
||||
super(type);
|
||||
@@ -45,6 +47,7 @@ public abstract class BaseRepository extends TaskRepository {
|
||||
myUsername = other.getUsername();
|
||||
myUseProxy = other.myUseProxy;
|
||||
myUseHttpAuthentication = other.myUseHttpAuthentication;
|
||||
myLoginAnonymously = other.myLoginAnonymously;
|
||||
}
|
||||
|
||||
public BaseRepository() {
|
||||
@@ -93,11 +96,14 @@ public abstract class BaseRepository extends TaskRepository {
|
||||
|
||||
BaseRepository that = (BaseRepository)o;
|
||||
|
||||
if (getUrl() != null ? !getUrl().equals(that.getUrl()) : that.getUrl() != null) return false;
|
||||
if (getPassword() != null ? !getPassword().equals(that.getPassword()) : that.getPassword() != null) return false;
|
||||
if (getUsername() != null ? !getUsername().equals(that.getUsername()) : that.getUsername() != null) return false;
|
||||
if (!Comparing.equal(getUrl(), that.getUrl())) return false;
|
||||
if (!Comparing.equal(getPassword(), that.getPassword())) return false;
|
||||
if (!Comparing.equal(getUsername(), that.getUsername())) return false;
|
||||
if (!Comparing.equal(isLoginAnonymously(), that.isLoginAnonymously())) return false;
|
||||
if (!Comparing.equal(isUseProxy(), that.isUseProxy())) return false;
|
||||
if (!Comparing.equal(isUseHttpAuthentication(), that.isUseHttpAuthentication())) return false;
|
||||
|
||||
return myUseProxy == that.myUseProxy && myUseHttpAuthentication == that.myUseHttpAuthentication;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isUseProxy() {
|
||||
@@ -116,6 +122,14 @@ public abstract class BaseRepository extends TaskRepository {
|
||||
myUseHttpAuthentication = useHttpAuthentication;
|
||||
}
|
||||
|
||||
public boolean isLoginAnonymously() {
|
||||
return myLoginAnonymously;
|
||||
}
|
||||
|
||||
public void setLoginAnonymously(final boolean loginAnonymously) {
|
||||
myLoginAnonymously = loginAnonymously;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String extractId(String taskName) {
|
||||
Matcher matcher = PATTERN.matcher(taskName);
|
||||
|
||||
@@ -61,7 +61,8 @@ public class WebRepository extends BaseRepositoryImpl {
|
||||
@Override
|
||||
public Task[] getIssues(@Nullable final String query, final int max, final long since) throws Exception {
|
||||
final HttpClient httpClient = getHttpClient();
|
||||
login(httpClient);
|
||||
|
||||
if (!isLoginAnonymously()) login(httpClient);
|
||||
|
||||
final GetMethod getMethod = new GetMethod(getFullTasksUrl());
|
||||
httpClient.executeMethod(getMethod);
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.intellij.util.ui.FormBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* User: Evgeny.Zakrevsky
|
||||
@@ -27,9 +29,22 @@ public class WebRepositoryEditor extends BaseRepositoryEditor<WebRepository> {
|
||||
myUsernameLabel.setText("{username}:");
|
||||
myPasswordLabel.setText("{password}:");
|
||||
|
||||
myLoginAnonymouslyJBCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
//setAnchor(myUsernameLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loginAnonymouslyChanged(boolean enabled) {
|
||||
super.loginAnonymouslyChanged(enabled);
|
||||
myLoginURLLabel.setEnabled(enabled);
|
||||
myLoginURLText.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
myRepository.setTasksListURL(myTasksListURLText.getText());
|
||||
|
||||
@@ -44,4 +44,9 @@ public class WebRepositoryType extends BaseRepositoryType<WebRepository> {
|
||||
final Consumer<WebRepository> changeListener) {
|
||||
return new WebRepositoryEditor(project, repository, changeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getFeatures() {
|
||||
return LOGIN_ANONYMOUSLY;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user