/** * Notifies any page changing listeners that the currently selected dialog * page is changing. Only listeners registered at the time this method is * called are notified. * * @param event * a selection changing event * * @see IPageChangingListener#handlePageChanging(PageChangingEvent) * @since 3.3 */ protected void firePageChanging(final PageChangingEvent event) { Object[] listeners = pageChangingListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { final IPageChangingListener l = (IPageChangingListener) listeners[i]; SafeRunnable.run(new SafeRunnable() { public void run() { l.handlePageChanging(event); } }); } }
@Override public void setContainer(IWizardContainer wizardContainer) { // TODO Auto-generated method stub super.setContainer(wizardContainer); if (wizardContainer == null) { if (this.dialog != null) { this.dialog = null; } return; } this.dialog = (WizardDialog)wizardContainer; this.dialog.addPageChangingListener(new IPageChangingListener() { @Override public void handlePageChanging(PageChangingEvent event) { // TODO Auto-generated method stub Object current = event.getCurrentPage(); Object target = event.getTargetPage(); List<IWizardPage> list = Arrays.asList(getPages()); int idxCurrent = list.indexOf(current); int idxTarget = list.indexOf(target); java.lang.System.out.println("Current: "+current.getClass().getName()+" ;; Target: "+target.getClass().getName()); if (current instanceof IWizardPageControll) { if (idxCurrent < idxTarget) { // perform Next ((IWizardPageControll)current).performNext(); } else { // perform Back ((IWizardPageControll)current).performBack(); } } if (target instanceof IWizardPageControll) { ((IWizardPageControll)target).performUpdate(); currentPage = (IWizardPageControll)target; } else { currentPage = null; } } }); }
/** * @see IDialogPage#createControl(Composite) */ public void createControl(Composite parent) { int columns = 6; //定义列数 ScrolledComposite scroll = new ScrolledComposite(parent, SWT.NULL | SWT.V_SCROLL); scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL)); //强制显示滚动条 scroll.setAlwaysShowScrollBars(false); scroll.setExpandVertical(true); scroll.setExpandHorizontal(true); //拖动滚动条里可以看到的Composite的最大高度 //(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight() scroll.setMinHeight(700); scroll.setLayout(new GridLayout(1, false)); Composite container = new Composite(scroll, SWT.NULL); GridLayout glContainer = new GridLayout(); glContainer.numColumns = columns; //glContainer.verticalSpacing = 2; container.setLayout(glContainer); scroll.setContent(container); createDatabaseArea(container, columns); createListTableArea(container, columns); createBaseProjectPath(container, columns); //定义Next事件 WizardDialog dialog = (WizardDialog) getContainer(); dialog.addPageChangingListener(new IPageChangingListener() { public void handlePageChanging(PageChangingEvent event) { if(event.getCurrentPage() instanceof Config1MainRuleWizardPage && event.getTargetPage() instanceof Config2TableRelationWizardPage) { try { gcRule.save(); updateStatus("成功保存配置到" + RmXmlHelper.formatToFile(gcRule.getMainRulePath())); } catch (Exception e1) { updateStatus("保存失败:" + e1.toString()); e1.printStackTrace(); event.doit = false; } } } }); initialize(); setControl(container); }
public void createControl(Composite parent) { final int columns = 7; //定义列数 Composite container = null; //从父容器获得ScrolledComposite if(parent.getChildren() != null && parent.getChildren().length > 1 && parent.getChildren()[1] instanceof ScrolledComposite) { ScrolledComposite scroll = (ScrolledComposite)parent.getChildren()[1]; container = new Composite(scroll, SWT.NULL); scroll.setContent(container); } else { container = new Composite(parent, SWT.NULL); } container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); container.setLayout(new GridLayout(columns, false)); final Composite containerFinal = container; //添加一组关系的按钮 Button addRelationGroup = new Button(container, SWT.CENTER); GridData gd = new GridData(GridData.CENTER); gd.horizontalSpan = columns; addRelationGroup.setLayoutData(gd); addRelationGroup.setText("添加一组关系"); addRelationGroup.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { relations.add(addRelationGroup(containerFinal, columns, null)); } }); initTableRelationWidget(container, columns); //定义Next事件 final TableRelation tableRelationFinal = tableRelation; WizardDialog dialog = (WizardDialog) getContainer(); dialog.addPageChangingListener(new IPageChangingListener() { public void handlePageChanging(PageChangingEvent event) { if(event.getCurrentPage() instanceof Config2TableRelationWizardPage && event.getTargetPage() instanceof Config3MvmWizardPage) { try { //把界面上的表关系体现到Xml tableRelationFinal.buildTableRelationXml(relations); //把子表合并到主表的xml中 tableRelationFinal.mergeChildTable(); gcRule.save(); updateStatus("成功保存配置到" + RmXmlHelper.formatToFile(gcRule.getMainRulePath())); } catch (Exception e1) { updateStatus("保存失败:" + e1.toString()); e1.printStackTrace(); event.doit = false; } } } }); setControl(container); initialize(); dialogChanged(); }
/** * Adds a listener for page changes to the list of page changing listeners * registered for this dialog. Has no effect if an identical listener is * already registered. * * @param listener * a page changing listener * @since 3.3 */ public void addPageChangingListener(IPageChangingListener listener) { pageChangingListeners.add(listener); }
/** * Removes the provided page changing listener from the list of page * changing listeners registered for the dialog. * * @param listener * a page changing listener * @since 3.3 */ public void removePageChangingListener(IPageChangingListener listener) { pageChangingListeners.remove(listener); }
/** * Removes the provided page changing listener from the list of page changing * listeners registered for the dialog. * * @param listener * a page changing listener * @since 3.3 */ public void removePageChangingListener(IPageChangingListener listener) { pageChangingListeners.remove(listener); }