Skip to content

Commit

Permalink
completed generation callback in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzg committed Jun 21, 2016
1 parent 5e97e41 commit 6f00e53
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.cfg4j</groupId>
<artifactId>cfg4j-core</artifactId>
<version>4.4.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.zzg.mybatis.generator.util.StringUtils;
import com.zzg.mybatis.generator.util.XMLConfigHelper;
import com.zzg.mybatis.generator.view.LeftDbTreeCell;
import com.zzg.mybatis.generator.view.UIProgressCallback;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
Expand Down Expand Up @@ -260,7 +261,7 @@ public void generateCode() throws Exception {
List<String> warnings = new ArrayList<>();
Set<String> fullyqualifiedTables = new HashSet<String>();
Set<String> contexts = new HashSet<>();
ProgressCallback progressCallback = new VerboseProgressCallback();
ProgressCallback progressCallback = new UIProgressCallback(consoleTextArea);

ShellCallback shellCallback = new DefaultShellCallback(true); // override=true
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.zzg.mybatis.generator.view;

import javafx.scene.control.TextArea;
import org.mybatis.generator.api.ProgressCallback;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Owen on 6/21/16.
*/
public class UIProgressCallback implements ProgressCallback {

private TextArea consoleTextArea;

private StringBuilder sb;

public UIProgressCallback(TextArea textArea) {
sb = new StringBuilder();
this.consoleTextArea = textArea;
}

@Override
public void introspectionStarted(int totalTasks) {
sb.append("introspection started\n");
consoleTextArea.setText(sb.toString());
}

@Override
public void generationStarted(int totalTasks) {
sb.append("generate started\n");
consoleTextArea.setText(sb.toString());
}

@Override
public void saveStarted(int totalTasks) {
sb.append("save started\n");
consoleTextArea.setText(sb.toString());
}

@Override
public void startTask(String taskName) {
sb.append("start task\n");
consoleTextArea.setText(sb.toString());
}

@Override
public void done() {
sb.append("generation done\n");
consoleTextArea.setText(sb.toString());
}

@Override
public void checkCancel() throws InterruptedException {
}
}

0 comments on commit 6f00e53

Please sign in to comment.