mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -235,6 +235,7 @@ public def layoutCommunityPlugins(String home) {
|
||||
}
|
||||
fileset(dir: "$home/plugins/git4idea/lib/jgit") {
|
||||
include(name: "org.eclipse.jgit*.jar")
|
||||
include(name: "jsch*.jar")
|
||||
exclude(name: "*.zip")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "
|
||||
libraryLicense(name: "JGoodies Looks", attachedTo: "platform-impl", version: "2.2.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JNA", libraryName: "jna", version: "3.2.4", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php")
|
||||
libraryLicense(name: "JNA", libraryName: "jna.jar", version: "3.2.7", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php")
|
||||
libraryLicense(name: "JSch", libraryName: "JSch", version: "0.1.44", license: "BSD", url: "http://www.jcraft.com/jsch/", licenseUrl: "http://www.jcraft.com/jsch/LICENSE.txt")
|
||||
libraryLicense(name: "JUnit", libraryName: "JUnit3", version: "3.8.1", license: "CPL 1.0", url: "http://junit.org/")
|
||||
libraryLicense(name: "JUnit", libraryName: "JUnit4", version: "4.8", license: "CPL 1.0", url: "http://junit.org/")
|
||||
libraryLicense(name: "Log4j", libraryName: "Log4J", version: "1.2", license: "Apache 2.0", url: "http://logging.apache.org/log4j/1.2/index.html", licenseUrl: "http://logging.apache.org/license.html")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -620,5 +620,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
copyMenu.removeAll();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCopyFromMenuAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -476,7 +476,12 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
|
||||
myConfigurable.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCopyFromMenuAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//========================================================================================================================================
|
||||
|
||||
private class MyIndentOptionsWrapper extends CodeStyleAbstractPanel {
|
||||
|
||||
+9
-5
@@ -317,11 +317,7 @@ public class CodeStyleSchemesPanel{
|
||||
public void setCodeStyleSettingsPanel(NewCodeStyleSettingsPanel settingsPanel) {
|
||||
mySettingsPanel = settingsPanel;
|
||||
CodeStyleAbstractPanel selectedPanel = mySettingsPanel.getSelectedPanel();
|
||||
if (selectedPanel != null) {
|
||||
initCopyFromMenu();
|
||||
selectedPanel.setupCopyFromMenu(myCopyFromMenu);
|
||||
}
|
||||
myCopyFromButton.setEnabled(myCopyFromMenu.getItemCount() > 0);
|
||||
myCopyFromButton.setEnabled(selectedPanel != null && selectedPanel.isCopyFromMenuAvailable());
|
||||
}
|
||||
|
||||
private void onSettingsTypeChange() {
|
||||
@@ -344,6 +340,14 @@ public class CodeStyleSchemesPanel{
|
||||
myCopyFromMenu = new PopupMenu();
|
||||
myCopyFromButton.add(myCopyFromMenu);
|
||||
}
|
||||
CodeStyleAbstractPanel selectedPanel = mySettingsPanel.getSelectedPanel();
|
||||
if (selectedPanel != null) {
|
||||
selectedPanel.setupCopyFromMenu(myCopyFromMenu);
|
||||
myCopyFromButton.setEnabled(myCopyFromMenu.getItemCount() > 0);
|
||||
}
|
||||
else {
|
||||
myCopyFromButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class NavBarItem extends SimpleColoredComponent implements Disposable {
|
||||
final Color bg = getBackground();
|
||||
append(myText, new SimpleTextAttributes(bg, fg, myAttributes.getWaveColor(), myAttributes.getStyle()));
|
||||
|
||||
repaint();
|
||||
//repaint();
|
||||
}
|
||||
|
||||
public boolean isInactive() {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
|
||||
import com.intellij.ide.projectView.impl.TransferableWrapper;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.customization.CustomActionsSchema;
|
||||
import com.intellij.ide.util.DeleteHandler;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -245,6 +246,11 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
|
||||
for (NavBarItem item : myList) {
|
||||
item.update();
|
||||
}
|
||||
if (UISettings.getInstance().SHOW_NAVIGATION_BAR) {
|
||||
JComponent parent = (JComponent)getParent().getParent().getParent().getParent().getParent().getParent();
|
||||
parent.revalidate();
|
||||
parent.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildAndSelectTail(final boolean requestFocus) {
|
||||
|
||||
+1
-6
@@ -83,14 +83,9 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
|
||||
public JComponent getComponent() {
|
||||
if (myWrapperPanel == null) {
|
||||
myWrapperPanel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
NavBarUIManager.getUI().doPaintWrapperPanelChildren((Graphics2D)g, getBounds(), isMainToolbarVisible());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
NavBarUIManager.getUI().doPaintWrapperPanel((Graphics2D)g, getBounds(), isMainToolbarVisible());
|
||||
}
|
||||
|
||||
|
||||
@@ -158,10 +158,6 @@ public abstract class AbstractNavBarUI implements NavBarUI {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPaintWrapperPanelChildren(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getWrapperPanelInsets(Insets insets) {
|
||||
return JBInsets.NONE;
|
||||
@@ -171,8 +167,8 @@ public abstract class AbstractNavBarUI implements NavBarUI {
|
||||
public void doPaintNavBarPanel(Graphics2D g, Rectangle r, boolean mainToolbarVisible, boolean undocked) {
|
||||
final Color startColor = UIUtil.getControlColor();
|
||||
final Color endColor = ColorUtil.shift(startColor, 7.0d / 8.0d);
|
||||
g.setPaint(new GradientPaint(0, 0, startColor, 0, r.height, endColor));
|
||||
g.fillRect(0, 0, r.width, r.height);
|
||||
g.setPaint(new GradientPaint(0, 0, startColor, 0, r.height-1, endColor));
|
||||
g.fillRect(0, 0, r.width, r.height-1);
|
||||
|
||||
if (!undocked) {
|
||||
g.setColor(new Color(255, 255, 255, 220));
|
||||
@@ -184,7 +180,7 @@ public abstract class AbstractNavBarUI implements NavBarUI {
|
||||
g.drawLine(0, r.height-1, r.width, r.height-1);
|
||||
|
||||
if (!mainToolbarVisible) {
|
||||
UIUtil.drawDottedLine(g, r.width - 1, 0, r.width - 1, r.height, null, Color.GRAY);
|
||||
UIUtil.drawDottedLine(g, r.width - 1, 0, r.width - 1, r.height-1, null, Color.GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,17 +34,6 @@ public class AquaNavBarUI extends AbstractNavBarUI {
|
||||
return !selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPaintWrapperPanelChildren(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible) {
|
||||
super.doPaintWrapperPanelChildren(g, bounds, mainToolbarVisible);
|
||||
if (!mainToolbarVisible) {
|
||||
g.setColor(new Color(0, 0, 0, 90));
|
||||
g.drawLine(0, bounds.height - 2, bounds.width, bounds.height - 2);
|
||||
g.setColor(new Color(0, 0, 0, 20));
|
||||
g.drawLine(0, bounds.height - 1, bounds.width, bounds.height - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPaintWrapperPanel(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible) {
|
||||
if (mainToolbarVisible) {
|
||||
@@ -52,6 +41,10 @@ public class AquaNavBarUI extends AbstractNavBarUI {
|
||||
g.fillRect(0, 0, bounds.width, bounds.height);
|
||||
} else {
|
||||
UIUtil.drawGradientHToolbarBackground(g, bounds.width, bounds.height);
|
||||
g.setColor(new Color(0, 0, 0, 90));
|
||||
g.drawLine(0, bounds.height - 1, bounds.width, bounds.height - 1);
|
||||
g.setColor(new Color(0, 0, 0, 20));
|
||||
g.drawLine(0, bounds.height, bounds.width, bounds.height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +55,12 @@ public class AquaNavBarUI extends AbstractNavBarUI {
|
||||
|
||||
@Override
|
||||
public void doPaintNavBarPanel(Graphics2D g, Rectangle r, boolean mainToolbarVisible, boolean undocked) {
|
||||
g.setPaint(new GradientPaint(0, 0, new Color(240, 240, 240), 0, r.height, new Color(210, 210, 210)));
|
||||
g.fillRect(0, 0, r.width, r.height);
|
||||
|
||||
if (mainToolbarVisible) {
|
||||
g.setPaint(new GradientPaint(0, 0, new Color(240, 240, 240), 0, r.height, new Color(210, 210, 210)));
|
||||
g.fillRect(0, 0, r.width, r.height);
|
||||
} else {
|
||||
UIUtil.drawGradientHToolbarBackground(g, r.width, r.height);
|
||||
}
|
||||
if (!undocked) {
|
||||
g.setColor(new Color(255, 255, 255, 220));
|
||||
g.drawLine(0, 1, r.width, 1);
|
||||
|
||||
@@ -42,7 +42,6 @@ public interface NavBarUI {
|
||||
Color getForeground(boolean selected, boolean focused, boolean inactive);
|
||||
|
||||
void doPaintWrapperPanel(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible);
|
||||
void doPaintWrapperPanelChildren(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible);
|
||||
|
||||
void doPaintNavBarPanel(Graphics2D g, Rectangle bounds, boolean mainToolbarVisible, boolean undocked);
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
setMargin(new Insets(margins.top, 2, margins.bottom, 2));
|
||||
if (isSmallVariant()) {
|
||||
setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
setFont(UIUtil.getLabelFont().deriveFont(11.0f));
|
||||
}
|
||||
addActionListener(
|
||||
new ActionListener() {
|
||||
@@ -292,7 +293,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
x += icon.getIconWidth() + 3;
|
||||
}
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
final Font font = UIUtil.getButtonFont();
|
||||
final Font font = getFont();
|
||||
g2.setFont(font);
|
||||
g2.setColor(UIManager.getColor("Button.foreground"));
|
||||
g2.drawString(getText(), x, (size.height + font.getSize())/2 - 1);
|
||||
|
||||
+9
-5
@@ -161,7 +161,11 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
private boolean doMacEnhancementsForMainToolbar() {
|
||||
return (UIUtil.isUnderAquaLookAndFeel() && ActionPlaces.MAIN_TOOLBAR.equals(myPlace))
|
||||
|| ActionPlaces.NAVIGATION_BAR.equals(myPlace);
|
||||
|| isInsideNavBar();
|
||||
}
|
||||
|
||||
private boolean isInsideNavBar() {
|
||||
return ActionPlaces.NAVIGATION_BAR.equals(myPlace);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +191,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
protected void paintComponent(final Graphics g) {
|
||||
if (ActionPlaces.NAVIGATION_BAR.equals(myPlace)) {
|
||||
if (isInsideNavBar()) {
|
||||
final Dimension size = getSize();
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
g.drawLine(0, size.height - 1, size.width, size.height - 1);
|
||||
@@ -258,7 +262,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
private Dimension getMinimumButtonSize() {
|
||||
return ActionPlaces.NAVIGATION_BAR.equals(myPlace) ? NAVBAR_MINIMUM_BUTTON_SIZE : DEFAULT_MINIMUM_BUTTON_SIZE;
|
||||
return isInsideNavBar() ? NAVBAR_MINIMUM_BUTTON_SIZE : DEFAULT_MINIMUM_BUTTON_SIZE;
|
||||
}
|
||||
|
||||
public ActionButton createToolbarButton(final AnAction action, final ActionButtonLook look, final String place, final Presentation presentation, final Dimension minimumSize) {
|
||||
@@ -1178,9 +1182,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
setOpaque(false);
|
||||
} else {
|
||||
if (ActionPlaces.NAVIGATION_BAR.equals(myPlace)) {
|
||||
if (isInsideNavBar()) {
|
||||
setMinimumButtonSize(NAVBAR_MINIMUM_BUTTON_SIZE);
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 2));
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 3, 1, 3));
|
||||
setOpaque(true);
|
||||
} else {
|
||||
setMinimumButtonSize(DEFAULT_MINIMUM_BUTTON_SIZE);
|
||||
|
||||
@@ -57,6 +57,18 @@
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="JSch">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/jgit/jsch-0.1.44.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MODULE_DIR$/lib/jgit/jsch-0.1.44.zip!/jsch-0.1.44/src" />
|
||||
<root url="jar://$MODULE_DIR$/lib/jgit/jsch-0.1.44.zip!/jsch-0.1.44/examples" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -30,6 +30,7 @@ import git4idea.repo.GitRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -121,6 +122,14 @@ public class Git {
|
||||
|
||||
return untrackedFiles;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GitCommandResult clone(@NotNull Project project, @NotNull File parentDirectory, @NotNull String url, @NotNull String clonedDirectoryName) {
|
||||
GitLineHandler handler = new GitLineHandler(project, parentDirectory, GitCommand.CLONE);
|
||||
handler.addParameters(url);
|
||||
handler.addParameters(clonedDirectoryName);
|
||||
return run(handler, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code git checkout <reference>} <br/>
|
||||
|
||||
@@ -15,30 +15,26 @@
|
||||
*/
|
||||
package git4idea.checkout;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.CheckoutProvider;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.Git;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.actions.BasicAction;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitSimpleHandler;
|
||||
import git4idea.commands.GitCommandResult;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.ui.GitUIUtil;
|
||||
import git4idea.jgit.GitHttpAdapter;
|
||||
import git4idea.update.GitFetchResult;
|
||||
import git4idea.update.GitFetcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -46,8 +42,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
*/
|
||||
public class GitCheckoutProvider implements CheckoutProvider {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(GitCheckoutProvider.class);
|
||||
|
||||
public String getVcsName() {
|
||||
return "_Git";
|
||||
}
|
||||
@@ -81,7 +75,7 @@ public class GitCheckoutProvider implements CheckoutProvider {
|
||||
new Task.Backgroundable(project, GitBundle.message("cloning.repository", sourceRepositoryURL)) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
cloneResult.set(doClone(indicator, project, directoryName, parentDirectory, sourceRepositoryURL));
|
||||
cloneResult.set(doClone(project, directoryName, parentDirectory, sourceRepositoryURL));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,87 +98,25 @@ public class GitCheckoutProvider implements CheckoutProvider {
|
||||
}.queue();
|
||||
}
|
||||
|
||||
private static boolean doClone(ProgressIndicator indicator, Project project, String directoryName, String parentDirectory, String sourceRepositoryURL) {
|
||||
File dir = mkdir(project, directoryName, parentDirectory);
|
||||
if (dir == null) {
|
||||
return false;
|
||||
private static boolean doClone(@NotNull Project project, @NotNull String directoryName, @NotNull String parentDirectory, @NotNull String sourceRepositoryURL) {
|
||||
if (GitHttpAdapter.isHttpUrl(sourceRepositoryURL)) {
|
||||
GitFetchResult result = GitHttpAdapter.cloneRepository(project, new File(parentDirectory, directoryName), sourceRepositoryURL);
|
||||
GitFetcher.displayFetchResult(project, result, "Clone failed", result.getErrors());
|
||||
return result.isSuccess();
|
||||
}
|
||||
VirtualFile root = VcsUtil.getVirtualFileWithRefresh(dir);
|
||||
if (root != null &&
|
||||
init(project, root) &&
|
||||
addRemote(project, root, sourceRepositoryURL) &&
|
||||
fetch(project, root, indicator) &&
|
||||
checkout(project, root)) {
|
||||
else {
|
||||
return cloneNatively(project, new File(parentDirectory), sourceRepositoryURL, directoryName);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean cloneNatively(Project project, File directory, String url, String cloneDirectoryName) {
|
||||
GitCommandResult result = Git.clone(project, directory, url, cloneDirectoryName);
|
||||
if (result.success()) {
|
||||
return true;
|
||||
}
|
||||
cleanup(dir);
|
||||
GitVcs.IMPORTANT_ERROR_NOTIFICATION.createNotification("Clone failed", result.getErrorOutputAsHtmlString(), NotificationType.ERROR, null)
|
||||
.notify(project.isDefault() ? null : project);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void cleanup(@NotNull File dir) {
|
||||
FileUtil.delete(dir);
|
||||
}
|
||||
|
||||
private static @Nullable File mkdir(Project project, String directoryName, String parentDirectory) {
|
||||
final File dir = new File(parentDirectory, directoryName);
|
||||
if (dir.exists()) {
|
||||
GitUIUtil.notifyError(project, "Couldn't clone", "Directory <code>" + dir + "</code> already exists.");
|
||||
return null;
|
||||
}
|
||||
if (!dir.mkdir()) {
|
||||
GitUIUtil.notifyError(project, "Couldn't clone", "Can't create directory <code>" + dir + "</code>");
|
||||
return null;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
private static boolean init(Project project, VirtualFile root) {
|
||||
try {
|
||||
Git.init(project, root);
|
||||
} catch (VcsException e) {
|
||||
LOG.info("init ", e);
|
||||
GitVcs vcs = GitVcs.getInstance(project);
|
||||
if (vcs == null || vcs.getExecutableValidator().isExecutableValid()) { // invalid executable will be notified in GitHandler.start()
|
||||
GitUIUtil.notifyError(project, "Couldn't clone", "Couldn't <code>git init</code> in <code>" + root.getPresentableUrl() + "</code>", true, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean addRemote(Project project, VirtualFile root, String remoteUrl) {
|
||||
final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
|
||||
addRemoteHandler.setNoSSH(true);
|
||||
addRemoteHandler.addParameters("add", "origin", remoteUrl);
|
||||
try {
|
||||
addRemoteHandler.run();
|
||||
return true;
|
||||
}
|
||||
catch (VcsException e) {
|
||||
LOG.info("addRemote ", e);
|
||||
GitUIUtil.notifyError(project, "Couldn't clone", "Couldn't add remote <code>" + remoteUrl + "</code>", true, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean fetch(Project project, VirtualFile root, ProgressIndicator indicator) {
|
||||
return new GitFetcher(project, indicator).fetchRootsAndNotify(Collections.singleton(root), "Couldn't clone", false);
|
||||
}
|
||||
|
||||
private static boolean checkout(Project project, VirtualFile root) {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CHECKOUT);
|
||||
h.setNoSSH(true);
|
||||
h.addParameters("-b", "master", "origin/master");
|
||||
try {
|
||||
h.run();
|
||||
return true;
|
||||
}
|
||||
catch (VcsException e) {
|
||||
LOG.info("checkout ", e);
|
||||
GitUIUtil.notifyError(project, "Clone not completed",
|
||||
"Couldn't checkout master branch. <br/>All changes were fetched to <code>" + root + "</code>.", true, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import git4idea.push.GitSimplePushResult;
|
||||
import git4idea.remote.GitRememberedInputs;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.update.GitFetchResult;
|
||||
import org.eclipse.jgit.api.CloneCommand;
|
||||
import org.eclipse.jgit.api.FetchCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.PushCommand;
|
||||
@@ -143,6 +144,34 @@ public final class GitHttpAdapter {
|
||||
return makeErrorResultFromException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GitFetchResult cloneRepository(@NotNull Project project, @NotNull final File directory, @NotNull final String url) {
|
||||
GitFetchResult.Type resultType;
|
||||
try {
|
||||
final GitHttpCredentialsProvider provider = new GitHttpCredentialsProvider(project, url);
|
||||
GeneralResult result = callWithAuthRetry(new MyRunnable() {
|
||||
@Override
|
||||
public void run() throws InvalidRemoteException {
|
||||
CloneCommand cloneCommand = Git.cloneRepository();
|
||||
cloneCommand.setDirectory(directory);
|
||||
cloneCommand.setURI(url);
|
||||
cloneCommand.setCredentialsProvider(provider);
|
||||
cloneCommand.call();
|
||||
}
|
||||
}, provider);
|
||||
resultType = convertToFetchResultType(result);
|
||||
}
|
||||
catch (InvalidRemoteException e) {
|
||||
LOG.info("Exception while cloning " + url + " to " + directory, e);
|
||||
return GitFetchResult.error(e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info("Exception while cloning " + url + " to " + directory, e);
|
||||
return GitFetchResult.error(e);
|
||||
}
|
||||
return new GitFetchResult(resultType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GitSimplePushResult convertToPushResultType(GeneralResult result) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class GitSimplePushResult {
|
||||
|
||||
@NotNull
|
||||
public static GitSimplePushResult error(@NotNull String errorOutput) {
|
||||
return new GitSimplePushResult(Type.REJECT, errorOutput, Collections.<String>emptyList());
|
||||
return new GitSimplePushResult(Type.ERROR, errorOutput, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -65,6 +65,15 @@ public class GitRememberedInputs implements PersistentStateComponent<GitRemember
|
||||
}
|
||||
|
||||
public void addUrl(@NotNull String url, @NotNull String userName) {
|
||||
for (UrlAndUserName visitedUrl : myState.visitedUrls) {
|
||||
if (visitedUrl.url.equalsIgnoreCase(url)) { // don't add multiple entries for a single url
|
||||
if (!userName.isEmpty()) { // rewrite username, unless no username is specified
|
||||
visitedUrl.userName = userName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UrlAndUserName urlAndUserName = new UrlAndUserName();
|
||||
urlAndUserName.url = url;
|
||||
urlAndUserName.userName = userName;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class GitUIUtil {
|
||||
errorMessages.add(message.replace("\n", "<br/>"));
|
||||
}
|
||||
} else {
|
||||
errorMessages.add(error.getMessage().replace("\n", "<br/>"));
|
||||
errorMessages.add(error.toString().replace("\n", "<br/>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.commands.*;
|
||||
@@ -60,13 +59,8 @@ public class GitFetcher {
|
||||
*/
|
||||
public GitFetchResult fetch(@NotNull VirtualFile root) {
|
||||
GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
|
||||
boolean disposeRepository = false;
|
||||
assert repository != null : "Repository can't be null for " + root + "\n" + myRepositoryManager;
|
||||
|
||||
if (repository == null) { // we are cloning => no repository is registered => making a fake repository
|
||||
repository = GitRepository.getTempRepository(root, myProject);
|
||||
disposeRepository = true;
|
||||
}
|
||||
|
||||
GitFetchResult result = GitFetchResult.success();
|
||||
for (GitRemote remote : repository.getRemotes()) {
|
||||
String url = remote.getFirstUrl();
|
||||
@@ -88,9 +82,6 @@ public class GitFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (disposeRepository) {
|
||||
Disposer.dispose(repository);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -126,11 +117,13 @@ public class GitFetcher {
|
||||
return myErrors;
|
||||
}
|
||||
|
||||
public void displayFetchResult(@NotNull GitFetchResult result, @Nullable String errorNotificationTitle) {
|
||||
public static void displayFetchResult(@NotNull Project project,
|
||||
@NotNull GitFetchResult result,
|
||||
@Nullable String errorNotificationTitle, @NotNull Collection<? extends Exception> errors) {
|
||||
if (result.isSuccess()) {
|
||||
GitVcs.NOTIFICATION_GROUP_ID.createNotification("Fetched successfully", NotificationType.WARNING).notify(myProject);
|
||||
GitVcs.NOTIFICATION_GROUP_ID.createNotification("Fetched successfully", NotificationType.WARNING).notify(project);
|
||||
} else if (result.isCancelled()) {
|
||||
GitVcs.NOTIFICATION_GROUP_ID.createNotification("Fetch cancelled by user", NotificationType.WARNING).notify(myProject);
|
||||
GitVcs.NOTIFICATION_GROUP_ID.createNotification("Fetch cancelled by user", NotificationType.WARNING).notify(project);
|
||||
} else if (result.isNotAuthorized()) {
|
||||
String title;
|
||||
String description;
|
||||
@@ -141,11 +134,11 @@ public class GitFetcher {
|
||||
title = "Fetch failed";
|
||||
description = "Couldn't authorize";
|
||||
}
|
||||
GitUIUtil.notifyMessage(myProject, title, description, NotificationType.ERROR, true, null);
|
||||
GitUIUtil.notifyMessage(project, title, description, NotificationType.ERROR, true, null);
|
||||
} else {
|
||||
GitVcs instance = GitVcs.getInstance(myProject);
|
||||
GitVcs instance = GitVcs.getInstance(project);
|
||||
if (instance != null && instance.getExecutableValidator().isExecutableValid()) {
|
||||
GitUIUtil.notifyMessage(myProject, "Fetch failed", null, NotificationType.ERROR, true, getErrors());
|
||||
GitUIUtil.notifyMessage(project, "Fetch failed", null, NotificationType.ERROR, true, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +157,7 @@ public class GitFetcher {
|
||||
for (VirtualFile root : roots) {
|
||||
GitFetchResult result = fetch(root);
|
||||
if (!result.isSuccess()) {
|
||||
displayFetchResult(result, errorNotificationTitle);
|
||||
displayFetchResult(myProject, result, errorNotificationTitle, getErrors());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -90,7 +90,7 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
|
||||
|
||||
public CreateNSDeclarationIntentionFix(final PsiElement element,
|
||||
final String namespacePrefix,
|
||||
final XmlToken token,
|
||||
@Nullable final XmlToken token,
|
||||
XmlFile containingFile) {
|
||||
myNamespacePrefix = namespacePrefix;
|
||||
myElement = element;
|
||||
@@ -151,10 +151,12 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
|
||||
return;
|
||||
} else {
|
||||
prefix = ExtendedTagInsertHandler.suggestPrefix(xmlFile, namespace);
|
||||
if (StringUtil.isNotEmpty(prefix)) {
|
||||
ExtendedTagInsertHandler.qualifyWithPrefix(prefix, myElement);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
|
||||
if (StringUtil.isEmpty(prefix)) {
|
||||
HintManager.getInstance().showInformationHint(editor, "Namespace not found");
|
||||
return;
|
||||
}
|
||||
ExtendedTagInsertHandler.qualifyWithPrefix(prefix, myElement);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
|
||||
}
|
||||
}
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
@@ -56,7 +56,7 @@ public class XmlElementFactoryImpl extends XmlElementFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public XmlAttribute createXmlAttribute(@NotNull String name, String value) throws IncorrectOperationException {
|
||||
public XmlAttribute createXmlAttribute(@NotNull String name, @NotNull String value) throws IncorrectOperationException {
|
||||
final char quoteChar;
|
||||
if (!value.contains("\"")) {
|
||||
quoteChar = '"';
|
||||
|
||||
@@ -86,5 +86,5 @@ public abstract class XmlElementFactory {
|
||||
* @throws IncorrectOperationException if either <code>name</code> or <code>value</code> are not valid.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract XmlAttribute createXmlAttribute(@NotNull @NonNls String name, String value) throws IncorrectOperationException;
|
||||
public abstract XmlAttribute createXmlAttribute(@NotNull @NonNls String name, @NotNull String value) throws IncorrectOperationException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user