mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Ignored Files. Toolbar decorator.
This commit is contained in:
+3
-3
@@ -44,7 +44,7 @@ public class IgnoredSettingsDialog extends DialogWrapper {
|
||||
|
||||
@Nullable
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel.getPanel();
|
||||
return myPanel.createComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,9 +67,9 @@ public class IgnoredSettingsDialog extends DialogWrapper {
|
||||
dlg.dispose();
|
||||
}
|
||||
|
||||
@Override @NonNls
|
||||
@Override
|
||||
@NonNls
|
||||
protected String getDimensionServiceKey() {
|
||||
return "IgnoredSettingsDialog";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.vcs.changes.ui.IgnoredSettingsPanel">
|
||||
<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="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="eebb3" 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="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="93239" class="javax.swing.JButton" binding="myAddButton" 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 value="Add..."/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="fcef0">
|
||||
<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="ee26d" class="javax.swing.JButton" binding="myEditButton" 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 value="Edit..."/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="aab12" class="javax.swing.JButton" binding="myRemoveButton" 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>
|
||||
<text value="Remove"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="740be">
|
||||
<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"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2b163" class="com.intellij.ui.components.JBList" binding="myList" default-binding="true">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+34
-40
@@ -29,8 +29,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.IgnoredFileBean;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -38,45 +37,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class IgnoredSettingsPanel implements SearchableConfigurable, Configurable.NoScroll {
|
||||
private JBList myList;
|
||||
private JButton myAddButton;
|
||||
private JButton myEditButton;
|
||||
private JButton myRemoveButton;
|
||||
private JPanel myPanel;
|
||||
private final Project myProject;
|
||||
private DefaultListModel myModel;
|
||||
private final ChangeListManager myChangeListManager;
|
||||
|
||||
public IgnoredSettingsPanel(Project project) {
|
||||
myProject = project;
|
||||
myList = new JBList();
|
||||
myList.setCellRenderer(new MyCellRenderer());
|
||||
myAddButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addItem();
|
||||
}
|
||||
});
|
||||
myEditButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editItem();
|
||||
}
|
||||
});
|
||||
myRemoveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
deleteItems();
|
||||
}
|
||||
});
|
||||
myChangeListManager = ChangeListManager.getInstance(myProject);
|
||||
|
||||
myList.getEmptyText().setText(VcsBundle.message("no.ignored.files"));
|
||||
|
||||
myProject = project;
|
||||
myChangeListManager = ChangeListManager.getInstance(myProject);
|
||||
}
|
||||
|
||||
private void setItems(final IgnoredFileBean[] filesToIgnore) {
|
||||
myModel = new DefaultListModel();
|
||||
for(IgnoredFileBean bean: filesToIgnore) {
|
||||
for (IgnoredFileBean bean : filesToIgnore) {
|
||||
myModel.addElement(bean);
|
||||
}
|
||||
myList.setModel(myModel);
|
||||
@@ -85,8 +65,8 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
public IgnoredFileBean[] getItems() {
|
||||
final int count = myList.getModel().getSize();
|
||||
IgnoredFileBean[] result = new IgnoredFileBean[count];
|
||||
for(int i=0; i<count; i++) {
|
||||
result [i] = (IgnoredFileBean) myList.getModel().getElementAt(i);
|
||||
for (int i = 0; i < count; i++) {
|
||||
result[i] = (IgnoredFileBean)myList.getModel().getElementAt(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -96,14 +76,14 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
dlg.show();
|
||||
if (dlg.isOK()) {
|
||||
final IgnoredFileBean[] ignoredFiles = dlg.getSelectedIgnoredFiles();
|
||||
for(IgnoredFileBean bean: ignoredFiles) {
|
||||
for (IgnoredFileBean bean : ignoredFiles) {
|
||||
myModel.addElement(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void editItem() {
|
||||
IgnoredFileBean bean = (IgnoredFileBean) myList.getSelectedValue();
|
||||
IgnoredFileBean bean = (IgnoredFileBean)myList.getSelectedValue();
|
||||
if (bean == null) return;
|
||||
IgnoreUnversionedDialog dlg = new IgnoreUnversionedDialog(myProject);
|
||||
dlg.setIgnoredFile(bean);
|
||||
@@ -112,7 +92,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
IgnoredFileBean[] beans = dlg.getSelectedIgnoredFiles();
|
||||
assert beans.length == 1;
|
||||
int selectedIndex = myList.getSelectedIndex();
|
||||
myModel.setElementAt(beans [0], selectedIndex);
|
||||
myModel.setElementAt(beans[0], selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +100,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
boolean contigiousSelection = true;
|
||||
int minSelectionIndex = myList.getSelectionModel().getMinSelectionIndex();
|
||||
int maxSelectionIndex = myList.getSelectionModel().getMaxSelectionIndex();
|
||||
for(int i=minSelectionIndex; i<=maxSelectionIndex; i++) {
|
||||
for (int i = minSelectionIndex; i <= maxSelectionIndex; i++) {
|
||||
if (!myList.getSelectionModel().isSelectedIndex(i)) {
|
||||
contigiousSelection = false;
|
||||
break;
|
||||
@@ -131,7 +111,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
}
|
||||
else {
|
||||
final Object[] selection = myList.getSelectedValues();
|
||||
for(Object item: selection) {
|
||||
for (Object item : selection) {
|
||||
myModel.removeElement(item);
|
||||
}
|
||||
}
|
||||
@@ -150,6 +130,25 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
if (myPanel == null) {
|
||||
myPanel = ToolbarDecorator.createDecorator(myList)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
addItem();
|
||||
}
|
||||
}).setEditAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
editItem();
|
||||
}
|
||||
}).setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
deleteItems();
|
||||
}
|
||||
}).disableUpDownActions().createPanel();
|
||||
}
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@@ -178,18 +177,14 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
return null;
|
||||
}
|
||||
|
||||
public JComponent getPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
private static class MyCellRenderer extends ColoredListCellRenderer {
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
if (UIUtil.isUnderGTKLookAndFeel()) {
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
|
||||
IgnoredFileBean bean = (IgnoredFileBean) value;
|
||||
IgnoredFileBean bean = (IgnoredFileBean)value;
|
||||
final String path = bean.getPath();
|
||||
if (path != null) {
|
||||
if (path.endsWith("/")) {
|
||||
@@ -204,5 +199,4 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user