diff --git a/.gitignore b/.gitignore
index b1a83d9..6f85526 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,41 +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
\ No newline at end of file
+.classpath
+.project
+.polyglot.META-INF
+.polyglot.feature.xml
+.settings/
+bin/
+target/
diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
deleted file mode 100644
index 12e63a2..0000000
--- a/.mvn/extensions.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- org.eclipse.tycho.extras
- tycho-pomless
- 1.0.0
-
-
diff --git a/README.md b/README.md
index 74edf09..e1617d5 100644
--- a/README.md
+++ b/README.md
@@ -11,30 +11,12 @@ or ask for push access here. Tell about new fork by adding new issue. I will hap
## What is this ?
-This repository is a fork of [https://code.google.com/p/csvedit/](https://code.google.com/p/csvedit/) created by Mathieu Savy in 2104. It contains the latest functionalities available for CSVEdit but most of the new features are still being tested. If you look for a more reliable version of the plugin you should probably visit the original repository.
-
-- The previous stable release 1.1.3 was available [on Eclipse Marketplace](https://marketplace.eclipse.org/content/csv-edit).
-- The version available in this repository is 1.2.x
-
-The intention was to contribute features from here to the original repository once they are mature.
+This repository is a fork of [https://github.com/Mathieuu/CsvEdit](https://github.com/Mathieuu/CsvEdit) created by Mathieu Savy in 2013
+which in itself is a fork of [https://code.google.com/p/csvedit/](https://code.google.com/p/csvedit/) created by Frederic Henri in 2010.
### How to get the latest version
-HELP WANTED WITH PUBLISHING 1.2+ build
-
-0. NOT AVAILABLE Via Eclipse marketplace at
-or drag-n-drop the image on the Eclipse toolbar
-[](http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=3739198)
-
-1. NOT AVAILABLE The latest version (1.2) 2017-10-31 built is NO LONGER available with update-site `http://www.nodeclipse.org/updates/csvedit/`.
-In Eclipse Help -> Install new software, add the URL and follow the instructions.
-
-2. Or from this repository:
-[https://raw.githubusercontent.com/SegFaultError/CsvEdit/master/csvedit.update/site.xml](https://raw.githubusercontent.com/SegFaultError/CsvEdit/master/csvedit.update/site.xml)
-
-- [] TODO 3. Offline site archive from GitHub releases.
-
-4. Other option is to build from sources with maven `mvn package` and install from local repository archive, that will be in `csvedit.site/target/repository`.
+[https://gnl42.github.io/CsvEdit2-update/](https://gnl42.github.io/CsvEdit2-update/)
### CSVEdit
@@ -42,27 +24,34 @@ CSVEdit make CSVFile edition easier.
+ Edit from the source editor
- The source editor has been enhanced to help you differentiate your data from the different column using a color mechanism
+ The source editor has been enhanced to help you differentiate your data from the different column using a color mechanism
+ Edit from a table view representing the csv data
- The table editing is definitely the added value of the plugin and allows a bunch of operation on your csv file among the following features
-
- - Easy editing of data
- - Insertion and deletion of table rows
- - Insertion and deletion of table column
- - Filtering of data
- - Customize view with hidding/display of column to simplify the view
- - Manage your column with moving/resizing columns
- - Sorting data in column
- - Manage your own CSV settings
-
+ The table editing is definitely the added value of the plugin and allows a bunch of operation on your csv file among the following features
+
+ - Easy editing of data
+ - Insertion and deletion of table rows
+ - Insertion and deletion of table column
+ - Filtering of data
+ - Customize view with hidding/display of column to simplify the view
+ - Manage your column with moving/resizing columns
+ - Sorting data in column
+ - Manage your own CSV settings
+


-
+
## History
+### Version 2.0.0 2024
+
+Update for Eclipse 2023-12
+Various bug fixes
+
+###
+
Optional maven/tycho build was added in 2017 by Paul Verest.
### New features of 1.2.x
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/.project b/csvedit.feature/.project
deleted file mode 100644
index e05670e..0000000
--- a/csvedit.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- csvedit.feature
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
diff --git a/csvedit.feature/feature.xml b/csvedit.feature/feature.xml
index 24e93c0..29f7cd0 100644
--- a/csvedit.feature/feature.xml
+++ b/csvedit.feature/feature.xml
@@ -1,12 +1,12 @@
+ version="2.1.0.qualifier"
+ provider-name="George Lindholm"
+ plugin="me.glindholm.plugin.csvedit2">
-
+
This aims to create a CSV file editor in Eclipse with features
such as :
- view csv file in source editor or table editor
@@ -46,23 +46,19 @@ permissions and limitations under the License.
-
-
+
+ id="wrapped.org.jumpmind.symmetric.symmetric-csv"
+ version="0.0.0"/>
+ id="me.glindholm.plugin.csvedit2"
+ version="0.0.0"/>
+
+
diff --git a/csvedit.feature/pom.xml b/csvedit.feature/pom.xml
new file mode 100644
index 0000000..e9d05a5
--- /dev/null
+++ b/csvedit.feature/pom.xml
@@ -0,0 +1,15 @@
+
+
+ 4.0.0
+
+ me.glindholm.plugin
+ csvedit2
+ 2.1.0-SNAPSHOT
+
+ me.glindholm.plugin.csvedit2.feature
+ eclipse-feature
+ [feature] CSV Edit
+
diff --git a/csvedit.plugin.ui/.classpath b/csvedit.plugin.ui/.classpath
deleted file mode 100644
index 2295842..0000000
--- a/csvedit.plugin.ui/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
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/.project b/csvedit.plugin.ui/.project
deleted file mode 100644
index 8871fdd..0000000
--- a/csvedit.plugin.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- csvedit.plugin.ui
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/csvedit.plugin.ui/META-INF/MANIFEST.MF b/csvedit.plugin.ui/META-INF/MANIFEST.MF
index 2097de5..6070ccb 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-Vendor: www.fhsolution.com
-Fragment-Host: org.fhsolution.eclipse.plugins.csvedit;bundle-version="1.2.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-SymbolicName: me.glindholm.plugin.csvedit2.ui;singleton:=true
+Bundle-Version: 2.1.0.qualifier
+Bundle-Vendor: George Lindholm
+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 1cbc97d..96a5ce9 100644
--- a/csvedit.plugin.ui/build.properties
+++ b/csvedit.plugin.ui/build.properties
@@ -1,6 +1,7 @@
source.. = src/
-output.. = bin/
+output.. = target/classes/
+
bin.includes = META-INF/,\
.,\
fragment.xml,\
- lib/
+ icons/
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/icons/csv.gif b/csvedit.plugin.ui/icons/csv.gif
similarity index 100%
rename from csvedit.plugin/icons/csv.gif
rename to csvedit.plugin.ui/icons/csv.gif
diff --git a/csvedit.plugin.ui/lib/javacsv.jar b/csvedit.plugin.ui/lib/javacsv.jar
deleted file mode 100644
index 75f404d..0000000
Binary files a/csvedit.plugin.ui/lib/javacsv.jar and /dev/null differ
diff --git a/csvedit.plugin.ui/pom.xml b/csvedit.plugin.ui/pom.xml
new file mode 100644
index 0000000..32e8aae
--- /dev/null
+++ b/csvedit.plugin.ui/pom.xml
@@ -0,0 +1,15 @@
+
+
+ 4.0.0
+
+ me.glindholm.plugin
+ csvedit2
+ 2.1.0-SNAPSHOT
+
+ me.glindholm.plugin.csvedit2.ui
+ eclipse-plugin
+ [bundle] Eclipse CSV Editor UI contributions
+
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 73%
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..50faa4b 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
@@ -52,6 +53,11 @@ public boolean getSensitiveSearch() {
return optionsProvider.getSensitiveSearch();
}
+ @Override
+ public char getCustomHeaderDelimiter() {
+ return optionsProvider.getCustomHeaderDelimiter().charAt(0);
+ }
+
@Override
public char getCustomDelimiter() {
return optionsProvider.getCustomDelimiter().charAt(0);
@@ -59,20 +65,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 +87,7 @@ public char getTextQualifier() {
public boolean useQualifier() {
return optionsProvider.useTextQualifier();
}
-
+
@Override
public String getInCellDelimiter() {
return optionsProvider.getInCellDelimiter();
@@ -89,16 +95,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..ef8fdc0
--- /dev/null
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/model/PreferencesCSVOptionsProvider.java
@@ -0,0 +1,99 @@
+/* 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 customHeaderDelimiter;
+ 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);
+ customHeaderDelimiter = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CUSTOM_HEADER_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 getCustomHeaderDelimiter() {
+ return customHeaderDelimiter;
+ }
+ @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/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java
new file mode 100644
index 0000000..2688a44
--- /dev/null
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CSVPreferencePage.java
@@ -0,0 +1,135 @@
+/* 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.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+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 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 constructor
+ */
+ public CSVPreferencePage() {
+ super(GRID);
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ setDescription("Some options that will be use for all the csv files");
+ }
+
+ /**
+ * 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() {
+
+ 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,
+ getFieldEditorParent()));
+
+ final BooleanFieldEditor firstLineIsHeader = new BooleanFieldEditor(PreferenceConstants.USE_FIRST_LINE_AS_HEADER, "&Use the first line of the CSV file as the column headers",
+ getFieldEditorParent());
+ addField(firstLineIsHeader);
+
+ final CustomDelimiterFieldEditor headerDelimiter = new CustomDelimiterFieldEditor(PreferenceConstants.CUSTOM_HEADER_DELIMITER, "Choose the delimiter to use for header:", getFieldEditorParent());
+ addField(headerDelimiter);
+
+ firstLineIsHeader.getDescriptionControl(getFieldEditorParent()).addListener(SWT.Selection, event -> {
+ final boolean enabled = firstLineIsHeader.getBooleanValue();
+ headerDelimiter.setEnabled(enabled, getFieldEditorParent());
+ });
+
+ addField(new CustomDelimiterFieldEditor(PreferenceConstants.CUSTOM_DELIMITER, "Choose the delimiter to use:", getFieldEditorParent()));
+
+ // final StringFieldEditor customDelimiterField = new StringFieldEditor(PreferenceConstants.CUSTOM_DELIMITER, "Choose the delimiter to use:", 2,
+ // getFieldEditorParent());
+ // customDelimiterField.setTextLimit(1);
+ // customDelimiterField.setEmptyStringAllowed(false);
+ // addField(customDelimiterField);
+
+ final StringFieldEditor textQualifierChar = new StringFieldEditor(PreferenceConstants.TEXT_QUALIFIER,
+ "Define the character used as a text qualifier of the data:", 2, getFieldEditorParent());
+ textQualifierChar.setTextLimit(1);
+ textQualifierChar.setEmptyStringAllowed(false);
+ addField(textQualifierChar);
+
+ addField(new BooleanFieldEditor(PreferenceConstants.USE_QUALIFIER, "For the text qualifier to be used for all fields", getFieldEditorParent()));
+
+ final StringFieldEditor commentChar = new StringFieldEditor(PreferenceConstants.COMMENT_CHAR, "Choose the character to use as a comment:", 2,
+ getFieldEditorParent());
+ commentChar.setTextLimit(1);
+ commentChar.setEmptyStringAllowed(true);
+ addField(commentChar);
+
+ 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);
+
+ 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.setEmptyStringAllowed(true);
+ addField(incellDelimiterField);
+
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ // TODO here we should reload all opened csv file with the new pref.
+ return super.performOk();
+ }
+
+ /**
+ *
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ @Override
+ public void init(final IWorkbench workbench) {
+ }
+
+}
\ No newline at end of file
diff --git a/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CustomDelimiterFieldEditor.java b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CustomDelimiterFieldEditor.java
new file mode 100644
index 0000000..de47612
--- /dev/null
+++ b/csvedit.plugin.ui/src/me/glindholm/plugin/csvedit2/customeditor/preferences/CustomDelimiterFieldEditor.java
@@ -0,0 +1,104 @@
+
+package me.glindholm.plugin.csvedit2.customeditor.preferences;
+
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+public class CustomDelimiterFieldEditor extends ComboFieldEditor {
+ private Combo combo;
+ private static final String[] delItems = { ",", ";", "|", "tab" };
+
+ public CustomDelimiterFieldEditor(final String name, final String labelText, final Composite parent) {
+ super(name, labelText, new String[][] {}, parent);
+ createControl(parent);
+ combo.setTextLimit(3);
+ }
+
+ @Override
+ protected void adjustForNumColumns(final int numColumns) {
+ final GridData gd = (GridData) combo.getLayoutData();
+ gd.horizontalSpan = numColumns - 1;
+ gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1;
+ }
+
+ @Override
+ protected void doFillIntoGrid(final Composite parent, final int numColumns) {
+ getLabelControl(parent);
+ if (combo == null) {
+ combo = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER);
+ combo.setItems(delItems);
+ combo.addModifyListener(e -> valueChanged());
+ combo.addVerifyListener(e -> {
+ if (e.text.length() == 0 || //
+ !"tab".equals(e.text) && e.text.length() > 1) {
+ e.doit = false;
+ }
+ });
+ }
+ final GridData gd = new GridData();
+ gd.horizontalSpan = numColumns - 1;
+ gd.horizontalAlignment = GridData.FILL;
+ combo.setLayoutData(gd);
+ }
+
+ @Override
+ protected void doLoad() {
+ updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
+ }
+
+ @Override
+ protected void doLoadDefault() {
+ updateComboForValue(getPreferenceStore().getDefaultString(getPreferenceName()));
+ }
+
+ @Override
+ protected void doStore() {
+ String value = combo.getText();
+ if ("tab".equals(value)) {
+ value = "\t";
+ }
+ getPreferenceStore().setValue(getPreferenceName(), value);
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ @Override
+ public void setEnabled(final boolean enabled, final Composite parent) {
+ // super.setEnabled(enabled, parent);
+ combo.setEnabled(enabled);
+ super.getLabelControl(parent).setEnabled(enabled);
+ }
+
+ private void updateComboForValue(final String value) {
+ if (combo != null) {
+ if ("\t".equals(value)) {
+ combo.setText("tab");
+ } else {
+ combo.setText(value);
+ }
+ }
+ }
+
+ private void valueChanged() {
+ setPresentsDefaultValue(false);
+ final boolean oldState = isValid();
+ refreshValidState();
+ final boolean newState = isValid();
+ if (newState != oldState) {
+ fireStateChanged(IS_VALID, oldState, newState);
+ }
+ String newValue = combo.getText();
+ if ("tab".equals(newValue)) {
+ newValue = "\t";
+ }
+ if (!newValue.equals(getPreferenceStore().getString(getPreferenceName()))) {
+ fireValueChanged(VALUE, getPreferenceStore().getString(getPreferenceName()), newValue);
+ }
+ }
+}
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 90%
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..e3abd58 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
@@ -32,4 +32,5 @@ public class PreferenceConstants {
public static final String INCELL_DELIMITER = "inCellDelimiter";
public static final String REGEX_HEADER_TABLE = "regexHeaderTable";
public static final String DEFAULT_VIEW_PAGE = "defaultPagePreference";
+ public static final String CUSTOM_HEADER_DELIMITER = "headerDelimiterPreference";
}
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 84%
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..a2af586 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,10 +32,12 @@ 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_HEADER_DELIMITER, ",");
store.setDefault(PreferenceConstants.CUSTOM_DELIMITER, ",");
store.setDefault(PreferenceConstants.TEXT_QUALIFIER, "\"");
store.setDefault(PreferenceConstants.USE_QUALIFIER, false);
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.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java b/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java
deleted file mode 100644
index c9cd923..0000000
--- a/csvedit.plugin.ui/src/org/fhsolution/eclipse/plugins/csvedit/customeditor/preferences/CSVPreferencePage.java
+++ /dev/null
@@ -1,138 +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.preferences;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.ComboFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.fhsolution.eclipse.plugins.csvedit.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 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 constructor
- */
- public CSVPreferencePage() {
- super(GRID);
- setPreferenceStore(Activator.getDefault().getPreferenceStore());
- setDescription("Some options that will be use for all the csv files");
- }
-
- /**
- * 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()
- */
- public void createFieldEditors() {
-
- 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,
- getFieldEditorParent()));
-
- 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());
- customDelimiterField.setTextLimit(1);
- customDelimiterField.setEmptyStringAllowed(false);
- addField(customDelimiterField);
-
- 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()));
-
- 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,
- "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,
- "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.setEmptyStringAllowed(true);
- addField(incellDelimiterField);
-
- }
-
- /**
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
- */
- public boolean performOk () {
- // TODO here we should reload all opened csv file with the new pref.
- return super.performOk();
- }
-
- /**
- *
- *
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
-}
\ No newline at end of file
diff --git a/csvedit.plugin/.classpath b/csvedit.plugin/.classpath
deleted file mode 100644
index d115351..0000000
--- a/csvedit.plugin/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/csvedit.plugin/.gitignore b/csvedit.plugin/.gitignore
deleted file mode 100644
index b71f363..0000000
--- a/csvedit.plugin/.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/.project b/csvedit.plugin/.project
deleted file mode 100644
index d498890..0000000
--- a/csvedit.plugin/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- csvedit.plugin
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/csvedit.plugin/META-INF/MANIFEST.MF b/csvedit.plugin/META-INF/MANIFEST.MF
index 6853fa5..b44b10c 100644
--- a/csvedit.plugin/META-INF/MANIFEST.MF
+++ b/csvedit.plugin/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
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-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-SymbolicName: me.glindholm.plugin.csvedit2;singleton:=true
+Bundle-Version: 2.1.0.qualifier
+Bundle-Activator: me.glindholm.plugin.csvedit2.Activator
+Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
@@ -12,16 +12,16 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.editors,
org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .,
- lib/javacsv.jar
-Export-Package: org.fhsolution.eclipse.plugins.csvedit.editors;
+Bundle-ClassPath: .
+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"
-Bundle-Vendor: www.fhsolution.com
+ me.glindholm.plugin.csvedit2.model;uses:="com.csvreader"
+Import-Package: org.jumpmind.symmetric.csv
+Bundle-Vendor: George Lindholm
diff --git a/csvedit.plugin/build.properties b/csvedit.plugin/build.properties
index 8f36d7c..bda1ecd 100644
--- a/csvedit.plugin/build.properties
+++ b/csvedit.plugin/build.properties
@@ -1,9 +1,7 @@
source.. = src/
+
+output.. = target/classes/
bin.includes = plugin.xml,\
META-INF/,\
- .,\
- icons/,\
- lib/javacsv.jar
-jre.compilation.profile=J2SE-1.5
-jars.compile.order = .
-src.includes = lib/
+ .
+jre.compilation.profile=JavaSE-17
diff --git a/csvedit.plugin/lib/javacsv.jar b/csvedit.plugin/lib/javacsv.jar
deleted file mode 100644
index 75f404d..0000000
Binary files a/csvedit.plugin/lib/javacsv.jar and /dev/null differ
diff --git a/csvedit.plugin/pom.xml b/csvedit.plugin/pom.xml
new file mode 100644
index 0000000..00aa968
--- /dev/null
+++ b/csvedit.plugin/pom.xml
@@ -0,0 +1,15 @@
+
+
+ 4.0.0
+
+ me.glindholm.plugin
+ csvedit2
+ 2.1.0-SNAPSHOT
+
+ me.glindholm.plugin.csvedit2
+ eclipse-plugin
+ [bundle] Eclipse CSV Editor
+
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 60%
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 58eec3f..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,19 +13,17 @@
* 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.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 {
/**
@@ -34,46 +32,47 @@ public class AttributeEditorCellModifier implements ICellModifier {
* @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)
*/
- 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 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..9835f95
--- /dev/null
+++ b/csvedit.plugin/src/me/glindholm/plugin/csvedit2/detailededitor/DetailedEditor.java
@@ -0,0 +1,248 @@
+/* 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