Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #800 from gnanaprakash-ravi/Enterprise429
cols and FieldDefinition.java code changes
- Loading branch information
Showing
6 changed files
with
127 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
common/client/src/main/java/zingg/common/client/cols/FieldDefSelectedCols.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,33 @@ | ||
package zingg.common.client.cols; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import zingg.common.client.FieldDefinition; | ||
|
||
public class FieldDefSelectedCols extends SelectedCols { | ||
|
||
public FieldDefSelectedCols(List<FieldDefinition> fieldDefs, boolean showConcise) { | ||
|
||
List<FieldDefinition> namedList = new ArrayList<>(); | ||
|
||
for (FieldDefinition fieldDef : fieldDefs) { | ||
if (showConcise && fieldDef.isDontUse()) { | ||
continue; | ||
} | ||
namedList.add(fieldDef); | ||
} | ||
|
||
namedList.add(new FieldDefinition()); | ||
List<String> stringList = convertNamedListToStringList(namedList); | ||
setCols(stringList); | ||
} | ||
|
||
private List<String> convertNamedListToStringList(List<FieldDefinition> namedList) { | ||
List<String> stringList = new ArrayList<>(); | ||
for (FieldDefinition named : namedList) { | ||
stringList.add(named.getName()); | ||
} | ||
return stringList; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
common/client/src/main/java/zingg/common/client/cols/ISelectedCols.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,16 @@ | ||
package zingg.common.client.cols; | ||
|
||
import java.util.List; | ||
|
||
public interface ISelectedCols { | ||
|
||
String[] getCols(List<? extends Named> n); | ||
|
||
String[] getCols(); | ||
|
||
void setCols(List<String> cols); | ||
|
||
void setNamedCols(List<? extends Named> n); | ||
|
||
void setStringCols(List<String> cols); | ||
} |
8 changes: 8 additions & 0 deletions
8
common/client/src/main/java/zingg/common/client/cols/Named.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,8 @@ | ||
package zingg.common.client.cols; | ||
|
||
public interface Named { | ||
|
||
String getName(); | ||
|
||
void setName(String name); | ||
} |
37 changes: 37 additions & 0 deletions
37
common/client/src/main/java/zingg/common/client/cols/SelectedCols.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,37 @@ | ||
package zingg.common.client.cols; | ||
|
||
import java.util.List; | ||
|
||
public class SelectedCols implements ISelectedCols { | ||
|
||
private String[] cols; | ||
|
||
@Override | ||
public String[] getCols(List<? extends Named> n) { | ||
String[] result = new String[n.size()]; | ||
for (int i = 0; i < n.size(); i++) { | ||
result[i] = n.get(i).getName(); | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public String[] getCols() { | ||
return cols; | ||
} | ||
|
||
@Override | ||
public void setCols(List<String> strings) { | ||
this.cols = strings.toArray(new String[0]); | ||
} | ||
|
||
@Override | ||
public void setNamedCols(List<? extends Named> n) { | ||
this.cols = getCols(n); | ||
} | ||
|
||
@Override | ||
public void setStringCols(List<String> columnNames) { | ||
this.cols = columnNames.toArray(new String[0]); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.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,16 @@ | ||
package zingg.common.client.cols; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import zingg.common.client.util.ColName; | ||
|
||
public class ZidAndFieldDefSelector extends SelectedCols { | ||
|
||
public ZidAndFieldDefSelector(String[] fieldDefs) { | ||
|
||
List<String> fieldDefList = Arrays.asList(fieldDefs); | ||
fieldDefList.add(0, ColName.ID_COL); | ||
setCols(fieldDefList); | ||
} | ||
} |