public FuseIntegrationProjectWizardRuntimeAndCamelPage() { super(Messages.newProjectWizardRuntimePageName); setTitle(Messages.newProjectWizardRuntimePageTitle); setDescription(Messages.newProjectWizardRuntimePageDescription); setImageDescriptor( ProjectTemplatesActivator.imageDescriptorFromPlugin( ProjectTemplatesActivator.PLUGIN_ID, ProjectTemplatesActivator.IMAGE_CAMEL_PROJECT_ICON)); setPageComplete(false); }
/* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); container.setLayout(new GridLayout(3, false)); Group runtimeGrp = new Group(container, SWT.NONE); GridData runtimeGrpData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); runtimeGrp.setLayout(new GridLayout(3, false)); runtimeGrp.setLayoutData(runtimeGrpData); runtimeGrp.setText(Messages.newProjectWizardRuntimePageRuntimeGroupLabel); Label runtimeLabel = new Label(runtimeGrp, SWT.NONE); GridData runtimeLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); runtimeLabel.setLayoutData(runtimeLabelData); runtimeLabel.setText(Messages.newProjectWizardRuntimePageRuntimeLabel); runtimeComboViewer = new ComboViewer(runtimeGrp, SWT.NONE | SWT.READ_ONLY); runtimeComboViewer.setComparator( new ViewerComparator( new Comparator<String>() { @Override public int compare(String o1, String o2) { if (Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel.equals(o1)) { return -1; } return o1.compareTo(o2); } })); GridData runtimeComboData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); runtimeComboViewer.getCombo().setLayoutData(runtimeComboData); runtimeComboViewer .getCombo() .setToolTipText(Messages.newProjectWizardRuntimePageRuntimeDescription); runtimeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); runtimeComboViewer .getCombo() .addModifyListener( new ModifyListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ @Override public void modifyText(ModifyEvent e) { lastSelectedRuntime = runtimeComboViewer.getSelection().toString(); preselectCamelVersionForRuntime(determineRuntimeCamelVersion(getSelectedRuntime())); validate(); } }); try { configureRuntimeCombo(); } catch (CoreException ex) { ProjectTemplatesActivator.pluginLog().logError(ex); } Button runtimeNewButton = new Button(runtimeGrp, SWT.NONE); GridData runtimeNewButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false); runtimeNewButton.setLayoutData(runtimeNewButtonData); runtimeNewButton.setText(Messages.newProjectWizardRuntimePageRuntimeNewButtonLabel); runtimeNewButton.setToolTipText( Messages.newProjectWizardRuntimePageRuntimeNewButtonDescription); runtimeNewButton.addSelectionListener( new SelectionAdapter() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { String[] oldRuntimes = runtimeComboViewer.getCombo().getItems(); boolean created = ServerUIUtil.showNewRuntimeWizard(getShell(), null, null); if (created) { String[] newRuntimes = runtimeComboViewer.getCombo().getItems(); String newRuntime = getNewRuntime(oldRuntimes, newRuntimes); if (newRuntime != null) { runtimeComboViewer.setSelection(new StructuredSelection(newRuntime)); } } } }); new Label(runtimeGrp, SWT.None); Group camelGrp = new Group(container, SWT.NONE); GridData camelGrpData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 20); camelGrp.setLayout(new GridLayout(3, false)); camelGrp.setLayoutData(camelGrpData); camelGrp.setText(Messages.newProjectWizardRuntimePageCamelGroupLabel); Label camelVersionLabel = new Label(camelGrp, SWT.NONE); GridData camelLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); camelVersionLabel.setLayoutData(camelLabelData); camelVersionLabel.setText(Messages.newProjectWizardRuntimePageCamelLabel); camelVersionCombo = new Combo(camelGrp, SWT.RIGHT | SWT.READ_ONLY); GridData camelComboData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); camelVersionCombo.setLayoutData(camelComboData); camelVersionCombo.setItems(getSupportedCamelVersions()); camelVersionCombo.select(Math.max(camelVersionCombo.getItemCount() - 1, 0)); camelVersionCombo.setToolTipText(Messages.newProjectWizardRuntimePageCamelDescription); camelVersionCombo.addSelectionListener( new SelectionAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { validate(); } }); // TODO: leaving that out until we decide to support other camel versions than the ones we ship // camelVersionCombo.addFocusListener(new FocusAdapter() { // /* (non-Javadoc) // * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) // */ // @Override // public void focusLost(FocusEvent e) { // super.focusLost(e); // validate(); // } // // /* (non-Javadoc) // * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) // */ // @Override // public void focusGained(FocusEvent e) { // super.focusGained(e); // setPageComplete(false); // } // }); new Label(camelGrp, SWT.None); warningIconLabel = new Label(camelGrp, SWT.None); GridData camelLblData = new GridData(SWT.FILL, SWT.TOP, false, true, 1, 20); camelLblData.verticalIndent = 20; warningIconLabel.setImage(getSWTImage(SWT.ICON_WARNING)); warningIconLabel.setLayoutData(camelLblData); warningIconLabel.setVisible(false); camelInfoText = new StyledText(camelGrp, SWT.WRAP | SWT.MULTI); GridData camelInfoData = new GridData(SWT.FILL, SWT.TOP, true, true, 2, 20); camelInfoData.verticalIndent = 0; camelInfoData.heightHint = 150; camelInfoText.setLayoutData(camelInfoData); camelInfoText.setEnabled(false); camelInfoText.setEditable(false); camelInfoText.setBackground(container.getBackground()); new Label(camelGrp, SWT.None); setControl(container); IRuntimeLifecycleListener listener = new IRuntimeLifecycleListener() { @Override public void runtimeRemoved(IRuntime runtime) { runInUIThread(); } @Override public void runtimeChanged(IRuntime runtime) { runInUIThread(); } @Override public void runtimeAdded(IRuntime runtime) { runInUIThread(); } private void runInUIThread() { Display.getDefault() .asyncExec( new Runnable() { @Override public void run() { try { configureRuntimeCombo(); } catch (CoreException ex) { ProjectTemplatesActivator.pluginLog() .logError("Unable to handle runtime change event", ex); // $NON-NLS-1$ } } }); } }; ServerCore.addRuntimeLifecycleListener(listener); validate(); }