summaryrefslogtreecommitdiffstats
path: root/logo
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2014-12-17 00:58:47 +0000
committerMarko Živković <[email protected]>2014-12-17 00:58:47 +0000
commitca9b32e986324f06a3230986f26e4f214d229223 (patch)
treee51a3dc80db3d8dc161841827c6350eb14ecd04e /logo
parent1fd42f81c4a9884f5b702ab9ff854393b2dc5256 (diff)
When creating new file, the file is immediately opened, the list item has focus and text is selected for renaming the file.
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@14 3b0d7934-f7ef-4143-9606-b51f2e2281fd
Diffstat (limited to 'logo')
-rw-r--r--logo/src/xlogo/gui/components/fileslist/FilesList.java8
-rw-r--r--logo/src/xlogo/gui/components/fileslist/FilesListItem.java4
-rw-r--r--logo/src/xlogo/interfaces/BasicFileContainer.java2
-rw-r--r--logo/src/xlogo/kernel/userspace/UserSpace.java9
-rw-r--r--logo/src/xlogo/kernel/userspace/files/LogoFilesManager.java6
5 files changed, 23 insertions, 6 deletions
diff --git a/logo/src/xlogo/gui/components/fileslist/FilesList.java b/logo/src/xlogo/gui/components/fileslist/FilesList.java
index e653fb9..7888140 100644
--- a/logo/src/xlogo/gui/components/fileslist/FilesList.java
+++ b/logo/src/xlogo/gui/components/fileslist/FilesList.java
@@ -44,6 +44,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
+import xlogo.AppSettings;
import xlogo.Logo;
import xlogo.interfaces.BasicFileContainer;
import xlogo.interfaces.BasicFileContainer.FileContainerChangeListener;
@@ -651,7 +652,14 @@ public class FilesList extends JPanel
String name = model.makeUniqueFileName(Logo.messages.getString("new.file")); // TODO remove dependency
try
{
+ if (model.hasTooManyEmptyFiles()){
+ DialogMessenger.getInstance().dispatchMessage(AppSettings.getInstance().translate("message.too.many.empty.files"));
+ return;
+ }
model.createFile(name);
+ model.openFile(name);
+ IFilesListItem item = listItems.get(name);
+ item.setEditing(true);
}
catch (Exception e)
{
diff --git a/logo/src/xlogo/gui/components/fileslist/FilesListItem.java b/logo/src/xlogo/gui/components/fileslist/FilesListItem.java
index efd472b..0065a52 100644
--- a/logo/src/xlogo/gui/components/fileslist/FilesListItem.java
+++ b/logo/src/xlogo/gui/components/fileslist/FilesListItem.java
@@ -454,6 +454,10 @@ public class FilesListItem extends JPanel implements IFilesListItem
this.setBorder(BorderFactory.createLineBorder(state.getBorderColor(), state.getBorderThickness()) );
+ if (isEditing){
+ textField.requestFocusInWindow();
+ textField.selectAll();
+ }
}
/*
diff --git a/logo/src/xlogo/interfaces/BasicFileContainer.java b/logo/src/xlogo/interfaces/BasicFileContainer.java
index 34d87cd..c648c79 100644
--- a/logo/src/xlogo/interfaces/BasicFileContainer.java
+++ b/logo/src/xlogo/interfaces/BasicFileContainer.java
@@ -67,6 +67,8 @@ public interface BasicFileContainer
public String getOpenFileName();
public boolean isFilesListEditable();
+
+ public boolean hasTooManyEmptyFiles();
//public boolean hasErrors(String fileName);
diff --git a/logo/src/xlogo/kernel/userspace/UserSpace.java b/logo/src/xlogo/kernel/userspace/UserSpace.java
index 6f2c065..bd1bf86 100644
--- a/logo/src/xlogo/kernel/userspace/UserSpace.java
+++ b/logo/src/xlogo/kernel/userspace/UserSpace.java
@@ -30,7 +30,6 @@ package xlogo.kernel.userspace;
import java.util.ArrayList;
import java.util.Collection;
-import xlogo.AppSettings;
import xlogo.Logo;
import xlogo.interfaces.BroadcasterErrorFileContainer;
import xlogo.interfaces.X4SModeSwitcher;
@@ -300,10 +299,6 @@ public class UserSpace implements X4SModeSwitcher, LogoFileContainer, Broadcaste
@Override
public void createFile(String fileName) throws IOException
{
- if (contextManager.getContext().hasTooManyEmptyFiles()){
- DialogMessenger.getInstance().dispatchMessage(AppSettings.getInstance().translate("message.too.many.empty.files"));
- return;
- }
try
{
filesManager.createFile(fileName);
@@ -462,6 +457,10 @@ public class UserSpace implements X4SModeSwitcher, LogoFileContainer, Broadcaste
return true;
}
+ public boolean hasTooManyEmptyFiles(){
+ return contextManager.getContext().hasTooManyEmptyFiles();
+ }
+
public boolean hasErrors(String fileName)
{
try
diff --git a/logo/src/xlogo/kernel/userspace/files/LogoFilesManager.java b/logo/src/xlogo/kernel/userspace/files/LogoFilesManager.java
index 4fb05a3..ece7bdb 100644
--- a/logo/src/xlogo/kernel/userspace/files/LogoFilesManager.java
+++ b/logo/src/xlogo/kernel/userspace/files/LogoFilesManager.java
@@ -384,7 +384,11 @@ public class LogoFilesManager implements LogoFileContainer, FileErrorCollector
{
return context.isFilesListEditAllowed();
}
-
+
+ public boolean hasTooManyEmptyFiles(){
+ return context.hasTooManyEmptyFiles();
+ }
+
/**
* the name of the file that was edited last in this context.
*/