mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Create patch additional component panel optimized
* unused dvcsUsed variable and appropriate for-statement removed; * cache additionalUIPanel instead of double creation; * new patch dialog creation become 2 times faster when called from commitChanges dialog
This commit is contained in:
+15
-24
@@ -29,14 +29,15 @@ import com.intellij.openapi.diff.impl.patch.IdeaTextPatchBuilder;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsApplicationSettings;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -54,7 +55,7 @@ import java.util.List;
|
||||
*/
|
||||
public class CreatePatchCommitExecutor extends LocalCommitExecutor implements ProjectComponent, JDOMExternalizable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.patch.CreatePatchCommitExecutor");
|
||||
|
||||
|
||||
private final Project myProject;
|
||||
private final ChangeListManager myChangeListManager;
|
||||
|
||||
@@ -139,24 +140,13 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr
|
||||
myPanel.setFileName(ShelveChangesManager.suggestPatchName(myProject, commitMessage, new File(PATCH_PATH), null));
|
||||
myPanel.setReversePatch(false);
|
||||
|
||||
boolean dvcsIsUsed = false;
|
||||
|
||||
if (ProjectLevelVcsManager.getInstance(myProject).dvcsUsedInProject()) {
|
||||
for (Change change : changes) {
|
||||
final AbstractVcs vcs = ChangesUtil.getVcsForChange(change, myProject);
|
||||
if (vcs != null && VcsType.distributed.equals(vcs.getType())) {
|
||||
dvcsIsUsed = true;
|
||||
break;
|
||||
}
|
||||
myPanel.setChanges(ContainerUtil.filter(changes, new Condition<Change>() {
|
||||
@Override
|
||||
public boolean value(Change change) {
|
||||
return change.getBeforeRevision() != null && change.getAfterRevision() != null;
|
||||
}
|
||||
}
|
||||
final List<Change> modified = new ArrayList<Change>();
|
||||
for (Change change : changes) {
|
||||
if (change.getBeforeRevision() == null || change.getAfterRevision() == null) continue;
|
||||
modified.add(change);
|
||||
}
|
||||
myPanel.setChanges(modified);
|
||||
myPanel.showTextStoreOption(dvcsIsUsed);
|
||||
}));
|
||||
myPanel.showTextStoreOption();
|
||||
return myPanel.getPanel();
|
||||
}
|
||||
|
||||
@@ -258,7 +248,8 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr
|
||||
LOG.info(ex);
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
|
||||
public void run() {
|
||||
Messages.showErrorDialog(myProject, VcsBundle.message("create.patch.error.title", ex.getMessage()), CommonBundle.getErrorTitle());
|
||||
Messages.showErrorDialog(myProject, VcsBundle.message("create.patch.error.title", ex.getMessage()),
|
||||
CommonBundle.getErrorTitle());
|
||||
}
|
||||
}, null, myProject);
|
||||
}
|
||||
|
||||
+1
-3
@@ -66,7 +66,6 @@ public class CreatePatchConfigurationPanel {
|
||||
private JCheckBox myIncludeBaseRevisionTextCheckBox;
|
||||
private Consumer<Boolean> myOkEnabledListener;
|
||||
private final Project myProject;
|
||||
private boolean myDvcsIsUsed;
|
||||
private List<Change> myChanges;
|
||||
private Collection<Change> myIncludedChanges;
|
||||
private SelectFilesToAddTextsToPatchPanel mySelectFilesToAddTextsToPatchPanel;
|
||||
@@ -173,8 +172,7 @@ public class CreatePatchConfigurationPanel {
|
||||
myPanelWithSelectedFiles.add(myHideableTitledPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void showTextStoreOption(final boolean dvcsIsUsed) {
|
||||
myDvcsIsUsed = dvcsIsUsed;
|
||||
public void showTextStoreOption() {
|
||||
if (myChanges.size() > 0) {
|
||||
myIncludeBaseRevisionTextCheckBox.setVisible(true);
|
||||
|
||||
|
||||
+3
-2
@@ -653,12 +653,13 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
return;
|
||||
}
|
||||
boolean isOK = true;
|
||||
if (SessionDialog.createConfigurationUI(session, getIncludedChanges(), getCommitMessage())!= null) {
|
||||
final JComponent configurationUI = SessionDialog.createConfigurationUI(session, getIncludedChanges(), getCommitMessage());
|
||||
if (configurationUI != null) {
|
||||
DialogWrapper sessionDialog = new SessionDialog(commitExecutor.getActionText(),
|
||||
getProject(),
|
||||
session,
|
||||
getIncludedChanges(),
|
||||
getCommitMessage());
|
||||
getCommitMessage(), configurationUI);
|
||||
isOK = sessionDialog.showAndGet();
|
||||
}
|
||||
if (isOK) {
|
||||
|
||||
@@ -41,17 +41,24 @@ public class SessionDialog extends DialogWrapper {
|
||||
|
||||
public SessionDialog(String title, Project project,
|
||||
CommitSession session, List<Change> changes,
|
||||
String commitMessage) {
|
||||
String commitMessage, @Nullable JComponent configurationComponent) {
|
||||
super(project, true);
|
||||
mySession = session;
|
||||
myChanges = changes;
|
||||
myCommitMessage = commitMessage;
|
||||
myConfigurationComponent = createConfigurationUI(mySession, myChanges, myCommitMessage);
|
||||
myConfigurationComponent =
|
||||
configurationComponent == null ? createConfigurationUI(mySession, myChanges, myCommitMessage) : configurationComponent;
|
||||
setTitle(CommitChangeListDialog.trimEllipsis(title));
|
||||
init();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
public SessionDialog(String title, Project project,
|
||||
CommitSession session, List<Change> changes,
|
||||
String commitMessage) {
|
||||
this(title, project, session, changes, commitMessage, null);
|
||||
}
|
||||
|
||||
public static JComponent createConfigurationUI(final CommitSession session, final List<Change> changes, final String commitMessage) {
|
||||
try {
|
||||
return session.getAdditionalConfigurationUI(changes, commitMessage);
|
||||
|
||||
Reference in New Issue
Block a user