1 11 package org.eclipse.pde.internal.ui.wizards.exports; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.runtime.IAdaptable; 15 import org.eclipse.jface.dialogs.IDialogSettings; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.jface.wizard.IWizardPage; 18 import org.eclipse.pde.core.IModel; 19 import org.eclipse.pde.internal.core.FeatureModelManager; 20 import org.eclipse.pde.internal.core.PDECore; 21 import org.eclipse.pde.internal.core.ifeature.IFeatureModel; 22 import org.eclipse.pde.internal.ui.IHelpContextIds; 23 import org.eclipse.pde.internal.ui.PDEUIMessages; 24 import org.eclipse.swt.SWT; 25 import org.eclipse.swt.widgets.Control; 26 import org.eclipse.swt.widgets.TabFolder; 27 import org.eclipse.swt.widgets.TabItem; 28 import org.eclipse.ui.PlatformUI; 29 30 31 public class FeatureExportWizardPage extends BaseExportWizardPage { 32 33 private JNLPTab fJNLPTab; 34 35 public FeatureExportWizardPage(IStructuredSelection selection) { 36 super( 37 selection, 38 "featureExport", PDEUIMessages.ExportWizard_Feature_pageBlock); 40 setTitle(PDEUIMessages.ExportWizard_Feature_pageTitle); 41 } 42 43 protected Object getInput() { 44 return PDECore.getDefault().getFeatureModelManager(); 45 } 46 47 public Object [] getListElements() { 48 FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager(); 49 return manager.getWorkspaceModels(); 50 } 51 52 protected void hookHelpContext(Control control) { 53 PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.FEATURE_EXPORT_WIZARD); 54 } 55 56 protected boolean isValidModel(IModel model) { 57 return model instanceof IFeatureModel; 58 } 59 60 protected void createTabs(TabFolder folder, IDialogSettings settings) { 61 super.createTabs(folder, settings); 62 if (fDestinationTab.doExportToDirectory() && fOptionsTab.useJARFormat()) { 63 createJNLPTab(folder); 64 fJNLPTab.initialize(settings); 65 } 66 } 67 68 protected void createDestinationTab(TabFolder folder) { 69 fDestinationTab = new FeatureDestinationTab(this); 70 TabItem item = new TabItem(folder, SWT.NONE); 71 item.setControl(fDestinationTab.createControl(folder)); 72 item.setText(PDEUIMessages.ExportWizard_destination); 73 } 74 75 protected void createOptionsTab(TabFolder folder) { 76 fOptionsTab = new FeatureOptionsTab(this); 77 TabItem item = new TabItem(folder, SWT.NONE); 78 item.setControl(fOptionsTab.createControl(folder)); 79 item.setText(PDEUIMessages.ExportWizard_options); 80 } 81 82 private void createJNLPTab(TabFolder folder) { 83 fJNLPTab = new JNLPTab(this); 84 TabItem item = new TabItem(folder, SWT.NONE); 85 item.setControl(fJNLPTab.createControl(folder)); 86 item.setText(PDEUIMessages.AdvancedFeatureExportPage_jnlp); 87 } 88 89 protected IModel findModelFor(IAdaptable object) { 90 IProject project = (IProject) object.getAdapter(IProject.class); 91 if (project != null) 92 return PDECore.getDefault().getFeatureModelManager().getFeatureModel(project); 93 return null; 94 } 95 96 protected void saveSettings(IDialogSettings settings) { 97 super.saveSettings(settings); 98 if (fJNLPTab != null) 99 fJNLPTab.saveSettings(settings); 100 } 101 102 protected String validateTabs() { 103 String message = super.validateTabs(); 104 if (message == null && fTabFolder.getItemCount() > 3) 105 message = fJNLPTab.validate(); 106 return message; 107 } 108 109 protected void adjustAdvancedTabsVisibility() { 110 adjustJARSigningTabVisibility(); 111 adjustJNLPTabVisibility(); 112 pageChanged(); 113 } 114 115 protected void adjustJNLPTabVisibility() { 116 IDialogSettings settings = getDialogSettings(); 117 if (useJARFormat() && doExportToDirectory()) { 118 if (fTabFolder.getItemCount() < 4) { 119 createJNLPTab(fTabFolder); 120 fJNLPTab.initialize(settings); 121 } 122 } else { 123 int count = fTabFolder.getItemCount(); 124 if (count >= (useJARFormat() ? 4 : 3)) { 125 fJNLPTab.saveSettings(settings); 126 fTabFolder.getItem(count-1).dispose(); 127 } 128 } 129 } 130 131 protected boolean doMultiPlatform() { 132 return ((FeatureOptionsTab)fOptionsTab).doMultiplePlatform(); 133 } 134 135 protected String [] getJNLPInfo() { 136 if (fJNLPTab == null || fTabFolder.getItemCount() < 4) 137 return null; 138 return fJNLPTab.getJNLPInfo(); 139 } 140 141 public IWizardPage getNextPage() { 142 return doMultiPlatform() ? getWizard().getNextPage(this) : null; 143 } 144 145 } 146 | Popular Tags |