@Bindable public void setSelectedDatasource(IWizardDatasource datasource) { IWizardDatasource prevSelection = activeDatasource; activeDatasource = datasource; if (datasource == null || prevSelection == activeDatasource) { return; } try { datasource.activating(); if (prevSelection != null) { steps.removeAll(prevSelection.getSteps()); prevSelection.deactivating(); } for (int i = 1; i < datasource.getSteps().size(); i++) { steps.add(datasource.getSteps().get(i)); } steps.addAll(datasource.getSteps()); wizardModel.setSelectedDatasource(datasource); activeStep = 0; updateBindings(); } catch (XulException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
@Bindable public void setSelectedDatasource(IWizardDatasource datasource) { if (datasource instanceof DummyDatasource) { this.datasourceDeck.setSelectedIndex(0); this.datasource = null; this.wrappedStep = null; return; } if (datasource == null) { return; } if (this.datasource != null) { this.wrappedStep.removePropertyChangeListener(validListener); this.datasource.removePropertyChangeListener(finishableListener); } this.wrappedStep = datasource.getSteps().get(0); this.datasource = datasource; this.wrappedStep.addPropertyChangeListener(validListener); this.datasource.addPropertyChangeListener(finishableListener); this.datasourceDeck.setSelectedIndex( datasourceDeck.getChildNodes().indexOf(datasource.getSteps().get(0).getUIComponent())); datasource.getSteps().get(0).refresh(); firePropertyChange("valid", !isValid(), isValid()); }
@Override public void propertyChange(PropertyChangeEvent propertyChangeEvent) { if (datasource == null) { return; } parentDatasource.setFinishable(datasource.isFinishable()); }
private void selectDataSourceMenuList(IWizardStep activatingWizardStep, int index) { if (datatypeMenuList.getElements().size() > 0 && index != -1 && activeDatasource != null) { if (activeDatasource.getId().equals("NONE")) { this.datatypeMenuList.setSelectedIndex(0); } else { if (activeDatasource.getId().equals("CSV")) { this.datatypeMenuList.setSelectedIndex(1); } else { if (activeDatasource.getId().equals("MULTI-TABLE-DS")) { this.datatypeMenuList.setSelectedIndex(3); } else { if (activeDatasource.getId().equals("SQL-DS")) { this.datatypeMenuList.setSelectedIndex(2); } } } } } }
private void setFinished() { wizardDialog.hide(); MessageHandler.getInstance().showWaitingDialog(); activeDatasource.onFinish( new XulServiceCallback<IDatasourceSummary>() { @Override public void success(IDatasourceSummary iDatasourceSummary) { iDatasourceSummary .getDomain() .getLogicalModels() .get(0) .setProperty("DatasourceType", new Property<String>(activeDatasource.getId())); for (IWizardListener wizardListener : wizardListeners) { wizardListener.onFinish(iDatasourceSummary); } } @Override public void error(String s, Throwable throwable) { throwable.printStackTrace(); // TODO: improve error messaging MessageHandler.getInstance().closeWaitingDialog(); MessageHandler.getInstance() .showErrorDialog( "Error", ExceptionParser //$NON-NLS-1$ .getErrorMessage( throwable, MessageHandler.getString( "DatasourceEditor.ERROR_0001_UNKNOWN_ERROR_HAS_OCCURED")), true); //$NON-NLS-1$ } }); }
public void init() { // We need the SelectDatasourceStep at all times, add it now wizardDialog = (XulDialog) document.getElementById("main_wizard_window"); summaryDialog = (XulDialog) document.getElementById("summaryDialog"); finishButton = (XulButton) document.getElementById(FINISH_BTN_ELEMENT_ID); datasourceName = (XulTextbox) document.getElementById("datasourceName"); // $NON-NLS-1$ bf.createBinding(datasourceName, "value", wizardModel, "datasourceName"); wizardModel.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent propertyChangeEvent) { if (propertyChangeEvent.getPropertyName().equals("datasourceName")) { steps.get(activeStep).setValid(steps.get(activeStep).isValid()); } } }); bf.setBindingType(Binding.Type.ONE_WAY); datatypeMenuList = (XulMenuList) document.getElementById("datatypeMenuList"); Binding datasourceBinding = bf.createBinding(wizardModel, "datasources", datatypeMenuList, "elements"); bf.setBindingType(Binding.Type.ONE_WAY); bf.createBinding(datatypeMenuList, "selectedItem", wizardModel, "selectedDatasource"); bf.setBindingType(Binding.Type.ONE_WAY); bf.createBinding(wizardModel, "selectedDatasource", this, "selectedDatasource"); bf.createBinding( this, ACTIVE_STEP_PROPERTY_NAME, BACK_BTN_ELEMENT_ID, DISABLED_PROPERTY_NAME, new BackButtonBindingConverter()); dummyDatasource = ((DummyDatasource) wizardModel.getDatasources().iterator().next()); activeDatasource = dummyDatasource; selectDatasourceStep = dummyDatasource.getSelectDatasourceStep(); try { for (IWizardDatasource datasource : wizardModel.getDatasources()) { datasource.init(getXulDomContainer(), wizardModel); } steps.add(selectDatasourceStep); selectDatasourceStep.activating(); setActiveStep(0); datasourceBinding.fireSourceChanged(); setSelectedDatasource(dummyDatasource); datasourceService.getDatasourceIllegalCharacters( new XulServiceCallback<String>() { @Override public void success(String retVal) {} @Override public void error(String message, Throwable error) {} }); } catch (XulException e) { MessageHandler.getInstance().showErrorDialog("Error", e.getMessage()); e.printStackTrace(); } catch (InvocationTargetException e) { MessageHandler.getInstance().showErrorDialog("Error", e.getMessage()); e.printStackTrace(); } }