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 {
if(defaultValue == null) {
defaultValue = param.defaultValue;
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Updating parameter SimulationTopFile, defaultValue="+defaultValue);
}
// if (id.equals("SimulationTopFile")){ // Andrey
// System.out.println("Updating parameter SimulationTopFile, defaultValue="+defaultValue);
// }
}
if(label == null)
......
......@@ -17,8 +17,13 @@
*******************************************************************************/
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.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 {
......@@ -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) {
// 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) {
case UPPERCASE:
return value.toUpperCase();
......
......@@ -17,9 +17,13 @@
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Dialog to promt list of files.
*
......@@ -27,27 +31,46 @@ import org.eclipse.swt.widgets.Shell;
* @author Lvov Konstantin
*/
public class FileListPromptDialog extends ListPromptDialog {
/*
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
, final String[] extensions)
}
*/
public FileListPromptDialog( final Shell parentShell,
String title,
final String[] extensions,
final String projectPath
)
{
super( parentShell
, title
, new IAddAction() {
public String getNewValue() {
FileDialog dialog = new FileDialog(parentShell);
dialog.setFilterExtensions(extensions);
String selectedFile = dialog.open();
return selectedFile;
, title
, new IAddAction() {
public String getNewValue() {
FileDialog dialog = new FileDialog(parentShell);
dialog.setFilterExtensions(extensions);
if (projectPath!=null){
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
......@@ -50,7 +50,11 @@ public class ContextOptionsDialog extends Dialog {
, context
, 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) {
......
......@@ -17,10 +17,13 @@
*******************************************************************************/
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.types.ParamTypeString;
import com.elphel.vdt.ui.dialogs.FileListPromptDialog;
import com.elphel.vdt.ui.dialogs.ListPromptDialog;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class FileListComponent extends ListComponent {
......@@ -29,12 +32,21 @@ public class FileListComponent extends ListComponent {
}
protected ListPromptDialog createDialog() {
String filemask = ((ParamTypeString)param.getType()).getFilemask();
final String[] extensions = (filemask != null? new String[] { filemask } : null);
String filemask = ((ParamTypeString)param.getType()).getFilemask();
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()
, "File list prompt"
, extensions );
return new FileListPromptDialog( promptField.getVisibleNameField().getShell(),
"File list prompt",
extensions,
fProjectPath);
}
}
......@@ -150,9 +150,9 @@ public abstract class ListComponent extends Component {
if (promptField.getPromptDialog() == null)
promptField.setPromptDialog(createDialog());
ListPromptDialog dialog = promptField.getPromptDialog();
List<String> list = dialog.open(current);
returnCode = dialog.getReturnCode();
ListPromptDialog dialog = promptField.getPromptDialog(); // clicked on edit list button
List<String> list = dialog.open(current); // opened list dialog, running
returnCode = dialog.getReturnCode(); // canceled list
return list;
}
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