Skip to content

Commit

Permalink
update release info
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntungho committed Jun 17, 2019
1 parent 6867540 commit 53c5fdb
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
7 changes: 3 additions & 4 deletions changeNotes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ul>
<li>Supported customizable basic statements</li>
<li>Supported to rename mapper, example and sql file</li>
<li>Improved select with lock plugin </li>
<li>Fixed table config persistence issue</li>
<li>Added "Copy as Executable SQL" popup menu which will resolve placeholders of printed SQL in Mybatis log</li>
<li>Improved java file merger to remove unused import</li>
<li>Other minor enhancements</li>
</ul>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 1.0.4
version = 1.0.5
ideaVersion = IC-2019.1
customUtilBuild = 192.*
isEAP = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,19 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
IndicatorProcessCallback processCallback = new IndicatorProcessCallback(progressIndicator);
GeneratorToolWrapper toolWrapper = new GeneratorToolWrapper(paramWrapper, processCallback);
try {
toolWrapper.generate();
List<String> warnings = toolWrapper.generate();

VirtualFile projectDir = ProjectUtil.guessProjectDir(project);
if (projectDir != null) {
VfsUtil.markDirtyAndRefresh(true, true, true, projectDir);
}

int cnt = paramWrapper.getSelectedTables().size();
String successMsg = cnt + (cnt > 1 ? " tables were built" : " table was built");
NotificationHelper.getInstance().notifyInfo(successMsg, project);
String msg = "Generation for " + cnt + (cnt > 1 ? " tables" : " table") + " was done.";
if (!warnings.isEmpty()) {
msg = msg + "\n" + String.join("\n", warnings);
}
NotificationHelper.getInstance().notifyInfo(msg, project);
} catch (Exception e) {
logger.warn("Failed to generate", e);
NotificationHelper.getInstance().notifyError(String.valueOf(e.getMessage()), project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(sql), null);

NotificationHelper.getInstance().notifyInfo("Normal SQL copied to clipboard", event.getProject());
NotificationHelper.getInstance().notifyInfo("Executable SQL copied to clipboard", event.getProject());
}

@NotNull
Expand Down Expand Up @@ -100,10 +100,12 @@ private static String extractLine(String str, String keyword) {
// only visible for selection
public void update(@NotNull AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
SelectionModel selectionModel = editor.getSelectionModel();
String selectedText = selectionModel.getSelectedText();
if (StringUtil.stringHasValue(selectedText)) {
return;
if (editor != null) {
SelectionModel selectionModel = editor.getSelectionModel();
String selectedText = selectionModel.getSelectedText();
if (StringUtil.stringHasValue(selectedText)) {
return;
}
}

event.getPresentation().setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.List;
import java.util.Properties;

/**
Expand Down Expand Up @@ -46,9 +47,12 @@ public void actionPerformed(@NotNull AnActionEvent event) {
public void run(@NotNull ProgressIndicator progressIndicator) {
String error = null;
try {
GeneratorToolWrapper.runWithConfigurationFile(vFile.getPath(), properties, new IndicatorProcessCallback(progressIndicator));

NotificationHelper.getInstance().notifyInfo("Generated successfully", event.getProject());
List<String> warnings = GeneratorToolWrapper.runWithConfigurationFile(vFile.getPath(), properties, new IndicatorProcessCallback(progressIndicator));
String msg = "Generation was done.";
if (!warnings.isEmpty()) {
msg = msg + "\n" + String.join("\n", warnings);
}
NotificationHelper.getInstance().notifyInfo(msg, event.getProject());

VirtualFile projectDir = ProjectUtil.guessProjectDir(event.getProject());
if (projectDir != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.Problem;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.ImportDeclaration;
import com.github.javaparser.ast.NodeList;
Expand All @@ -21,6 +22,7 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;

/**
Expand Down Expand Up @@ -59,9 +61,15 @@ public String mergeJavaFile(String newFileSource, File existingFile, String[] ja
try {
oldParseResult = new JavaParser().parse(existingFile);
if (oldParseResult.getProblems().size() > 0) {
throw new ShellException(Arrays.toString(oldParseResult.getProblems().toArray()));
List<String> problems = new ArrayList<>(oldParseResult.getProblems().size());
for (Problem problem : oldParseResult.getProblems()) {
problems.add(problem.getMessage());
}
StringBuilder sb = new StringBuilder("Failed to parse ").append(existingFile.getCanonicalPath());
sb.append("\nProblems:\n").append(String.join("\n", problems));
throw new ShellException(sb.toString());
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
throw new ShellException(e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface PluginInfo {
String PLUGIN_NAME = "Mybatis Builder";
String PLUGIN_VERSION = "1.0.4";
String PLUGIN_VERSION = "1.0.5";

String AUTHOR = "Tony Ho";

Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
<group id="ProjectViewPopupMenuMybatisBuilderGroup">
<add-to-group group-id="ProjectViewPopupMenu" anchor="before" relative-to-action="ProjectViewPopupMenuRunGroup"/>
<action id="RunMybatisGenerator" text="Run Mybatis Generator" icon="/images/mybatis-icon.png"
description="Run Mybatis Generator with selected configuration file"
class="com.chuntung.plugin.mybatisbuilder.action.idea.RunMybatisGeneratorAction" />
</group>

<!-- Copy as Executable SQL popup menu -->
<action id="CopyAsNormalSQL" text="Copy as Executable SQL"
description="Copy selection in Mybatis log (keywords 'Preparing: ' and 'Parameters: ' are required) as Executable SQL to clipboard"
class="com.chuntung.plugin.mybatisbuilder.action.idea.CopyAsExecutableSQLAction" >
<add-to-group group-id="EditorPopupMenu" anchor="before" relative-to-action="CopyAsPlainText" />
<add-to-group group-id="ConsoleEditorPopupMenu" anchor="before" relative-to-action="CopyAsPlainText" />
<add-to-group group-id="EditorPopupMenu" anchor="after" relative-to-action="CopyAsPlainText" />
<add-to-group group-id="ConsoleEditorPopupMenu" anchor="after" relative-to-action="CutCopyPasteGroup" />
</action>
</actions>

Expand Down

0 comments on commit 53c5fdb

Please sign in to comment.