View | Details | Raw Unified | Return to bug 309045 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+6 lines)
Lines 227-232 Link Here
227
            class="org.eclipse.photran.internal.ui.preferences.CDTFortranPreferencePage"
227
            class="org.eclipse.photran.internal.ui.preferences.CDTFortranPreferencePage"
228
            id="org.eclipse.photran.ui.CDTFortranPreferencePage">
228
            id="org.eclipse.photran.ui.CDTFortranPreferencePage">
229
      </page>
229
      </page>
230
      <page
231
            name="CPP File Types"
232
            category="org.eclipse.photran.ui.MainFortranPreferencePage"
233
            class="org.eclipse.photran.internal.ui.preferences.CppFileTypesPreferencePage"
234
            id="org.eclipse.photran.ui.CppFileTypesPreferencePage">
235
      </page>
230
   </extension>
236
   </extension>
231
237
232
   <!--=========================================-->
238
   <!--=========================================-->
(-)src/org/eclipse/photran/internal/ui/preferences/CppFileTypesPreferencePage.java (+43 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    UIUC - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.photran.internal.ui.preferences;
12
13
import org.eclipse.jface.preference.StringFieldEditor;
14
import org.eclipse.photran.internal.core.preferences.FortranPreferences;
15
16
/**
17
 * 
18
 * @author Kurt Hendle
19
 */
20
public class CppFileTypesPreferencePage extends AbstractFortranPreferencePage
21
{
22
    protected void setDescrption()
23
    {
24
    }
25
    
26
    protected void initializeDefaults()
27
    {
28
        FortranPreferences.CPP_FIXED_FORM_TYPES.setDefault();
29
        FortranPreferences.CPP_FREE_FORM_TYPES.setDefault();
30
    }
31
    
32
    protected void createFieldEditors()
33
    {
34
        addField(new StringFieldEditor(FortranPreferences.CPP_FIXED_FORM_TYPES.getName(), 
35
                                        "Fixed Form file types", 
36
                                        getFieldEditorParent()));
37
        
38
        addField(new StringFieldEditor(FortranPreferences.CPP_FREE_FORM_TYPES.getName(), 
39
                                        "Free Form file types", 
40
                                        getFieldEditorParent()));
41
    }
42
43
}
(-)src/org/eclipse/photran/internal/ui/properties/CPPFileTypeEditor.java (+97 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.photran.internal.ui.properties;
12
13
import java.util.Arrays;
14
15
import org.eclipse.jface.preference.ListEditor;
16
import org.eclipse.jface.viewers.ArrayContentProvider;
17
import org.eclipse.jface.viewers.LabelProvider;
18
import org.eclipse.photran.internal.core.properties.SearchPathProperties;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.ui.dialogs.ListDialog;
22
23
/**
24
 * A field editor to edit which file types to send to the C Preprocessor.
25
 * 
26
 * @author Jeff Overbey, Kurt Hendle
27
 */
28
public class CPPFileTypeEditor extends ListEditor
29
{
30
    private String[] fileTypes;
31
    /**
32
     * The special label text for  chooser, 
33
     * or <code>null</code> if none.
34
     */
35
    private String fileTypeInputLabelText;
36
37
    /**
38
     * Creates a new path field editor 
39
     */
40
    protected CPPFileTypeEditor()
41
    {
42
    }
43
44
    /**
45
     * Creates a CPP file type chooser.
46
     * 
47
     * @param name the name of the preference this field editor works on
48
     * @param labelText the label text of the field editor
49
     * @param fileTypes an array of file types to be available in the list
50
     * @param typeChooserText the label text displayed for the directory chooser
51
     * @param parent the parent of the field editor's control
52
     */
53
    public CPPFileTypeEditor(String name, String labelText, String[] fileTypes, String typeChooserText, Composite parent)
54
    {
55
        parent = new Composite(parent, SWT.NONE);
56
        init(name, labelText);
57
        this.fileTypes = fileTypes;
58
        this.fileTypeInputLabelText = typeChooserText;
59
        createControl(parent);
60
    }
61
62
    /* (non-Javadoc)
63
     * Method declared on ListEditor.
64
     * Creates a new path element by means of a directory dialog.
65
     */
66
    protected String getNewInputObject()
67
    {   
68
        //set up the list dialog box
69
        ListDialog dialog = new ListDialog(getShell());
70
        dialog.setInput(fileTypes);
71
        dialog.setContentProvider(new ArrayContentProvider()); 
72
        dialog.setLabelProvider(new LabelProvider()); 
73
        dialog.setMessage(fileTypeInputLabelText);
74
        
75
        if (dialog.open() == ListDialog.OK)
76
        {
77
            //result is returned as an object array, must convert it to string and return string
78
            Object[] selection = dialog.getResult();
79
            String [] type = Arrays.asList(selection).toArray(new String[selection.length]);
80
            return type[0];
81
        }
82
        
83
        return null;
84
    }
85
86
    @Override
87
    protected String createList(String[] items)
88
    {
89
        return SearchPathProperties.createList(items);
90
    }
91
92
    @Override
93
    protected String[] parseString(String stringList)
94
    {
95
        return SearchPathProperties.parseString(stringList);
96
    }
97
}
(-)src/org/eclipse/photran/internal/ui/properties/SearchPathsPropertyPage.java (+26 lines)
Lines 106-111 Link Here
106
106
107
    private FortranBooleanFieldEditor enableVPG, enableDeclView, enableContentAssist, enableHoverTip;
107
    private FortranBooleanFieldEditor enableVPG, enableDeclView, enableContentAssist, enableHoverTip;
108
    private WorkspacePathEditor modulePathEditor, includePathEditor;
108
    private WorkspacePathEditor modulePathEditor, includePathEditor;
109
    private CPPFileTypeEditor fixedFormEditor, freeFormEditor;
109
    
110
    
110
    /**
111
    /**
111
     * @see PreferencePage#createContents(Composite)
112
     * @see PreferencePage#createContents(Composite)
Lines 208-213 Link Here
208
        includePathEditor.setPreferenceStore(scopedStore);
209
        includePathEditor.setPreferenceStore(scopedStore);
209
        includePathEditor.load();
210
        includePathEditor.load();
210
        
211
        
212
        l = new Label(composite, SWT.WRAP);
213
        l.setText("The following specify the types of fixed form and free form\n" +
214
        		  "Fortran files you wish to be processed by the C preprocessor.");
215
        l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
216
        
217
        fixedFormEditor = new CPPFileTypeEditor(SearchPathProperties.FIXED_FORM_CPP_TYPES_PROPERTY_NAME,
218
            "Fixed form file types to be C preprocessed", 
219
           new String[] { "F77","fpp","F","FOR","FTN","FIX","FPP" },
220
           "Please choose a fixed form file type",
221
            parent);
222
        
223
        fixedFormEditor.setPreferenceStore(scopedStore);
224
        fixedFormEditor.load();
225
        
226
        freeFormEditor = new CPPFileTypeEditor(SearchPathProperties.FREE_FORM_CPP_TYPES_PROPERTY_NAME,
227
            "Free form file types to be C preprocessed", 
228
            new String[] { "F90","F95","F03","F08" },
229
            "Please choose a free form file type",
230
            parent);
231
        
232
        freeFormEditor.setPreferenceStore(scopedStore);
233
        freeFormEditor.load();
234
        
235
        
236
        
211
        return composite;
237
        return composite;
212
    }
238
    }
213
239

Return to bug 309045