]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/imports/internal/ExternalImportModulesAction.java
(refs #7524) Set Refresh automatically as default in SCLConsole
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / imports / internal / ExternalImportModulesAction.java
1 package org.simantics.scl.ui.imports.internal;
2
3 import java.util.ArrayList;
4
5 import org.eclipse.swt.widgets.FileDialog;
6 import org.eclipse.swt.widgets.Shell;
7 import org.simantics.scl.compiler.commands.CommandSessionImportEntry;
8 import org.simantics.scl.ui.imports.ImportModulesAction;
9
10 public class ExternalImportModulesAction extends ImportModulesAction {
11     
12     public static final ExternalImportModulesAction INSTANCE = new ExternalImportModulesAction();
13             
14     public ExternalImportModulesAction() {
15         super("Add external module", 95.0);
16     }
17
18     @Override
19     public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
20         FileDialog dialog = new FileDialog(shell);
21         dialog.setFilterExtensions(new String[] {"*.scl"});
22         
23         String result = dialog.open();
24         if(result != null) {
25             new CommandSessionImportEntry("file:" + result, "", true).addTo(imports);
26             return true;
27         }
28         else
29             return false;
30     }
31
32 }