Skip to content

Commit

Permalink
closes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
GavriYashar committed Mar 20, 2017
1 parent 151b60b commit 8003c93
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/Replacements/Variables/MEPV_THIS.m
Expand Up @@ -12,5 +12,5 @@
% See also
expr = '\$\{(THIS)\}';
if ~isempty(regexp(txt,expr,'once'))
txt = char(at.justin.matlab.editor.EditorWrapper.getFullQualifiedClass());
txt = char(at.mep.editor.EditorWrapper.getFullQualifiedClass());
end
3 changes: 3 additions & 0 deletions resources/properties/DefaultProps.properties
Expand Up @@ -13,6 +13,9 @@ feature.enableReplacements = true
# Automatically switches file for detailviewer (matlabs internal filestructure
feature.enableAutoDetailViewer = true

# Automatically switches file for current folder
feature.enableAutoCurrentFolder = true

# paths for live templates
path.mepr.rep =
path.mepr.var =
Expand Down
1 change: 1 addition & 0 deletions resources/properties/Internal.properties
Expand Up @@ -42,3 +42,4 @@ help.feature.enableDeleteCurrentLine = enables/disables delete current line
help.feature.enableReplacements = enables/disables Live Templates
help.feature.enableAutoDetailViewer = enables/disables auto detail viewer
help.feature.enableExecuteCurrentLine = enables/disables execute current line
help.feature.enableAutoCurrentFolder = enables/disables auto switch current folder
4 changes: 4 additions & 0 deletions src/at/mep/editor/EditorApp.java
Expand Up @@ -2,6 +2,7 @@

import at.mep.KeyReleasedHandler;
import at.mep.Matlab;
import at.mep.gui.AutoSwitchCurrentFolder;
import at.mep.gui.autoDetailViewer.AutoDetailViewer;
import at.mep.gui.bookmarks.Bookmarks;
import at.mep.mepr.MEPR;
Expand Down Expand Up @@ -132,6 +133,9 @@ public void eventOccurred(EditorEvent editorEvent) {
if (editorEvent == EditorEvent.ACTIVATED && Settings.getPropertyBoolean("feature.enableAutoDetailViewer")) {
AutoDetailViewer.doYourThing();
}
if (editorEvent == EditorEvent.ACTIVATED && Settings.getPropertyBoolean("feature.enableAutoCurrentFolder")) {
AutoSwitchCurrentFolder.doYourThing();
}
}
});

Expand Down
25 changes: 25 additions & 0 deletions src/at/mep/gui/AutoSwitchCurrentFolder.java
@@ -0,0 +1,25 @@
package at.mep.gui;

import at.mep.editor.EditorWrapper;
import com.mathworks.matlab.api.explorer.FileLocation;
import com.mathworks.mde.explorer.Explorer;
import com.mathworks.mlwidgets.explorer.model.navigation.InvalidLocationException;
import com.mathworks.mlwidgets.explorer.model.navigation.NavigationContext;

/** Created by Gavri on 2017-03-20. */
public class AutoSwitchCurrentFolder {
public static NavigationContext navigationContext = Explorer.getInstance().getContext();

public static void doYourThing() {
if (!EditorWrapper.getFile().exists()) {
// check for "Untitled" as name is not good, since a "Untitled.m" can exist
return;
}
FileLocation fileLocation = new FileLocation(EditorWrapper.getFile().getParent());
try {
navigationContext.setLocation(fileLocation);
} catch (InvalidLocationException e) {
e.printStackTrace();
}
}
}
2 changes: 2 additions & 0 deletions src/at/mep/prefs/PrefsPanel.java
Expand Up @@ -129,6 +129,7 @@ private void addFeatureSelector() {
"feature.enableDeleteCurrentLine",
"feature.enableReplacements",
"feature.enableAutoDetailViewer",
"feature.enableAutoCurrentFolder",
"feature.enableExecuteCurrentLine"
};
PropertyType[] types = {PropertyType.BOOLEAN,
Expand All @@ -138,6 +139,7 @@ private void addFeatureSelector() {
PropertyType.BOOLEAN,
PropertyType.BOOLEAN,
PropertyType.BOOLEAN,
PropertyType.BOOLEAN,
PropertyType.BOOLEAN
};

Expand Down

0 comments on commit 8003c93

Please sign in to comment.