Commit b6bfc326 authored by Andrey Filippov's avatar Andrey Filippov

converted paths to project-relative when possible

parent 2e5900c7
...@@ -433,9 +433,9 @@ public class Parameter implements Cloneable, Updateable { ...@@ -433,9 +433,9 @@ public class Parameter implements Cloneable, Updateable {
if(defaultValue == null) { if(defaultValue == null) {
defaultValue = param.defaultValue; defaultValue = param.defaultValue;
if (id.equals("SimulationTopFile")){ // Andrey // if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Updating parameter SimulationTopFile, defaultValue="+defaultValue); // System.out.println("Updating parameter SimulationTopFile, defaultValue="+defaultValue);
} // }
} }
if(label == null) if(label == null)
......
...@@ -17,8 +17,13 @@ ...@@ -17,8 +17,13 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.params.types; package com.elphel.vdt.core.tools.params.types;
import org.eclipse.core.resources.IProject;
import com.elphel.vdt.core.tools.config.ConfigException; import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface; import com.elphel.vdt.core.tools.params.ControlInterface;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class ParamTypeString extends ParamType { public class ParamTypeString extends ParamType {
...@@ -137,7 +142,30 @@ public class ParamTypeString extends ParamType { ...@@ -137,7 +142,30 @@ public class ParamTypeString extends ParamType {
} }
} }
public String tryProjectRelativePath(String path){
if (path==null)
return null;
IProject project = SelectedResourceManager.getDefault().getSelectedProject();
if (project==null) return path;
String projectPath=project.getLocation().toString();
if (path.startsWith(projectPath)) {
if (path.equals(projectPath)){
System.out.println("Path equals to project path = \""+path+"\", returning \".\"");
return ".";
}
return path.substring(projectPath.length()+1);
}
return path;
}
public String canonicalizeValue(String value) { public String canonicalizeValue(String value) {
// Try to convert file/dir parameters to project-relative
if ((kind == KIND.FILE) || (kind == KIND.FILE)) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.print("Converting \""+value+"\"to ");
value=tryProjectRelativePath(value);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("\""+value+"\"");
}
switch(caseSensitive) { switch(caseSensitive) {
case UPPERCASE: case UPPERCASE:
return value.toUpperCase(); return value.toUpperCase();
......
...@@ -17,9 +17,13 @@ ...@@ -17,9 +17,13 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.ui.dialogs; package com.elphel.vdt.ui.dialogs;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/** /**
* Dialog to promt list of files. * Dialog to promt list of files.
* *
...@@ -27,27 +31,46 @@ import org.eclipse.swt.widgets.Shell; ...@@ -27,27 +31,46 @@ import org.eclipse.swt.widgets.Shell;
* @author Lvov Konstantin * @author Lvov Konstantin
*/ */
public class FileListPromptDialog extends ListPromptDialog { public class FileListPromptDialog extends ListPromptDialog {
/*
public FileListPromptDialog( final Shell parentShell, String title) { public FileListPromptDialog( final Shell parentShell, String title) {
this(parentShell, title, null); this(parentShell, title, null,null);
} }
public FileListPromptDialog( final Shell parentShell,
String title,
final String[] extensions
)
{
this(parentShell, title, extensions,null);
}
public FileListPromptDialog( final Shell parentShell */
, String title public FileListPromptDialog( final Shell parentShell,
, final String[] extensions) String title,
final String[] extensions,
final String projectPath
)
{ {
super( parentShell super( parentShell
, title , title
, new IAddAction() { , new IAddAction() {
public String getNewValue() { public String getNewValue() {
FileDialog dialog = new FileDialog(parentShell); FileDialog dialog = new FileDialog(parentShell);
dialog.setFilterExtensions(extensions); dialog.setFilterExtensions(extensions);
String selectedFile = dialog.open(); if (projectPath!=null){
return selectedFile; dialog.setFileName(projectPath);
}
String selectedFile = dialog.open();
// try to convert to project-relative
if ((selectedFile!=null) && selectedFile.startsWith(projectPath)) {
if (selectedFile.equals(projectPath)){
System.out.println("FileListPromptDialog(): Path equals to project path = \""+selectedFile+"\", returning \".\"");
return ".";
}
return selectedFile.substring(projectPath.length()+1);
} }
} return selectedFile;
); }
}
);
} }
} // class FileListPromptDialog } // class FileListPromptDialog
...@@ -50,7 +50,11 @@ public class ContextOptionsDialog extends Dialog { ...@@ -50,7 +50,11 @@ public class ContextOptionsDialog extends Dialog {
, context , context
, OptionsCore.getPreferenceStore(context, project) , OptionsCore.getPreferenceStore(context, project)
); );
location = project.getLocation().toOSString(); location = project.getLocation().toOSString(); // project location
// System.out.println("ContextOptionsDialog: location was "+location);
// location = project.getProjectRelativePath().toOSString();
// System.out.println("ContextOptionsDialog: location changed to "+location);
} }
public ContextOptionsDialog(Shell parent, Context context) { public ContextOptionsDialog(Shell parent, Context context) {
......
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.ui.options.component; package com.elphel.vdt.ui.options.component;
import org.eclipse.core.resources.IProject;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.types.ParamTypeString; import com.elphel.vdt.core.tools.params.types.ParamTypeString;
import com.elphel.vdt.ui.dialogs.FileListPromptDialog; import com.elphel.vdt.ui.dialogs.FileListPromptDialog;
import com.elphel.vdt.ui.dialogs.ListPromptDialog; import com.elphel.vdt.ui.dialogs.ListPromptDialog;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class FileListComponent extends ListComponent { public class FileListComponent extends ListComponent {
...@@ -29,12 +32,21 @@ public class FileListComponent extends ListComponent { ...@@ -29,12 +32,21 @@ public class FileListComponent extends ListComponent {
} }
protected ListPromptDialog createDialog() { protected ListPromptDialog createDialog() {
String filemask = ((ParamTypeString)param.getType()).getFilemask(); String filemask = ((ParamTypeString)param.getType()).getFilemask();
final String[] extensions = (filemask != null? new String[] { filemask } : null); final String[] extensions = (filemask != null? new String[] { filemask } : null);
IProject project = SelectedResourceManager.getDefault().getSelectedProject();
String projectPath=null;
if (project!=null) {
projectPath=project.getLocation().toString();
}
final String fProjectPath=projectPath;
return new FileListPromptDialog( promptField.getVisibleNameField().getShell() return new FileListPromptDialog( promptField.getVisibleNameField().getShell(),
, "File list prompt" "File list prompt",
, extensions ); extensions,
fProjectPath);
} }
} }
...@@ -150,9 +150,9 @@ public abstract class ListComponent extends Component { ...@@ -150,9 +150,9 @@ public abstract class ListComponent extends Component {
if (promptField.getPromptDialog() == null) if (promptField.getPromptDialog() == null)
promptField.setPromptDialog(createDialog()); promptField.setPromptDialog(createDialog());
ListPromptDialog dialog = promptField.getPromptDialog(); ListPromptDialog dialog = promptField.getPromptDialog(); // clicked on edit list button
List<String> list = dialog.open(current); List<String> list = dialog.open(current); // opened list dialog, running
returnCode = dialog.getReturnCode(); returnCode = dialog.getReturnCode(); // canceled list
return list; return list;
} }
public void slectionChanged() { public void slectionChanged() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment