1 11 package org.eclipse.ant.internal.ui.launchConfigurations; 12 13 import org.eclipse.ant.internal.ui.AntUtil; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.ui.ILaunchConfigurationTab; 17 import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab; 18 import org.eclipse.jdt.internal.debug.ui.actions.AddExternalJarAction; 19 import org.eclipse.jdt.internal.debug.ui.actions.AddFolderAction; 20 import org.eclipse.jdt.internal.debug.ui.actions.AddJarAction; 21 import org.eclipse.jdt.internal.debug.ui.actions.MoveDownAction; 22 import org.eclipse.jdt.internal.debug.ui.actions.MoveUpAction; 23 import org.eclipse.jdt.internal.debug.ui.actions.RemoveAction; 24 import org.eclipse.jdt.internal.debug.ui.actions.RestoreDefaultEntriesAction; 25 import org.eclipse.jdt.internal.debug.ui.actions.RuntimeClasspathAction; 26 import org.eclipse.jdt.internal.debug.ui.classpath.ClasspathEntry; 27 import org.eclipse.jdt.internal.debug.ui.classpath.ClasspathModel; 28 import org.eclipse.jdt.internal.debug.ui.classpath.IClasspathEntry; 29 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer; 30 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; 31 import org.eclipse.swt.widgets.Button; 32 import org.eclipse.swt.widgets.Composite; 33 34 37 public class AntClasspathTab extends JavaClasspathTab { 38 39 40 43 public boolean isShowBootpath() { 44 return false; 45 } 46 47 53 protected void createPathButtons(Composite pathButtonComp) { 54 createButton(pathButtonComp, new MoveUpAction(fClasspathViewer)); 55 createButton(pathButtonComp, new MoveDownAction(fClasspathViewer)); 56 createButton(pathButtonComp, new RemoveAction(fClasspathViewer)); 57 createButton(pathButtonComp, new AddJarAction(fClasspathViewer)); 58 createButton(pathButtonComp, new AddExternalJarAction(fClasspathViewer, DIALOG_SETTINGS_PREFIX)); 59 Button button = createButton(pathButtonComp, new AddFolderAction(fClasspathViewer)); 60 button.setText(AntLaunchConfigurationMessages.AntClasspathTab_0); 61 createButton(pathButtonComp, new AddVariableStringAction(fClasspathViewer)); 62 RuntimeClasspathAction action= new RestoreDefaultEntriesAction(fClasspathViewer, this); 63 createButton(pathButtonComp, action); 64 action.setEnabled(true); 65 66 action= new EditAntHomeEntryAction(fClasspathViewer, this); 67 createButton(pathButtonComp, action); 68 action.setEnabled(true); 69 } 70 71 74 public void setDirty(boolean dirty) { 75 super.setDirty(dirty); 76 } 77 78 79 82 public void initializeFrom(ILaunchConfiguration configuration) { 83 try { 84 AntUtil.migrateToNewClasspathFormat(configuration); 85 } catch (CoreException e) { 86 } 87 super.initializeFrom(configuration); 88 } 89 92 public void entriesChanged(IClasspathViewer viewer) { 93 super.entriesChanged(viewer); 94 ILaunchConfigurationTab[] tabs = getLaunchConfigurationDialog().getTabs(); 95 for (int i = 0; i < tabs.length; i++) { 96 ILaunchConfigurationTab tab = tabs[i]; 97 if (tab instanceof AntTargetsTab) { 98 ((AntTargetsTab)tab).setDirty(true); 99 } 100 } 101 } 102 103 106 public boolean isValid(ILaunchConfiguration launchConfig) { 107 108 boolean valid= super.isValid(launchConfig); 109 if (!valid) { 110 return false; 111 } 112 113 return validateAntHome(); 114 } 115 116 private boolean validateAntHome() { 117 ClasspathModel model= getModel(); 118 IClasspathEntry userEntry= model.getUserEntry(); 119 IClasspathEntry[] entries= userEntry.getEntries(); 120 for (int i = 0; i < entries.length; i++) { 121 ClasspathEntry entry = (ClasspathEntry) entries[i]; 122 IRuntimeClasspathEntry runtimeEntry= entry.getDelegate(); 123 if (runtimeEntry instanceof AntHomeClasspathEntry) { 124 try { 125 ((AntHomeClasspathEntry)runtimeEntry).resolveAntHome(); 126 } catch (CoreException ce) { 127 setErrorMessage(ce.getStatus().getMessage()); 128 return false; 129 } 130 break; 131 } 132 } 133 return true; 134 } 135 } 136 | Popular Tags |