mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] remove unused classes.
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="git4idea.ui.GitRefspecAddRefsDialog">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" 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="369" height="106"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="86086" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="a7e6b">
|
||||
<constraints>
|
||||
<grid row="3" 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="5fc7b" class="javax.swing.JCheckBox" binding="myIncludeBranchesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.include.branches"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.include.branches.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="98d32" class="javax.swing.JCheckBox" binding="myIncludeTagsCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.include.tags"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.include.tags.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a44d3" class="javax.swing.JButton" binding="myGetRefsButton">
|
||||
<constraints>
|
||||
<grid row="2" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.get.references"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.get.references.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="2a9cb">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="40"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="6fbfc" class="com.intellij.ui.CheckboxTree" binding="myReferenceChooser" custom-create="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<rootVisible value="false"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="addrefspec.reference.chooser.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</grid>
|
||||
<inspectionSuppressions>
|
||||
<suppress inspection="NoLabelFor" id="2a9cb"/>
|
||||
</inspectionSuppressions>
|
||||
</form>
|
||||
@@ -1,340 +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.ui;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.CheckboxTree;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitTag;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitHandlerUtil;
|
||||
import git4idea.commands.GitSimpleHandler;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.util.StringScanner;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.HashSet;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* This dialog allows adding selected tag and branches are references.
|
||||
*/
|
||||
public class GitRefspecAddRefsDialog extends DialogWrapper {
|
||||
/**
|
||||
* Get references button
|
||||
*/
|
||||
private JButton myGetRefsButton;
|
||||
/**
|
||||
* If selected, the branches are fetched by {@link #myGetRefsButton}
|
||||
*/
|
||||
private JCheckBox myIncludeBranchesCheckBox;
|
||||
/**
|
||||
* If selected, the tags are fetched by {@link #myGetRefsButton}
|
||||
*/
|
||||
private JCheckBox myIncludeTagsCheckBox;
|
||||
/**
|
||||
* The selector for tags and branches
|
||||
*/
|
||||
private CheckboxTree myReferenceChooser;
|
||||
/**
|
||||
* The root panel of the dialog
|
||||
*/
|
||||
private JPanel myPanel;
|
||||
/**
|
||||
* The context project
|
||||
*/
|
||||
private final Project myProject;
|
||||
/**
|
||||
* Root of the tree
|
||||
*/
|
||||
private CheckedTreeNode myTreeRoot;
|
||||
/**
|
||||
* The git root of the repository
|
||||
*/
|
||||
private final VirtualFile myRoot;
|
||||
/**
|
||||
* The name of the remote
|
||||
*/
|
||||
private final String myRemote;
|
||||
/**
|
||||
* The set of tags
|
||||
*/
|
||||
private final SortedSet<String> myTags;
|
||||
/**
|
||||
* The set of branches
|
||||
*/
|
||||
private final SortedSet<String> myBranches;
|
||||
/**
|
||||
* The logger for the class
|
||||
*/
|
||||
private static final Logger log = Logger.getInstance(GitRefspecAddRefsDialog.class.getName());
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*
|
||||
* @param project the project
|
||||
* @param root the git repository root
|
||||
* @param remote the remote name or url of remote repository
|
||||
* @param tags the set of tags (might be modified if update button is pressed)
|
||||
* @param branches the set of branches (might be modified if update button is pressed)
|
||||
*/
|
||||
protected GitRefspecAddRefsDialog(@NotNull Project project,
|
||||
@NotNull VirtualFile root,
|
||||
@NotNull String remote,
|
||||
@NotNull SortedSet<String> tags,
|
||||
@NotNull SortedSet<String> branches) {
|
||||
super(project, true);
|
||||
setTitle(GitBundle.getString("addrefspec.title"));
|
||||
setOKButtonText(GitBundle.getString("addrefspec.button"));
|
||||
myProject = project;
|
||||
myRoot = root;
|
||||
myRemote = remote;
|
||||
myTags = tags;
|
||||
myBranches = branches;
|
||||
updateTree();
|
||||
setupGetReferences();
|
||||
init();
|
||||
setOKActionEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set up action listener for {@link #myGetRefsButton}
|
||||
*/
|
||||
private void setupGetReferences() {
|
||||
// setup enabled state
|
||||
final ActionListener enabledListener = new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
myGetRefsButton.setEnabled(myIncludeBranchesCheckBox.isSelected() || myIncludeTagsCheckBox.isSelected());
|
||||
}
|
||||
};
|
||||
myIncludeBranchesCheckBox.addActionListener(enabledListener);
|
||||
myIncludeTagsCheckBox.addActionListener(enabledListener);
|
||||
// perform update
|
||||
myGetRefsButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitCommand.LS_REMOTE);
|
||||
if (myIncludeBranchesCheckBox.isSelected()) {
|
||||
handler.addParameters("--heads");
|
||||
myBranches.clear();
|
||||
}
|
||||
if (myIncludeTagsCheckBox.isSelected()) {
|
||||
handler.addParameters("--tags");
|
||||
myTags.clear();
|
||||
}
|
||||
handler.addParameters(myRemote);
|
||||
String result = GitHandlerUtil
|
||||
.doSynchronously(handler, GitBundle.message("addrefspec.getting.references.title", myRemote), handler.printableCommandLine());
|
||||
if (result != null) {
|
||||
StringScanner s = new StringScanner(result);
|
||||
while (s.hasMoreData()) {
|
||||
s.tabToken(); // skip last commit hash
|
||||
String ref = s.line();
|
||||
if (ref.startsWith(GitBranch.REFS_HEADS_PREFIX)) {
|
||||
myBranches.add(ref);
|
||||
}
|
||||
else if (ref.startsWith(GitTag.REFS_TAGS_PREFIX)) {
|
||||
myTags.add(ref);
|
||||
}
|
||||
else {
|
||||
log.warn("Unknwon reference type from ls-remote \"" + myRemote + "\" :" + ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateTree();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update checkbox tree basing on the current state of the tag and branches set. The checkbox state is preserved. New items are created
|
||||
* in unselected state.
|
||||
*/
|
||||
private void updateTree() {
|
||||
// save the previous selection
|
||||
HashSet<String> oldTags = new HashSet<String>();
|
||||
HashSet<String> oldBranches = new HashSet<String>();
|
||||
for (Reference ref : myReferenceChooser.getCheckedNodes(Reference.class, null)) {
|
||||
(ref.isTag ? oldTags : oldBranches).add(ref.name);
|
||||
}
|
||||
// clear the tree
|
||||
myTreeRoot.removeAllChildren();
|
||||
// fill tags and branches
|
||||
addReferences(false, oldBranches, myBranches, GitBundle.getString("addrefspec.node.branches"));
|
||||
addReferences(true, oldTags, myTags, GitBundle.getString("addrefspec.node.tags"));
|
||||
TreeUtil.expandAll(myReferenceChooser);
|
||||
myReferenceChooser.treeDidChange();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add references to the tree along with category node
|
||||
*
|
||||
* @param isTag if true tag nodes are added
|
||||
* @param old the set of old elements (used to select
|
||||
* @param current the current set of elements (after update)
|
||||
* @param name the name of the set
|
||||
*/
|
||||
private void addReferences(final boolean isTag, final HashSet<String> old, final SortedSet<String> current, @Nls final String name) {
|
||||
if (!current.isEmpty()) {
|
||||
final CheckedTreeNode tagsRoot = new CheckedTreeNode(name);
|
||||
for (String t : current) {
|
||||
final CheckedTreeNode node = new CheckedTreeNode(new Reference(isTag, t));
|
||||
node.setChecked(old.contains(t));
|
||||
tagsRoot.add(node);
|
||||
}
|
||||
myTreeRoot.add(tagsRoot);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return GitRefspecAddRefsDialog.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create UI components that require custom creation: {@link #myReferenceChooser}
|
||||
*/
|
||||
private void createUIComponents() {
|
||||
myTreeRoot = new CheckedTreeNode("");
|
||||
myReferenceChooser = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer() {
|
||||
|
||||
public void customizeRenderer(final JTree tree,
|
||||
final Object value,
|
||||
final boolean selected,
|
||||
final boolean expanded,
|
||||
final boolean leaf,
|
||||
final int row,
|
||||
final boolean hasFocus) {
|
||||
if (!(value instanceof CheckedTreeNode)) return;
|
||||
final CheckedTreeNode node = (CheckedTreeNode)value;
|
||||
final Object userObject = node.getUserObject();
|
||||
String text;
|
||||
SimpleTextAttributes attributes;
|
||||
Icon icon;
|
||||
if (userObject == null) {
|
||||
// invisible root (do nothing)
|
||||
//noinspection HardCodedStringLiteral
|
||||
text = "INVISBLE ROOT";
|
||||
attributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
|
||||
icon = null;
|
||||
}
|
||||
else if (userObject instanceof String) {
|
||||
// category node (render as bold)
|
||||
text = (String)userObject;
|
||||
attributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
icon = PlatformIcons.DIRECTORY_CLOSED_ICON;
|
||||
}
|
||||
else {
|
||||
// reference node
|
||||
text = ((Reference)userObject).name;
|
||||
attributes = node.isChecked() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
icon = null;
|
||||
}
|
||||
final ColoredTreeCellRenderer textRenderer = getTextRenderer();
|
||||
if (icon != null) {
|
||||
textRenderer.setIcon(icon);
|
||||
}
|
||||
if (text != null) {
|
||||
textRenderer.append(text, attributes);
|
||||
}
|
||||
}
|
||||
}, myTreeRoot) {
|
||||
@Override
|
||||
protected void onNodeStateChanged(final CheckedTreeNode node) {
|
||||
boolean flag = node.isChecked() || myReferenceChooser.getCheckedNodes(Reference.class, null).length != 0;
|
||||
setOKActionEnabled(flag);
|
||||
super.onNodeStateChanged(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected elements
|
||||
*
|
||||
* @param isTag if true tags are returned, heads otherwise
|
||||
* @return a collection of selected reference of the specified type
|
||||
*/
|
||||
public SortedSet<String> getSelected(final boolean isTag) {
|
||||
TreeSet<String> rc = new TreeSet<String>();
|
||||
final Reference[] checked = myReferenceChooser.getCheckedNodes(Reference.class, new Tree.NodeFilter<Reference>() {
|
||||
public boolean accept(final Reference node) {
|
||||
return node.isTag == isTag;
|
||||
}
|
||||
});
|
||||
for (Reference r : checked) {
|
||||
rc.add(r.name);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getHelpId() {
|
||||
return "reference.VersionControl.Git.Fetch.AddReference";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A remote reference
|
||||
*/
|
||||
static final class Reference {
|
||||
/**
|
||||
* If true, the name represents a tag. if false, the name represents the branch name.
|
||||
*/
|
||||
final boolean isTag;
|
||||
/**
|
||||
* Name of the reference
|
||||
*/
|
||||
final String name;
|
||||
|
||||
/**
|
||||
* A constructor from fields
|
||||
*
|
||||
* @param tag the value for {@link #isTag}
|
||||
* @param name the value for {@link #name}
|
||||
*/
|
||||
public Reference(final boolean tag, final String name) {
|
||||
isTag = tag;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="git4idea.ui.GitRefspecPanel">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" 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="401" height="258"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title-resource-bundle="git4idea/i18n/GitBundle" title-key="refspec.title" title-position="2">
|
||||
<font/>
|
||||
</border>
|
||||
<children>
|
||||
<scrollpane id="97a2b" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="1" column="0" 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="73d28" class="com.intellij.ui.table.JBTable" binding="myReferences">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="e7434" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="17d8e" class="javax.swing.JButton" binding="myAddAllBranchesButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.all.branches"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.all.branches.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="ce0bf">
|
||||
<constraints>
|
||||
<grid row="5" 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="5bbae" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="false"/>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.ref"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.ref.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4baeb" class="javax.swing.JButton" binding="myRemoveButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="refspec.remove"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.remove.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b3517" class="javax.swing.JButton" binding="myAddAllTagsButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" 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 resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.all.tags"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.add.all.tags.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8c8a2" class="javax.swing.JButton" binding="myDefaultButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="false"/>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="refspec.default"/>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.default.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="af8ed" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e0fab" 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>
|
||||
<labelFor value="5f8b9"/>
|
||||
<text resource-bundle="git4idea/i18n/GitBundle" key="refspec.branch.prefix"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5f8b9" class="javax.swing.JTextField" binding="myRemoteNameTextField" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" 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>
|
||||
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="refspec.branch.prefix.tooltip"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<inspectionSuppressions>
|
||||
<suppress inspection="NoLabelFor" id="97a2b"/>
|
||||
</inspectionSuppressions>
|
||||
</form>
|
||||
@@ -1,652 +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.ui;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitDeprecatedRemote;
|
||||
import git4idea.GitTag;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import git4idea.util.StringScanner;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.validators.GitBranchNameValidator;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* The component that allows specifying a list of references
|
||||
*/
|
||||
public class GitRefspecPanel extends JPanel {
|
||||
/**
|
||||
* The logger for the class
|
||||
*/
|
||||
private static final Logger log = Logger.getInstance(Logger.class.getName());
|
||||
/**
|
||||
* Named remotes associated with the current git root
|
||||
*/
|
||||
private final HashMap<String, GitDeprecatedRemote> myRemotes = new HashMap<String, GitDeprecatedRemote>();
|
||||
/**
|
||||
* The project
|
||||
*/
|
||||
private Project myProject;
|
||||
/**
|
||||
* The git root for mapping
|
||||
*/
|
||||
private VirtualFile myGitRoot;
|
||||
/**
|
||||
* Remote heads (for Add... dialog)
|
||||
*/
|
||||
private final SortedSet<String> myRemoteHeads = new TreeSet<String>();
|
||||
/**
|
||||
* Remote tags (for Add.. dialog)
|
||||
*/
|
||||
private final SortedSet<String> myRemoteTags = new TreeSet<String>();
|
||||
/**
|
||||
* The button that adds all branches button
|
||||
*/
|
||||
private JButton myAddAllBranchesButton;
|
||||
/**
|
||||
* The button that adds selected references
|
||||
*/
|
||||
private JButton myAddButton;
|
||||
/**
|
||||
* The button that removes currently selected entries from the table
|
||||
*/
|
||||
private JButton myRemoveButton;
|
||||
/**
|
||||
* The text that contains remote name
|
||||
*/
|
||||
private JTextField myRemoteNameTextField;
|
||||
/**
|
||||
* The root panel of the form
|
||||
*/
|
||||
private JPanel myPanel;
|
||||
/**
|
||||
* The references table
|
||||
*/
|
||||
private JTable myReferences;
|
||||
/**
|
||||
* The button that adds entry that maps all tags
|
||||
*/
|
||||
private JButton myAddAllTagsButton;
|
||||
/**
|
||||
* Restore default mapping button
|
||||
*/
|
||||
private JButton myDefaultButton;
|
||||
/**
|
||||
* The name of the remote
|
||||
*/
|
||||
private String myRemote;
|
||||
/**
|
||||
* The source of default references
|
||||
*/
|
||||
private ReferenceSource myReferenceSource;
|
||||
/**
|
||||
* Mapping table model
|
||||
*/
|
||||
private final MyMappingTableModel myReferencesModel = new MyMappingTableModel();
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
*/
|
||||
public GitRefspecPanel() {
|
||||
super(new GridBagLayout());
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
add(myPanel, c);
|
||||
setupTable();
|
||||
setupButtons();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates fields
|
||||
*
|
||||
* @return null if there is no error; empty string means that there is no error yet but OK should be disabled; otherwise error text should be used as the current error for dialog
|
||||
*/
|
||||
@Nullable
|
||||
public String validateFields() {
|
||||
final String remote = getRemoteName();
|
||||
if (remote.length() == 0) {
|
||||
if (myReferencesModel.isRemoteNameUsed()) {
|
||||
return GitBundle.getString("refspec.validation.remote.is.blank");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!GitBranchNameValidator.INSTANCE.checkInput(remote)) {
|
||||
return GitBundle.getString("refspec.validation.remote.invalid");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set project for panel
|
||||
*
|
||||
* @param project the context project
|
||||
*/
|
||||
public void setProject(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup add/remove buttons
|
||||
*/
|
||||
private void setupButtons() {
|
||||
// disable ok button if nothing is selected
|
||||
myReferences.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(final ListSelectionEvent e) {
|
||||
myRemoveButton.setEnabled(myReferences.getSelectedRowCount() != 0);
|
||||
}
|
||||
});
|
||||
// remove selected mappings
|
||||
myRemoveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
myReferencesModel.removeSelectedMapping();
|
||||
}
|
||||
});
|
||||
// add all tags (mapped to tags directory)
|
||||
myAddAllTagsButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
myReferencesModel.addMapping(false, tagName("*"), tagName("*"));
|
||||
}
|
||||
});
|
||||
// all heads (mapped to remotes directory)
|
||||
myAddAllBranchesButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
addAllBranches();
|
||||
}
|
||||
});
|
||||
// map selected tags and heads
|
||||
myAddButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (myGitRoot == null) {
|
||||
throw new IllegalStateException("Git root must be already set at this point.");
|
||||
}
|
||||
GitRefspecAddRefsDialog d = new GitRefspecAddRefsDialog(myProject, myGitRoot, myRemote, myRemoteTags, myRemoteHeads);
|
||||
d.show();
|
||||
if (!d.isOK()) {
|
||||
return;
|
||||
}
|
||||
for (String tag : d.getSelected(true)) {
|
||||
myReferencesModel.addMapping(false, tag, tag);
|
||||
}
|
||||
for (String head : d.getSelected(false)) {
|
||||
myReferencesModel.addMapping(true, head, remoteName(head.substring(GitBranch.REFS_HEADS_PREFIX.length())));
|
||||
}
|
||||
}
|
||||
});
|
||||
myDefaultButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
String remote = myRemote;
|
||||
setRemote(null);
|
||||
setRemote(remote);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mapping for all branches
|
||||
*/
|
||||
private void addAllBranches() {
|
||||
myReferencesModel.addMapping(false, headName("*"), remoteName("*"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate tag with remote name
|
||||
*
|
||||
* @param remoteName the name of remote in the local system
|
||||
* @param tagName the name of the tag
|
||||
* @return the full path to the head
|
||||
*/
|
||||
private static String tagRemoteName(final String remoteName, final String tagName) {
|
||||
return GitTag.REFS_TAGS_PREFIX + remoteName + "/" + tagName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple tag name
|
||||
*
|
||||
* @param tagName the short name of tag
|
||||
* @return the fully qualified tag reference name
|
||||
*/
|
||||
private static String tagName(final String tagName) {
|
||||
return GitTag.REFS_TAGS_PREFIX + tagName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate remote head name in local file system, note that as name of remote {@link #getRemoteName()} is used.
|
||||
*
|
||||
* @param headName the name head of remote in the local system
|
||||
* @return the full path to the head
|
||||
*/
|
||||
private String remoteName(final String headName) {
|
||||
return remoteName(getRemoteName(), headName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate remote name in local file system
|
||||
*
|
||||
* @param remote a remote name, if blank a local branch is returned.
|
||||
* @param headName the name head of remote in the local system
|
||||
* @return the full path to the head
|
||||
*/
|
||||
private static String remoteName(final String remote, final String headName) {
|
||||
return remote.length() != 0 ? GitBranch.REFS_REMOTES_PREFIX + remote + "/" + headName : headName(headName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate head name
|
||||
*
|
||||
* @param head the head name
|
||||
* @return the full path to the head
|
||||
*/
|
||||
private static String headName(final String head) {
|
||||
return GitBranch.REFS_HEADS_PREFIX + head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current name of the remote
|
||||
*/
|
||||
public String getRemoteName() {
|
||||
return myRemoteNameTextField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup table header and table model
|
||||
*/
|
||||
private void setupTable() {
|
||||
// setup model
|
||||
myReferences.setModel(myReferencesModel);
|
||||
myReferences.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
myReferences.getColumnModel().getColumn(MyMappingTableModel.FORCE_COLUMN).sizeWidthToFit();
|
||||
myRemoteNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
myReferencesModel.remoteUpdated();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set git root for reference mapping
|
||||
*
|
||||
* @param gitRoot a git root
|
||||
*/
|
||||
public void setGitRoot(final VirtualFile gitRoot) {
|
||||
if (Comparing.equal(gitRoot, myGitRoot)) {
|
||||
return;
|
||||
}
|
||||
myGitRoot = gitRoot;
|
||||
myRemotes.clear();
|
||||
if (myGitRoot != null) {
|
||||
try {
|
||||
for (GitDeprecatedRemote r : GitDeprecatedRemote.list(myProject, myGitRoot)) {
|
||||
myRemotes.put(r.name(), r);
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
GitUIUtil.showOperationError(myProject, e, "listing remotes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set remote or url
|
||||
*
|
||||
* @param name a name of remote or URL
|
||||
*/
|
||||
public void setRemote(String name) {
|
||||
if (name != null && name.length() == 0) {
|
||||
name = null;
|
||||
}
|
||||
if (myRemote == null && name == null || myRemote != null && myRemote.equals(name)) {
|
||||
return;
|
||||
}
|
||||
myRemote = name;
|
||||
myAddButton.setEnabled(myRemote != null && myRemote.length() != 0);
|
||||
final GitDeprecatedRemote remote = myRemotes.get(name);
|
||||
if (remote != null) {
|
||||
myRemoteNameTextField.setText(name);
|
||||
myRemoteNameTextField.setEditable(false);
|
||||
myDefaultButton.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
myRemoteNameTextField.setText("");
|
||||
myRemoteNameTextField.setEditable(true);
|
||||
myDefaultButton.setEnabled(false);
|
||||
}
|
||||
myRemoteHeads.clear();
|
||||
myRemoteTags.clear();
|
||||
setDefaultMapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default mapping
|
||||
*/
|
||||
private void setDefaultMapping() {
|
||||
final GitDeprecatedRemote remote = myRemotes.get(myRemote);
|
||||
myReferencesModel.clear();
|
||||
if (remote != null && myReferenceSource == ReferenceSource.FETCH) {
|
||||
try {
|
||||
for (String ref : GitDeprecatedRemote.getFetchSpecs(myProject, myGitRoot, remote.name())) {
|
||||
StringScanner s = new StringScanner(ref);
|
||||
boolean force = s.tryConsume('+');
|
||||
String remotePart = s.boundedToken(':');
|
||||
String localPart = s.line();
|
||||
myReferencesModel.addMapping(force, remotePart, localPart);
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
log.error("Failed to get fetch references ", e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
addAllBranches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listener that is fired when validation is required
|
||||
*
|
||||
* @param l a listener to add
|
||||
*/
|
||||
public void addValidationRequiredListener(final ActionListener l) {
|
||||
myRemoteNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
l.actionPerformed(new ActionEvent(myRemoteNameTextField, ActionEvent.ACTION_PERFORMED, "validationRequired"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default reference source for panel.
|
||||
*
|
||||
* @param referenceSource a reference source
|
||||
*/
|
||||
public void setReferenceSource(final ReferenceSource referenceSource) {
|
||||
myReferenceSource = referenceSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return references added to the model
|
||||
*/
|
||||
public String[] getReferences() {
|
||||
return myReferencesModel.getReferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping table model
|
||||
*/
|
||||
private class MyMappingTableModel extends AbstractTableModel {
|
||||
/**
|
||||
* Force column in the table
|
||||
*/
|
||||
private static final int FORCE_COLUMN = 0;
|
||||
/**
|
||||
* Remote reference column in the table
|
||||
*/
|
||||
private static final int REMOTE_COLUMN = 1;
|
||||
/**
|
||||
* Local reference column in the table
|
||||
*/
|
||||
private static final int LOCAL_COLUMN = 2;
|
||||
/**
|
||||
* Remote name used for the table update
|
||||
*/
|
||||
private String mySavedRemoteName = null;
|
||||
/**
|
||||
* The currently constructed mapping
|
||||
*/
|
||||
private final ArrayList<RefMapping> myMapping = new ArrayList<RefMapping>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int getRowCount() {
|
||||
return myMapping.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove currently selected mappings
|
||||
*/
|
||||
public void removeSelectedMapping() {
|
||||
final int[] rows = myReferences.getSelectedRows();
|
||||
Arrays.sort(rows);
|
||||
for (int i = rows.length - 1; i >= 0; i--) {
|
||||
myMapping.remove(rows[i]);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return LOCAL_COLUMN + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isCellEditable(final int rowIndex, final int columnIndex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) {
|
||||
RefMapping m = myMapping.get(rowIndex);
|
||||
switch (columnIndex) {
|
||||
case FORCE_COLUMN:
|
||||
m.force = ((Boolean)aValue).booleanValue();
|
||||
break;
|
||||
case LOCAL_COLUMN:
|
||||
m.local = (String)aValue;
|
||||
break;
|
||||
case REMOTE_COLUMN:
|
||||
m.remote = (String)aValue;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Invalid column: " + columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getColumnName(final int column) {
|
||||
switch (column) {
|
||||
case FORCE_COLUMN:
|
||||
return GitBundle.getString("refspec.column.force");
|
||||
case LOCAL_COLUMN:
|
||||
return GitBundle.getString("refspec.column.local");
|
||||
case REMOTE_COLUMN:
|
||||
return GitBundle.getString("refspec.column.remote");
|
||||
default:
|
||||
throw new IllegalStateException("Invalid column: " + column);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object getValueAt(final int rowIndex, final int columnIndex) {
|
||||
RefMapping m = myMapping.get(rowIndex);
|
||||
switch (columnIndex) {
|
||||
case FORCE_COLUMN:
|
||||
return m.force;
|
||||
case LOCAL_COLUMN:
|
||||
return m.local;
|
||||
case REMOTE_COLUMN:
|
||||
return m.remote;
|
||||
default:
|
||||
throw new IllegalStateException("Invalid column: " + columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mapping
|
||||
*
|
||||
* @param force a force flag
|
||||
* @param remote a remote reference
|
||||
* @param local a local reference
|
||||
*/
|
||||
public void addMapping(final boolean force, @NonNls final String remote, @NonNls final String local) {
|
||||
final RefMapping m = new RefMapping();
|
||||
m.force = force;
|
||||
m.remote = remote;
|
||||
m.local = local;
|
||||
int row = myMapping.size();
|
||||
myMapping.add(m);
|
||||
fireTableRowsInserted(row, row);
|
||||
if (mySavedRemoteName == null) {
|
||||
remoteUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates all local heads in the table with remote name
|
||||
*/
|
||||
private void remoteUpdated() {
|
||||
String newText = myRemoteNameTextField.getText();
|
||||
if (mySavedRemoteName != null && !newText.equals(mySavedRemoteName)) {
|
||||
@NonNls String oldTagsPrefix = tagRemoteName(mySavedRemoteName, "");
|
||||
@NonNls String newTagsPrefix = tagRemoteName(newText, "");
|
||||
@NonNls String oldHeadsPrefix = remoteName(mySavedRemoteName, "");
|
||||
@NonNls String newHeadsPrefix = remoteName(newText, "");
|
||||
for (RefMapping m : myMapping) {
|
||||
if (m.local.startsWith(oldTagsPrefix)) {
|
||||
m.local = newTagsPrefix + m.local.substring(oldTagsPrefix.length());
|
||||
}
|
||||
else if (m.local.startsWith(oldHeadsPrefix)) {
|
||||
m.local = newHeadsPrefix + m.local.substring(oldHeadsPrefix.length());
|
||||
}
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
mySavedRemoteName = newText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(final int columnIndex) {
|
||||
if (columnIndex == FORCE_COLUMN) {
|
||||
return Boolean.class;
|
||||
}
|
||||
return super.getColumnClass(columnIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if remote name is actually used in the entries
|
||||
*/
|
||||
boolean isRemoteNameUsed() {
|
||||
String text = myRemoteNameTextField.getText();
|
||||
@NonNls String tagsPrefix = tagRemoteName(text, "");
|
||||
for (RefMapping m : myMapping) {
|
||||
if (m.local.startsWith(tagsPrefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the mapping
|
||||
*/
|
||||
public void clear() {
|
||||
myMapping.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of references
|
||||
*/
|
||||
public String[] getReferences() {
|
||||
final int n = myMapping.size();
|
||||
String[] rc = new String[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
rc[i] = myMapping.get(i).toString();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference mapping object used in the table model
|
||||
*/
|
||||
class RefMapping {
|
||||
/**
|
||||
* if true update is forced
|
||||
*/
|
||||
boolean force;
|
||||
/**
|
||||
* remote reference name
|
||||
*/
|
||||
String remote;
|
||||
/**
|
||||
* local reference name
|
||||
*/
|
||||
String local;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return (force ? "+" : "") + remote + ":" + local;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The source of default references
|
||||
*/
|
||||
public enum ReferenceSource {
|
||||
/**
|
||||
* The references are pulled from fetch specification
|
||||
*/
|
||||
FETCH,
|
||||
/**
|
||||
* The references are pulled from push specification
|
||||
*/
|
||||
PUSH, }
|
||||
}
|
||||
Reference in New Issue
Block a user