Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
fix imported file tab name
Browse files Browse the repository at this point in the history
  • Loading branch information
UnforgivenZZZ committed Oct 8, 2018
1 parent e3ee5af commit b8801ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/main/java/org/tron/studio/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public void initialize() throws IOException {
boolean alreadyOpen = false;
for (Tab tab : codeAreaTabPane.getTabs()) {
if (StringUtils.equals(tab.getText(), currentContractName)) {
System.out.println(tab.getText());
codeAreaTabPane.getSelectionModel().select(tab);
alreadyOpen = true;
break;
}
}
if (!alreadyOpen) {
Expand All @@ -115,11 +117,11 @@ public void initialize() throws IOException {
ShareData.openContractFileName.addListener((observable, oldValue, newValue) ->{
String filePath = ShareData.openContractFileName.get();
File newFile = new File(filePath);

System.out.println(filePath);
Tab newTab = setTab(newFile);
newTab.setClosable(true);
ShareData.currentContractName.set(newFile.getName());
ShareData.allContractFileName.add(newFile.getName());
// ShareData.currentContractName.set(filePath);
// ShareData.allContractFileName.add(filePath);
codeAreaTabPane.getSelectionModel().select(newTab);
});

Expand Down Expand Up @@ -152,7 +154,7 @@ private Tab setTab(File file) {
AutoCompletion autoCompletion = new AutoCompletion(codeArea);
autoCompletion.autoComplete(codeArea);

codeTab.setText(file.getName());
codeTab.setText(file.getPath());
//Just not allow to close the default tab
codeTab.setClosable(true);

Expand All @@ -171,8 +173,8 @@ private Tab setTab(File file) {

new FormatCode(codeArea);

ShareData.allContractFileName.add(file.getName());
ShareData.currentContractName.set(file.getName());
ShareData.allContractFileName.add(file.getPath());
ShareData.currentContractName.set(file.getPath());
ShareData.currentContractTab = codeTab;

return codeTab;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/tron/studio/ui/LeftCodeListController.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void saveContractContent() {

private void openFile(File file) {
try {
ShareData.newContractFileName.set(file.getPath());
ShareData.openContractFileName.set(file.getPath());
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -230,7 +230,7 @@ public void openContract(MouseEvent mouseEvent) {
// fileName = SolidityFileUtil.formatFileName(fileName);
// SolidityFileUtil.createNewFile(fileName);
// ShareData.newContractFileName.set(fileName);
ShareData.allContractFileName.get().add(file.getPath());
// ShareData.allContractFileName.get().add(file.getPath());
// ShareData.currentContractName.set(file.getPath());
}
}
Expand Down

0 comments on commit b8801ee

Please sign in to comment.