forked from cake-build/cake-rider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
a new settings page was introduced: "Search paths". This page contains two settings: The search paths to start the search for Cake files and excludes for paths that should not be searched. Default search paths is ["."], which correlates to the "old" functionality. Default exclude is [".*/tools/.*"] to exclude the tools folder and thereby excluding Cake files that were added from NuGet packages.
- Loading branch information
Showing
11 changed files
with
388 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ formatting: | |
style: | ||
ReturnCount: | ||
max: 10 | ||
LoopWithTooManyJumpStatements: | ||
maxJumpCount: 5 |
57 changes: 57 additions & 0 deletions
57
rider/src/main/java/net/cakebuild/settings/CakeSearchPathSettingsEditor.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="net.cakebuild.settings.CakeSearchPathSettingsEditor"> | ||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="2" 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> | ||
<xy x="20" y="20" width="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<grid id="59657" layout-manager="BorderLayout" hgap="0" vgap="0"> | ||
<constraints> | ||
<grid row="0" column="0" 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="f01f4" class="javax.swing.JLabel"> | ||
<constraints border-constraint="North"/> | ||
<properties> | ||
<text value="Search paths"/> | ||
</properties> | ||
</component> | ||
<grid id="b465e" binding="searchPathsPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" 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 border-constraint="Center"/> | ||
<properties/> | ||
<border type="none"/> | ||
<children/> | ||
</grid> | ||
</children> | ||
</grid> | ||
<grid id="adaa6" layout-manager="BorderLayout" hgap="0" vgap="0"> | ||
<constraints> | ||
<grid row="1" column="0" 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="333f8" class="javax.swing.JLabel"> | ||
<constraints border-constraint="North"/> | ||
<properties> | ||
<text value="Exclude expressions"/> | ||
</properties> | ||
</component> | ||
<grid id="9dd86" binding="excludesPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" 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 border-constraint="Center"/> | ||
<properties/> | ||
<border type="none"/> | ||
<children/> | ||
</grid> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
</form> |
46 changes: 46 additions & 0 deletions
46
rider/src/main/java/net/cakebuild/settings/CakeSearchPathSettingsEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.cakebuild.settings; | ||
|
||
import net.cakebuild.settings.controls.SimpleAddEditControl; | ||
import net.cakebuild.shared.ui.RegexCellEditor; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.*; | ||
import java.util.Collection; | ||
|
||
public class CakeSearchPathSettingsEditor { | ||
private JPanel content; | ||
private JPanel searchPathsPanel; | ||
private JPanel excludesPanel; | ||
private SimpleAddEditControl mySearchPathsPanel; | ||
private SimpleAddEditControl myExcludesPanel; | ||
|
||
public JPanel getContent() { return content; } | ||
|
||
public void setScriptSearchPaths(@NotNull Collection<String> paths){ | ||
mySearchPathsPanel.setData(paths); | ||
} | ||
|
||
public Collection<String> getScriptSearchPaths() { | ||
return mySearchPathsPanel.getData(); | ||
} | ||
|
||
public void setScriptSearchIgnores(@NotNull Collection<String> expressions) { | ||
myExcludesPanel.setData(expressions); | ||
} | ||
|
||
public Collection<String> getScriptSearchIgnores() { | ||
return myExcludesPanel.getData(); | ||
} | ||
|
||
private void createUIComponents() { | ||
mySearchPathsPanel = new SimpleAddEditControl(new String[] { "Path" }, () -> new String[] { "" } ); | ||
searchPathsPanel = mySearchPathsPanel.getContent(); | ||
|
||
myExcludesPanel = new SimpleAddEditControl(new String[] { "Exclude Regex" }, () -> new String[] { "" }); | ||
excludesPanel = myExcludesPanel.getContent(); | ||
RegexCellEditor regexCellEditor = new RegexCellEditor(); | ||
regexCellEditor.setOnValidationError(s -> { myExcludesPanel.setValidationError(s); return null; }); | ||
regexCellEditor.setOnValidationSuccess(() -> { myExcludesPanel.setValidationError(null); return null; }); | ||
myExcludesPanel.setCellEditor(0, regexCellEditor); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
rider/src/main/java/net/cakebuild/settings/controls/SimpleAddEditControl.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="net.cakebuild.settings.controls.SimpleAddEditControl"> | ||
<grid id="27dc6" binding="panel" 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="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="eee7b" class="javax.swing.JTable" binding="table"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="50"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
<grid id="1dc84" layout-manager="GridBagLayout"> | ||
<constraints> | ||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="91f3c" class="javax.swing.JButton" binding="addItem"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="0" indent="0" use-parent-layout="false"/> | ||
<gridbag weightx="0.0" weighty="0.0"/> | ||
</constraints> | ||
<properties> | ||
<icon value="general/add.png"/> | ||
<maximumSize width="30" height="30"/> | ||
<minimumSize width="30" height="30"/> | ||
<opaque value="true"/> | ||
<preferredSize width="30" height="30"/> | ||
<text value=""/> | ||
</properties> | ||
</component> | ||
<component id="a279" class="javax.swing.JButton" binding="removeItem"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="0" indent="0" use-parent-layout="false"/> | ||
<gridbag weightx="0.0" weighty="0.0"/> | ||
</constraints> | ||
<properties> | ||
<icon value="general/remove.png"/> | ||
<label value=""/> | ||
<maximumSize width="30" height="30"/> | ||
<minimumSize width="30" height="30"/> | ||
<preferredSize width="30" height="30"/> | ||
<text value=""/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
<component id="7e676" class="javax.swing.JLabel" binding="errorText"> | ||
<constraints> | ||
<grid row="1" 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> | ||
<foreground color="-65536"/> | ||
<text value=""/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</form> |
90 changes: 90 additions & 0 deletions
90
rider/src/main/java/net/cakebuild/settings/controls/SimpleAddEditControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package net.cakebuild.settings.controls; | ||
|
||
import javax.swing.*; | ||
import javax.swing.table.DefaultTableModel; | ||
import javax.swing.table.TableCellEditor; | ||
import javax.swing.table.TableColumnModel; | ||
import java.awt.*; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.function.Supplier; | ||
|
||
public class SimpleAddEditControl { | ||
private JTable table; | ||
private JButton addItem; | ||
private JButton removeItem; | ||
private JPanel panel; | ||
private JLabel errorText; | ||
private final DefaultTableModel model; | ||
|
||
public SimpleAddEditControl(String[] headers, Supplier<String[]> newItemGenerator){ | ||
model = (DefaultTableModel) table.getModel(); | ||
for(int i = 0; i< headers.length; i++){ | ||
model.addColumn("col"+i); | ||
} | ||
TableColumnModel columnModel = table.getColumnModel(); | ||
for(int i = 0; i< headers.length; i++){ | ||
columnModel.getColumn(i).setHeaderValue(headers[i]); | ||
} | ||
table.putClientProperty("terminateEditOnFocusLost", true); | ||
table.setCellSelectionEnabled(false); | ||
table.setRowSelectionAllowed(true); | ||
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); | ||
table.getSelectionModel().addListSelectionListener(e -> { | ||
int row = table.getSelectedRow(); | ||
removeItem.setEnabled(row >= 0); | ||
}); | ||
addItem.addActionListener(e -> { | ||
model.addRow(newItemGenerator.get()); | ||
int row = model.getRowCount()-1; | ||
table.editCellAt(row, 0); | ||
table.changeSelection(row, 0, false, false); | ||
TableCellEditor editor = table.getCellEditor(row, 0); | ||
Component textEdit = table.prepareEditor(editor, row, 0); | ||
textEdit.requestFocus(); | ||
}); | ||
removeItem.setEnabled(false); | ||
removeItem.addActionListener(e -> { | ||
int row = table.getSelectedRow(); | ||
if(row < 0) { | ||
return; | ||
} | ||
|
||
model.removeRow(row); | ||
}); | ||
} | ||
|
||
public void setCellEditor(int columnIndex, TableCellEditor cellEditor){ | ||
table.getColumnModel().getColumn(columnIndex).setCellEditor(cellEditor); | ||
} | ||
|
||
public Collection<String> getData() { | ||
Collection<String> items = new HashSet<>(); | ||
int rows = model.getRowCount(); | ||
for(int i =0; i < rows; i++) { | ||
String item = (String)model.getValueAt(i, 0); | ||
|
||
items.add(item); | ||
} | ||
|
||
return items; | ||
} | ||
|
||
public void setData(Collection<String> data) { | ||
while (model.getRowCount() > 0){ | ||
model.removeRow(0); | ||
} | ||
data.forEach(it -> model.addRow(new Object[]{ it })); | ||
} | ||
|
||
public void setValidationError(String error) { | ||
if(error == null) { | ||
errorText.setText(""); | ||
return; | ||
} | ||
|
||
errorText.setText(error); | ||
} | ||
|
||
public JPanel getContent() { return panel; } | ||
} |
49 changes: 49 additions & 0 deletions
49
rider/src/main/kotlin/net/cakebuild/settings/CakeSearchPathSettingsConfigurable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package net.cakebuild.settings | ||
|
||
import com.intellij.openapi.options.Configurable | ||
import com.intellij.openapi.project.Project | ||
import javax.swing.JComponent | ||
|
||
class CakeSearchPathSettingsConfigurable(private val project: Project) : Configurable { | ||
private val editor = CakeSearchPathSettingsEditor() | ||
|
||
override fun createComponent(): JComponent? { | ||
return editor.content | ||
} | ||
|
||
override fun getDisplayName(): String { | ||
return "Search Paths" | ||
} | ||
|
||
override fun apply() { | ||
val settings = CakeSettings.getInstance(project) | ||
settings.cakeScriptSearchPaths = editor.scriptSearchPaths.toList() | ||
settings.cakeScriptSearchIgnores = editor.scriptSearchIgnores.toList() | ||
} | ||
|
||
override fun reset() { | ||
val settings = CakeSettings.getInstance(project) | ||
editor.scriptSearchPaths = settings.cakeScriptSearchPaths.toMutableList() | ||
editor.scriptSearchIgnores = settings.cakeScriptSearchIgnores.toMutableList() | ||
} | ||
|
||
override fun isModified(): Boolean { | ||
val settings = CakeSettings.getInstance(project) | ||
return isModified(editor.scriptSearchPaths, settings.cakeScriptSearchPaths) || | ||
isModified(editor.scriptSearchIgnores, settings.cakeScriptSearchIgnores) | ||
} | ||
|
||
private fun isModified(left: Collection<String>, right: Collection<String>): Boolean { | ||
if (left.size != right.size) { | ||
return true | ||
} | ||
|
||
left.forEach { | ||
if (!right.contains(it)) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.