L
z_k+4!abyl-(Uqz!DBL_7VZUY^=^&|b>VtljG_s?LD|xi8ntF=pyCh;d_PB#P=Blow0pyJFYJD3N-xgmh{Wlx4r+${eOQl;6JW^{cOO$eL)KRe-pX>*Y*EADezAR|IeX8Kz=)T+Z)2~
z+W!9>^MAYho4Wt^?Kh9Lx82`7{;$^mKfZsh_WzG}fj{h9eeq}Cf71T{aTb3qbpHd_
z?5$?`d))t#z5fdQtBm^(;H@_y*WUsED(e0f^;b3WAE*wHe~q>f7R3e0SpcO
z_rQOuuz!X8Rk8U8();
- listeners = new ArrayList();
- header = new ArrayList();
+ rows = new ArrayList<>();
+ listeners = new ArrayList<>();
+ header = new ArrayList<>();
}
// TODO : all abstract methods should be moved to a specific interface
/**
* Check if first line in the file will be considered as the file header
+ *
* @return true if the first line in the file represents the header
*/
public abstract boolean isFirstLineHeader();
/**
* Check search in the text must be case sensitive
+ *
* @return true if the search must be case sensitive.
*/
public abstract boolean getSensitiveSearch();
/**
* Get custom delimiter to use as a separator
+ *
* @return the delimiter
*/
public abstract char getCustomDelimiter();
/**
* Get the character that defines comment lines
- * @return the comment line starting character. If no comments are allowed in this
- * file, then Character.UNASSIGNED constant must be returned;
+ *
+ * @return the comment line starting character. If no comments are allowed in
+ * this file, then Character.UNASSIGNED constant must be returned;
*
*/
public abstract char getCommentChar();
/**
* Get custom text qualifier to use as a text qualifier in the data
+ *
* @return the text qualifier character to use as a text qualifier in the data
*/
public abstract char getTextQualifier();
/**
* check if the text qualifier has to be use for all fields or not
+ *
* @return true if the text qualifier is to be used for all data fields
*/
public abstract boolean useQualifier();
/**
* Get the delimiter used to separate different values in a same csv cell
+ *
* @return the delimiter used to separate values
*/
public abstract String getInCellDelimiter();
-
+
/**
- * Get the pattern to identify a column header where values can be splitted with the inCellDelimiter
- * and displayed in a table instead of a textfield
+ * Get the pattern to identify a column header where values can be splitted with
+ * the inCellDelimiter and displayed in a table instead of a textfield
+ *
* @return the regex
*/
public abstract String getRegexTableMarker();
@@ -104,14 +112,14 @@ public AbstractCSVFile() {
/**
* @param text
*/
- public void setInput(String text) {
+ public void setInput(final String text) {
readLines(text);
}
/**
* @param display
*/
- public void displayFirstLine(boolean display) {
+ public void displayFirstLine(final boolean display) {
displayFirstLine = display;
}
@@ -119,14 +127,13 @@ public void displayFirstLine(boolean display) {
* @param reader
* @return
*/
- protected CsvReader initializeReader (Reader reader)
- {
- CsvReader csvReader = new CsvReader(reader);
+ protected CsvReader initializeReader(final Reader reader) {
+ final CsvReader csvReader = new CsvReader(reader);
- char customDelimiter = getCustomDelimiter();
+ final char customDelimiter = getCustomDelimiter();
csvReader.setDelimiter(customDelimiter);
- char commentChar = getCommentChar();
+ final char commentChar = getCommentChar();
if (commentChar != Character.UNASSIGNED) {
csvReader.setComment(commentChar);
// prevent loss of comment in csv source file
@@ -142,11 +149,11 @@ protected CsvReader initializeReader (Reader reader)
/**
* @param fileText
*/
- protected void readLines(String fileText) {
+ protected void readLines(final String fileText) {
rows.clear();
try {
- CsvReader csvReader = initializeReader(new StringReader(fileText));
+ final CsvReader csvReader = initializeReader(new StringReader(fileText));
// case when the first line is the encoding
if (!displayFirstLine) {
csvReader.skipLine();
@@ -154,16 +161,15 @@ protected void readLines(String fileText) {
boolean setHeader = false;
while (csvReader.readRecord()) {
- String[] rowValues = csvReader.getValues();
- CSVRow csvRow = new CSVRow(rowValues, this);
+ final String[] rowValues = csvReader.getValues();
+ final CSVRow csvRow = new CSVRow(rowValues, this);
if (!rowValues[0].startsWith(String.valueOf(getCommentChar()))) {
if (isFirstLineHeader() && !setHeader) {
setHeader = true;
csvRow.setHeader(true);
populateHeaders(rowValues);
}
- }
- else {
+ } else {
csvRow.setCommentLine(true);
}
rows.add(csvRow);
@@ -178,7 +184,7 @@ protected void readLines(String fileText) {
}
csvReader.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
System.out.println("exception in readLines " + e);
e.printStackTrace();
}
@@ -190,17 +196,17 @@ protected void readLines(String fileText) {
/**
* @param entries
*/
- private void populateHeaders (String[] entries) {
+ private void populateHeaders(final String[] entries) {
header.clear();
if (entries != null) {
- for (String entry : entries) {
+ for (final String entry : entries) {
header.add(entry);
}
-/* for (int i = header.size(); i < nbOfColumns; i++) {
- header.add("");
- }*/
+ /*
+ * for (int i = header.size(); i < nbOfColumns; i++) { header.add(""); }
+ */
} else {
for (int i = 1; i < nbOfColumns + 1; i++) {
header.add("Column" + i);
@@ -218,7 +224,7 @@ public ArrayList getHeader() {
/**
* @return
*/
- public String[] getArrayHeader () {
+ public String[] getArrayHeader() {
return header.toArray(new String[header.size()]);
}
@@ -228,42 +234,40 @@ public String[] getArrayHeader () {
/**
*
*/
- public void addRow () {
- CSVRow row = CSVRow.createEmptyLine(nbOfColumns, this);
+ public void addRow() {
+ final CSVRow row = CSVRow.createEmptyLine(nbOfColumns, this);
addRow(row);
}
/**
* @param row
*/
- public void addRow (CSVRow row) {
+ public void addRow(final CSVRow row) {
rows.add(row);
}
/**
* @param row
*/
- public void addRowAfterElement (CSVRow row) {
- CSVRow newRow = CSVRow.createEmptyLine(nbOfColumns, this);
- int indexRow = findRow(row);
+ public void addRowAfterElement(final CSVRow row) {
+ final CSVRow newRow = CSVRow.createEmptyLine(nbOfColumns, this);
+ final int indexRow = findRow(row);
if (indexRow != -1) {
rows.add(indexRow, newRow);
- }
- else {
+ } else {
addRow(newRow);
}
}
-
+
/**
* @param row
*/
- public void duplicateRow (CSVRow row) {
- CSVRow newRow = new CSVRow(row, this);
- int indexRow = findRow(row);
+ public void duplicateRow(final CSVRow row) {
+ final CSVRow newRow = new CSVRow(row, this);
+ final int indexRow = findRow(row);
if (indexRow != -1) {
rows.add(indexRow, newRow);
- }
- else {
+ } else {
addRow(newRow);
}
}
@@ -272,9 +276,9 @@ public void duplicateRow (CSVRow row) {
* @param row
* @return
*/
- public int findRow (CSVRow findRow) {
+ public int findRow(final CSVRow findRow) {
for (int i = 0; i <= getArrayRows(true).length; i++) {
- CSVRow row = getRowAt(i);
+ final CSVRow row = getRowAt(i);
if (row.equals(findRow)) {
return i;
}
@@ -292,10 +296,10 @@ public List getRows() {
/**
* @return
*/
- public Object[] getArrayRows (boolean includeCommentLine) {
+ public Object[] getArrayRows(final boolean includeCommentLine) {
// filter header and comment rows
- ArrayList myrows = new ArrayList();
- for (CSVRow row : rows) {
+ final ArrayList myrows = new ArrayList<>();
+ for (final CSVRow row : rows) {
// should we return the comment line
if (row.isCommentLine()) {
if (includeCommentLine) {
@@ -314,36 +318,37 @@ else if (!row.isHeader()) {
* @param index
* @return
*/
- public CSVRow getRowAt (int index) {
+ public CSVRow getRowAt(final int index) {
return rows.get(index);
}
/**
- * @see org.fhsolution.eclipse.plugins.csvedit.model.IRowChangesListener#rowChanged(org.fhsolution.eclipse.plugins.csvedit.model.CSVRow, int)
+ * @see org.fhsolution.eclipse.plugins.csvedit.model.IRowChangesListener#rowChanged(org.fhsolution.eclipse.plugins.csvedit.model.CSVRow,
+ * int)
*/
- public void rowChanged (CSVRow row, int rowIndex) {
- for (ICsvFileModelListener l : listeners) {
- ((ICsvFileModelListener) l).entryChanged(row, rowIndex);
+ @Override
+ public void rowChanged(final CSVRow row, final int rowIndex) {
+ for (final ICsvFileModelListener l : listeners) {
+ l.entryChanged(row, rowIndex);
}
}
/**
* @param rowIndex
*/
- public void removeRow (int rowIndex) {
+ public void removeRow(final int rowIndex) {
rows.remove(rowIndex);
}
/**
*
*/
- public void removeRow (CSVRow row) {
+ public void removeRow(final CSVRow row) {
if (!rows.remove(row)) {
// TODO return error message
}
}
-
// ----------------------------------
// Helper method on column management
// ----------------------------------
@@ -351,10 +356,10 @@ public void removeRow (CSVRow row) {
/**
* @param colName
*/
- public void addColumn (String colName) {
+ public void addColumn(final String colName) {
nbOfColumns++;
header.add(colName);
- for (CSVRow row : rows) {
+ for (final CSVRow row : rows) {
row.addElement("");
}
}
@@ -371,14 +376,14 @@ public int getColumnCount() {
*
* @param colIndex
*/
- public void removeColumn (int colIndex) {
+ public void removeColumn(final int colIndex) {
if (isFirstLineHeader()) {
header.remove(colIndex);
nbOfColumns--;
}
- for (CSVRow row : rows) {
+ for (final CSVRow row : rows) {
if (!row.isCommentLine()) {
- System.out.println("remove elmt:["+colIndex+"] in row [" + row +"]");
+ System.out.println("remove elmt:[" + colIndex + "] in row [" + row + "]");
row.removeElementAt(colIndex);
}
}
@@ -389,38 +394,39 @@ public void removeColumn (int colIndex) {
*
* @param colIndex
*/
- public void removeColumn (String columnName) {
+ public void removeColumn(final String columnName) {
if (columnName == null) {
return;
}
- int colIndex = header.indexOf(columnName);
+ final int colIndex = header.indexOf(columnName);
removeColumn(colIndex);
}
/**
* @param csvFileListener
*/
- public void removeModelListener (ICsvFileModelListener csvFileListener) {
+ public void removeModelListener(final ICsvFileModelListener csvFileListener) {
listeners.remove(csvFileListener);
}
/**
* @param csvFileListener
*/
- public void addModelListener (ICsvFileModelListener csvFileListener) {
- if (!listeners.contains(csvFileListener))
+ public void addModelListener(final ICsvFileModelListener csvFileListener) {
+ if (!listeners.contains(csvFileListener)) {
listeners.add(csvFileListener);
+ }
}
/**
* Initialize the CsvWriter
+ *
* @param writer
* @return
*/
- protected CsvWriter initializeWriter (Writer writer)
- {
- char delimiter = getCustomDelimiter();
- CsvWriter csvWriter = new CsvWriter(writer, delimiter);
+ protected CsvWriter initializeWriter(final Writer writer) {
+ final char delimiter = getCustomDelimiter();
+ final CsvWriter csvWriter = new CsvWriter(writer, delimiter);
csvWriter.setTextQualifier(getTextQualifier());
csvWriter.setForceQualifier(useQualifier());
csvWriter.setComment(getCommentChar());
@@ -430,32 +436,28 @@ protected CsvWriter initializeWriter (Writer writer)
/**
* @return
*/
- public String getTextRepresentation () {
+ public String getTextRepresentation() {
- StringWriter sw = new StringWriter();
+ final StringWriter sw = new StringWriter();
try {
- CsvWriter clw = initializeWriter(sw);
+ final CsvWriter clw = initializeWriter(sw);
/*
- if (isFirstLineHeader() && header.size() > 0) {
- String[] headerArray = new String[header.size()];
- for (int i=0; i 0) { String[] headerArray = new
+ * String[header.size()]; for (int i=0; i
-
- 4.0.0
-
- csvedit
- org.nodeclipse
- 1.2.0-SNAPSHOT
-
- csvedit.site
- eclipse-repository
- csvedit :: update site
+
+ 4.0.0
+
+ csvedit
+ org.nodeclipse
+ 1.2.0-SNAPSHOT
+
+ csvedit.site
+ eclipse-repository
+ csvedit :: update site
diff --git a/csvedit.target/csvedit.target b/csvedit.target/csvedit.target
new file mode 100644
index 0000000..6b2e3ca
--- /dev/null
+++ b/csvedit.target/csvedit.target
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.jumpmind.symmetric
+ symmetric-csv
+ 2.5.13
+ jar
+
+
+
+
+
\ No newline at end of file
diff --git a/csvedit.target/pom.xml b/csvedit.target/pom.xml
new file mode 100644
index 0000000..3aeae87
--- /dev/null
+++ b/csvedit.target/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+
+ org.nodeclipse
+ csvedit
+ 1.2.0-SNAPSHOT
+
+ csvedit.target
+ eclipse-target-definition
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 308f723..947ee38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,99 +1,271 @@
-
- 4.0.0
- org.nodeclipse
- csvedit
- 1.2.0-SNAPSHOT
- pom
- csvedit :: parent
- csvedit parent
+
+ 4.0.0
+ org.nodeclipse
+ csvedit
+ 1.2.0-SNAPSHOT
+ pom
+ csvedit :: parent
+ csvedit parent
-
- 3.0
-
+
+ 17
+ 4.0.4
+ -Xmx512m -XX:MaxPermSize=256m
+ UTF-8
+
-
- 1.6
- 3.0
- 1.0.0
- -Xmx512m -XX:MaxPermSize=256m
- UTF-8
-
+
+ scm:git@github.com:gnl42/CsvEdit.git
+ scm:git@github.com:gnl42/CsvEdit.git
+ https://github.com/gnl42/CsvEdit
+
-
-
- luna
- p2
- http://download.eclipse.org/releases/luna
-
-
-
-
- sonatype-public
- http://repository.sonatype.org/content/groups/sonatype-public-grid
-
-
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.5.0
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.12.1
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 3.1.1
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.4.0
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+ 3.1.2
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.3.0
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.3.1
+
+
+ org.apache.maven.plugins
+ maven-clean-plugin
+ 3.3.1
+
+
+ org.apache.maven.plugins
+ maven-jxr-plugin
+ 3.3.0
+
+
+ org.eclipse.tycho
+ tycho-compiler-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-maven-plugin
+ ${tycho.version}
+ true
+
+
+ org.eclipse.tycho
+ tycho-p2-repository-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-source-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho.extras
+ tycho-source-feature-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-p2-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-versions-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-p2-director-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ tycho-surefire-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho
+ target-platform-configuration
+ ${tycho.version}
+
+
+ org.eclipse.tycho.extras
+ tycho-eclipserun-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho.extras
+ tycho-pack200a-plugin
+ ${tycho.version}
+
+
+ org.eclipse.tycho.extras
+ tycho-pack200b-plugin
+ ${tycho.version}
+
+
+ org.eclipse.cbi.maven.plugins
+ eclipse-jarsigner-plugin
+ 1.4.2
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ UTF-8
+
+
+
+ org.eclipse.tycho
+ tycho-compiler-plugin
+
+ 17
+ true
+ true
+
+
+
+ org.eclipse.tycho
+ tycho-maven-plugin
+ true
+
+
+ org.eclipse.tycho
+ tycho-p2-repository-plugin
+
+
+ org.eclipse.tycho
+ tycho-packaging-plugin
+ ${tycho.version}
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.1.0
+
+
+ org.eclipse.tycho
+ tycho-p2-plugin
+
+
+ attach-p2-metadata
+ package
+
+ p2-metadata
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-versions-plugin
+
+
+ org.eclipse.tycho
+ tycho-surefire-plugin
+
+ false
+ true
+ true
+
+
+ ${ui.test.vmargs}
+
+
+ org.eclipse.equinox.launcher
+ 4
+ true
+
+
+
+
+
+
+
+
+ p2-installable-unit
+ org.eclipse.equinox.event
+
+
+
+
+
+ org.eclipse.tycho
+ target-platform-configuration
+
+
+
+ linux
+ gtk
+ x86_64
+
+
+ win32
+ win32
+ x86_64
+
+
+ macosx
+ cocoa
+ x86_64
+
+
+
+
+ org.nodeclipse
+ csvedit.target
+ 1.2.0-SNAPSHOT
+
+
+
+
+
+
-
-
-
- org.eclipse.tycho
- tycho-maven-plugin
- ${tycho.version}
- true
-
-
- org.eclipse.tycho
- target-platform-configuration
- ${tycho.version}
-
- p2
- consider
- true
-
-
-
-
-
-
-
- org.eclipse.tycho
- tycho-packaging-plugin
- ${tycho.version}
-
- yyyyMMdd-HHmm
-
-
-
- org.eclipse.tycho
- tycho-surefire-plugin
- ${tycho.version}
-
- true
-
- **/*Test.java
-
- ${tycho.test.jvmArgs}
-
- 60
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 2.3
-
-
-
-
-
- csvedit.plugin
- csvedit.plugin.ui
- csvedit.feature
-
- csvedit.site
-
+
+ csvedit.target
+ csvedit.plugin
+ csvedit.plugin.ui
+ csvedit.feature
+ csvedit.site
+
\ No newline at end of file
From 0e4f44dde7e567f05ad51cbe082fa6931b154f2d Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Tue, 12 Dec 2023 23:08:47 -0800
Subject: [PATCH 02/18] Fix NPE
---
.../csvedit/providers/CSVLabelProvider.java | 48 ++++++++++---------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/providers/CSVLabelProvider.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/providers/CSVLabelProvider.java
index e85b72a..d0c6fdf 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/providers/CSVLabelProvider.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/providers/CSVLabelProvider.java
@@ -37,12 +37,12 @@ public class CSVLabelProvider extends StyledCellLabelProvider {
//implements ITableLabelProvider
private String searchText;
- private Color searchColor;
+ private final Color searchColor;
/**
*
*/
- public CSVLabelProvider () {
+ public CSVLabelProvider() {
searchColor = Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW);
}
@@ -51,7 +51,7 @@ public CSVLabelProvider () {
* @param columnIndex
* @return
*/
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(final Object element, final int columnIndex) {
return null;
}
@@ -60,11 +60,12 @@ public Image getColumnImage(Object element, int columnIndex) {
* @param columnIndex
* @return
*/
- public String getColumnText(Object element, int columnIndex) {
- CSVRow row = (CSVRow) element;
+ public String getColumnText(final Object element, final int columnIndex) {
+ final CSVRow row = (CSVRow) element;
- if(row.getEntries().size() > columnIndex) {
- return row.getEntries().get(columnIndex).toString();
+ if (row.getEntries().size() > columnIndex) {
+ final String entry = row.getEntries().get(columnIndex);
+ return entry != null ? entry.toString() : "";
}
return "";
@@ -73,32 +74,37 @@ public String getColumnText(Object element, int columnIndex) {
/**
* @see org.eclipse.jface.viewers.BaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
- public void addListener(ILabelProviderListener listener) {
+ @Override
+ public void addListener(final ILabelProviderListener listener) {
}
/**
- * @see org.eclipse.jface.viewers.BaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+ * @see org.eclipse.jface.viewers.BaseLabelProvider#isLabelProperty(java.lang.Object,
+ * java.lang.String)
*/
- public boolean isLabelProperty(Object element, String property) {
+ @Override
+ public boolean isLabelProperty(final Object element, final String property) {
return true;
}
/**
* @see org.eclipse.jface.viewers.BaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
- public void removeListener(ILabelProviderListener listener) {
+ @Override
+ public void removeListener(final ILabelProviderListener listener) {
}
/**
* @param searchText
*/
- public void setSearchText(String searchText) {
+ public void setSearchText(final String searchText) {
this.searchText = searchText;
}
/**
* @see org.eclipse.jface.viewers.StyledCellLabelProvider#dispose()
*/
+ @Override
public void dispose() {
}
@@ -106,24 +112,22 @@ public void dispose() {
* @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
@Override
- public void update(ViewerCell cell) {
- CSVRow element = (CSVRow) cell.getElement();
- int index = cell.getColumnIndex();
- String columnText = getColumnText(element, index);
+ public void update(final ViewerCell cell) {
+ final CSVRow element = (CSVRow) cell.getElement();
+ final int index = cell.getColumnIndex();
+ final String columnText = getColumnText(element, index);
cell.setText(columnText);
cell.setImage(getColumnImage(element, index));
if (searchText != null && searchText.length() > 0) {
- int intRangesCorrectSize[] =
- SearchResultStyle.getSearchTermOccurrences(searchText, columnText);
- List styleRange = new ArrayList();
+ final int intRangesCorrectSize[] = SearchResultStyle.getSearchTermOccurrences(searchText, columnText);
+ final List styleRange = new ArrayList<>();
for (int i = 0; i < intRangesCorrectSize.length / 2; i++) {
- StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor);
+ final StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor);
myStyleRange.start = intRangesCorrectSize[i];
myStyleRange.length = intRangesCorrectSize[++i];
styleRange.add(myStyleRange);
}
- cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange
- .size()]));
+ cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange.size()]));
} else {
cell.setStyleRanges(null);
}
From e035141f3f7722651ebf97f06d49ab388cbba1b6 Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Tue, 12 Dec 2023 23:26:17 -0800
Subject: [PATCH 03/18] Deploy to GitHub #9
mvn clean deploy -P release-composite
---
csvedit.site/packaging-p2composite.ant | 181 ++++++++++++++++++++
csvedit.site/pom.xml | 221 +++++++++++++++++++++++++
pom.xml | 42 ++++-
3 files changed, 441 insertions(+), 3 deletions(-)
create mode 100644 csvedit.site/packaging-p2composite.ant
diff --git a/csvedit.site/packaging-p2composite.ant b/csvedit.site/packaging-p2composite.ant
new file mode 100644
index 0000000..f9bd40c
--- /dev/null
+++ b/csvedit.site/packaging-p2composite.ant
@@ -0,0 +1,181 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ version=1
+metadata.repository.factory.order=compositeContent.xml,\!
+artifact.repository.factory.order=compositeArtifacts.xml,\!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csvedit.site/pom.xml b/csvedit.site/pom.xml
index 8b03533..0027ec7 100644
--- a/csvedit.site/pom.xml
+++ b/csvedit.site/pom.xml
@@ -11,4 +11,225 @@
csvedit.site
eclipse-repository
csvedit :: update site
+
+
+
+
+ org.eclipse.tycho
+ tycho-packaging-plugin
+
+ 'v'yyyyMMdd'-'HHmm
+
+
+
+
+ org.eclipse.tycho
+ tycho-p2-repository-plugin
+
+ ${project.artifactId}-${qualifiedVersion}
+
+
+
+
+
+
+
+
+ release-composite
+
+ false
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+ parse-version
+
+ parse-version
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+ git
+
+
+
+ git-clone
+ prepare-package
+
+ exec
+
+
+
+ clone
+ --depth=1
+ -b
+ master
+ ${github-update-repo}
+ ${github-local-clone}
+
+
+
+
+ git-add
+ verify
+
+ exec
+
+
+
+ -C
+ ${github-local-clone}
+ add
+ -A
+
+
+
+
+ git-commit
+ verify
+
+ exec
+
+
+
+ -C
+ ${github-local-clone}
+ commit
+ -m
+ Release ${qualifiedVersion}
+
+
+
+
+ git-push
+ deploy
+
+ exec
+
+
+
+ -C
+ ${github-local-clone}
+ push
+ origin
+ master
+
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-repository
+ package
+
+ copy-resources
+
+
+
+ ${current-release-directory}
+
+
+
+ ${project.build.directory}/repository
+
+
+
+
+
+
+
+ org.eclipse.tycho.extras
+ tycho-eclipserun-plugin
+
+
+
+ eclipse-version
+ p2
+
+ https://download.eclipse.org/releases/2023-06
+
+
+
+
+ org.eclipse.ant.core
+ eclipse-plugin
+
+
+ org.apache.ant
+ eclipse-plugin
+
+
+
+ org.eclipse.equinox.p2.repository.tools
+ eclipse-plugin
+
+
+
+ org.eclipse.equinox.p2.core.feature
+ eclipse-feature
+
+
+
+ org.eclipse.equinox.p2.extras.feature
+ eclipse-feature
+
+
+ org.eclipse.rcp
+ eclipse-feature
+
+
+
+
+
+
+ add-p2-composite-repository
+ package
+
+ eclipse-run
+
+
+
+ -application
+ org.eclipse.ant.core.antRunner
+ -buildfile
+ packaging-p2composite.ant
+ p2.composite.add
+ -Dsite.label="${site.label}"
+
+ -Dcomposite.base.dir=${github-local-clone}
+
+ -DunqualifiedVersion=${unqualifiedVersion}
+ -DbuildQualifier=${buildQualifier}
+
+ -DparsedVersion.majorVersion=${parsedVersion.majorVersion}
+
+ -DparsedVersion.minorVersion=${parsedVersion.minorVersion}
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 947ee38..a9cb6d8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,12 +15,21 @@
4.0.4
-Xmx512m -XX:MaxPermSize=256m
UTF-8
+
+
+
+ git@github.com:Mathieuu/CsvEdit-update.git
+ ${project.build.directory}/checkout
+ ${github-local-clone}/releases
+ ${releases-directory}/${qualifiedVersion}
+
+ CsvEdit-update
- scm:git@github.com:gnl42/CsvEdit.git
- scm:git@github.com:gnl42/CsvEdit.git
- https://github.com/gnl42/CsvEdit
+ scm:git@github.com:Mathieuu/CsvEdit.git
+ scm:git@github.com:Mathieuu/CsvEdit.git
+ https://github.com/Mathieuu/CsvEdit
@@ -261,6 +270,33 @@
+
+
+
+ release-composite
+
+
+
+
+ maven-install-plugin
+
+
+ default-install
+ none
+
+
+
+
+ maven-deploy-plugin
+
+ true
+
+
+
+
+
+
+
csvedit.target
csvedit.plugin
From b6e6104eae3e30e22ea1f7c0f457a09c9693db54 Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Wed, 13 Dec 2023 00:35:41 -0800
Subject: [PATCH 04/18] Fix column sorting #17
---
.../csvedit/editors/MultiPageCSVEditor.java | 1550 ++++++++---------
.../csvedit/sorter/CSVTableSorter.java | 27 +-
2 files changed, 781 insertions(+), 796 deletions(-)
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/editors/MultiPageCSVEditor.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/editors/MultiPageCSVEditor.java
index e233cc1..ff8688d 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/editors/MultiPageCSVEditor.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/editors/MultiPageCSVEditor.java
@@ -66,810 +66,792 @@
import org.fhsolution.eclipse.plugins.csvedit.sorter.CSVTableSorter;
/**
- *
+ *
* @author fhenri
* @author msavy
- *
+ *
*/
-public abstract class MultiPageCSVEditor extends MultiPageEditorPart implements
- IResourceChangeListener {
+public abstract class MultiPageCSVEditor extends MultiPageEditorPart implements IResourceChangeListener {
+
+ private boolean isPageModified;
+
+ /** index of the source page */
+ public static final int indexSRC = 1;
+ /** index of the table page */
+ public static final int indexTBL = 0;
+
+ /** The text editor used in page 0. */
+ protected TextEditor editor;
+
+ /** The table viewer used in page 1. */
+ protected TableViewer tableViewer;
- private boolean isPageModified;
-
- /** index of the source page */
- public static final int indexSRC = 1;
- /** index of the table page */
- public static final int indexTBL = 0;
+ private CSVTableSorter tableSorter;
- /** The text editor used in page 0. */
- protected TextEditor editor;
+ private Menu tableHeaderMenu;
- /** The table viewer used in page 1. */
- protected TableViewer tableViewer;
+ private final AbstractCSVFile model;
+
+ /**
+ *
+ */
+ private final ICsvFileModelListener csvFileListener = new ICsvFileModelListener() {
+ @Override
+ public void entryChanged(final CSVRow row, final int rowIndex) {
+ // tableViewer.update(row, new String[] { Integer.toString(rowIndex)
+ // });
+ tableModified();
+ }
+ };
+
+ /**
+ * Creates a multi-page editor example.
+ */
+ public MultiPageCSVEditor() {
+ super();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ model = createCSVFile();
+ }
+
+ /**
+ * Create the CSV file object. Class that extends the MultiPageCSVEditor
+ * must implement this class.
+ *
+ * @return an {@link AbstractCSVFile} object which provides the contents as well
+ * as some formatting information such as the delimiter and extra meta
+ * information
+ */
+ protected abstract AbstractCSVFile createCSVFile();
- private CSVTableSorter tableSorter;
+ /**
+ * Creates the pages of the multi-page editor.
+ *
+ * @see org.eclipse.ui.part.MultiPageEditorPart#createPages()
+ */
+ @Override
+ protected void createPages() {
+ try {
+ createTablePage();
+ createSourcePage();
+ updateTitle();
+ populateTablePage();
+ } catch (final Exception e) {
+ System.err.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates page 0 of the multi-page editor, which contains a text editor.
+ */
+ private void createSourcePage() {
+ try {
+ editor = new CSVTextEditor(model.getCustomDelimiter());
+ addPage(editor, getEditorInput());
+ setPageText(indexSRC, "CSV Source");
+ } catch (final PartInitException e) {
+ ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
+ }
+ }
+
+ /**
+ *
+ */
+ private void createTablePage() {
+ final Composite parent = getContainer();
+
+ // XXX move all the creation into its own component
+ final Canvas canvas = new Canvas(parent, SWT.None);
+
+ final GridLayout layout = new GridLayout(6, false);
+ canvas.setLayout(layout);
+
+ // create the header part with the search function and Add/Delete rows
+ final Label searchLabel = new Label(canvas, SWT.NONE);
+ searchLabel.setText("Filter: ");
+ final Text searchText = new Text(canvas, SWT.BORDER | SWT.SEARCH);
+ searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Create and configure the buttons
+ final Button duplicate = new Button(canvas, SWT.PUSH | SWT.CENTER);
+ duplicate.setText("Duplicate");
+ duplicate.setToolTipText("Duplicate the current row");
+ final GridData buttonDuplicateGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ buttonDuplicateGridData.widthHint = 80;
+ duplicate.setLayoutData(buttonDuplicateGridData);
+ duplicate.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ final CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+ if (row != null) {
+ model.duplicateRow(row);
+ tableModified();
+ }
+ }
+ });
+
+ final Button insert = new Button(canvas, SWT.PUSH | SWT.CENTER);
+ insert.setText("Insert Row");
+ insert.setToolTipText("Insert a new row before the current one");
+ final GridData buttonInsertGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ buttonInsertGridData.widthHint = 80;
+ insert.setLayoutData(buttonInsertGridData);
+ insert.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ final CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+ if (row != null) {
+ model.addRowAfterElement(row);
+ tableModified();
+ }
+ }
+ });
+ /*
+ * insert.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) {
+ * //if(((e.stateMask & SWT.CTRL) != 0) & (e.keyCode == 'd')) { //if
+ * (e.stateMask == SWT.CTRL && e.keyCode == 'd') { if (e.character == SWT.DEL) {
+ * CSVRow row = (CSVRow) ((IStructuredSelection)
+ * tableViewer.getSelection()).getFirstElement(); if (row != null) {
+ * model.addLineAfterElement(row); tableViewer.refresh(); tableModified(); } } }
+ * });
+ */
+
+ final Button add = new Button(canvas, SWT.PUSH | SWT.CENTER);
+ add.setText("Add Row");
+ add.setToolTipText("Add a new row at the end of the file");
+ final GridData buttonAddGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ buttonAddGridData.widthHint = 80;
+ add.setLayoutData(buttonAddGridData);
+ add.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ model.addRow();
+ tableModified();
+ }
+ });
+
+ final Button delete = new Button(canvas, SWT.PUSH | SWT.CENTER);
+ delete.setText("Delete Row");
+ delete.setToolTipText("Delete the current row");
+ final GridData buttonDelGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ buttonDelGridData.widthHint = 80;
+ delete.setLayoutData(buttonDelGridData);
+ delete.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+
+ while (row != null) {
+ row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+ if (row != null) {
+ model.removeRow(row);
+ tableModified();
+ }
+ }
+ }
+ });
+ /*
+ * insert.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) {
+ * if (e.stateMask == SWT.CTRL && e.keyCode == 'd') { CSVRow row = (CSVRow)
+ * ((IStructuredSelection) tableViewer.getSelection()).getFirstElement(); if
+ * (row != null) { model.removeLine(row); tableViewer.refresh();
+ * tableModified(); } } } });
+ */
+ /*
+ *
+ * // manage 1st line - should only be visible if global option is set if
+ * (pref.getUseFirstLineAsHeader()) { Label encodingLineLabel = new
+ * Label(canvas, SWT.NONE); encodingLineLabel.setText("Display 1st line"); final
+ * Button encodingLineBtn = new Button(canvas, SWT.CHECK);
+ * encodingLineBtn.setLayoutData(new
+ * GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ * encodingLineBtn.setSelection(true); encodingLineBtn.addSelectionListener(new
+ * SelectionAdapter() { public void widgetSelected(SelectionEvent e) {
+ * model.displayFirstLine(encodingLineBtn.getSelection());
+ * updateTableFromTextEditor(); } }); } sensitiveBtn.addSelectionListener(new
+ * SelectionAdapter() { public void widgetSelected(SelectionEvent e) {
+ * tableFilter.setSearchText(searchText.getText(), sensitiveBtn.getSelection());
+ * labelProvider.setSearchText(searchText.getText()); tableViewer.refresh(); }
+ * });
+ */
+ tableViewer = new TableViewer(canvas, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ tableViewer.setUseHashlookup(true);
+ final Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ // set the sorter for the table
+ tableSorter = new CSVTableSorter();
+ tableViewer.setComparator(tableSorter);
+
+ // set a table filter
+ final CSVTableFilter tableFilter = new CSVTableFilter();
+ tableViewer.addFilter(tableFilter);
+
+ // add the filtering and coloring when searching specific elements.
+ searchText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(final KeyEvent ke) {
+ tableFilter.setSearchText(searchText.getText(), model.getSensitiveSearch());
+ final String filterText = searchText.getText();
+ for (int i = 0; i < tableViewer.getColumnProperties().length; i++) {
+ final CellLabelProvider labelProvider = tableViewer.getLabelProvider(i);
+ if (labelProvider != null) {
+ ((CSVLabelProvider) labelProvider).setSearchText(filterText);
+ }
+ }
+ tableViewer.refresh();
+ }
+ });
+
+ /*
+ * // create a TableCursor to navigate around the table final TableCursor cursor
+ * = new TableCursor(table, SWT.NONE); // create an editor to edit the cell when
+ * the user hits "ENTER" // while over a cell in the table final ControlEditor
+ * editor = new ControlEditor(cursor); editor.grabHorizontal = true;
+ * editor.grabVertical = true;
+ *
+ * cursor.addSelectionListener(new SelectionAdapter() { // This is called as the
+ * user navigates around the table public void widgetSelected(SelectionEvent e)
+ * { // Select the row in the table where the TableCursor is
+ * table.setSelection(new TableItem[] {cursor.getRow()}); }
+ *
+ * // when the user hits "ENTER" in the TableCursor, // pop up a text editor so
+ * that user can change the text of the cell public void
+ * widgetDefaultSelected(SelectionEvent e) { // Begin an editing session final
+ * Text text = new Text(cursor, SWT.NONE);
+ *
+ * // Copy the text from the cell to the Text int column = cursor.getColumn();
+ * text.setText(cursor.getRow().getText(column));
+ *
+ * // Add a handler to detect key presses text.addKeyListener(new KeyAdapter() {
+ * public void keyPressed(KeyEvent e) { // tab will save & move to the next
+ * column if (e.character == SWT.TAB) { TableItem row = cursor.getRow(); int
+ * column = cursor.getColumn(); row.setText(column, text.getText());
+ * text.dispose(); cursor.setSelection(row, column+1); tableModified(); } //
+ * close the text editor and copy the data over // when the user hits "ENTER" if
+ * (e.character == SWT.CR) { TableItem row = cursor.getRow();
+ * row.setText(cursor.getColumn(), text.getText()); tableModified();
+ * text.dispose(); } // close the text editor when the user hits "ESC" if
+ * (e.character == SWT.ESC) { text.dispose(); } } }); // close the text editor
+ * when the user tabs away text.addFocusListener(new FocusAdapter() { public
+ * void focusLost(FocusEvent e) { text.dispose(); } }); editor.setEditor(text);
+ * text.setFocus(); } });
+ *
+ * /* // Hide the TableCursor when the user hits the "CTRL" or "SHIFT" key. //
+ * This allows the user to select multiple items in the table.
+ * cursor.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) {
+ *
+ * // delete line if (e.character == SWT.DEL) { TableItem row = cursor.getRow();
+ * tableModified(); row.dispose(); //table.showItem(row);
+ * //cursor.setSelection(row, 0); }
+ *
+ * // insert line if (e.character == (char) SWT.F8) { TableItem row =
+ * cursor.getRow(); row.dispose(); }
+ *
+ * // add line
+ *
+ * cursor.setVisible(true); cursor.setFocus();
+ *
+ * if (e.keyCode == SWT.CTRL || e.keyCode == SWT.SHIFT || (e.stateMask &
+ * SWT.CONTROL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
+ * cursor.setVisible(false); return; } } });
+ *
+ * // When the user double clicks in the TableCursor, pop up a text editor so
+ * that // they can change the text of the cell. cursor.addMouseListener(new
+ * MouseAdapter() { public void mouseDown(MouseEvent e) { final Text text = new
+ * Text(cursor, SWT.NONE); TableItem row = cursor.getRow(); int column =
+ * cursor.getColumn(); text.setText(row.getText(column));
+ * text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) {
+ * // close the text editor and copy the data over // when the user hits "ENTER"
+ * if (e.character == SWT.CR) { TableItem row = cursor.getRow(); int column =
+ * cursor.getColumn(); row.setText(column, text.getText()); tableModified();
+ * text.dispose(); } // close the text editor when the user hits "ESC" if
+ * (e.character == SWT.ESC) { text.dispose(); } } }); // close the text editor
+ * when the user clicks away text.addFocusListener(new FocusAdapter() { public
+ * void focusLost(FocusEvent e) { text.dispose(); } }); editor.setEditor(text);
+ * text.setFocus(); } });
+ *
+ * // Show the TableCursor when the user releases the "SHIFT" or "CTRL" key. //
+ * This signals the end of the multiple selection task. table.addKeyListener(new
+ * KeyAdapter() { public void keyReleased(KeyEvent e) {
+ *
+ * if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0) return; if
+ * (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0) return; if
+ * (e.keyCode != SWT.CONTROL && (e.stateMask & SWT.CONTROL) != 0) return; if
+ * (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0) return;
+ *
+ * TableItem[] selection = table.getSelection(); TableItem row =
+ * (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
+ * table.showItem(row); cursor.setSelection(row, 0); cursor.setVisible(true);
+ * cursor.setFocus(); } });
+ */
+
+ /*
+ * tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ *
+ * public void doubleClick(DoubleClickEvent event) {
+ *
+ * CSVRow row = (CSVRow) ((IStructuredSelection)
+ * tableViewer.getSelection()).getFirstElement(); DetailedView input = new
+ * DetailedView(Display.getDefault(), model.getHeader(), row);
+ *
+ * input.open();
+ *
+ * } });
+ */
+
+ // Layout the viewer
+ final GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 6;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ tableViewer.getControl().setLayoutData(gridData);
+
+ addPage(canvas);
+ setPageText(indexTBL, "CSV Table");
+ }
+
+ /**
+ * Set Name of the file to the tab
+ */
+ private void updateTitle() {
+ final IEditorInput input = getEditorInput();
+ setPartName(input.getName());
+ setTitleToolTip(input.getToolTipText());
+ }
+
+ /**
+ * @throws Exception
+ */
+ private void populateTablePage() throws Exception {
+ tableViewer.setContentProvider(new CSVContentProvider());
- private Menu tableHeaderMenu;
+ // make the selection available
+ getSite().setSelectionProvider(tableViewer);
- private AbstractCSVFile model;
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ updateTableFromTextEditor();
+ }
+ });
+ }
- /**
+ /**
*
*/
- private final ICsvFileModelListener csvFileListener = new ICsvFileModelListener() {
- public void entryChanged(CSVRow row, int rowIndex) {
- // tableViewer.update(row, new String[] { Integer.toString(rowIndex)
- // });
- tableModified();
- }
- };
-
- /**
- * Creates a multi-page editor example.
- */
- public MultiPageCSVEditor() {
- super();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
- model = createCSVFile();
- }
-
- /**
- * Create the CSV file object. Class that extends the MultiPageCSVEditor
- * must implement this class.
- *
- * @return an {@link AbstractCSVFile} object which provides the contents as
- * well as some formatting information such as the delimiter and
- * extra meta information
- */
- protected abstract AbstractCSVFile createCSVFile();
-
- /**
- * Creates the pages of the multi-page editor.
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#createPages()
- */
- protected void createPages() {
- try {
- createTablePage();
- createSourcePage();
- updateTitle();
- populateTablePage();
- } catch (Exception e) {
- System.err.println(e);
- e.printStackTrace();
- }
- }
-
- /**
- * Creates page 0 of the multi-page editor, which contains a text editor.
- */
- private void createSourcePage() {
- try {
- editor = new CSVTextEditor(model.getCustomDelimiter());
- addPage(editor, getEditorInput());
- setPageText(indexSRC, "CSV Source");
- } catch (PartInitException e) {
- ErrorDialog.openError(getSite().getShell(),
- "Error creating nested text editor", null, e.getStatus());
- }
- }
-
- /**
+ public void tableModified() {
+ tableViewer.refresh();
+ final boolean wasPageModified = isPageModified;
+ isPageModified = true;
+ if (!wasPageModified) {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ editor.validateEditorInputState(); // will invoke:
+ // FileModificationValidator.validateEdit()
+ // (expected by some repository
+ // providers)
+ }
+ }
+
+ /**
*
*/
- private void createTablePage() {
- Composite parent = getContainer();
-
- // XXX move all the creation into its own component
- Canvas canvas = new Canvas(parent, SWT.None);
-
- GridLayout layout = new GridLayout(6, false);
- canvas.setLayout(layout);
-
- // create the header part with the search function and Add/Delete rows
- Label searchLabel = new Label(canvas, SWT.NONE);
- searchLabel.setText("Filter: ");
- final Text searchText = new Text(canvas, SWT.BORDER | SWT.SEARCH);
- searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
- | GridData.HORIZONTAL_ALIGN_FILL));
-
- // Create and configure the buttons
- Button duplicate = new Button(canvas, SWT.PUSH | SWT.CENTER);
- duplicate.setText("Duplicate");
- duplicate.setToolTipText("Duplicate the current row");
- GridData buttonDuplicateGridData = new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING);
- buttonDuplicateGridData.widthHint = 80;
- duplicate.setLayoutData(buttonDuplicateGridData);
- duplicate.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
- .getSelection()).getFirstElement();
- if (row != null) {
- model.duplicateRow(row);
- tableModified();
- }
- }
- });
-
- Button insert = new Button(canvas, SWT.PUSH | SWT.CENTER);
- insert.setText("Insert Row");
- insert.setToolTipText("Insert a new row before the current one");
- GridData buttonInsertGridData = new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING);
- buttonInsertGridData.widthHint = 80;
- insert.setLayoutData(buttonInsertGridData);
- insert.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
- .getSelection()).getFirstElement();
- if (row != null) {
- model.addRowAfterElement(row);
- tableModified();
- }
- }
- });
- /*
- * insert.addKeyListener(new KeyAdapter() { public void
- * keyPressed(KeyEvent e) { //if(((e.stateMask & SWT.CTRL) != 0) &
- * (e.keyCode == 'd')) { //if (e.stateMask == SWT.CTRL && e.keyCode ==
- * 'd') { if (e.character == SWT.DEL) { CSVRow row = (CSVRow)
- * ((IStructuredSelection)
- * tableViewer.getSelection()).getFirstElement(); if (row != null) {
- * model.addLineAfterElement(row); tableViewer.refresh();
- * tableModified(); } } } });
- */
-
- Button add = new Button(canvas, SWT.PUSH | SWT.CENTER);
- add.setText("Add Row");
- add.setToolTipText("Add a new row at the end of the file");
- GridData buttonAddGridData = new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING);
- buttonAddGridData.widthHint = 80;
- add.setLayoutData(buttonAddGridData);
- add.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- model.addRow();
- tableModified();
- }
- });
-
- Button delete = new Button(canvas, SWT.PUSH | SWT.CENTER);
- delete.setText("Delete Row");
- delete.setToolTipText("Delete the current row");
- GridData buttonDelGridData = new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING);
- buttonDelGridData.widthHint = 80;
- delete.setLayoutData(buttonDelGridData);
- delete.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
- .getSelection()).getFirstElement();
-
- while(row != null){
- row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
- if (row != null) {
- model.removeRow(row);
- tableModified();
- }
- }
- }
- });
- /*
- * insert.addKeyListener(new KeyAdapter() { public void
- * keyPressed(KeyEvent e) { if (e.stateMask == SWT.CTRL && e.keyCode ==
- * 'd') { CSVRow row = (CSVRow) ((IStructuredSelection)
- * tableViewer.getSelection()).getFirstElement(); if (row != null) {
- * model.removeLine(row); tableViewer.refresh(); tableModified(); } } }
- * });
- */
- /*
- *
- * // manage 1st line - should only be visible if global option is set
- * if (pref.getUseFirstLineAsHeader()) { Label encodingLineLabel = new
- * Label(canvas, SWT.NONE);
- * encodingLineLabel.setText("Display 1st line"); final Button
- * encodingLineBtn = new Button(canvas, SWT.CHECK);
- * encodingLineBtn.setLayoutData(new
- * GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- * encodingLineBtn.setSelection(true);
- * encodingLineBtn.addSelectionListener(new SelectionAdapter() { public
- * void widgetSelected(SelectionEvent e) {
- * model.displayFirstLine(encodingLineBtn.getSelection());
- * updateTableFromTextEditor(); } }); }
- * sensitiveBtn.addSelectionListener(new SelectionAdapter() { public
- * void widgetSelected(SelectionEvent e) {
- * tableFilter.setSearchText(searchText.getText(),
- * sensitiveBtn.getSelection());
- * labelProvider.setSearchText(searchText.getText());
- * tableViewer.refresh(); } });
- */
- tableViewer = new TableViewer(canvas, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- tableViewer.setUseHashlookup(true);
- final Table table = tableViewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- // set the sorter for the table
- tableSorter = new CSVTableSorter();
- tableViewer.setSorter(tableSorter);
-
- // set a table filter
- final CSVTableFilter tableFilter = new CSVTableFilter();
- tableViewer.addFilter(tableFilter);
-
- // add the filtering and coloring when searching specific elements.
- searchText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent ke) {
- tableFilter.setSearchText(searchText.getText(),
- model.getSensitiveSearch());
- String filterText = searchText.getText();
- for (int i = 0; i < tableViewer.getColumnProperties().length; i++) {
- CellLabelProvider labelProvider = tableViewer
- .getLabelProvider(i);
- if(labelProvider != null){
- ((CSVLabelProvider) labelProvider)
- .setSearchText(filterText);
- }
- }
- tableViewer.refresh();
- }
- });
-
- /*
- * // create a TableCursor to navigate around the table final
- * TableCursor cursor = new TableCursor(table, SWT.NONE); // create an
- * editor to edit the cell when the user hits "ENTER" // while over a
- * cell in the table final ControlEditor editor = new
- * ControlEditor(cursor); editor.grabHorizontal = true;
- * editor.grabVertical = true;
- *
- * cursor.addSelectionListener(new SelectionAdapter() { // This is
- * called as the user navigates around the table public void
- * widgetSelected(SelectionEvent e) { // Select the row in the table
- * where the TableCursor is table.setSelection(new TableItem[]
- * {cursor.getRow()}); }
- *
- * // when the user hits "ENTER" in the TableCursor, // pop up a text
- * editor so that user can change the text of the cell public void
- * widgetDefaultSelected(SelectionEvent e) { // Begin an editing session
- * final Text text = new Text(cursor, SWT.NONE);
- *
- * // Copy the text from the cell to the Text int column =
- * cursor.getColumn(); text.setText(cursor.getRow().getText(column));
- *
- * // Add a handler to detect key presses text.addKeyListener(new
- * KeyAdapter() { public void keyPressed(KeyEvent e) { // tab will save
- * & move to the next column if (e.character == SWT.TAB) { TableItem row
- * = cursor.getRow(); int column = cursor.getColumn();
- * row.setText(column, text.getText()); text.dispose();
- * cursor.setSelection(row, column+1); tableModified(); } // close the
- * text editor and copy the data over // when the user hits "ENTER" if
- * (e.character == SWT.CR) { TableItem row = cursor.getRow();
- * row.setText(cursor.getColumn(), text.getText()); tableModified();
- * text.dispose(); } // close the text editor when the user hits "ESC"
- * if (e.character == SWT.ESC) { text.dispose(); } } }); // close the
- * text editor when the user tabs away text.addFocusListener(new
- * FocusAdapter() { public void focusLost(FocusEvent e) {
- * text.dispose(); } }); editor.setEditor(text); text.setFocus(); } });
- *
- * /* // Hide the TableCursor when the user hits the "CTRL" or "SHIFT"
- * key. // This allows the user to select multiple items in the table.
- * cursor.addKeyListener(new KeyAdapter() { public void
- * keyPressed(KeyEvent e) {
- *
- * // delete line if (e.character == SWT.DEL) { TableItem row =
- * cursor.getRow(); tableModified(); row.dispose();
- * //table.showItem(row); //cursor.setSelection(row, 0); }
- *
- * // insert line if (e.character == (char) SWT.F8) { TableItem row =
- * cursor.getRow(); row.dispose(); }
- *
- * // add line
- *
- * cursor.setVisible(true); cursor.setFocus();
- *
- * if (e.keyCode == SWT.CTRL || e.keyCode == SWT.SHIFT || (e.stateMask &
- * SWT.CONTROL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
- * cursor.setVisible(false); return; } } });
- *
- * // When the user double clicks in the TableCursor, pop up a text
- * editor so that // they can change the text of the cell.
- * cursor.addMouseListener(new MouseAdapter() { public void
- * mouseDown(MouseEvent e) { final Text text = new Text(cursor,
- * SWT.NONE); TableItem row = cursor.getRow(); int column =
- * cursor.getColumn(); text.setText(row.getText(column));
- * text.addKeyListener(new KeyAdapter() { public void
- * keyPressed(KeyEvent e) { // close the text editor and copy the data
- * over // when the user hits "ENTER" if (e.character == SWT.CR) {
- * TableItem row = cursor.getRow(); int column = cursor.getColumn();
- * row.setText(column, text.getText()); tableModified(); text.dispose();
- * } // close the text editor when the user hits "ESC" if (e.character
- * == SWT.ESC) { text.dispose(); } } }); // close the text editor when
- * the user clicks away text.addFocusListener(new FocusAdapter() {
- * public void focusLost(FocusEvent e) { text.dispose(); } });
- * editor.setEditor(text); text.setFocus(); } });
- *
- * // Show the TableCursor when the user releases the "SHIFT" or "CTRL"
- * key. // This signals the end of the multiple selection task.
- * table.addKeyListener(new KeyAdapter() { public void
- * keyReleased(KeyEvent e) {
- *
- * if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0)
- * return; if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) !=
- * 0) return; if (e.keyCode != SWT.CONTROL && (e.stateMask &
- * SWT.CONTROL) != 0) return; if (e.keyCode != SWT.SHIFT && (e.stateMask
- * & SWT.SHIFT) != 0) return;
- *
- * TableItem[] selection = table.getSelection(); TableItem row =
- * (selection.length == 0) ? table.getItem(table.getTopIndex()) :
- * selection[0]; table.showItem(row); cursor.setSelection(row, 0);
- * cursor.setVisible(true); cursor.setFocus(); } });
- */
-
-/* tableViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
-
- CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
- DetailedView input = new DetailedView(Display.getDefault(), model.getHeader(), row);
-
- input.open();
-
- }
- });*/
-
- // Layout the viewer
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 6;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = GridData.FILL;
- tableViewer.getControl().setLayoutData(gridData);
-
- addPage(canvas);
- setPageText(indexTBL, "CSV Table");
- }
-
- /**
- * Set Name of the file to the tab
- */
- private void updateTitle() {
- IEditorInput input = getEditorInput();
- setPartName(input.getName());
- setTitleToolTip(input.getToolTipText());
- }
-
- /**
- * @throws Exception
- */
- private void populateTablePage() throws Exception {
- tableViewer.setContentProvider(new CSVContentProvider());
-
- // make the selection available
- getSite().setSelectionProvider(tableViewer);
-
- tableViewer.getTable().getDisplay().asyncExec(new Runnable() {
- public void run() {
- updateTableFromTextEditor();
- }
- });
- }
-
- /**
+ private void updateTableFromTextEditor() {
+
+ tableHeaderMenu = new Menu(tableViewer.getTable());
+
+ // PropertyFile propertyFile = (PropertyFile) treeViewer.getInput();
+ model.removeModelListener(csvFileListener);
+
+ model.setInput(editor.getDocumentProvider().getDocument(editor.getEditorInput()).get());
+
+ final MenuItem detailedEditItem = new MenuItem(tableHeaderMenu, SWT.PUSH, 0);
+ detailedEditItem.setText("Edit");
+ detailedEditItem.setSelection(false);
+ detailedEditItem.addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(final Event event) {
+
+ final CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+
+ if (row != null) {
+ final DetailedEditor input = new DetailedEditor(Display.getDefault(), model.getHeader(), row, model.getInCellDelimiter(),
+ model.getRegexTableMarker());
+ input.open();
+ }
+ }
+ });
+
+ new MenuItem(tableHeaderMenu, SWT.SEPARATOR, 1);
+
+ final TableColumn[] columns = tableViewer.getTable().getColumns();
+ if (columns.length > 0) { // if table header columns already created
+ // update column header text
+ for (int i = 0; i < model.getHeader().size(); i++) {
+ if (i < columns.length) {
+ columns[i].setText(model.getHeader().get(i));
+ addMenuItemToColumn(columns[i], i);
+ }
+ }
+ } else {
+ // create columns
+ for (int i = 0; i < model.getHeader().size(); i++) {
+ final TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.LEFT);
+ final int index = i;
+ column.getColumn().setText(model.getHeader().get(i));
+ column.getColumn().setWidth(100);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+ column.setLabelProvider(new CSVLabelProvider());
+ addMenuItemToColumn(column.getColumn(), index);
+ }
+ }
+
+ if (model.isFirstLineHeader()) {
+ new MenuItem(tableHeaderMenu, SWT.SEPARATOR);
+
+ // create menu item to delete column
+ final MenuItem deleteColumnItem = new MenuItem(tableHeaderMenu, SWT.PUSH);
+ deleteColumnItem.setText("Delete Column");
+ deleteColumnItem.setSelection(false);
+ deleteColumnItem.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ // call delete column page
+ final DeleteColumnPage dcPage = new DeleteColumnPage(getSite().getShell(), model.getArrayHeader());
+ if (dcPage.open() == InputDialog.OK) {
+ final String[] colToDelete = dcPage.getColumnSelected();
+ for (final String column : colToDelete) {
+ final int colIndex = findColumnForName(column);
+ tableViewer.getTable().getColumn(colIndex).dispose();
+ // +2 because the first two items are Edit and a separator
+ tableHeaderMenu.getItem(colIndex + 2).dispose();
+ model.removeColumn(column);
+ }
+ tableModified();
+ }
+ }
+ });
+
+ // create menu item to insert column
+ final MenuItem insertColumnItem = new MenuItem(tableHeaderMenu, SWT.PUSH);
+ insertColumnItem.setText("Add Column");
+ insertColumnItem.setSelection(false);
+ insertColumnItem.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ // call insert/add column page
+ final InsertColumnPage acPage = new InsertColumnPage(getSite().getShell(), model.getArrayHeader());
+ if (acPage.open() == InputDialog.OK) {
+ final String colToInsert = acPage.getColumnNewName();
+ model.addColumn(colToInsert);
+
+ tableViewer.setInput(model);
+ final TableColumn column = new TableColumn(tableViewer.getTable(), SWT.LEFT);
+ column.setText(colToInsert);
+ column.setWidth(100);
+ column.setResizable(true);
+ column.setMoveable(true);
+
+ addMenuItemToColumn(column, model.getColumnCount() - 1);
+ defineCellEditing();
+
+ tableModified();
+ }
+ }
+ });
+ }
+
+ tableViewer.setInput(model);
+ model.addModelListener(csvFileListener);
+
+ tableViewer.getTable().addListener(SWT.MenuDetect, new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ tableViewer.getTable().setMenu(tableHeaderMenu);
+ }
+ });
+
+ defineCellEditing();
+ }
+
+ /**
+ *
+ */
+ private void defineCellEditing() {
+ final String[] columnProperties = new String[model.getColumnCount()];
+ final CellEditor[] cellEditors = new CellEditor[model.getColumnCount()];
+
+ for (int i = 0; i < model.getColumnCount(); i++) {
+ columnProperties[i] = Integer.toString(i);
+ cellEditors[i] = new TextCellEditor(tableViewer.getTable());
+ }
+
+ tableViewer.setColumnProperties(columnProperties);
+
+ // XXX can be replaced by tableViewer.setEditingSupport()
+ tableViewer.setCellEditors(cellEditors);
+ tableViewer.setCellModifier(new CSVEditorCellModifier());
+
+ }
+
+ /**
+ * Find a column in the Table by its name
+ *
+ * @param columnName
+ * @return the index of the Column indicated by its name
+ */
+ private int findColumnForName(final String columnName) {
+ final int index = -1;
+ final TableColumn[] tableColumns = tableViewer.getTable().getColumns();
+ for (int i = 0; i < tableColumns.length; i++) {
+ final TableColumn column = tableColumns[i];
+ if (columnName.equalsIgnoreCase(column.getText())) {
+ return i;
+ }
+ }
+ return index;
+ }
+
+ /**
+ * @param column
+ * @param index
+ */
+ private void addMenuItemToColumn(final TableColumn column, final int index) {
+
+ // create menu item
+ final MenuItem itemName = new MenuItem(tableHeaderMenu, SWT.CHECK, index);
+ itemName.setText(column.getText());
+ itemName.setSelection(column.getResizable());
+ itemName.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ if (itemName.getSelection()) {
+ column.setWidth(100);
+ column.setResizable(true);
+ } else {
+ column.setWidth(0);
+ column.setResizable(false);
+ }
+ }
+ });
+
+ // Setting the right sorter
+ column.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ int dir = tableViewer.getTable().getSortDirection();
+ switch (dir) {
+ case SWT.UP:
+ dir = SWT.DOWN;
+ break;
+ case SWT.DOWN:
+ dir = SWT.NONE;
+ break;
+ case SWT.NONE:
+ dir = SWT.UP;
+ break;
+ }
+ tableSorter.setColumn(index, dir);
+ tableViewer.getTable().setSortDirection(dir);
+ if (dir == SWT.NONE) {
+ tableViewer.getTable().setSortColumn(null);
+ } else {
+ tableViewer.getTable().setSortColumn(column);
+ }
+ tableViewer.refresh();
+ }
+ });
+
+ }
+
+ /**
+ * The MultiPageEditorPart implementation of this
+ * IWorkbenchPart method disposes all nested editors. This method
+ * is automatically called when the editor is closed and marks the end of the
+ * editor's life cycle. It cleans up any platform resources, such as images,
+ * clipboard, and so on, which were created by this class.
+ *
+ * @see org.eclipse.ui.part.MultiPageEditorPart#dispose()
+ */
+ @Override
+ public void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ super.dispose();
+ }
+
+ /**
+ * Saves the multi-page editor's document. If the save is successful, the part
+ * should fire a property changed event (PROP_DIRTY property), reflecting the
+ * new dirty state. If the save is canceled via user action, or for any other
+ * reason, the part should invoke setCanceled on the IProgressMonitor to inform
+ * the caller
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(final IProgressMonitor monitor) {
+ if (getActivePage() == indexTBL && isPageModified) {
+ updateTextEditorFromTable();
+ } else {
+ updateTableFromTextEditor();
+ }
+
+ isPageModified = false;
+ editor.doSave(monitor);
+ }
+
+ /**
+ * Returns whether the "Save As" operation is supported by this part.
+ *
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * Saves the multi-page editor's document as another file. Also updates the text
+ * for page 0's tab, and updates this multi-page editor's input to correspond to
+ * the nested editor's.
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ if (getActivePage() == indexTBL && isPageModified) {
+ updateTextEditorFromTable();
+ } else {
+ updateTableFromTextEditor();
+ }
+
+ isPageModified = false;
+
+ editor.doSaveAs();
+ setInput(editor.getEditorInput());
+ updateTitle();
+ }
+
+ /**
+ * Initializes this editor with the given editor site and input. This method is
+ * automatically called shortly after editor construction; it marks the start of
+ * the editor's lifecycle.
+ *
+ * The MultiPageEditorExample implementation of this method checks
+ * that the input is an instance of IFileEditorInput.
+ *
+ * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(final IEditorSite site, final IEditorInput editorInput) throws PartInitException {
+ /*
+ * String message = "Input is " + editorInput + " of instance " +
+ * editorInput.getClass().getName(); IStatus status = new Status(IStatus.ERROR,
+ * "csvedit", IStatus.ERROR, message, null);
+ * Activator.getDefault().getLog().log(status);
+ */
+
+ /*
+ * if (!(editorInput instanceof IFileEditorInput)) throw new
+ * PartInitException("Invalid Input: Must be IFileEditorInput");
+ */
+ super.init(site, editorInput);
+ }
+
+ /**
+ * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
+ */
+ @Override
+ protected void handlePropertyChange(final int propertyId) {
+ if (propertyId == IEditorPart.PROP_DIRTY) {
+ isPageModified = isDirty();
+ }
+ super.handlePropertyChange(propertyId);
+ }
+
+ /**
+ * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
+ */
+ @Override
+ public boolean isDirty() {
+ return isPageModified || super.isDirty();
+ }
+
+ /**
+ * Calculates the contents of page 2 when the it is activated.
*
+ * @see org.eclipse.ui.part.MultiPageEditorPart#pageChange(int)
*/
- public void tableModified() {
- tableViewer.refresh();
- boolean wasPageModified = isPageModified;
- isPageModified = true;
- if (!wasPageModified) {
- firePropertyChange(IEditorPart.PROP_DIRTY);
- editor.validateEditorInputState(); // will invoke:
- // FileModificationValidator.validateEdit()
- // (expected by some repository
- // providers)
- }
- }
-
- /**
+ @Override
+ protected void pageChange(final int newPageIndex) {
+ switch (newPageIndex) {
+ case indexSRC:
+ if (isDirty()) {
+ updateTextEditorFromTable();
+ }
+ break;
+ case indexTBL:
+ if (isDirty()) {
+ updateTableFromTextEditor();
+ }
+ break;
+ }
+ isPageModified = false;
+ super.pageChange(newPageIndex);
+ }
+
+ /**
*
*/
- private void updateTableFromTextEditor() {
-
- tableHeaderMenu = new Menu(tableViewer.getTable());
-
- // PropertyFile propertyFile = (PropertyFile) treeViewer.getInput();
- model.removeModelListener(csvFileListener);
-
- model.setInput(editor.getDocumentProvider()
- .getDocument(editor.getEditorInput()).get());
-
- final MenuItem detailedEditItem = new MenuItem(tableHeaderMenu,
- SWT.PUSH, 0);
- detailedEditItem.setText("Edit");
- detailedEditItem.setSelection(false);
- detailedEditItem.addListener(SWT.Selection, new Listener() {
-
- public void handleEvent(Event event) {
-
- CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
-
- if(row != null){
- DetailedEditor input = new DetailedEditor(Display.getDefault(), model.getHeader(),
- row, model.getInCellDelimiter(), model.getRegexTableMarker());
- input.open();
- }
- }
- });
-
- new MenuItem(tableHeaderMenu, SWT.SEPARATOR, 1);
-
- TableColumn[] columns = tableViewer.getTable().getColumns();
- if (columns.length > 0) { // if table header columns already created
- // update column header text
- for (int i = 0; i < model.getHeader().size(); i++){
- if(i < columns.length){
- columns[i].setText(model.getHeader().get(i));
- final int index = i;
- addMenuItemToColumn(columns[i], index+2);
- }
- }
- } else {
- // create columns
- for (int i = 0; i < model.getHeader().size(); i++) {
- final TableViewerColumn column = new TableViewerColumn(
- tableViewer, SWT.LEFT);
- final int index = i;
- column.getColumn().setText(model.getHeader().get(i));
- column.getColumn().setWidth(100);
- column.getColumn().setResizable(true);
- column.getColumn().setMoveable(true);
- column.setLabelProvider(new CSVLabelProvider());
- //+2 because the first two items are Edit and a separator
- addMenuItemToColumn(column.getColumn(), index+2);
- }
- }
-
- if (model.isFirstLineHeader()) {
- new MenuItem(tableHeaderMenu, SWT.SEPARATOR);
-
- // create menu item to delete column
- final MenuItem deleteColumnItem = new MenuItem(tableHeaderMenu,
- SWT.PUSH);
- deleteColumnItem.setText("Delete Column");
- deleteColumnItem.setSelection(false);
- deleteColumnItem.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- // call delete column page
- DeleteColumnPage dcPage = new DeleteColumnPage(getSite()
- .getShell(), model.getArrayHeader());
- if (dcPage.open() == InputDialog.OK) {
- String[] colToDelete = dcPage.getColumnSelected();
- for (String column : colToDelete) {
- int colIndex = findColumnForName(column);
- tableViewer.getTable().getColumn(colIndex)
- .dispose();
- //+2 because the first two items are Edit and a separator
- tableHeaderMenu.getItem(colIndex+2).dispose();
- model.removeColumn(column);
- }
- tableModified();
- }
- }
- });
-
- // create menu item to insert column
- final MenuItem insertColumnItem = new MenuItem(tableHeaderMenu,
- SWT.PUSH);
- insertColumnItem.setText("Add Column");
- insertColumnItem.setSelection(false);
- insertColumnItem.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- // call insert/add column page
- InsertColumnPage acPage = new InsertColumnPage(getSite()
- .getShell(), model.getArrayHeader());
- if (acPage.open() == InputDialog.OK) {
- String colToInsert = acPage.getColumnNewName();
- model.addColumn(colToInsert);
-
- tableViewer.setInput(model);
- final TableColumn column = new TableColumn(tableViewer
- .getTable(), SWT.LEFT);
- column.setText(colToInsert);
- column.setWidth(100);
- column.setResizable(true);
- column.setMoveable(true);
-
- addMenuItemToColumn(column, model.getColumnCount() - 1);
- defineCellEditing();
-
- tableModified();
- }
- }
- });
- }
-
- tableViewer.setInput(model);
- model.addModelListener(csvFileListener);
-
- tableViewer.getTable().addListener(SWT.MenuDetect, new Listener() {
- public void handleEvent(Event event) {
- tableViewer.getTable().setMenu(tableHeaderMenu);
- }
- });
-
- defineCellEditing();
- }
-
- /**
+ private void updateTextEditorFromTable() {
+ editor.getDocumentProvider().getDocument(editor.getEditorInput()).set(((AbstractCSVFile) tableViewer.getInput()).getTextRepresentation());
+ }
+
+ /**
+ * When the focus shifts to the editor, this method is called; it must then
+ * redirect focus to the appropriate editor based on which page is currently
+ * selected.
*
+ * @see org.eclipse.ui.part.MultiPageEditorPart#setFocus()
*/
- private void defineCellEditing() {
- String[] columnProperties = new String[model.getColumnCount()];
- CellEditor[] cellEditors = new CellEditor[model.getColumnCount()];
-
- for (int i = 0; i < model.getColumnCount(); i++) {
- columnProperties[i] = Integer.toString(i);
- cellEditors[i] = new TextCellEditor(tableViewer.getTable());
- }
-
- tableViewer.setColumnProperties(columnProperties);
-
- // XXX can be replaced by tableViewer.setEditingSupport()
- tableViewer.setCellEditors(cellEditors);
- tableViewer.setCellModifier(new CSVEditorCellModifier());
-
- }
-
- /**
- * Find a column in the Table by its name
- *
- * @param columnName
- * @return the index of the Column indicated by its name
- */
- private int findColumnForName(String columnName) {
- int index = -1;
- TableColumn[] tableColumns = tableViewer.getTable().getColumns();
- for (int i = 0; i < tableColumns.length; i++) {
- TableColumn column = tableColumns[i];
- if (columnName.equalsIgnoreCase(column.getText()))
- return i;
- }
- return index;
- }
-
- /**
- * @param column
- * @param index
- */
- private void addMenuItemToColumn(final TableColumn column, final int index) {
-
- // create menu item
- final MenuItem itemName = new MenuItem(tableHeaderMenu, SWT.CHECK,
- index);
- itemName.setText(column.getText());
- itemName.setSelection(column.getResizable());
- itemName.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- if (itemName.getSelection()) {
- column.setWidth(100);
- column.setResizable(true);
- } else {
- column.setWidth(0);
- column.setResizable(false);
- }
- }
- });
-
- // Setting the right sorter
- column.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int dir = tableViewer.getTable().getSortDirection();
- switch (dir) {
- case SWT.UP:
- dir = SWT.DOWN;
- break;
- case SWT.DOWN:
- dir = SWT.NONE;
- break;
- case SWT.NONE:
- dir = SWT.UP;
- break;
- }
- tableSorter.setColumn(index, dir);
- tableViewer.getTable().setSortDirection(dir);
- if (dir == SWT.NONE) {
- tableViewer.getTable().setSortColumn(null);
- } else {
- tableViewer.getTable().setSortColumn(column);
- }
- tableViewer.refresh();
- }
- });
-
- }
-
- /**
- * The MultiPageEditorPart implementation of this
- * IWorkbenchPart method disposes all nested editors. This
- * method is automatically called when the editor is closed and marks the
- * end of the editor's life cycle. It cleans up any platform resources, such
- * as images, clipboard, and so on, which were created by this class.
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#dispose()
- */
- public void dispose() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- super.dispose();
- }
-
- /**
- * Saves the multi-page editor's document. If the save is successful, the
- * part should fire a property changed event (PROP_DIRTY property),
- * reflecting the new dirty state. If the save is canceled via user action,
- * or for any other reason, the part should invoke setCanceled on the
- * IProgressMonitor to inform the caller
- *
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void doSave(IProgressMonitor monitor) {
- if (getActivePage() == indexTBL && isPageModified) {
- updateTextEditorFromTable();
- } else {
- updateTableFromTextEditor();
- }
-
- isPageModified = false;
- editor.doSave(monitor);
- }
-
- /**
- * Returns whether the "Save As" operation is supported by this part.
- *
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /**
- * Saves the multi-page editor's document as another file. Also updates the
- * text for page 0's tab, and updates this multi-page editor's input to
- * correspond to the nested editor's.
- *
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- public void doSaveAs() {
- if (getActivePage() == indexTBL && isPageModified) {
- updateTextEditorFromTable();
- } else {
- updateTableFromTextEditor();
- }
-
- isPageModified = false;
-
- editor.doSaveAs();
- setInput(editor.getEditorInput());
- updateTitle();
- }
-
- /**
- * Initializes this editor with the given editor site and input. This method
- * is automatically called shortly after editor construction; it marks the
- * start of the editor's lifecycle.
- *
- * The MultiPageEditorExample implementation of this method
- * checks that the input is an instance of IFileEditorInput.
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- public void init(IEditorSite site, IEditorInput editorInput)
- throws PartInitException {
- /*
- * String message = "Input is " + editorInput + " of instance " +
- * editorInput.getClass().getName(); IStatus status = new
- * Status(IStatus.ERROR, "csvedit", IStatus.ERROR, message, null);
- * Activator.getDefault().getLog().log(status);
- */
-
- /*
- * if (!(editorInput instanceof IFileEditorInput)) throw new
- * PartInitException("Invalid Input: Must be IFileEditorInput");
- */
- super.init(site, editorInput);
- }
-
- /**
- * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
- */
- protected void handlePropertyChange(int propertyId) {
- if (propertyId == IEditorPart.PROP_DIRTY)
- isPageModified = isDirty();
- super.handlePropertyChange(propertyId);
- }
-
- /**
- * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
- */
- public boolean isDirty() {
- return isPageModified || super.isDirty();
- }
-
- /**
- * Calculates the contents of page 2 when the it is activated.
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#pageChange(int)
- */
- protected void pageChange(int newPageIndex) {
- switch (newPageIndex) {
- case indexSRC:
- if (isDirty())
- updateTextEditorFromTable();
- break;
- case indexTBL:
- if (isDirty())
- updateTableFromTextEditor();
- break;
- }
- isPageModified = false;
- super.pageChange(newPageIndex);
- }
-
- /**
+ @Override
+ public void setFocus() {
+ switch (getActivePage()) {
+ case indexSRC:
+ editor.setFocus();
+ break;
+ case indexTBL:
+ tableViewer.getTable().setFocus();
+ break;
+ }
+ }
+
+ /**
+ * Closes all project files on project close.
*
+ * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/
- private void updateTextEditorFromTable() {
- editor.getDocumentProvider()
- .getDocument(editor.getEditorInput())
- .set(((AbstractCSVFile) tableViewer.getInput())
- .getTextRepresentation());
- }
-
- /**
- * When the focus shifts to the editor, this method is called; it must then
- * redirect focus to the appropriate editor based on which page is currently
- * selected.
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#setFocus()
- */
- public void setFocus() {
- switch (getActivePage()) {
- case indexSRC:
- editor.setFocus();
- break;
- case indexTBL:
- tableViewer.getTable().setFocus();
- break;
- }
- }
-
- /**
- * Closes all project files on project close.
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(final IResourceChangeEvent event) {
- if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchPage[] pages = getSite().getWorkbenchWindow()
- .getPages();
- for (int i = 0; i < pages.length; i++) {
- if (((FileEditorInput) editor.getEditorInput())
- .getFile().getProject()
- .equals(event.getResource())) {
- IEditorPart editorPart = pages[i].findEditor(editor
- .getEditorInput());
- pages[i].closeEditor(editorPart, true);
- }
- }
- }
- });
- }
- }
+ @Override
+ public void resourceChanged(final IResourceChangeEvent event) {
+ if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ final IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+ for (final IWorkbenchPage page : pages) {
+ if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
+ final IEditorPart editorPart = page.findEditor(editor.getEditorInput());
+ page.closeEditor(editorPart, true);
+ }
+ }
+ }
+ });
+ }
+ }
}
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
index 0287481..03c831e 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
@@ -15,7 +15,7 @@
package org.fhsolution.eclipse.plugins.csvedit.sorter;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.fhsolution.eclipse.plugins.csvedit.model.CSVRow;
@@ -24,7 +24,7 @@
* @author fhenri
*
*/
-public class CSVTableSorter extends ViewerSorter {
+public class CSVTableSorter extends ViewerComparator {
private int propertyIndex;
private static final int DESCENDING = 1;
@@ -38,7 +38,7 @@ public class CSVTableSorter extends ViewerSorter {
* Public Constructor
*/
public CSVTableSorter() {
- this.propertyIndex = -1;
+ propertyIndex = -1;
direction = DESCENDING;
}
@@ -47,29 +47,32 @@ public CSVTableSorter() {
*
* @param column columnId selected by the user.
*/
- public void setColumn(int column, int dir) {
+ public void setColumn(final int column, final int dir) {
if (dir == SWT.NONE) {
noSort = true;
return;
}
noSort = false;
- if (column != this.propertyIndex) {
+ if (column != propertyIndex) {
// New column; do an ascending sort
- this.propertyIndex = column;
+ propertyIndex = column;
}
- this.direction = dir == SWT.UP ? ASCENDING : DESCENDING;
+ direction = dir == SWT.UP ? ASCENDING : DESCENDING;
}
/**
- * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
*/
@Override
- public int compare(Viewer viewer, Object e1, Object e2) {
+ public int compare(final Viewer viewer, final Object e1, final Object e2) {
// this is necessary at opening of csv file so column are not sorted.
- if (propertyIndex == -1 || noSort) return 0;
+ if (propertyIndex == -1 || noSort) {
+ return 0;
+ }
- String row1 = ((CSVRow) e1).getElementAt(propertyIndex);
- String row2 = ((CSVRow) e2).getElementAt(propertyIndex);
+ final String row1 = ((CSVRow) e1).getElementAt(propertyIndex);
+ final String row2 = ((CSVRow) e2).getElementAt(propertyIndex);
int rc = row1.compareTo(row2);
From 386efaf0bb7ddb9d0d8dc2ce17111db9ba63d634 Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Wed, 13 Dec 2023 00:36:08 -0800
Subject: [PATCH 05/18] Empty column is null
---
.../csvedit/filter/CSVTableFilter.java | 24 ++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/filter/CSVTableFilter.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/filter/CSVTableFilter.java
index 13bc541..d1a8dde 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/filter/CSVTableFilter.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/filter/CSVTableFilter.java
@@ -37,32 +37,34 @@ public class CSVTableFilter extends ViewerFilter {
*
* @param s string to search
*/
- public void setSearchText (String s, boolean isCaseSensitive) {
+ public void setSearchText(final String s, final boolean isCaseSensitive) {
// Search must be a substring of the existing value
- this.searchString = ".*" + s + ".*";
+ searchString = ".*" + s + ".*";
if (isCaseSensitive) {
- searchPattern =
- Pattern.compile(searchString);
+ searchPattern = Pattern.compile(searchString);
} else {
- searchPattern =
- Pattern.compile(searchString, Pattern.CASE_INSENSITIVE);
+ searchPattern = Pattern.compile(searchString, Pattern.CASE_INSENSITIVE);
}
}
/**
- * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
*/
@Override
- public boolean select (Viewer viewer, Object parentElement, Object element) {
+ public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
// loop on all column of the current row to find matches
- CSVRow row = (CSVRow) element;
- for (String s:row.getEntries()) {
- Matcher m = searchPattern.matcher(s);
+ final CSVRow row = (CSVRow) element;
+ for (String s : row.getEntries()) {
+ if (s == null) {
+ s = "";
+ }
+ final Matcher m = searchPattern.matcher(s);
if (m.matches()) {
return true;
}
From 33bfffc406cab9fae4398c4fac4ca5cec549518c Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Thu, 14 Dec 2023 00:02:55 -0800
Subject: [PATCH 06/18] lint complaints
---
.../AttributeEditorCellModifier.java | 63 +++++-----
.../csvedit/model/AbstractCSVFile.java | 1 -
.../eclipse/plugins/csvedit/model/CSVRow.java | 118 +++++++++---------
3 files changed, 94 insertions(+), 88 deletions(-)
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java
index 58eec3f..3b907fc 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java
@@ -16,64 +16,67 @@
package org.fhsolution.eclipse.plugins.csvedit.detailededitor;
import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableItem;
/**
-*
-* @author fhenri
-* @author msavy
-*
-*/
+ *
+ * @author fhenri
+ * @author msavy
+ *
+ */
public class AttributeEditorCellModifier implements ICellModifier {
/**
* Checks whether the given property of the given element can be modified.
*
- * @return true if the property can be modified, and false if it is not modifiable
- * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
+ * @return true if the property can be modified, and false if it is not
+ * modifiable
+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
+ * java.lang.String)
*/
- public boolean canModify (Object element, String property) {
+ @Override
+ public boolean canModify(final Object element, final String property) {
return true;
}
/**
- * Returns the value for the given property of the given element.
- * Returns "" if the element does not have the given property.
+ * Returns the value for the given property of the given element. Returns "" if
+ * the element does not have the given property.
*
- * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
+ * java.lang.String)
*/
- public Object getValue (Object element, String property) {
- int elementIndex = Integer.parseInt(property);
- AttributeRow row = (AttributeRow) element;
+ @Override
+ public Object getValue(final Object element, final String property) {
+ final int elementIndex = Integer.parseInt(property);
+ final AttributeRow row = (AttributeRow) element;
- if(elementIndex < row.getNumberOfElements()) {
+ if (elementIndex < row.getNumberOfElements()) {
return row.getElementAt(elementIndex);
- }
- else {
+ } else {
return "";
}
}
/**
- * Modifies the value for the given property of the given element.
- * Has no effect if the element does not have the given property,
- * or if the property cannot be modified.
+ * Modifies the value for the given property of the given element. Has no effect
+ * if the element does not have the given property, or if the property cannot be
+ * modified.
*
- * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
+ * java.lang.String, java.lang.Object)
*/
- public void modify (Object element, String property, Object value) {
- int elementIndex = Integer.parseInt(property);
+ @Override
+ public void modify(final Object element, final String property, final Object value) {
+ final int elementIndex = Integer.parseInt(property);
if (element instanceof TableItem) {
- AttributeRow row = (AttributeRow) ((TableItem) element).getData();
+ final AttributeRow row = (AttributeRow) ((TableItem) element).getData();
- if(elementIndex < row.getNumberOfElements()) {
+ if (elementIndex < row.getNumberOfElements()) {
row.setRowEntry(elementIndex, value.toString());
- }
- else {
- for (int i=row.getNumberOfElements();i line, IRowChangesListener listener) {
- entries = new ArrayList(line);
+ public CSVRow(final List line, final IRowChangesListener listener) {
+ entries = new ArrayList<>(line);
this.listener = listener;
}
/**
* Constructor
+ *
* @param row
* @param listener
*/
- public CSVRow(CSVRow row, IRowChangesListener listener){
-
- this.entries = (ArrayList)row.entries.clone();
- this.listener = listener;
- this.isCommentLine = row.isCommentLine;
- this.isHeader = row.isHeader;
- }
-
+ public CSVRow(final CSVRow row, final IRowChangesListener listener) {
+
+ entries = new ArrayList<>(row.getEntries());
+ this.listener = listener;
+ isCommentLine = row.isCommentLine;
+ isHeader = row.isHeader;
+ }
+
/**
* Constructor
+ *
* @param lineElements
* @param listener
*/
- public CSVRow(String[] lineElements, IRowChangesListener listener) {
+ public CSVRow(final String[] lineElements, final IRowChangesListener listener) {
this(Arrays.asList(lineElements), listener);
}
/**
* Create an empty row
+ *
* @param nbOfColumns
* @param delimiter
* @param listener
* @return
*/
- public static CSVRow createEmptyLine (int nbOfColumns, IRowChangesListener listener) {
- List line = new LinkedList();
- for (int i=0; i line = new LinkedList<>();
+ for (int i = 0; i < nbOfColumns; i++) {
line.add("");
}
return new CSVRow(line, listener);
@@ -89,14 +94,14 @@ public static CSVRow createEmptyLine (int nbOfColumns, IRowChangesListener liste
/**
* @return
*/
- public ArrayList getEntries () {
+ public ArrayList getEntries() {
return entries;
}
/**
* @return
*/
- public String[] getEntriesAsArray () {
+ public String[] getEntriesAsArray() {
return entries.toArray(new String[entries.size()]);
}
@@ -104,22 +109,22 @@ public String[] getEntriesAsArray () {
* @param elementIndex
* @param elementString
*/
- public void setRowEntry (int elementIndex, String elementString) {
- if (entries.get(elementIndex).compareTo(elementString) != 0) {
+ public void setRowEntry(final int elementIndex, final String elementString) {
+ if (entries.get(elementIndex).compareTo(elementString) != 0) {
entries.set(elementIndex, elementString);
listener.rowChanged(this, elementIndex);
}
}
/**
- * return the element at a given index.
- * This method makes sure that if the current line does not have as many
- * elements as the header, it will not break and return an empty string
+ * return the element at a given index. This method makes sure that if the
+ * current line does not have as many elements as the header, it will not break
+ * and return an empty string
*
* @param index
* @return the element at a given index
*/
- public String getElementAt (int index) {
+ public String getElementAt(final int index) {
if (index >= entries.size()) {
return "";
}
@@ -128,16 +133,17 @@ public String getElementAt (int index) {
/**
* Return the number of elements in this row
+ *
* @return number of elements in this row
*/
- public int getNumberOfElements () {
+ public int getNumberOfElements() {
return entries.size();
}
/**
* @param element
*/
- public void addElement(String element) {
+ public void addElement(final String element) {
entries.add(element);
}
@@ -146,27 +152,27 @@ public void addElement(String element) {
*
* @param index
*/
- public void removeElementAt (int index) {
+ public void removeElementAt(final int index) {
entries.remove(index);
}
- public void setCommentLine (boolean comment) {
+ public void setCommentLine(final boolean comment) {
isCommentLine = comment;
}
- public boolean isCommentLine () {
+ public boolean isCommentLine() {
return isCommentLine;
}
- public void setHeader (boolean header) {
+ public void setHeader(final boolean header) {
isHeader = header;
}
- public boolean isHeader () {
+ public boolean isHeader() {
return isHeader;
}
- public String getComment () {
+ public String getComment() {
return entries.get(0).substring(1);
}
@@ -175,9 +181,10 @@ public String getComment () {
*
* @see java.lang.Object#toString()
*/
- public String toString () {
+ @Override
+ public String toString() {
String result = "";
- for (String s:entries) {
+ for (final String s : entries) {
// FIXME get preferences here
result = result.concat(s).concat(",");
}
@@ -189,10 +196,7 @@ public String toString () {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((entries == null) ? 0 : entries.hashCode());
- return result;
+ return Objects.hash(entries);
}
/**
@@ -200,26 +204,26 @@ public int hashCode() {
*
* @see java.lang.Object#equals(java.lang.Object)
*/
- @Override
- public boolean equals(Object anObject) {
-
- // The commented lines implies that if two rows have the same content,
- // the cell editor will modify
- // the first one found instead of the focused one
- // each row should be considered as unique even if they have the same content
-
- /*
- * AttributeRow thisRow = (AttributeRow) anObject; for (int i=0;
- * i
Date: Thu, 14 Dec 2023 00:14:37 -0800
Subject: [PATCH 07/18] Another NPE
---
.../eclipse/plugins/csvedit/sorter/CSVTableSorter.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
index 03c831e..2c40247 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
+++ b/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/sorter/CSVTableSorter.java
@@ -71,8 +71,8 @@ public int compare(final Viewer viewer, final Object e1, final Object e2) {
return 0;
}
- final String row1 = ((CSVRow) e1).getElementAt(propertyIndex);
- final String row2 = ((CSVRow) e2).getElementAt(propertyIndex);
+ final String row1 = nvl(((CSVRow) e1).getElementAt(propertyIndex));
+ final String row2 = nvl(((CSVRow) e2).getElementAt(propertyIndex));
int rc = row1.compareTo(row2);
@@ -82,4 +82,8 @@ public int compare(final Viewer viewer, final Object e1, final Object e2) {
}
return rc;
}
+
+ private static final String nvl(final String string) {
+ return string != null ? string : "";
+ }
}
From 4d8d2db818ecc97db9e8be1920d80e60cf1f32e1 Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Thu, 14 Dec 2023 00:14:46 -0800
Subject: [PATCH 08/18] Update .gitignore
---
.gitignore | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index b1a83d9..59a623f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,4 +38,7 @@ RemoteSystemsTempFiles/
# TeXlipse plugin
.texlipse
-internalChangelog.txt
\ No newline at end of file
+internalChangelog.txt
+.project
+.classpath
+
From d3d25b1dc6a83e8e12d76d89c1f7d39041b900a0 Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Sat, 16 Dec 2023 17:49:37 -0800
Subject: [PATCH 09/18] Revert "Deploy to GitHub #9"
This reverts commit e035141f3f7722651ebf97f06d49ab388cbba1b6.
---
csvedit.site/packaging-p2composite.ant | 181 --------------------
csvedit.site/pom.xml | 221 -------------------------
pom.xml | 42 +----
3 files changed, 3 insertions(+), 441 deletions(-)
delete mode 100644 csvedit.site/packaging-p2composite.ant
diff --git a/csvedit.site/packaging-p2composite.ant b/csvedit.site/packaging-p2composite.ant
deleted file mode 100644
index f9bd40c..0000000
--- a/csvedit.site/packaging-p2composite.ant
+++ /dev/null
@@ -1,181 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- version=1
-metadata.repository.factory.order=compositeContent.xml,\!
-artifact.repository.factory.order=compositeArtifacts.xml,\!
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/csvedit.site/pom.xml b/csvedit.site/pom.xml
index 0027ec7..8b03533 100644
--- a/csvedit.site/pom.xml
+++ b/csvedit.site/pom.xml
@@ -11,225 +11,4 @@
csvedit.site
eclipse-repository
csvedit :: update site
-
-
-
-
- org.eclipse.tycho
- tycho-packaging-plugin
-
- 'v'yyyyMMdd'-'HHmm
-
-
-
-
- org.eclipse.tycho
- tycho-p2-repository-plugin
-
- ${project.artifactId}-${qualifiedVersion}
-
-
-
-
-
-
-
-
- release-composite
-
- false
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
-
- parse-version
-
- parse-version
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
- git
-
-
-
- git-clone
- prepare-package
-
- exec
-
-
-
- clone
- --depth=1
- -b
- master
- ${github-update-repo}
- ${github-local-clone}
-
-
-
-
- git-add
- verify
-
- exec
-
-
-
- -C
- ${github-local-clone}
- add
- -A
-
-
-
-
- git-commit
- verify
-
- exec
-
-
-
- -C
- ${github-local-clone}
- commit
- -m
- Release ${qualifiedVersion}
-
-
-
-
- git-push
- deploy
-
- exec
-
-
-
- -C
- ${github-local-clone}
- push
- origin
- master
-
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-repository
- package
-
- copy-resources
-
-
-
- ${current-release-directory}
-
-
-
- ${project.build.directory}/repository
-
-
-
-
-
-
-
- org.eclipse.tycho.extras
- tycho-eclipserun-plugin
-
-
-
- eclipse-version
- p2
-
- https://download.eclipse.org/releases/2023-06
-
-
-
-
- org.eclipse.ant.core
- eclipse-plugin
-
-
- org.apache.ant
- eclipse-plugin
-
-
-
- org.eclipse.equinox.p2.repository.tools
- eclipse-plugin
-
-
-
- org.eclipse.equinox.p2.core.feature
- eclipse-feature
-
-
-
- org.eclipse.equinox.p2.extras.feature
- eclipse-feature
-
-
- org.eclipse.rcp
- eclipse-feature
-
-
-
-
-
-
- add-p2-composite-repository
- package
-
- eclipse-run
-
-
-
- -application
- org.eclipse.ant.core.antRunner
- -buildfile
- packaging-p2composite.ant
- p2.composite.add
- -Dsite.label="${site.label}"
-
- -Dcomposite.base.dir=${github-local-clone}
-
- -DunqualifiedVersion=${unqualifiedVersion}
- -DbuildQualifier=${buildQualifier}
-
- -DparsedVersion.majorVersion=${parsedVersion.majorVersion}
-
- -DparsedVersion.minorVersion=${parsedVersion.minorVersion}
-
-
-
-
-
-
-
-
-
diff --git a/pom.xml b/pom.xml
index a9cb6d8..947ee38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,21 +15,12 @@
4.0.4
-Xmx512m -XX:MaxPermSize=256m
UTF-8
-
-
-
- git@github.com:Mathieuu/CsvEdit-update.git
- ${project.build.directory}/checkout
- ${github-local-clone}/releases
- ${releases-directory}/${qualifiedVersion}
-
- CsvEdit-update
- scm:git@github.com:Mathieuu/CsvEdit.git
- scm:git@github.com:Mathieuu/CsvEdit.git
- https://github.com/Mathieuu/CsvEdit
+ scm:git@github.com:gnl42/CsvEdit.git
+ scm:git@github.com:gnl42/CsvEdit.git
+ https://github.com/gnl42/CsvEdit
@@ -270,33 +261,6 @@
-
-
-
- release-composite
-
-
-
-
- maven-install-plugin
-
-
- default-install
- none
-
-
-
-
- maven-deploy-plugin
-
- true
-
-
-
-
-
-
-
csvedit.target
csvedit.plugin
From 607db0dd61d0462e0d1f7df508a1808ba458804b Mon Sep 17 00:00:00 2001
From: George Lindholm <66577321+gnl42@users.noreply.github.com>
Date: Sun, 17 Dec 2023 00:20:14 -0800
Subject: [PATCH 10/18] Cleanup
---
.gitignore | 51 +--
.mvn/extensions.xml | 10 +-
csvedit.feature/.gitignore | 30 --
csvedit.feature/feature.xml | 12 +-
csvedit.plugin.ui/.gitignore | 30 --
csvedit.plugin.ui/META-INF/MANIFEST.MF | 6 +-
csvedit.plugin.ui/build.properties | 3 +-
csvedit.plugin.ui/fragment.xml | 14 +-
.../DefaultCSVMultipageEditor.java | 23 +-
.../customeditor/model/DefaultCSVFile.java | 39 +-
.../model/PreferencesCSVOptionsProvider.java | 93 +++++
.../preferences/CSVPreferencePage.java | 82 ++--
.../preferences/PreferenceConstants.java | 2 +-
.../preferences/PreferenceInitializer.java | 8 +-
.../model/PreferencesCSVOptionsProvider.java | 95 -----
csvedit.plugin/.gitignore | 31 --
csvedit.plugin/META-INF/MANIFEST.MF | 12 +-
csvedit.plugin/build.properties | 2 +
.../glindholm/plugin/csvedit2}/Activator.java | 19 +-
.../AttributeEditorCellModifier.java | 24 +-
.../csvedit2/detailededitor/AttributeRow.java | 184 +++++++++
.../DetailedAttributeTableViewer.java | 213 ++++++++++
.../detailededitor/DetailedEditor.java | 243 ++++++++++++
.../IAttributeChangesListener.java | 18 +-
.../editors/CSVEditorCellModifier.java | 46 ++-
.../csvedit2}/editors/MultiPageCSVEditor.java | 375 ++++++++----------
.../MultiPageCSVEditorContributor.java | 25 +-
.../csvedit2}/editors/text/CSVRegion.java | 16 +-
.../csvedit2}/editors/text/CSVTextEditor.java | 13 +-
.../CSVTextSourceViewerConfiguration.java | 20 +-
.../csvedit2}/editors/text/CSVToken.java | 24 +-
.../editors/text/CSVTokenScanner.java | 63 ++-
.../csvedit2}/filter/CSVTableFilter.java | 5 +-
.../csvedit2}/model/AbstractCSVFile.java | 18 +-
.../plugin/csvedit2}/model/CSVRow.java | 13 +-
.../model/ICsvFileModelListener.java | 2 +-
.../csvedit2}/model/ICsvModelProvider.java | 2 +-
.../csvedit2}/model/ICsvOptionsProvider.java | 6 +-
.../csvedit2}/model/IRowChangesListener.java | 9 +-
.../csvedit2}/page/DeleteColumnPage.java | 44 +-
.../csvedit2}/page/InsertColumnPage.java | 74 ++--
.../providers/CSVContentProvider.java | 22 +-
.../csvedit2}/providers/CSVLabelProvider.java | 7 +-
.../csvedit2}/sorter/CSVTableSorter.java | 5 +-
.../csvedit2}/style/SearchResultStyle.java | 42 +-
.../csvedit/detailededitor/AttributeRow.java | 189 ---------
.../DetailedAttributeTableViewer.java | 232 -----------
.../detailededitor/DetailedEditor.java | 253 ------------
csvedit.site/category.xml | 7 +-
csvedit.site/packaging-p2composite.ant | 181 +++++++++
csvedit.site/pom.xml | 227 ++++++++++-
csvedit.target/pom.xml | 6 +-
csvedit.update/.gitignore | 30 --
csvedit.update/.project | 17 -
csvedit.update/artifacts.jar | Bin 670 -> 0 bytes
csvedit.update/content.jar | Bin 2107 -> 0 bytes
...solution.eclipse.feature.csvedit_1.0.1.jar | Bin 931 -> 0 bytes
...solution.eclipse.feature.csvedit_1.0.2.jar | Bin 926 -> 0 bytes
...solution.eclipse.feature.csvedit_1.0.3.jar | Bin 931 -> 0 bytes
...solution.eclipse.feature.csvedit_1.1.0.jar | Bin 959 -> 0 bytes
...solution.eclipse.feature.csvedit_1.1.1.jar | Bin 957 -> 0 bytes
...solution.eclipse.feature.csvedit_1.1.2.jar | Bin 959 -> 0 bytes
...solution.eclipse.feature.csvedit_1.2.0.jar | Bin 970 -> 0 bytes
...ution.eclipse.plugins.csvedit.ui_1.1.0.jar | Bin 20864 -> 0 bytes
...ution.eclipse.plugins.csvedit.ui_1.1.1.jar | Bin 20881 -> 0 bytes
...ution.eclipse.plugins.csvedit.ui_1.1.2.jar | Bin 20572 -> 0 bytes
...ution.eclipse.plugins.csvedit.ui_1.2.0.jar | Bin 21487 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.0.2.jar | Bin 90691 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.0.3.jar | Bin 89549 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.1.0.jar | Bin 61455 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.1.1.jar | Bin 61995 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.1.2.jar | Bin 62056 -> 0 bytes
...solution.eclipse.plugins.csvedit_1.2.0.jar | Bin 83683 -> 0 bytes
csvedit.update/site.xml | 22 -
pom.xml | 55 ++-
75 files changed, 1705 insertions(+), 1589 deletions(-)
delete mode 100644 csvedit.feature/.gitignore
delete mode 100644 csvedit.plugin.ui/.gitignore
rename csvedit.plugin.ui/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/customeditor/DefaultCSVMultipageEditor.java (62%)
rename csvedit.plugin.ui/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/customeditor/model/DefaultCSVFile.java (75%)
create mode 100644 csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/PreferencesCSVOptionsProvider.java
rename csvedit.plugin.ui/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/customeditor/preferences/CSVPreferencePage.java (54%)
rename csvedit.plugin.ui/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/customeditor/preferences/PreferenceConstants.java (95%)
rename csvedit.plugin.ui/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/customeditor/preferences/PreferenceInitializer.java (87%)
delete mode 100644 csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/PreferencesCSVOptionsProvider.java
delete mode 100644 csvedit.plugin/.gitignore
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/Activator.java (78%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/detailededitor/AttributeEditorCellModifier.java (84%)
create mode 100644 csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeRow.java
create mode 100644 csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedAttributeTableViewer.java
create mode 100644 csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedEditor.java
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/detailededitor/IAttributeChangesListener.java (72%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/CSVEditorCellModifier.java (61%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/MultiPageCSVEditor.java (65%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/MultiPageCSVEditorContributor.java (73%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/text/CSVRegion.java (86%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/text/CSVTextEditor.java (74%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/text/CSVTextSourceViewerConfiguration.java (72%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/text/CSVToken.java (78%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/editors/text/CSVTokenScanner.java (64%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/filter/CSVTableFilter.java (95%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/AbstractCSVFile.java (95%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/CSVRow.java (94%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/ICsvFileModelListener.java (92%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/ICsvModelProvider.java (92%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/ICsvOptionsProvider.java (93%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/model/IRowChangesListener.java (83%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/page/DeleteColumnPage.java (69%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/page/InsertColumnPage.java (55%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/providers/CSVContentProvider.java (72%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/providers/CSVLabelProvider.java (95%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/sorter/CSVTableSorter.java (95%)
rename csvedit.plugin/src/{org/fhsolution/eclipse/plugins/csvedit => me/glindholm/plugin/csvedit2}/style/SearchResultStyle.java (59%)
delete mode 100644 csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeRow.java
delete mode 100644 csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/DetailedAttributeTableViewer.java
delete mode 100644 csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/DetailedEditor.java
create mode 100644 csvedit.site/packaging-p2composite.ant
delete mode 100644 csvedit.update/.gitignore
delete mode 100644 csvedit.update/.project
delete mode 100644 csvedit.update/artifacts.jar
delete mode 100644 csvedit.update/content.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.0.1.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.0.2.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.0.3.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.1.0.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.1.1.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.1.2.jar
delete mode 100644 csvedit.update/features/org.fhsolution.eclipse.feature.csvedit_1.2.0.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit.ui_1.1.0.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit.ui_1.1.1.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit.ui_1.1.2.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit.ui_1.2.0.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.0.2.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.0.3.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.1.0.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.1.1.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.1.2.jar
delete mode 100644 csvedit.update/plugins/org.fhsolution.eclipse.plugins.csvedit_1.2.0.jar
delete mode 100644 csvedit.update/site.xml
diff --git a/.gitignore b/.gitignore
index 59a623f..6f85526 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,44 +1,7 @@
-# maven tycho build output
-target
-
-*.pydevproject
-.metadata
-.gradle
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-
-# Runtime Eclipse
-runtime-EclipseApplication/
-
-# Temp filesystem
-RemoteSystemsTempFiles/
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# TeXlipse plugin
-.texlipse
-
-internalChangelog.txt
-.project
-.classpath
-
+.classpath
+.project
+.polyglot.META-INF
+.polyglot.feature.xml
+.settings/
+bin/
+target/
diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index ecfbd8f..b7cea6f 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -1,8 +1,8 @@
-
- org.eclipse.tycho.extras
- tycho-pomless
- 4.0.4
-
+
+ org.eclipse.tycho
+ tycho-build
+ 4.0.4
+
diff --git a/csvedit.feature/.gitignore b/csvedit.feature/.gitignore
deleted file mode 100644
index b71f363..0000000
--- a/csvedit.feature/.gitignore
+++ /dev/null
@@ -1,30 +0,0 @@
-*.pydevproject
-.metadata
-.gradle
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# TeXlipse plugin
-.texlipse
\ No newline at end of file
diff --git a/csvedit.feature/feature.xml b/csvedit.feature/feature.xml
index fc2bde1..40e5616 100644
--- a/csvedit.feature/feature.xml
+++ b/csvedit.feature/feature.xml
@@ -1,10 +1,10 @@
+ plugin="me.glindholm.plugin.csvedit2.plugins.csvedit">
This aims to create a CSV file editor in Eclipse with features
@@ -51,15 +51,15 @@ permissions and limitations under the License.
diff --git a/csvedit.plugin.ui/.gitignore b/csvedit.plugin.ui/.gitignore
deleted file mode 100644
index b71f363..0000000
--- a/csvedit.plugin.ui/.gitignore
+++ /dev/null
@@ -1,30 +0,0 @@
-*.pydevproject
-.metadata
-.gradle
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# TeXlipse plugin
-.texlipse
\ No newline at end of file
diff --git a/csvedit.plugin.ui/META-INF/MANIFEST.MF b/csvedit.plugin.ui/META-INF/MANIFEST.MF
index 6ef4487..812a822 100644
--- a/csvedit.plugin.ui/META-INF/MANIFEST.MF
+++ b/csvedit.plugin.ui/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse CSV Editor UI contributions
-Bundle-SymbolicName: org.fhsolution.eclipse.plugins.csvedit.ui;singleton:=true
-Bundle-Version: 1.2.0
+Bundle-SymbolicName: me.glindholm.plugin.csvedit2.ui;singleton:=true
+Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: www.fhsolution.com
-Fragment-Host: org.fhsolution.eclipse.plugins.csvedit;bundle-version="1.2.0"
+Fragment-Host: me.glindholm.plugin.csvedit2
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.ui.ide,
org.eclipse.core.resources
diff --git a/csvedit.plugin.ui/build.properties b/csvedit.plugin.ui/build.properties
index e3023e1..d68138b 100644
--- a/csvedit.plugin.ui/build.properties
+++ b/csvedit.plugin.ui/build.properties
@@ -1,5 +1,6 @@
source.. = src/
-output.. = bin/
+output.. = target/classes
+
bin.includes = META-INF/,\
.,\
fragment.xml
diff --git a/csvedit.plugin.ui/fragment.xml b/csvedit.plugin.ui/fragment.xml
index 723d89a..9e429fa 100644
--- a/csvedit.plugin.ui/fragment.xml
+++ b/csvedit.plugin.ui/fragment.xml
@@ -4,27 +4,27 @@
+ class="me.glindholm.plugin.csvedit2.customeditor.preferences.PreferenceInitializer">
+ id="me.glindholm.plugin.csvedit2.views.CSVEditView">
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/DefaultCSVMultipageEditor.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/DefaultCSVMultipageEditor.java
similarity index 62%
rename from csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/DefaultCSVMultipageEditor.java
rename to csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/DefaultCSVMultipageEditor.java
index 7639ed5..76bf513 100644
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/DefaultCSVMultipageEditor.java
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/DefaultCSVMultipageEditor.java
@@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.customeditor;
+package me.glindholm.plugin.csvedit2.customeditor;
-import org.fhsolution.eclipse.plugins.csvedit.customeditor.model.DefaultCSVFile;
-import org.fhsolution.eclipse.plugins.csvedit.customeditor.model.PreferencesCSVOptionsProvider;
-import org.fhsolution.eclipse.plugins.csvedit.editors.MultiPageCSVEditor;
-import org.fhsolution.eclipse.plugins.csvedit.model.AbstractCSVFile;
+import me.glindholm.plugin.csvedit2.customeditor.model.DefaultCSVFile;
+import me.glindholm.plugin.csvedit2.customeditor.model.PreferencesCSVOptionsProvider;
+import me.glindholm.plugin.csvedit2.editors.MultiPageCSVEditor;
+import me.glindholm.plugin.csvedit2.model.AbstractCSVFile;
public class DefaultCSVMultipageEditor extends MultiPageCSVEditor {
@@ -26,19 +26,20 @@ public class DefaultCSVMultipageEditor extends MultiPageCSVEditor {
/**
* Create the CSV file
*/
- protected AbstractCSVFile createCSVFile()
- {
+ @Override
+ protected AbstractCSVFile createCSVFile() {
preferences = new PreferencesCSVOptionsProvider();
return new DefaultCSVFile(preferences);
}
/**
- * Create the different tab for the multi editor and set the focus to the
- * page according to user preferences.
+ * Create the different tab for the multi editor and set the focus to the page according to user
+ * preferences.
*
- * @see org.fhsolution.eclipse.plugins.csvedit.editors.MultiPageCSVEditor#createPages()
+ * @see me.glindholm.plugin.csvedit2.editors.MultiPageCSVEditor#createPages()
*/
- protected void createPages () {
+ @Override
+ protected void createPages() {
super.createPages();
setActivePage(preferences.getDefaultPage());
}
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/DefaultCSVFile.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/DefaultCSVFile.java
similarity index 75%
rename from csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/DefaultCSVFile.java
rename to csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/DefaultCSVFile.java
index 303dff0..fc1b8b4 100644
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/DefaultCSVFile.java
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/DefaultCSVFile.java
@@ -12,18 +12,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.customeditor.model;
+package me.glindholm.plugin.csvedit2.customeditor.model;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import org.fhsolution.eclipse.plugins.csvedit.model.AbstractCSVFile;
-import org.fhsolution.eclipse.plugins.csvedit.model.ICsvOptionsProvider;
+import me.glindholm.plugin.csvedit2.model.AbstractCSVFile;
+import me.glindholm.plugin.csvedit2.model.ICsvOptionsProvider;
/**
*
- * {@link DefaultCSVFile} implements the {@link AbstractCSVFile} abstract
- * methods based on the values stored in the preferences system
+ * {@link DefaultCSVFile} implements the {@link AbstractCSVFile} abstract methods based on the
+ * values stored in the preferences system
+ *
* @author jpizar
* @author msavy
*
@@ -35,11 +36,11 @@ public class DefaultCSVFile extends AbstractCSVFile {
/**
* Constructor
+ *
* @param provider the {@link PreferencesCSVOptionsProvider}
*/
- public DefaultCSVFile(ICsvOptionsProvider provider) {
- super();
- this.optionsProvider = provider;
+ public DefaultCSVFile(final ICsvOptionsProvider provider) {
+ optionsProvider = provider;
}
@Override
@@ -59,20 +60,20 @@ public char getCustomDelimiter() {
@Override
public char getCommentChar() {
- String commentChar = optionsProvider.getCommentChar();
+ final String commentChar = optionsProvider.getCommentChar();
char result = Character.UNASSIGNED;
if (commentChar != null && commentChar != "") {
- result = commentChar.charAt(0);
+ result = commentChar.charAt(0);
}
return result;
}
@Override
public char getTextQualifier() {
- String qualifierChar = optionsProvider.getTextQualifier();
+ final String qualifierChar = optionsProvider.getTextQualifier();
char result = Character.UNASSIGNED;
if (qualifierChar != null && qualifierChar != "" && qualifierChar.length() > 0) {
- result = qualifierChar.charAt(0);
+ result = qualifierChar.charAt(0);
}
return result;
}
@@ -81,7 +82,7 @@ public char getTextQualifier() {
public boolean useQualifier() {
return optionsProvider.useTextQualifier();
}
-
+
@Override
public String getInCellDelimiter() {
return optionsProvider.getInCellDelimiter();
@@ -89,16 +90,16 @@ public String getInCellDelimiter() {
@Override
public String getRegexTableMarker() {
-
- String result = "";
-
+
+ String result = "";
+
try {
Pattern.compile(optionsProvider.getRegexTableMarker());
result = optionsProvider.getRegexTableMarker();
- } catch (PatternSyntaxException exception) {
-
+ } catch (final PatternSyntaxException exception) {
+
}
-
+
return result;
}
}
\ No newline at end of file
diff --git a/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/PreferencesCSVOptionsProvider.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/PreferencesCSVOptionsProvider.java
new file mode 100644
index 0000000..a97a7dd
--- /dev/null
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/PreferencesCSVOptionsProvider.java
@@ -0,0 +1,93 @@
+/* Copyright 2011 csvedit
+ *
+ * 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 me.glindholm.plugin.csvedit2.customeditor.model;
+
+import me.glindholm.plugin.csvedit2.Activator;
+import me.glindholm.plugin.csvedit2.customeditor.preferences.PreferenceConstants;
+import me.glindholm.plugin.csvedit2.model.ICsvOptionsProvider;
+
+/**
+ *
+ * @author fhenri, msavy
+ *
+ */
+public class PreferencesCSVOptionsProvider implements ICsvOptionsProvider {
+
+ private final boolean useFirstLineAsHeader;
+ private final boolean sensitiveSearch;
+ private final boolean useQualifier;
+ private final String customDelimiter;
+ private final String commentChar;
+ private final String defaultPage;
+ private final String textQualifier;
+ private final String inCellDelimiter;
+ private final String regexTableMarker;
+
+ public PreferencesCSVOptionsProvider() {
+ useFirstLineAsHeader = Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.USE_FIRST_LINE_AS_HEADER);
+ customDelimiter = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CUSTOM_DELIMITER);
+ sensitiveSearch = Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CASE_SENSITIVE_SEARCH);
+ commentChar = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.COMMENT_CHAR);
+ textQualifier = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.TEXT_QUALIFIER);
+ useQualifier = Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.USE_QUALIFIER);
+ defaultPage = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.DEFAULT_VIEW_PAGE);
+ inCellDelimiter = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.INCELL_DELIMITER);
+ regexTableMarker = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.REGEX_HEADER_TABLE);
+ }
+
+ @Override
+ public String getCustomDelimiter() {
+ return customDelimiter;
+ }
+
+ @Override
+ public boolean getUseFirstLineAsHeader() {
+ return useFirstLineAsHeader;
+ }
+
+ @Override
+ public boolean getSensitiveSearch() {
+ return sensitiveSearch;
+ }
+
+ @Override
+ public String getCommentChar() {
+ return commentChar;
+ }
+
+ public int getDefaultPage() {
+ return Integer.parseInt(defaultPage);
+ }
+
+ @Override
+ public String getTextQualifier() {
+ return textQualifier;
+ }
+
+ @Override
+ public boolean useTextQualifier() {
+ return useQualifier;
+ }
+
+ @Override
+ public String getRegexTableMarker() {
+ return regexTableMarker;
+ }
+
+ @Override
+ public String getInCellDelimiter() {
+ return inCellDelimiter;
+ }
+}
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java
similarity index 54%
rename from csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java
rename to csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java
index c9cd923..ef3bb41 100644
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.customeditor.preferences;
+package me.glindholm.plugin.csvedit2.customeditor.preferences;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
@@ -20,23 +20,22 @@
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.fhsolution.eclipse.plugins.csvedit.Activator;
+
+import me.glindholm.plugin.csvedit2.Activator;
/**
- * This class represents a preference page that is contributed to the
- * Preferences dialog. By subclassing FieldEditorPreferencePage, we
- * can use the field support built into JFace that allows us to create a page
- * that is small and knows how to save, restore and apply itself.
+ * This class represents a preference page that is contributed to the Preferences dialog. By
+ * subclassing FieldEditorPreferencePage, we can use the field support built into JFace
+ * that allows us to create a page that is small and knows how to save, restore and apply itself.
*
- * This page is used to modify preferences only. They are stored in the
- * preference store that belongs to the main plug-in class. That way,
- * preferences can be accessed directly via the preference store.
+ * This page is used to modify preferences only. They are stored in the preference store that
+ * belongs to the main plug-in class. That way, preferences can be accessed directly via the
+ * preference store.
*
* @author fhenri
*
*/
-public class CSVPreferencePage extends FieldEditorPreferencePage
-implements IWorkbenchPreferencePage {
+public class CSVPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
/**
* Public constructor
@@ -48,72 +47,55 @@ public CSVPreferencePage() {
}
/**
- * Creates the field editors. Field editors are abstractions of the common
- * GUI blocks needed to manipulate various types of preferences. Each field
- * editor knows how to save and restore itself.
+ * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to
+ * manipulate various types of preferences. Each field editor knows how to save and restore itself.
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
+ @Override
public void createFieldEditors() {
- String[][] pagesLabelsAndValues = new String[2][2];
+ final String[][] pagesLabelsAndValues = new String[2][2];
pagesLabelsAndValues[0][0] = "Table";
pagesLabelsAndValues[0][1] = "0";
pagesLabelsAndValues[1][0] = "Source";
pagesLabelsAndValues[1][1] = "1";
- addField(new ComboFieldEditor(
- PreferenceConstants.DEFAULT_VIEW_PAGE,
- "Select the default tab to view csv file:",
- pagesLabelsAndValues,
+ addField(new ComboFieldEditor(PreferenceConstants.DEFAULT_VIEW_PAGE, "Select the default tab to view csv file:", pagesLabelsAndValues,
getFieldEditorParent()));
- addField(new BooleanFieldEditor(
- PreferenceConstants.USE_FIRST_LINE_AS_HEADER,
- "&Use the first line of the CSV file as the column headers",
+ addField(new BooleanFieldEditor(PreferenceConstants.USE_FIRST_LINE_AS_HEADER, "&Use the first line of the CSV file as the column headers",
getFieldEditorParent()));
- StringFieldEditor customDelimiterField = new StringFieldEditor(
- PreferenceConstants.CUSTOM_DELIMITER,
- "Choose the delimiter to use:", 2, getFieldEditorParent());
+ final StringFieldEditor customDelimiterField = new StringFieldEditor(PreferenceConstants.CUSTOM_DELIMITER, "Choose the delimiter to use:", 2,
+ getFieldEditorParent());
customDelimiterField.setTextLimit(1);
customDelimiterField.setEmptyStringAllowed(false);
addField(customDelimiterField);
- StringFieldEditor textQualifierChar = new StringFieldEditor(
- PreferenceConstants.TEXT_QUALIFIER,
+ final StringFieldEditor textQualifierChar = new StringFieldEditor(PreferenceConstants.TEXT_QUALIFIER,
"Define the character used as a text qualifier of the data:", 2, getFieldEditorParent());
customDelimiterField.setTextLimit(1);
customDelimiterField.setEmptyStringAllowed(false);
addField(textQualifierChar);
- addField(new BooleanFieldEditor(
- PreferenceConstants.USE_QUALIFIER,
- "For the text qualifier to be used for all fields",
- getFieldEditorParent()));
+ addField(new BooleanFieldEditor(PreferenceConstants.USE_QUALIFIER, "For the text qualifier to be used for all fields", getFieldEditorParent()));
- StringFieldEditor commentChar = new StringFieldEditor(
- PreferenceConstants.COMMENT_CHAR,
- "Choose the character to use as a comment:", 2, getFieldEditorParent());
+ final StringFieldEditor commentChar = new StringFieldEditor(PreferenceConstants.COMMENT_CHAR, "Choose the character to use as a comment:", 2,
+ getFieldEditorParent());
customDelimiterField.setTextLimit(1);
customDelimiterField.setEmptyStringAllowed(true);
addField(commentChar);
- addField(new BooleanFieldEditor(
- PreferenceConstants.CASE_SENSITIVE_SEARCH,
- "&Case sensitive filtering",
- getFieldEditorParent()));
-
-
- StringFieldEditor regexField = new StringFieldEditor(
- PreferenceConstants.REGEX_HEADER_TABLE,
+ addField(new BooleanFieldEditor(PreferenceConstants.CASE_SENSITIVE_SEARCH, "&Case sensitive filtering", getFieldEditorParent()));
+
+ final StringFieldEditor regexField = new StringFieldEditor(PreferenceConstants.REGEX_HEADER_TABLE,
"Header regex indicating that the column should be displayed as table", StringFieldEditor.UNLIMITED, getFieldEditorParent());
regexField.setEmptyStringAllowed(true);
addField(regexField);
-
-
- StringFieldEditor incellDelimiterField = new StringFieldEditor(
- PreferenceConstants.INCELL_DELIMITER,
+
+ final StringFieldEditor incellDelimiterField = new StringFieldEditor(PreferenceConstants.INCELL_DELIMITER,
"Delimiter to use as a value delimiter in a cell", StringFieldEditor.UNLIMITED, getFieldEditorParent());
- //incellDelimiterField.setTextLimit(1); //TODO test: does it really work with more than 1 character delimiter
+ // incellDelimiterField.setTextLimit(1); //TODO test: does it really work with more than 1 character
+ // delimiter
incellDelimiterField.setEmptyStringAllowed(true);
addField(incellDelimiterField);
@@ -122,7 +104,8 @@ public void createFieldEditors() {
/**
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/
- public boolean performOk () {
+ @Override
+ public boolean performOk() {
// TODO here we should reload all opened csv file with the new pref.
return super.performOk();
}
@@ -132,7 +115,8 @@ public boolean performOk () {
*
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
- public void init(IWorkbench workbench) {
+ @Override
+ public void init(final IWorkbench workbench) {
}
}
\ No newline at end of file
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceConstants.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceConstants.java
similarity index 95%
rename from csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceConstants.java
rename to csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceConstants.java
index 1e5180c..0913350 100644
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceConstants.java
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceConstants.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.customeditor.preferences;
+package me.glindholm.plugin.csvedit2.customeditor.preferences;
/**
* Constant definitions for plug-in preferences
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceInitializer.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceInitializer.java
similarity index 87%
rename from csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceInitializer.java
rename to csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceInitializer.java
index 00d7e7c..5c3b47e 100644
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/PreferenceInitializer.java
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/PreferenceInitializer.java
@@ -12,11 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.customeditor.preferences;
+package me.glindholm.plugin.csvedit2.customeditor.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.fhsolution.eclipse.plugins.csvedit.Activator;
+
+import me.glindholm.plugin.csvedit2.Activator;
/**
* Class used to initialize default preference values.
@@ -31,8 +32,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
+ @Override
public void initializeDefaultPreferences() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.USE_FIRST_LINE_AS_HEADER, true);
store.setDefault(PreferenceConstants.CASE_SENSITIVE_SEARCH, false);
store.setDefault(PreferenceConstants.CUSTOM_DELIMITER, ",");
diff --git a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/PreferencesCSVOptionsProvider.java b/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/PreferencesCSVOptionsProvider.java
deleted file mode 100644
index 464db3a..0000000
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/model/PreferencesCSVOptionsProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2011 csvedit
- *
- * 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 org.fhsolution.eclipse.plugins.csvedit.customeditor.model;
-
-import org.fhsolution.eclipse.plugins.csvedit.Activator;
-import org.fhsolution.eclipse.plugins.csvedit.customeditor.preferences.PreferenceConstants;
-import org.fhsolution.eclipse.plugins.csvedit.model.ICsvOptionsProvider;
-
-/**
- *
- * @author fhenri, msavy
- *
- */
-public class PreferencesCSVOptionsProvider implements ICsvOptionsProvider {
-
- private boolean useFirstLineAsHeader;
- private boolean sensitiveSearch;
- private boolean useQualifier;
- private String customDelimiter;
- private String commentChar;
- private String defaultPage;
- private String textQualifier;
- private String inCellDelimiter;
- private String regexTableMarker;
-
- public PreferencesCSVOptionsProvider ()
- {
- useFirstLineAsHeader =
- Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.USE_FIRST_LINE_AS_HEADER);
- customDelimiter =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CUSTOM_DELIMITER);
- sensitiveSearch =
- Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CASE_SENSITIVE_SEARCH);
- commentChar =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.COMMENT_CHAR);
- textQualifier =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.TEXT_QUALIFIER);
- useQualifier =
- Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.USE_QUALIFIER);
- defaultPage =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.DEFAULT_VIEW_PAGE);
- inCellDelimiter =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.INCELL_DELIMITER);
- regexTableMarker =
- Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.REGEX_HEADER_TABLE);
- }
-
- public String getCustomDelimiter () {
- return customDelimiter;
- }
-
- public boolean getUseFirstLineAsHeader () {
- return useFirstLineAsHeader;
- }
-
- public boolean getSensitiveSearch () {
- return sensitiveSearch;
- }
-
- public String getCommentChar () {
- return commentChar;
- }
-
- public int getDefaultPage () {
- return Integer.parseInt(defaultPage);
- }
-
- public String getTextQualifier() {
- return textQualifier;
- }
-
- public boolean useTextQualifier() {
- return useQualifier;
- }
-
- public String getRegexTableMarker() {
- return regexTableMarker;
- }
-
- public String getInCellDelimiter() {
- return inCellDelimiter;
- }
-}
diff --git a/csvedit.plugin/.gitignore b/csvedit.plugin/.gitignore
deleted file mode 100644
index db9592b..0000000
--- a/csvedit.plugin/.gitignore
+++ /dev/null
@@ -1,31 +0,0 @@
-*.pydevproject
-.metadata
-.gradle
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# TeXlipse plugin
-.texlipse
-/.polyglot.build.properties
diff --git a/csvedit.plugin/META-INF/MANIFEST.MF b/csvedit.plugin/META-INF/MANIFEST.MF
index 1e0faca..9e1c222 100644
--- a/csvedit.plugin/META-INF/MANIFEST.MF
+++ b/csvedit.plugin/META-INF/MANIFEST.MF
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse CSV Editor
-Bundle-SymbolicName: org.fhsolution.eclipse.plugins.csvedit;singleton:=true
-Bundle-Version: 1.2.0
-Bundle-Activator: org.fhsolution.eclipse.plugins.csvedit.Activator
+Bundle-SymbolicName: me.glindholm.plugin.csvedit2;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: me.glindholm.plugin.csvedit2.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -13,15 +13,15 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Export-Package: org.fhsolution.eclipse.plugins.csvedit.editors;
+Export-Package: me.glindholm.plugin.csvedit2.editors;
uses:="org.eclipse.jface.action,
org.eclipse.ui.texteditor,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
- org.fhsolution.eclipse.plugins.csvedit.model,
+ me.glindholm.plugin.csvedit2.plugins.csvedit.model,
org.eclipse.ui.part",
- org.fhsolution.eclipse.plugins.csvedit.model;uses:="com.csvreader"
+ me.glindholm.plugin.csvedit2.model;uses:="com.csvreader"
Import-Package: org.jumpmind.symmetric.csv
Bundle-Vendor: www.fhsolution.com
diff --git a/csvedit.plugin/build.properties b/csvedit.plugin/build.properties
index 0fbcf40..be0890c 100644
--- a/csvedit.plugin/build.properties
+++ b/csvedit.plugin/build.properties
@@ -1,4 +1,6 @@
source.. = src/
+output.. = target/classes
+
bin.includes = plugin.xml,\
META-INF/,\
.,\
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/Activator.java b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/Activator.java
similarity index 78%
rename from csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/Activator.java
rename to csvedit.plugin/src/me/glindholm/plugin/csvedit2/Activator.java
index 1b6110e..d4358cf 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/Activator.java
+++ b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/Activator.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit;
+package me.glindholm.plugin.csvedit2;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -27,7 +27,7 @@
public class Activator extends AbstractUIPlugin {
// The plug-in ID
- public static final String PLUGIN_ID = "org.fhsolution.eclipse.csvedit";
+ public static final String PLUGIN_ID = "me.glindholm.plugin.csvedit2.csvedit";
// The shared instance
private static Activator plugin;
@@ -35,14 +35,15 @@ public class Activator extends AbstractUIPlugin {
/**
* The constructor
*/
- public Activator () {
+ public Activator() {
}
/**
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- public void start (BundleContext context) throws Exception {
+ @Override
+ public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@@ -51,7 +52,8 @@ public void start (BundleContext context) throws Exception {
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop (BundleContext context) throws Exception {
+ @Override
+ public void stop(final BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
@@ -61,18 +63,17 @@ public void stop (BundleContext context) throws Exception {
*
* @return the shared instance
*/
- public static Activator getDefault () {
+ public static Activator getDefault() {
return plugin;
}
/**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
+ * Returns an image descriptor for the image file at the given plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
- public static ImageDescriptor getImageDescriptor (String path) {
+ public static ImageDescriptor getImageDescriptor(final String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
diff --git a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeEditorCellModifier.java
similarity index 84%
rename from csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java
rename to csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeEditorCellModifier.java
index 3b907fc..d45bc16 100644
--- a/csvedit.plugin/src/org/fhsolution/eclipse/plugins/csvedit/detailededitor/AttributeEditorCellModifier.java
+++ b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeEditorCellModifier.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.fhsolution.eclipse.plugins.csvedit.detailededitor;
+package me.glindholm.plugin.csvedit2.detailededitor;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.swt.widgets.TableItem;
@@ -29,10 +29,8 @@ public class AttributeEditorCellModifier implements ICellModifier {
/**
* Checks whether the given property of the given element can be modified.
*
- * @return true if the property can be modified, and false if it is not
- * modifiable
- * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
- * java.lang.String)
+ * @return true if the property can be modified, and false if it is not modifiable
+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
*/
@Override
public boolean canModify(final Object element, final String property) {
@@ -40,11 +38,10 @@ public boolean canModify(final Object element, final String property) {
}
/**
- * Returns the value for the given property of the given element. Returns "" if
- * the element does not have the given property.
+ * Returns the value for the given property of the given element. Returns "" if the element does not
+ * have the given property.
*
- * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
- * java.lang.String)
+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
*/
@Override
public Object getValue(final Object element, final String property) {
@@ -59,12 +56,11 @@ public Object getValue(final Object element, final String property) {
}
/**
- * Modifies the value for the given property of the given element. Has no effect
- * if the element does not have the given property, or if the property cannot be
- * modified.
+ * Modifies the value for the given property of the given element. Has no effect if the element does
+ * not have the given property, or if the property cannot be modified.
*
- * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
- * java.lang.String, java.lang.Object)
+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String,
+ * java.lang.Object)
*/
@Override
public void modify(final Object element, final String property, final Object value) {
diff --git a/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeRow.java b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeRow.java
new file mode 100644
index 0000000..b0b6ad7
--- /dev/null
+++ b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/AttributeRow.java
@@ -0,0 +1,184 @@
+/* Copyright 2011 csvedit
+ *
+ * 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 me.glindholm.plugin.csvedit2.detailededitor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a row made of String elements for the detailed view
+ *
+ * @author fhenri
+ * @author msavy
+ *
+ */
+public class AttributeRow {
+
+ /** Splitted line */
+ private final ArrayList entries;
+
+ /** Row changes listener */
+ private final IAttributeChangesListener listener;
+
+ /**
+ * Constructor
+ *
+ * @param line
+ * @param listener
+ */
+ public AttributeRow(final List line, final IAttributeChangesListener listener) {
+ entries = new ArrayList<>(line);
+ this.listener = listener;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param lineElements
+ * @param listener
+ */
+ public AttributeRow(final String[] lineElements, final IAttributeChangesListener listener) {
+ this(Arrays.asList(lineElements), listener);
+ }
+
+ /**
+ * Create an empty row
+ *
+ * @param nbOfColumns
+ * @param delimiter
+ * @param listener
+ * @return
+ */
+ public static AttributeRow createEmptyLine(final int nbOfColumns, final IAttributeChangesListener listener) {
+ final List line = new LinkedList<>();
+ for (int i = 0; i < nbOfColumns; i++) {
+ line.add("");
+ }
+ return new AttributeRow(line, listener);
+ }
+
+ /**
+ * @return
+ */
+ public ArrayList getEntries() {
+ return entries;
+ }
+
+ /**
+ * @return
+ */
+ public String[] getEntriesAsArray() {
+ return entries.toArray(new String[entries.size()]);
+ }
+
+ /**
+ * @param elementIndex
+ * @param elementString
+ */
+ public void setRowEntry(final int elementIndex, final String elementString) {
+ if (entries.get(elementIndex).compareTo(elementString) != 0) {
+ entries.set(elementIndex, elementString);
+ listener.rowChanged(this, elementIndex);
+ }
+ }
+
+ /**
+ * return the element at a given index. This method makes sure that if the current line does not
+ * have as many elements as the header, it will not break and return an empty string
+ *
+ * @param index
+ * @return the element at a given index
+ */
+ public String getElementAt(final int index) {
+ if (index >= entries.size()) {
+ return "";
+ }
+ return entries.get(index);
+ }
+
+ /**
+ * Return the number of elements in this row
+ *
+ * @return number of elements in this row
+ */
+ public int getNumberOfElements() {
+ return entries.size();
+ }
+
+ /**
+ * @param element
+ */
+ public void addElement(final String element) {
+ entries.add(element);
+ }
+
+ /**
+ * Remove an element of the row represented by its index
+ *
+ * @param index
+ */
+ public void removeElementAt(final int index) {
+ entries.remove(index);
+ }
+
+ /**
+ * Give the String representation of a CSVRow object.
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ String result = "";
+ for (final String s : entries) {
+ // FIXME get preferences here
+ result = result.concat(s).concat(",");
+ }
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hash(entries);
+ }
+
+ @Override
+ public boolean equals(final Object anObject) {
+ // The commented lines implies that if two rows have the same content,
+ // the cell editor will modify
+ // the first one found instead of the focused one
+ // each row is unique
+
+ /*
+ * //System.out.println("compare:\n[" + this + "] and\n[" + anObject + "]"); if (!(anObject
+ * instanceof AttributeRow)) { return false; }
+ *
+ * AttributeRow thisRow = (AttributeRow) anObject; for (int i=0; i model = new ArrayList<>();
+
+ IAttributeChangesListener listener = (row, index) -> tableViewer.refresh();
+
+ /**
+ * Default constructor Add an empty TableViewer to a Composite view
+ */
+ public DetailedAttributeTableViewer(final Composite composite) {
+
+ tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
+ final Table table = tableViewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ gd.minimumHeight = 100;
+ table.setLayoutData(gd);
+ }
+
+ /**
+ * Fill the table
+ *
+ * @param headers
+ * @param content a List where each String[] is a column of the table
+ */
+ public void fillTable(final List headers, final List content) {
+
+ for (int i = 0; i < headers.size(); i++) {
+ final TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.LEFT);
+
+ column.getColumn().setText(headers.get(i));
+ column.getColumn().setWidth(200);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+
+ final int index = i;
+
+ column.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(final Object element) {
+ return ((AttributeRow) element).getElementAt(index);
+ }
+ });
+ }
+
+ model = new ArrayList<>();
+
+ if (content.size() > 0) {
+ // We first look for the biggest column, it will be the reference to generate all AttributeRow
+ int biggestColumn = 0;
+
+ for (int i = 0; i < content.size(); i++) {
+ if (content.get(biggestColumn).length < content.get(i).length) {
+ biggestColumn = i;
+ }
+ }
+
+ // For each row of the biggest column (String[]), we look for the rows
+ // at the same level in other columns and we build a AttributeRow with those data
+ for (int i = 0; i < content.get(biggestColumn).length; i++) {
+ final List attributes = new ArrayList<>();
+ for (int j = 0; j < content.size(); j++) {
+ if (i < content.get(j).length) {
+ attributes.add(content.get(j)[i]);
+ } else {
+ attributes.add("");
+ }
+ }
+ model.add(new AttributeRow(attributes, listener));
+ }
+ }
+
+ tableViewer.setContentProvider(new ArrayContentProvider());
+ tableViewer.setInput(model);
+
+ defineCellEditing(tableViewer, headers.size());
+ addRightClickItems(tableViewer);
+ }
+
+ /**
+ * Make cells of the tableViewer editable
+ */
+ private void defineCellEditing(final TableViewer tableViewer, final int numberOfColumns) {
+ final String[] columnProperties = new String[numberOfColumns];
+ final CellEditor[] cellEditors = new CellEditor[numberOfColumns];
+
+ for (int i = 0; i < numberOfColumns; i++) {
+ columnProperties[i] = Integer.toString(i);
+ cellEditors[i] = new TextCellEditor(tableViewer.getTable());
+ }
+
+ tableViewer.setColumnProperties(columnProperties);
+
+ tableViewer.setCellEditors(cellEditors);
+ tableViewer.setCellModifier(new AttributeEditorCellModifier());
+
+ }
+
+ /**
+ * Describe the behavior of right click on the tableViewer
+ */
+ private void addRightClickItems(final TableViewer tableViewer) {
+
+ // create menu item to delete column
+ final Menu tableHeaderMenu = new Menu(tableViewer.getTable());
+
+ // create menu item to insert column
+ final MenuItem insertColumnItem = new MenuItem(tableHeaderMenu, SWT.PUSH);
+ insertColumnItem.setText("Add row");
+ insertColumnItem.setSelection(false);
+ insertColumnItem.addListener(SWT.Selection, event -> {
+ // call insert/add column page
+ final AttributeRow row = (AttributeRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+
+ final IAttributeChangesListener listener = (row1, index) -> tableViewer.refresh();
+
+ final List emptyAttributes = new ArrayList<>();
+ for (int i = 0; i < tableViewer.getTable().getColumnCount(); i++) {
+ emptyAttributes.add("#TO_FILL#");
+ }
+
+ final AttributeRow emptyRow = new AttributeRow(emptyAttributes, listener);
+
+ if (row != null) {
+ model.add(model.indexOf(row) + 1, emptyRow);
+ } else {
+ model.add(emptyRow);
+ }
+
+ tableViewer.refresh();
+ });
+
+ final MenuItem deleteColumnItem = new MenuItem(tableHeaderMenu, SWT.PUSH);
+ deleteColumnItem.setText("Delete Row");
+ deleteColumnItem.setSelection(false);
+ deleteColumnItem.addListener(SWT.Selection, event -> {
+
+ AttributeRow row = (AttributeRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+
+ while (row != null) {
+ row = (AttributeRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+ if (row != null) {
+ model.remove(model.indexOf(row));
+ tableViewer.refresh();
+ }
+ }
+ });
+
+ // Link to the tableViewer
+ tableViewer.getTable().addListener(SWT.MenuDetect, event -> {
+ tableViewer.getTable().setMenu(tableHeaderMenu);
+ tableViewer.refresh();
+ });
+ }
+
+ public TableViewer getTableViewer() {
+ return tableViewer;
+ }
+
+ public void setTableViewer(final TableViewer tableViewer) {
+ this.tableViewer = tableViewer;
+ }
+
+ public List getModel() {
+ return model;
+ }
+
+ public void setModele(final List model) {
+ this.model = model;
+ }
+}
diff --git a/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedEditor.java b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedEditor.java
new file mode 100644
index 0000000..225c36f
--- /dev/null
+++ b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedEditor.java
@@ -0,0 +1,243 @@
+/* Copyright 2011 csvedit
+ *
+ * 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 me.glindholm.plugin.csvedit2.detailededitor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import me.glindholm.plugin.csvedit2.model.CSVRow;
+
+/**
+ * Class providing methods to add a custom tableViewer to a Composite
+ *
+ * @author msavy
+ *
+ */
+public class DetailedEditor {
+
+ Shell shell;
+ protected List