1 11 package org.eclipse.pde.internal.ui.preferences; 12 13 14 import java.io.BufferedInputStream ; 15 import java.io.IOException ; 16 import java.io.InputStream ; 17 import java.net.URL ; 18 import java.util.ArrayList ; 19 import java.util.StringTokenizer ; 20 21 import org.eclipse.core.resources.IFile; 22 import org.eclipse.core.runtime.CoreException; 23 import org.eclipse.core.runtime.IConfigurationElement; 24 import org.eclipse.core.runtime.IPath; 25 import org.eclipse.core.runtime.Path; 26 import org.eclipse.core.runtime.Preferences; 27 import org.eclipse.core.variables.IStringVariableManager; 28 import org.eclipse.core.variables.VariablesPlugin; 29 import org.eclipse.jface.dialogs.Dialog; 30 import org.eclipse.jface.dialogs.IDialogConstants; 31 import org.eclipse.jface.dialogs.MessageDialog; 32 import org.eclipse.jface.preference.PreferencePage; 33 import org.eclipse.jface.window.Window; 34 import org.eclipse.jface.wizard.WizardDialog; 35 import org.eclipse.pde.core.plugin.IPluginModelBase; 36 import org.eclipse.pde.core.plugin.TargetPlatform; 37 import org.eclipse.pde.internal.core.ICoreConstants; 38 import org.eclipse.pde.internal.core.PDECore; 39 import org.eclipse.pde.internal.core.PDEState; 40 import org.eclipse.pde.internal.core.TargetDefinitionManager; 41 import org.eclipse.pde.internal.core.itarget.IAdditionalLocation; 42 import org.eclipse.pde.internal.core.itarget.ILocationInfo; 43 import org.eclipse.pde.internal.core.itarget.ITarget; 44 import org.eclipse.pde.internal.core.itarget.ITargetModel; 45 import org.eclipse.pde.internal.core.target.TargetModel; 46 import org.eclipse.pde.internal.ui.IHelpContextIds; 47 import org.eclipse.pde.internal.ui.PDEPlugin; 48 import org.eclipse.pde.internal.ui.PDEUIMessages; 49 import org.eclipse.pde.internal.ui.editor.target.OpenTargetProfileAction; 50 import org.eclipse.pde.internal.ui.util.FileExtensionFilter; 51 import org.eclipse.pde.internal.ui.util.FileValidator; 52 import org.eclipse.pde.internal.ui.util.SWTUtil; 53 import org.eclipse.pde.internal.ui.wizards.target.NewTargetDefinitionWizard; 54 import org.eclipse.swt.SWT; 55 import org.eclipse.swt.custom.BusyIndicator; 56 import org.eclipse.swt.events.ModifyEvent; 57 import org.eclipse.swt.events.ModifyListener; 58 import org.eclipse.swt.events.SelectionAdapter; 59 import org.eclipse.swt.events.SelectionEvent; 60 import org.eclipse.swt.layout.GridData; 61 import org.eclipse.swt.layout.GridLayout; 62 import org.eclipse.swt.widgets.Button; 63 import org.eclipse.swt.widgets.Combo; 64 import org.eclipse.swt.widgets.Composite; 65 import org.eclipse.swt.widgets.Control; 66 import org.eclipse.swt.widgets.DirectoryDialog; 67 import org.eclipse.swt.widgets.Group; 68 import org.eclipse.swt.widgets.Label; 69 import org.eclipse.swt.widgets.Link; 70 import org.eclipse.swt.widgets.TabFolder; 71 import org.eclipse.swt.widgets.TabItem; 72 import org.eclipse.ui.IWorkbench; 73 import org.eclipse.ui.IWorkbenchPreferencePage; 74 import org.eclipse.ui.PlatformUI; 75 import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; 76 import org.eclipse.ui.model.WorkbenchContentProvider; 77 import org.eclipse.ui.model.WorkbenchLabelProvider; 78 79 public class TargetPlatformPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 80 81 public static final int PLUGINS_INDEX = 0; 82 public static final int ENVIRONMENT_INDEX = 1; 83 public static final int SOURCE_INDEX = 4; 84 85 private Label fHomeLabel; 86 private Combo fHomeText; 87 private Combo fProfileCombo; 88 private Button fBrowseButton; 89 private Button fLoadProfileButton; 90 91 private TargetPluginsTab fPluginsTab; 92 private TargetEnvironmentTab fEnvironmentTab; 93 private JavaArgumentsTab fArgumentsTab; 94 private TargetImplicitPluginsTab fImplicitDependenciesTab; 95 private TargetSourceTab fSourceTab; 96 private IConfigurationElement [] fElements; 97 98 private Preferences fPreferences = null; 99 protected boolean fNeedsReload = false; 100 private String fOriginalText; 101 private int fIndex; 102 private TabFolder fTabFolder; 103 private boolean fContainsWorkspaceProfile = false; 104 private Button fResetButton; 105 106 109 public TargetPlatformPreferencePage() { 110 this(PLUGINS_INDEX); 111 } 112 113 public TargetPlatformPreferencePage(int index) { 114 setDescription(PDEUIMessages.Preferences_TargetPlatformPage_Description); 115 fPreferences = PDECore.getDefault().getPluginPreferences(); 116 fPluginsTab = new TargetPluginsTab(this); 117 fIndex = index; 118 } 119 120 public void dispose() { 121 if (fPluginsTab != null) 123 fPluginsTab.dispose(); 124 if (fSourceTab != null) 125 fSourceTab.dispose(); 126 super.dispose(); 127 } 128 129 public Control createContents(Composite parent) { 130 Composite container = new Composite(parent, SWT.NONE); 131 GridLayout layout = new GridLayout(); 132 layout.marginHeight = layout.marginWidth = 0; 133 container.setLayout(layout); 134 135 createCurrentTargetPlatformGroup(container); 136 createTargetProfilesGroup(container); 137 138 Dialog.applyDialogFont(container); 139 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.TARGET_PLATFORM_PREFERENCE_PAGE); 140 return container; 141 } 142 143 private void createTargetProfilesGroup(Composite container) { 144 Group profiles = new Group(container, SWT.NONE); 145 profiles.setText(PDEUIMessages.TargetPlatformPreferencePage_TargetGroupTitle); 146 profiles.setLayout(new GridLayout(4, false)); 147 profiles.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 148 149 Link profile = new Link(profiles, SWT.NONE); 150 profile.setText(PDEUIMessages.TargetPlatformPreferencePage_CurrentProfileLabel); 151 profile.addSelectionListener(new SelectionAdapter() { 152 public void widgetSelected(SelectionEvent e) { 153 if (!fProfileCombo.getText().equals("")) new OpenTargetProfileAction(getShell(), getTargetModel(), fProfileCombo.getText()).run(); 155 else 156 openTargetWizard(); 157 } 158 }); 159 160 fProfileCombo = new Combo(profiles, SWT.BORDER | SWT.READ_ONLY); 161 loadTargetCombo(); 162 fProfileCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 163 164 Button browse = new Button(profiles, SWT.PUSH); 165 browse.setText(PDEUIMessages.TargetPlatformPreferencePage_BrowseButton); 166 GridData gd = new GridData(); 167 browse.setLayoutData(gd); 168 browse.addSelectionListener(new SelectionAdapter() { 169 public void widgetSelected(SelectionEvent e) { 170 handleTargetBrowse(); 171 } 172 }); 173 SWTUtil.setButtonDimensionHint(browse); 174 175 fLoadProfileButton = new Button(profiles, SWT.PUSH); 176 fLoadProfileButton.setText(PDEUIMessages.TargetPlatformPreferencePage_ApplyButton); 177 fLoadProfileButton.setLayoutData(new GridData()); 178 fLoadProfileButton.addSelectionListener(new SelectionAdapter() { 179 public void widgetSelected(SelectionEvent e) { 180 handleLoadTargetProfile(); 181 } 182 }); 183 fLoadProfileButton.setEnabled(!fProfileCombo.getText().equals("")); 185 fProfileCombo.addSelectionListener(new SelectionAdapter() { 186 public void widgetSelected(SelectionEvent e) { 187 fLoadProfileButton.setEnabled(!fProfileCombo.getText().equals("")); } 189 }); 190 191 SWTUtil.setButtonDimensionHint(fLoadProfileButton); 192 } 193 194 private void createCurrentTargetPlatformGroup(Composite container) { 195 Composite target = new Composite(container, SWT.NONE); 196 GridLayout layout = new GridLayout(4, false); 197 layout.marginHeight = layout.marginWidth = 0; 198 target.setLayout(layout); 199 target.setLayoutData(new GridData(GridData.FILL_BOTH)); 200 201 fHomeLabel = new Label(target, SWT.NULL); 202 fHomeLabel.setText(PDEUIMessages.Preferences_TargetPlatformPage_PlatformHome); 203 204 fHomeText = new Combo(target, SWT.NONE); 205 fHomeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 206 ArrayList locations = new ArrayList (); 207 for (int i = 0; i < 5; i++) { 208 String value = fPreferences.getString(ICoreConstants.SAVED_PLATFORM + i); 209 if (value.equals("")) break; 211 locations.add(value); 212 } 213 String homeLocation = fPreferences.getString(ICoreConstants.PLATFORM_PATH); 214 if (!locations.contains(homeLocation)) 215 locations.add(0, homeLocation); 216 fHomeText.setItems((String [])locations.toArray(new String [locations.size()])); 217 fHomeText.setText(homeLocation); 218 fOriginalText = fHomeText.getText(); 219 fHomeText.addModifyListener(new ModifyListener() { 220 public void modifyText(ModifyEvent e) { 221 fNeedsReload = true; 222 } 223 }); 224 225 fBrowseButton = new Button(target, SWT.PUSH); 226 fBrowseButton.setText(PDEUIMessages.Preferences_TargetPlatformPage_PlatformHome_Button); 227 fBrowseButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 228 SWTUtil.setButtonDimensionHint(fBrowseButton); 229 fBrowseButton.addSelectionListener(new SelectionAdapter() { 230 public void widgetSelected(SelectionEvent e) { 231 handleBrowse(); 232 } 233 }); 234 235 fResetButton = new Button(target, SWT.PUSH); 236 fResetButton.setText(PDEUIMessages.TargetPlatformPreferencePage_reset); 237 fResetButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 238 SWTUtil.setButtonDimensionHint(fResetButton); 239 fResetButton.addSelectionListener(new SelectionAdapter() { 240 public void widgetSelected(SelectionEvent e) { 241 fHomeText.setText(TargetPlatform.getDefaultLocation()); 242 fPluginsTab.handleReload(new ArrayList ()); 243 resetTargetProfile(); 244 } 245 }); 246 247 fTabFolder = new TabFolder(target, SWT.NONE); 248 GridData gd = new GridData(GridData.FILL_BOTH); 249 gd.horizontalSpan = 4; 250 fTabFolder.setLayoutData(gd); 251 252 BusyIndicator.showWhile(getShell().getDisplay(), new Runnable () { 253 public void run() { 254 createPluginsTab(fTabFolder); 255 createEnvironmentTab(fTabFolder); 256 createArgumentsTab(fTabFolder); 257 createExplicitTab(fTabFolder); 258 createSourceTab(fTabFolder); 259 fTabFolder.setSelection(fIndex); 260 } 261 }); 262 263 fTabFolder.addSelectionListener(new SelectionAdapter() { 264 public void widgetSelected(SelectionEvent e) { 265 if (fTabFolder.getSelectionIndex() == ENVIRONMENT_INDEX) { 266 fEnvironmentTab.updateChoices(); 267 } 268 } 269 }); 270 } 271 272 private void createPluginsTab(TabFolder folder) { 273 Control block = fPluginsTab.createContents(folder); 274 block.setLayoutData(new GridData(GridData.FILL_BOTH)); 275 fPluginsTab.initialize(); 276 277 TabItem tab = new TabItem(folder, SWT.NONE); 278 tab.setText(PDEUIMessages.TargetPlatformPreferencePage_pluginsTab); 279 tab.setControl(block); 280 } 281 282 private void createEnvironmentTab(TabFolder folder) { 283 fEnvironmentTab = new TargetEnvironmentTab(this); 284 Control block = fEnvironmentTab.createContents(folder); 285 286 TabItem tab = new TabItem(folder, SWT.NONE); 287 tab.setText(PDEUIMessages.TargetPlatformPreferencePage_environmentTab); 288 tab.setControl(block); 289 } 290 291 private void createSourceTab(TabFolder folder) { 292 fSourceTab = new TargetSourceTab(this); 293 Control block = fSourceTab.createContents(folder); 294 295 TabItem tab = new TabItem(folder, SWT.NONE); 296 tab.setText(PDEUIMessages.TargetPlatformPreferencePage_sourceCode); 297 tab.setControl(block); 298 } 299 300 private void createExplicitTab(TabFolder folder) { 301 fImplicitDependenciesTab = new TargetImplicitPluginsTab(this); 302 Control block = fImplicitDependenciesTab.createContents(folder); 303 304 TabItem tab = new TabItem(folder, SWT.NONE); 305 tab.setText(PDEUIMessages.TargetPlatformPreferencePage_implicitTab); 306 tab.setControl(block); 307 } 308 309 private void createArgumentsTab(TabFolder folder) { 310 fArgumentsTab = new JavaArgumentsTab(this); 311 Control block = fArgumentsTab.createControl(folder); 312 313 TabItem tab = new TabItem(folder, SWT.NONE); 314 tab.setText(PDEUIMessages.TargetPlatformPreferencePage_agrumentsTab); 315 tab.setControl(block); 316 } 317 318 String getPlatformPath() { 319 return fHomeText.getText(); 320 } 321 322 private void handleBrowse() { 323 DirectoryDialog dialog = new DirectoryDialog(getShell()); 324 dialog.setMessage(PDEUIMessages.TargetPlatformPreferencePage_chooseInstall); 325 if (fHomeText.getText().length() > 0) 326 dialog.setFilterPath(fHomeText.getText()); 327 String newPath = dialog.open(); 328 if (newPath != null && !new Path(fHomeText.getText()).equals(new Path(newPath))) { 329 if (fHomeText.indexOf(newPath) == -1) 330 fHomeText.add(newPath, 0); 331 fHomeText.setText(newPath); 332 fPluginsTab.handleReload(new ArrayList ()); 333 fNeedsReload = false; 334 resetTargetProfile(); 335 } 336 } 337 338 private void loadTargetCombo() { 339 String prefId = null; 340 String pref = fPreferences.getString(ICoreConstants.TARGET_PROFILE); 341 fProfileCombo.add(""); 343 if (pref.startsWith("${workspace_loc:")) { try { 345 pref = pref.substring(16, pref.length() -1); 346 IFile file = PDEPlugin.getWorkspace().getRoot().getFile(new Path(pref)); 347 addWorkspaceTarget(file); 348 }catch (CoreException e) { 349 } 350 } else if (pref.length() > 3){ prefId = pref.substring(3); 352 } 353 354 fElements = PDECore.getDefault().getTargetProfileManager().getSortedTargets(); 356 for (int i = 0; i < fElements.length; i++) { 357 String name =fElements[i].getAttribute("name"); String id = fElements[i].getAttribute("id"); if (fProfileCombo.indexOf(name) == -1) 360 fProfileCombo.add(name); 361 if (id.equals(prefId)) 362 fProfileCombo.setText(name); 363 } 364 } 365 366 private void addWorkspaceTarget(IFile file) throws CoreException { 367 if (file != null && file.exists()) { 369 TargetModel model = new TargetModel(); 370 model.load(new BufferedInputStream (file.getContents()), false); 371 String value = model.getTarget().getName(); 372 value = value + " [" + file.getFullPath().toString() + "]"; if (fProfileCombo.indexOf(value) == -1) 374 fProfileCombo.add(value, 1); fProfileCombo.setText(value); 376 fContainsWorkspaceProfile = true; 377 } 378 } 379 380 private void handleTargetBrowse() { 381 ElementTreeSelectionDialog dialog = 382 new ElementTreeSelectionDialog( 383 getShell(), 384 new WorkbenchLabelProvider(), 385 new WorkbenchContentProvider()); 386 387 dialog.setValidator(new FileValidator()); 388 dialog.setAllowMultiple(false); 389 dialog.setTitle(PDEUIMessages.TargetPlatformPreferencePage_FileSelectionTitle); 390 dialog.setMessage(PDEUIMessages.TargetPlatformPreferencePage_FileSelectionMessage); 391 dialog.addFilter(new FileExtensionFilter("target")); dialog.setInput(PDEPlugin.getWorkspace().getRoot()); 393 IFile target = getTargetFile(); 394 if (target != null) dialog.setInitialSelection(target); 395 396 if (dialog.open() == Window.OK) { 397 IFile file = (IFile)dialog.getFirstResult(); 398 try { 399 addWorkspaceTarget(file); 400 fLoadProfileButton.setEnabled(!fProfileCombo.getText().equals("")); } catch (CoreException e) { 402 } 403 } 404 } 405 406 private IFile getTargetFile() { 407 if (!fContainsWorkspaceProfile || !(fProfileCombo.getSelectionIndex() < (fProfileCombo.getItemCount() - fElements.length))) 408 return null; 409 String target = fProfileCombo.getText().trim(); 410 if (target.equals("")) return null; 412 int beginIndex = target.lastIndexOf('['); 413 target = target.substring(beginIndex +1, target.length() - 1); 414 IPath targetPath = new Path(target); 415 if (targetPath.segmentCount() < 2) 416 return null; 417 return PDEPlugin.getWorkspace().getRoot().getFile(targetPath); 418 } 419 420 private URL getExternalTargetURL() { 421 int offSet = fProfileCombo.getItemCount() - fElements.length; 422 if (offSet > fProfileCombo.getSelectionIndex()) 423 return null; 424 IConfigurationElement elem = fElements[fProfileCombo.getSelectionIndex() - offSet]; 425 String path = elem.getAttribute("definition"); String symbolicName = elem.getDeclaringExtension().getNamespaceIdentifier(); 427 return TargetDefinitionManager.getResourceURL(symbolicName, path); 428 } 429 430 private String getTargetDescription() { 431 int offSet = fProfileCombo.getItemCount() - fElements.length; 432 if (offSet > fProfileCombo.getSelectionIndex()) 433 return null; 434 IConfigurationElement elem = fElements[fProfileCombo.getSelectionIndex() - offSet]; 435 IConfigurationElement [] children = elem.getChildren("description"); if (children.length > 0) 437 return children[0].getValue(); 438 return null; 439 } 440 441 public void init(IWorkbench workbench) { 442 } 443 444 private ITargetModel getTargetModel() { 445 InputStream stream = null; 446 try { 447 IFile file = getTargetFile(); 448 String desc = null; 449 if (file != null) 450 stream = new BufferedInputStream (file.getContents()); 451 if (stream == null) { 452 URL url = getExternalTargetURL(); 453 desc = getTargetDescription(); 454 if (url != null) 455 stream = new BufferedInputStream (url.openStream()); 456 } 457 458 if (stream != null) { 459 ITargetModel model = new TargetModel(); 460 model.load(stream, false); 461 if (desc != null) 462 model.getTarget().setDescription(desc); 463 return model; 464 } 465 } catch (CoreException e) { 466 } catch (IOException e) { 467 } finally { 468 try { 469 if (stream != null) 470 stream.close(); 471 } catch (IOException e) { 472 } 473 } 474 return null; 475 } 476 477 private void handleLoadTargetProfile() { 478 if (fProfileCombo.getText().equals("")) return; ITargetModel model = getTargetModel(); 480 if (model == null) { 481 MessageDialog.openError(getShell(), PDEUIMessages.TargetPlatformPreferencePage_notFoundTitle, PDEUIMessages.TargetPlatformPreferencePage_notFoundDescription); 482 return; 483 } 484 485 if (!model.isLoaded()) { 486 MessageDialog.openError(getShell(), PDEUIMessages.TargetPlatformPreferencePage_invalidTitle, PDEUIMessages.TargetPlatformPreferencePage_invalidDescription); 487 return; 488 } 489 490 ITarget target = model.getTarget(); 491 ILocationInfo info = target.getLocationInfo(); 492 String path; 493 if (info == null || info.useDefault()) { 494 path = TargetPlatform.getDefaultLocation(); 495 } else { 496 try { 497 IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); 498 path = manager.performStringSubstitution(info.getPath()); 499 } catch (CoreException e) { 500 return; 501 } 502 } 503 if (!new Path(path).equals(new Path(fHomeText.getText())) 504 || !areAdditionalLocationsEqual(target)) { 505 fHomeText.setText(path); 506 ArrayList additional = new ArrayList (); 507 IAdditionalLocation[] locations = target.getAdditionalDirectories(); 508 IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); 509 for (int i = 0; i < locations.length; i++) { 510 try { 511 additional.add(manager.performStringSubstitution(locations[i].getPath())); 512 } catch (CoreException e) { 513 additional.add(locations[i]); 514 } 515 } 516 fPluginsTab.handleReload(additional); 517 } 518 519 fPluginsTab.loadTargetProfile(target); 520 fEnvironmentTab.loadTargetProfile(target); 521 fArgumentsTab.loadTargetProfile(target); 522 fImplicitDependenciesTab.loadTargetProfile(target); 523 fSourceTab.loadTargetProfile(target); 524 } 525 526 private boolean areAdditionalLocationsEqual(ITarget target) { 527 IAdditionalLocation[] addtionalLocs = target.getAdditionalDirectories(); 528 Preferences preferences = PDECore.getDefault().getPluginPreferences(); 529 String value = preferences.getString(ICoreConstants.ADDITIONAL_LOCATIONS); 530 StringTokenizer tokenzier = new StringTokenizer (value); 531 if (addtionalLocs.length != tokenzier.countTokens()) 532 return false; 533 while (tokenzier.hasMoreTokens()) { 534 boolean found = false; 535 String location = tokenzier.nextToken(); 536 for (int i = 0; i < addtionalLocs.length; i++) { 537 if (addtionalLocs[i].getPath().equals(location)) { 538 found = true; 539 break; 540 } 541 } 542 if (!found) 543 return false; 544 } 545 return true; 546 } 547 548 public void performDefaults() { 549 fHomeText.setText(TargetPlatform.getDefaultLocation()); 550 fPluginsTab.handleReload(new ArrayList ()); 551 fEnvironmentTab.performDefaults(); 552 fArgumentsTab.performDefaults(); 553 fImplicitDependenciesTab.performDefauls(); 554 fSourceTab.performDefaults(); 555 resetTargetProfile(); 556 super.performDefaults(); 557 } 558 559 public boolean performOk() { 560 if (fNeedsReload && !new Path(fOriginalText).equals(new Path(fHomeText.getText()))) { 561 MessageDialog dialog = 562 new MessageDialog( 563 getShell(), 564 PDEUIMessages.Preferences_TargetPlatformPage_title, 565 null, 566 PDEUIMessages.Preferences_TargetPlatformPage_question, 567 MessageDialog.QUESTION, 568 new String [] { 569 IDialogConstants.YES_LABEL, 570 IDialogConstants.NO_LABEL}, 571 1); 572 if (dialog.open() == 1) { 573 getContainer().updateButtons(); 574 return false; 575 } 576 fPluginsTab.handleReload(new ArrayList ()); 577 resetTargetProfile(); 578 } 579 fOriginalText = fHomeText.getText(); 581 fEnvironmentTab.performOk(); 582 fSourceTab.performOk(); 583 fPluginsTab.performOk(); 584 fArgumentsTab.performOk(); 585 fImplicitDependenciesTab.performOk(); 586 saveTarget(); 587 return super.performOk(); 588 } 589 590 private void saveTarget() { 591 if (fProfileCombo.getText().equals("")) fPreferences.setValue(ICoreConstants.TARGET_PROFILE, ""); else if (fContainsWorkspaceProfile && (fProfileCombo.getSelectionIndex() < (fProfileCombo.getItemCount() - fElements.length))) { 594 String value = fProfileCombo.getText().trim(); 595 int index = value.lastIndexOf('['); 596 value = value.substring(index + 1, value.length() - 1); 597 fPreferences.setValue(ICoreConstants.TARGET_PROFILE, "${workspace_loc:" + value + "}"); } else { 599 int offSet = fProfileCombo.getItemCount() - fElements.length; 600 IConfigurationElement elem = fElements[fProfileCombo.getSelectionIndex() - offSet]; 601 fPreferences.setValue(ICoreConstants.TARGET_PROFILE, "id:" + elem.getAttribute("id")); } 603 } 604 605 public String [] getPlatformLocations() { 606 return fHomeText.getItems(); 607 } 608 609 public void resetNeedsReload() { 610 fNeedsReload = false; 611 String location = fHomeText.getText(); 612 if (fHomeText.indexOf(location) == -1) 613 fHomeText.add(location, 0); 614 } 615 616 public void resetTargetProfile() { 617 fProfileCombo.select(0); 618 fLoadProfileButton.setEnabled(false); 619 } 620 621 public TargetSourceTab getSourceBlock() { 622 return fSourceTab; 623 } 624 625 protected IPluginModelBase[] getCurrentModels() { 626 return fPluginsTab.getCurrentModels(); 627 } 628 629 protected PDEState getCurrentState() { 630 return fPluginsTab.getCurrentState(); 631 } 632 633 protected String [] getImplicitPlugins() { 634 return fImplicitDependenciesTab.getImplicitPlugins(); 635 } 636 637 private void openTargetWizard() { 638 NewTargetDefinitionWizard wizard = new NewTargetDefinitionWizard(); 639 WizardDialog dialog = new WizardDialog(getShell(), wizard); 640 wizard.setInitialPath(new Path(new String ())); 641 dialog.create(); 642 SWTUtil.setDialogSize(dialog, 400, 450); 643 if (dialog.open() == Window.OK) { 644 IPath filePath = wizard.getFilePath(); 645 IFile file = PDEPlugin.getWorkspace().getRoot().getFile(filePath); 646 try { 647 addWorkspaceTarget(file); 648 } catch (CoreException e) { 649 } 650 } 651 } 652 653 } 654 | Popular Tags |