Skip to content

Commit

Permalink
Merge 185a437 into 4a5cf43
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeSharpSoft committed Dec 2, 2018
2 parents 4a5cf43 + 185a437 commit 8906777
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.0.1
Dec 02, 2018

FIX: disabling table editor for large files
FIX: applying row height for newly opened files

2.0.0
Nov 20, 2018

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://www.jetbrains.com/intellij-repository/snapshots

name='CSV Plugin'
pluginVersion=2.0.0
pluginVersion=2.0.1
javaVersion=1.8
javaTargetVersion=1.8
downloadIntellijSources=false
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap;
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
import net.seesharpsoft.intellij.plugins.csv.editor.table.api.TableDataHandler;
Expand All @@ -38,7 +39,7 @@ public abstract class CsvTableEditor implements FileEditor, FileEditorLocation {
protected final UserDataHolder userDataHolder;
protected final Document document;
protected final PropertyChangeSupport changeSupport;
protected final CsvFile csvFile;
protected final PsiFile psiFile;
protected final String currentSeparator;
protected final TableDataHandler dataManagement;

Expand All @@ -54,9 +55,9 @@ public CsvTableEditor(@NotNull Project projectArg, @NotNull VirtualFile fileArg)
this.userDataHolder = new UserDataHolderBase();
this.document = FileDocumentManager.getInstance().getDocument(this.file);
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
this.csvFile = (CsvFile) documentManager.getPsiFile(this.document);
this.psiFile = documentManager.getPsiFile(this.document);
this.changeSupport = new PropertyChangeSupport(this);
this.currentSeparator = CsvCodeStyleSettings.getCurrentSeparator(this.project, this.csvFile.getLanguage());
this.currentSeparator = CsvCodeStyleSettings.getCurrentSeparator(this.project, this.psiFile.getLanguage());
this.dataManagement = new TableDataHandler(this, TableDataHandler.MAX_SIZE);
}

Expand Down Expand Up @@ -96,7 +97,7 @@ public boolean isEditable() {
}

public boolean hasErrors() {
return columnInfoMap != null && columnInfoMap.hasErrors();
return !isValid() || (columnInfoMap != null && columnInfoMap.hasErrors());
}

protected Object[][] storeStateChange(Object[][] data) {
Expand Down Expand Up @@ -192,7 +193,8 @@ public boolean isModified() {

@Override
public boolean isValid() {
return this.csvFile.isValid();
CsvFile csvFile = this.getCsvFile();
return csvFile != null && csvFile.isValid();
}

@Override
Expand Down Expand Up @@ -270,6 +272,11 @@ public Project getProject() {
return this.project;
}

@Nullable
public CsvFile getCsvFile() {
return this.psiFile instanceof CsvFile ? (CsvFile)psiFile : null;
}

public TableDataHandler getDataHandler() {
return this.dataManagement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public FileEditorPolicy getPolicy() {

@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
return CsvEditorSettingsExternalizable.getInstance().getEditorPrio() != CsvEditorSettingsExternalizable.EditorPrio.TEXT_ONLY &&
CsvFileEditorProvider.isCsvFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
return CsvEditorSettingsExternalizable.getInstance().getEditorPrio() != CsvEditorSettingsExternalizable.EditorPrio.TEXT_ONLY && CsvFileEditorProvider.isCsvFile(file) &&
!SingleRootFileViewProvider.isTooLargeForIntelligence(file);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable;
import net.seesharpsoft.intellij.plugins.csv.editor.table.*;
import net.seesharpsoft.intellij.plugins.csv.editor.table.api.TableDataChangeEvent;
import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -113,6 +114,8 @@ private void initializedUIComponents() {
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK), JComponent.WHEN_FOCUSED);
tblEditor.registerKeyboardAction(this.tableEditorActions.redo,
KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);

applyRowLines(getFileEditorState().getRowLines());
}


Expand Down Expand Up @@ -284,6 +287,11 @@ protected DefaultTableModel getTableModel() {

@Override
protected void updateUIComponents() {
CsvFile csvFile = getCsvFile();
if (csvFile == null) {
return;
}

CsvColumnInfoMap<PsiElement> newColumnInfoMap = csvFile.getMyColumnInfoMap();
if (Objects.equals(columnInfoMap, newColumnInfoMap)) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@

<change-notes><![CDATA[
<pre style="font-family: sans-serif">
NEW: !!! Table Editor !!!
FIX: disabling table editor for large files
FIX: applying row height for newly opened files
</pre>
]]>
</change-notes>
Expand Down

0 comments on commit 8906777

Please sign in to comment.