mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[git] remove some obsolete dialog
This commit is contained in:
@@ -416,20 +416,6 @@ unstash.unstashing=Unstashing...
|
||||
unstash.view.tooltip=View selected stash
|
||||
unstash.view=&View
|
||||
unstashing.title=UnStashing changes...
|
||||
update.locally.modified.files.tooltip=Locally modified files.
|
||||
update.locally.modified.files=&Files:
|
||||
update.locally.modified.git.root=Git Root:
|
||||
update.locally.modified.message=<html><p>The following files under this root are locally modified. <br/>\
|
||||
Possible reasons: uncommitted changes; a problem with crlf conversion; {0} configuration file auto-save.</p>\
|
||||
<p><ul>\
|
||||
<li>Press <b>Revert Files</b> to discard these local changes and continue the update process.</li>\
|
||||
<li>Press <b>Cancel</b> to cancel the update process. <br/> Use Auto-Stash option to stash local changes before update and restore them after it.</li>\
|
||||
</ul></p> \
|
||||
</html>
|
||||
update.locally.modified.rescan.tooltip=<html>Rescan the repository to check for locally modified files again.<br/>Use this button if you have resolved the problem manually.</html>
|
||||
update.locally.modified.rescan=Re&scan
|
||||
update.locally.modified.revert=Revert Files
|
||||
update.locally.modified.title=Locally modified files are detected
|
||||
update.options.display.name=Git Update Settings
|
||||
update.options.no.commit=No &Commit
|
||||
update.options.save.before.update=Clean working tree before update
|
||||
|
||||
@@ -18,12 +18,10 @@ package git4idea.update;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.branch.GitBranchPair;
|
||||
@@ -78,42 +76,12 @@ public class GitRebaseUpdater extends GitUpdater {
|
||||
return dest.getName();
|
||||
}
|
||||
|
||||
// TODO
|
||||
//if (!checkLocallyModified(myRoot)) {
|
||||
// cancel();
|
||||
// updateSucceeded.set(false);
|
||||
//}
|
||||
|
||||
|
||||
// TODO: show at any case of update successfullibility, also don't show here but for all roots
|
||||
//if (mySkippedCommits.size() > 0) {
|
||||
// GitSkippedCommits.showSkipped(myProject, mySkippedCommits);
|
||||
//}
|
||||
|
||||
public void cancel() {
|
||||
myRebaser.abortRebase(myRoot);
|
||||
myProgressIndicator.setText2("Refreshing files for the root " + myRoot.getPath());
|
||||
myRoot.refresh(false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and process locally modified files
|
||||
*
|
||||
* @param root the project root
|
||||
* @param ex the exception holder
|
||||
*/
|
||||
protected boolean checkLocallyModified(final VirtualFile root) throws VcsException {
|
||||
final Ref<Boolean> cancelled = new Ref<Boolean>(false);
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
if (!GitUpdateLocallyModifiedDialog.showIfNeeded(myProject, root)) {
|
||||
cancelled.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
return !cancelled.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Rebase updater";
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="git4idea.update.GitUpdateLocallyModifiedDialog">
|
||||
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="514" height="322"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="62c84" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="update.locally.modified.git.root"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="24443" class="javax.swing.JLabel" binding="myGitRoot">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e43af" class="javax.swing.JLabel" binding="myDescriptionLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="bde6e">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5d604" class="com.intellij.ui.components.JBList" binding="myFilesList" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="update.locally.modified.files.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<component id="8f763" class="javax.swing.JButton" binding="myRescanButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="update.locally.modified.rescan"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="update.locally.modified.rescan.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ab434" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="bde6e"/>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="update.locally.modified.files"/>
|
||||
<verticalAlignment value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 git4idea.update;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitSimpleHandler;
|
||||
import git4idea.util.StringScanner;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.rollback.GitRollbackEnvironment;
|
||||
import git4idea.util.GitUIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* The dialog that displays locally modified files during update process
|
||||
*/
|
||||
public class GitUpdateLocallyModifiedDialog extends DialogWrapper {
|
||||
/**
|
||||
* The rescan button
|
||||
*/
|
||||
private JButton myRescanButton;
|
||||
/**
|
||||
* The list of files to revert
|
||||
*/
|
||||
private JList myFilesList;
|
||||
|
||||
private JLabel myDescriptionLabel;
|
||||
/**
|
||||
* The git root label
|
||||
*/
|
||||
private JLabel myGitRoot;
|
||||
/**
|
||||
* The root panel
|
||||
*/
|
||||
private JPanel myRootPanel;
|
||||
/**
|
||||
* The collection with locally modified files
|
||||
*/
|
||||
private final List<String> myLocallyModifiedFiles;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @param project the current project
|
||||
* @param root the vcs root
|
||||
* @param locallyModifiedFiles the collection of locally modified files to use
|
||||
*/
|
||||
protected GitUpdateLocallyModifiedDialog(final Project project, final VirtualFile root, List<String> locallyModifiedFiles) {
|
||||
super(project, true);
|
||||
myLocallyModifiedFiles = locallyModifiedFiles;
|
||||
setTitle(GitBundle.getString("update.locally.modified.title"));
|
||||
myGitRoot.setText(root.getPresentableUrl());
|
||||
myFilesList.setModel(new DefaultListModel());
|
||||
setOKButtonText(GitBundle.getString("update.locally.modified.revert"));
|
||||
syncListModel();
|
||||
myRescanButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myLocallyModifiedFiles.clear();
|
||||
try {
|
||||
scanFiles(project, root, myLocallyModifiedFiles);
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
GitUIUtil.showOperationError(project, ex, "Checking for locally modified files");
|
||||
}
|
||||
}
|
||||
});
|
||||
myDescriptionLabel
|
||||
.setText(GitBundle.message("update.locally.modified.message", ApplicationNamesInfo.getInstance().getFullProductName()));
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh list model according to the current content of the collection
|
||||
*/
|
||||
private void syncListModel() {
|
||||
DefaultListModel listModel = (DefaultListModel)myFilesList.getModel();
|
||||
listModel.removeAllElements();
|
||||
for (String p : myLocallyModifiedFiles) {
|
||||
listModel.addElement(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return myRootPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan working tree and detect locally modified files
|
||||
*
|
||||
* @param project the project to scan
|
||||
* @param root the root to scan
|
||||
* @param files the collection with files
|
||||
* @throws VcsException if there problem with running git or working tree is dirty in unsupported way
|
||||
*/
|
||||
private static void scanFiles(Project project, VirtualFile root, List<String> files) throws VcsException {
|
||||
String rootPath = root.getPath();
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.DIFF);
|
||||
h.addParameters("--name-status");
|
||||
h.setSilent(true);
|
||||
h.setStdoutSuppressed(true);
|
||||
StringScanner s = new StringScanner(h.run());
|
||||
while (s.hasMoreData()) {
|
||||
if (s.isEol()) {
|
||||
s.line();
|
||||
continue;
|
||||
}
|
||||
if (s.tryConsume("M\t")) {
|
||||
String path = rootPath + "/" + GitUtil.unescapePath(s.line());
|
||||
files.add(path);
|
||||
}
|
||||
else {
|
||||
throw new VcsException("Working tree is dirty in unsupported way: " + s.line());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the dialog if needed
|
||||
*
|
||||
* @param project the project
|
||||
* @param root the vcs root
|
||||
* @return true if showing is not needed or operation completed successfully
|
||||
*/
|
||||
public static boolean showIfNeeded(final Project project, final VirtualFile root) {
|
||||
final ArrayList<String> files = new ArrayList<String>();
|
||||
try {
|
||||
scanFiles(project, root, files);
|
||||
final AtomicBoolean rc = new AtomicBoolean(true);
|
||||
if (!files.isEmpty()) {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
GitUpdateLocallyModifiedDialog d = new GitUpdateLocallyModifiedDialog(project, root, files);
|
||||
d.show();
|
||||
rc.set(d.isOK());
|
||||
}
|
||||
});
|
||||
if (rc.get()) {
|
||||
if (!files.isEmpty()) {
|
||||
revertFiles(project, root, files);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc.get();
|
||||
}
|
||||
catch (final VcsException e) {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
GitUIUtil.showOperationError(project, e, "Checking for locally modified files");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert files from the list
|
||||
*
|
||||
* @param project the project
|
||||
* @param root the vcs root
|
||||
* @param files the files to revert
|
||||
*/
|
||||
private static void revertFiles(Project project, VirtualFile root, ArrayList<String> files) throws VcsException {
|
||||
// TODO consider deleted files
|
||||
GitRollbackEnvironment rollback = GitRollbackEnvironment.getInstance(project);
|
||||
ArrayList<FilePath> list = new ArrayList<FilePath>(files.size());
|
||||
for (String p : files) {
|
||||
list.add(VcsUtil.getFilePath(p));
|
||||
}
|
||||
rollback.revert(root, list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user