1 11 package org.eclipse.ant.internal.ui.preferences; 12 13 14 import java.util.ArrayList ; 15 import java.util.Arrays ; 16 import java.util.List ; 17 import org.eclipse.ant.core.AntCorePlugin; 18 import org.eclipse.ant.core.AntCorePreferences; 19 import org.eclipse.ant.core.Property; 20 import org.eclipse.ant.core.Task; 21 import org.eclipse.ant.core.Type; 22 import org.eclipse.ant.internal.ui.AntUIPlugin; 23 import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; 24 import org.eclipse.jface.preference.PreferencePage; 25 import org.eclipse.swt.SWT; 26 import org.eclipse.swt.layout.GridData; 27 import org.eclipse.swt.widgets.Button; 28 import org.eclipse.swt.widgets.Composite; 29 import org.eclipse.swt.widgets.Control; 30 import org.eclipse.swt.widgets.TabFolder; 31 import org.eclipse.ui.IWorkbench; 32 import org.eclipse.ui.IWorkbenchPreferencePage; 33 import org.eclipse.ui.PlatformUI; 34 35 38 public class AntRuntimePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 39 40 private AntClasspathPage classpathPage; 41 private AntTasksPage tasksPage; 42 private AntTypesPage typesPage; 43 private AntPropertiesPage propertiesPage; 44 45 48 public AntRuntimePreferencePage() { 49 setDescription(AntPreferencesMessages.AntPreferencePage_description); 50 setPreferenceStore(AntUIPlugin.getDefault().getPreferenceStore()); 51 } 52 53 56 public void init(IWorkbench workbench) { 57 } 58 59 62 protected Control createContents(Composite parent) { 63 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IAntUIHelpContextIds.ANT_RUNTIME_PREFERENCE_PAGE); 64 initializeDialogUnits(parent); 65 66 TabFolder folder = new TabFolder(parent, SWT.NONE); 67 folder.setLayout(new TabFolderLayout()); 68 folder.setLayoutData(new GridData(GridData.FILL_BOTH)); 69 folder.setFont(parent.getFont()); 70 71 classpathPage = new AntClasspathPage(this); 72 classpathPage.createTabItem(folder); 73 74 tasksPage = new AntTasksPage(this); 75 tasksPage.createTabItem(folder); 76 77 typesPage = new AntTypesPage(this); 78 typesPage.createTabItem(folder); 79 80 propertiesPage= new AntPropertiesPage(this); 81 propertiesPage.createTabItem(folder); 82 83 tasksPage.initialize(); 84 typesPage.initialize(); 85 classpathPage.initialize(); 86 propertiesPage.initialize(); 87 88 return folder; 89 } 90 91 94 protected void performDefaults() { 95 super.performDefaults(); 96 97 AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences(); 98 tasksPage.setInput(prefs.getDefaultTasks()); 99 typesPage.setInput(prefs.getDefaultTypes()); 100 classpathPage.performDefaults(); 101 propertiesPage.performDefaults(); 102 } 103 104 107 public boolean performOk() { 108 AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences(); 109 110 prefs.setAntHomeClasspathEntries(classpathPage.getAntHomeEntries()); 111 112 113 prefs.setAdditionalClasspathEntries(classpathPage.getAdditionalEntries()); 114 115 String antHome= classpathPage.getAntHome(); 116 prefs.setAntHome(antHome); 117 118 List contents = tasksPage.getContents(false); 119 if (contents != null) { 120 Task[] tasks = (Task[]) contents.toArray(new Task[contents.size()]); 121 prefs.setCustomTasks(tasks); 122 } 123 124 contents = typesPage.getContents(false); 125 if (contents != null) { 126 Type[] types = (Type[]) contents.toArray(new Type[contents.size()]); 127 prefs.setCustomTypes(types); 128 } 129 130 contents = propertiesPage.getProperties(); 131 if (contents != null) { 132 Property[] properties = (Property[]) contents.toArray(new Property[contents.size()]); 133 prefs.setCustomProperties(properties); 134 } 135 136 String [] files = propertiesPage.getPropertyFiles(); 137 prefs.setCustomPropertyFiles(files); 138 139 prefs.updatePluginPreferences(); 140 141 return super.performOk(); 142 } 143 144 147 protected GridData setButtonLayoutData(Button button) { 148 return super.setButtonLayoutData(button); 149 } 150 151 protected List getLibraryEntries() { 152 List urls= new ArrayList (); 153 urls.addAll(Arrays.asList(classpathPage.getAntHomeEntries())); 154 urls.addAll(Arrays.asList(classpathPage.getAdditionalEntries())); 155 urls.addAll(Arrays.asList(classpathPage.getContributedEntries())); 156 return urls; 157 } 158 } 159 | Popular Tags |