Changeset 102

Show
Ignore:
Timestamp:
07/06/08 03:56:51 (6 months ago)
Author:
mb0
Message:

CLOSED - # 80: add launcher config to suppress swfviewer
http://axdt.org/ticket/80

  • also added choice and file fields to my little preference framework.
  • added browse button to flex config field
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • axdt/trunk/org.axdt.as3.debug/plugin.xml

    r87 r102  
    6161       point="org.eclipse.ui.preferencePages"> 
    6262      <page 
    63           category="org.axdt.as3.debug.preferences" 
     63          category="org.axdt.as3.preferences" 
    6464          class="org.axdt.as3.debug.preferences.AS3DebugPreferencePage" 
    6565          id="org.axdt.as3.debug.preferences" 
  • axdt/trunk/org.axdt.as3.debug/src/org/axdt/as3/debug/launcher/AS3LauncherDelegate.java

    r92 r102  
    11package org.axdt.as3.debug.launcher; 
    22 
    3 import java.io.File
     3import java.net.URI
    44 
    55import org.axdt.as3.compiler.AS3Compiler; 
    66import org.axdt.as3.compiler.AS3CompilerTarget; 
    77import org.axdt.as3.debug.IAS3DebugConstants; 
     8import org.axdt.as3.debug.preferences.AS3DebugPreferences; 
    89import org.eclipse.core.resources.IContainer; 
    910import org.eclipse.core.resources.IFile; 
     
    2526import org.eclipse.debug.core.ILaunchManager; 
    2627import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; 
     28import org.eclipse.jface.preference.IPreferenceStore; 
     29import org.eclipse.swt.program.Program; 
    2730import org.eclipse.swt.widgets.Display; 
    2831import org.eclipse.ui.IWorkbench; 
     
    9396                                        try { 
    9497                                                deployDir.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor()); 
    95                                                 File file = deployFile.toFile(); 
    96                                                 if (file.exists()) 
    97                                                         IDE.openEditor(activePage, file.toURI(), "org.axdt.swfview.editor", 
    98                                                                         false); 
     98                                                IPreferenceStore store = AS3DebugPreferences.getInstance().getStore(); 
     99                                                boolean open = store.getBoolean(AS3DebugPreferences.OPEN_SWF); 
     100                                                String type = store.getString(AS3DebugPreferences.OPEN_WITH); 
     101                                                URI file = AS3DebugPreferences.getInstance() 
     102                                                                .alterDeployLocation(deployFile); 
     103                                                if (open && file.isAbsolute()) { 
     104                                                        if (type.equals(AS3DebugPreferences.CHOICE_SWFVIEW)) { 
     105                                                                IDE.openEditor(activePage, file, "org.axdt.swfview.editor", false); 
     106                                                        } else { 
     107                                                                Program.launch(file.toString()); 
     108                                                        } 
     109                                                } 
    99110                                        } catch (Exception e) { 
    100111                                                e.printStackTrace(); 
  • axdt/trunk/org.axdt.as3.debug/src/org/axdt/as3/debug/launcher/AS3LauncherTabMain.java

    r92 r102  
    22 
    33import org.eclipse.core.resources.IFile; 
     4import org.eclipse.core.resources.IProject; 
    45import org.eclipse.core.resources.IResource; 
    56import org.eclipse.core.resources.ResourcesPlugin; 
    67import org.eclipse.core.runtime.CoreException; 
    7 import org.eclipse.core.runtime.IPath; 
    88import org.eclipse.debug.core.ILaunchConfiguration; 
    99import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 
     
    8888        protected void searchTarget() { 
    8989                ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(getShell(), 
    90                                 ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE) { 
    91                         protected String adjustPattern() { 
    92                                 String text = super.adjustPattern(); 
    93                                 return text + ".*"; 
    94                         } 
    95                 }; 
     90                                ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE); 
    9691                dialog.setTitle("AS3 Target"); 
    9792                dialog.setMessage("Select AS3 Target"); 
    9893                if (dialog.open() == Window.OK) { 
    9994                        Object[] files = dialog.getResult(); 
    100                         IFile file = (IFile) files[0]; 
    101                         target.setText(file.getFullPath().toString()); 
     95                        if (files.length > 0) { 
     96                                IFile file = (IFile) files[0]; 
     97                                target.setText(file.getFullPath().toString()); 
     98                        } 
    10299                } 
    103100        } 
     
    107104                                .getWorkspace().getRoot(), new ProjectSelectionContentProvider(), 
    108105                                new WorkbenchLabelProvider(), "Select the project:"); 
    109                 // ProjectSelectionDialog dialog = new 
    110                 // ProjectSelectionDialog(getShell()); 
    111106                dialog.setTitle("AS3 Project"); 
    112107                dialog.setMessage("Select AS3 Project"); 
    113                 if (dialog.open() == Window.OK) { 
     108                int status = dialog.open(); 
     109                if (status == Window.OK) { 
    114110                        Object[] files = dialog.getResult(); 
    115                         IPath file = (IPath) files[0]; 
    116                         project.setText(file.toString()); 
     111                        if (files.length > 0) { 
     112                                IProject file = (IProject) files[0]; 
     113                                project.setText(file.getFullPath().toString()); 
     114                        } 
    117115                } 
    118116        } 
  • axdt/trunk/org.axdt.as3.debug/src/org/axdt/as3/debug/preferences/AS3DebugPreferencePage.java

    r87 r102  
    88                super(AS3DebugPreferences.getInstance()); 
    99        } 
    10  
    1110} 
  • axdt/trunk/org.axdt.as3.debug/src/org/axdt/as3/debug/preferences/AS3DebugPreferences.java

    r92 r102  
    11package org.axdt.as3.debug.preferences; 
    22 
     3import java.net.URI; 
     4import java.net.URISyntaxException; 
     5 
    36import org.axdt.as3.debug.AS3DebugPlugin; 
    4 import org.axdt.as3.preferences.AS3Preferences; 
    57import org.axdt.preferences.AbstractPreferences; 
     8import org.eclipse.core.resources.ResourcesPlugin; 
     9import org.eclipse.core.runtime.IPath; 
    610import org.eclipse.jface.preference.IPreferenceStore; 
    711 
    812public class AS3DebugPreferences extends AbstractPreferences { 
    913 
    10         private static final String OPEN_SWF = "OPEN_SWF"; 
    11         private static final String USE_SWFVIEW = "USE_SWFVIEW"; 
    12         private static final String USE_BROWSER = "USE_BROWSER"; 
    13         private static final String USE_ALT_PATH = "USE_ALT_PATH"; 
    14         private static final String ALT_PATH = "ALT_PATH"; 
     14        public static final String OPEN_SWF = "OPEN_SWF"; 
     15        public static final String OPEN_WITH = "OPEN_WITH"; 
     16        public static final String CHOICE_SWFVIEW = "CHOICE_SWFVIEW"; 
     17        public static final String CHOICE_BROWSER = "CHOICE_BROWSER"; 
     18        public static final String USE_ALT_PATH = "USE_ALT_PATH"; 
     19        public static final String ALT_PATH = "ALT_PATH"; 
    1520 
    1621        private static AS3DebugPreferences instance; 
     
    3439        public void initializeFieldSpecs() { 
    3540                addGroup("Browser", ""); 
    36                 add(OPEN_SWF, "Open compiled SWF files", true); 
    37                 // todo add radio group 
    38                 add(USE_SWFVIEW, "Use SWFView", true); 
    39                 add(USE_BROWSER, "Use system browser", true); 
     41                add(OPEN_SWF, "&Open compiled SWF files", true); 
     42                add(OPEN_WITH, "&Use", new String[][] {new String[] {"internal SWFView", CHOICE_SWFVIEW}, 
     43                                new String[] {"system browser", CHOICE_BROWSER}}); 
    4044                addGroup("Launch path", ""); 
    41                 add(USE_ALT_PATH, "Use alternative path", false); 
    42                 IPreferenceStore store = AS3Preferences.getInstance().getStore(); 
    43                 add(ALT_PATH, "Path to use", store.getString(AS3Preferences.DEPLOY_PATH)); 
     45                add(USE_ALT_PATH, "Use &alternative path", false); 
     46                add(ALT_PATH, "&Path, use [[PROJ]], [[FILE]], [[EXT]] as placeholders", 
     47                                "http://localhost/[[PROJ]]/[[FILE]].html"); 
     48        } 
     49 
     50        public URI alterDeployLocation(IPath deployFile) throws URISyntaxException { 
     51                IPreferenceStore store = getStore(); 
     52                boolean useAlt = store.getBoolean(AS3DebugPreferences.USE_ALT_PATH); 
     53                if (!useAlt) return deployFile.toFile().toURI(); 
     54                String pathStr = store.getString(AS3DebugPreferences.ALT_PATH); 
     55                IPath file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(deployFile) 
     56                                .getFullPath(); 
     57                pathStr = pathStr.replace("[[FULL_PATH]]", file.toOSString().substring(1)); 
     58                pathStr = pathStr.replace("[[PROJ]]", file.segment(0)); 
     59                pathStr = pathStr.replace("[[FILE]]", deployFile.removeFileExtension().lastSegment()); 
     60                pathStr = pathStr.replace("[[EXT]]", deployFile.getFileExtension()); 
     61                return new URI(pathStr); 
    4462        } 
    4563} 
  • axdt/trunk/org.axdt.common/src/org/axdt/preferences/AbstractPreferencePage.java

    r92 r102  
    7070        public void init(IWorkbench workbench) { 
    7171        } 
    72  
    73         public boolean performOk() { 
    74                 if (!super.performOk()) return false; 
    75                 return true; 
    76         } 
    7772} 
  • axdt/trunk/org.axdt.common/src/org/axdt/preferences/AbstractPreferences.java

    r92 r102  
    7777        } 
    7878 
     79        protected FieldSpec add(String key, String desc, String defValue, boolean absolute, String[] extensions) { 
     80                return add(new FileField(key, desc, defValue, absolute, extensions)); 
     81        } 
     82 
     83        protected FieldSpec add(String key, String desc, String[][] choices) { 
     84                return add(new ComboField(key, desc, choices)); 
     85        } 
     86 
    7987        protected FieldSpec add(String key, String desc, String defValue) { 
    8088                return add(new StringField(key, desc, defValue)); 
  • axdt/trunk/org.axdt.common/src/org/axdt/preferences/FieldSpec.java

    r92 r102  
    33import org.eclipse.core.runtime.preferences.IEclipsePreferences; 
    44import org.eclipse.jface.preference.BooleanFieldEditor; 
     5import org.eclipse.jface.preference.ComboFieldEditor; 
    56import org.eclipse.jface.preference.FieldEditor; 
     7import org.eclipse.jface.preference.FileFieldEditor; 
    68import org.eclipse.jface.preference.IntegerFieldEditor; 
    79import org.eclipse.jface.preference.StringFieldEditor; 
     
    6668        } 
    6769} 
     70 
     71class ComboField extends FieldSpec { 
     72 
     73        public ComboField(String key, String desc, String[][] choices) { 
     74                super(key, desc, choices); 
     75        } 
     76 
     77        public FieldEditor createFieldEditor(Composite comp) { 
     78                return new ComboFieldEditor(key, desc, getChoices(), comp); 
     79        } 
     80 
     81        public void setDefault(IEclipsePreferences store) { 
     82                store.put(key, getChoices()[0][1]); 
     83        } 
     84 
     85        public String[][] getChoices() { 
     86                return (String[][]) defValue; 
     87        } 
     88} 
     89 
     90class FileField extends FieldSpec { 
     91        protected String[] extensions; 
     92        protected boolean absolute; 
     93 
     94        public FileField(String key, String desc, String defValue, boolean absolute, String[] extensions) { 
     95                super(key, desc, defValue); 
     96                this.absolute = absolute; 
     97                this.extensions = extensions; 
     98        } 
     99 
     100        public FieldEditor createFieldEditor(Composite comp) { 
     101                FileFieldEditor editor = new FileFieldEditor(key, desc, absolute, comp); 
     102                editor.setFileExtensions(extensions); 
     103                if ("".equals(defValue)) editor.setEmptyStringAllowed(true); 
     104                return editor; 
     105        } 
     106 
     107        public void setDefault(IEclipsePreferences store) { 
     108                store.put(key, (String) defValue); 
     109        } 
     110} 
  • axdt/trunk/org.axdt.flex3sdk.compiler/src/org/axdt/flex3sdk/preferences/FlexPreferences.java

    r92 r102  
    2828 
    2929        public void initializeFieldSpecs() { 
    30                 add(FLEX_CONFIG_FILE, "Flex config file", Flex3SDKPlugin.getBundleURL( 
    31                                 new Path("flexsdk/frameworks/flex-config.xml")).getPath()); 
     30                Path path = new Path("flexsdk/frameworks/flex-config.xml"); 
     31                String pathStr = Flex3SDKPlugin.getBundleURL(path).getPath(); 
     32                add(FLEX_CONFIG_FILE, "Flex config file", pathStr, true, null); 
    3233                add(GENERATE_REPORT, "Generate Reports", false); 
    3334        }