Search in sources :

Example 6 with IWizardPage

use of org.eclipse.jface.wizard.IWizardPage in project translationstudio8 by heartsome.

the class NewProjectWizardLanguagePage method getNextPage.

/**
	 * 处理扩展页面中需要获取项目源语言问题 (non-Javadoc)
	 * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
	 */
public IWizardPage getNextPage() {
    if (getWizard() == null) {
        return null;
    }
    IWizardPage[] pages = getWizard().getPages();
    for (int i = 0; i < pages.length; i++) {
        if (pages[i] instanceof AbstractNewProjectWizardPage) {
            AbstractNewProjectWizardPage extensoinPage = (AbstractNewProjectWizardPage) pages[i];
            extensoinPage.setProjSourceLang(getSrcLanguage());
        }
    }
    return getWizard().getNextPage(this);
}
Also used : AbstractNewProjectWizardPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage) IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Example 7 with IWizardPage

use of org.eclipse.jface.wizard.IWizardPage in project tdi-studio-se by Talend.

the class JSONWizard method performFinish.

/**
     * This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in
     * the wizard. We will create an operation and run it using wizard as execution context.
     */
@Override
public boolean performFinish() {
    boolean formIsPerformed = false;
    IWizardPage finalPage = getCurrentPage();
    if (finalPage == null) {
        finalPage = propertiesWizardPage;
    }
    // deleteTemFile();
    if (connection.isInputModel()) {
        if (finalPage instanceof JSONFileWizardPage) {
            int step = ((JSONFileWizardPage) finalPage).step;
            if (step == 2) {
                formIsPerformed = finalPage.isPageComplete();
                if (formIsPerformed) {
                    List schemas = connection.getSchema();
                    Set tables = ConnectionHelper.getTables(connection);
                    if (!schemas.isEmpty() && !tables.isEmpty()) {
                        JSONXPathLoopDescriptor currentSchema = (JSONXPathLoopDescriptor) schemas.get(0);
                        MetadataTable currentTable = (MetadataTable) tables.toArray(new MetadataTable[0])[0];
                        if (!currentSchema.getAbsoluteXPathQuery().equals(oldAbstractQueryPath)) {
                            resetMetadata(currentSchema.getSchemaTargets(), true);
                        } else {
                            resetMetadata(currentSchema.getSchemaTargets(), false);
                        }
                    }
                }
            } else {
                formIsPerformed = finalPage.isPageComplete();
            }
        } else {
            formIsPerformed = finalPage.isPageComplete();
        }
    } else {
        formIsPerformed = finalPage.isPageComplete();
    }
    if (formIsPerformed) {
        final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        final IWorkspaceRunnable op = new IWorkspaceRunnable() {

            @Override
            public void run(IProgressMonitor monitor) throws CoreException {
                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (creation) {
                            String nextId = factory.getNextId();
                            connectionProperty.setId(nextId);
                            // changed by hqzhang for TDI-19527, label=displayName
                            connectionProperty.setLabel(connectionProperty.getDisplayName());
                            final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {

                                @Override
                                protected void run() throws LoginException, PersistenceException {
                                    factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
                                }
                            };
                            workUnit.setAvoidUnloadResources(true);
                            factory.executeRepositoryWorkUnit(workUnit);
                        } else {
                            // changed by hqzhang for TDI-19527, label=displayName
                            connectionProperty.setLabel(connectionProperty.getDisplayName());
                            // update schemas
                            Map<String, SchemaTarget> schemaTargetMap = new HashMap<String, SchemaTarget>();
                            EList<JSONXPathLoopDescriptor> schema = connection.getSchema();
                            if (schema != null && schema.size() > 0) {
                                JSONXPathLoopDescriptor jsonXPathLoopDescriptor = schema.get(0);
                                if (jsonXPathLoopDescriptor != null) {
                                    EList<SchemaTarget> schemaTargets = jsonXPathLoopDescriptor.getSchemaTargets();
                                    if (schemaTargets != null && schemaTargets.size() > 0) {
                                        for (SchemaTarget schemaTarget : schemaTargets) {
                                            schemaTargetMap.put(schemaTarget.getTagName(), schemaTarget);
                                        }
                                    }
                                }
                            }
                            Map<String, MetadataColumn> columnsMap = new HashMap<String, MetadataColumn>();
                            MetadataTable[] tables = ConnectionHelper.getTables(connectionItem.getConnection()).toArray(new MetadataTable[0]);
                            for (MetadataTable table : tables) {
                                EList<MetadataColumn> columns = table.getColumns();
                                Iterator<MetadataColumn> columnsIter = columns.iterator();
                                while (columnsIter.hasNext()) {
                                    MetadataColumn column = columnsIter.next();
                                    if (connection.isInputModel()) {
                                        if (schemaTargetMap.get(column.getLabel()) == null) {
                                            columnsIter.remove();
                                        } else {
                                            columnsMap.put(column.getLabel(), column);
                                        }
                                    } else {
                                        columnsMap.put(column.getLabel(), column);
                                    }
                                }
                            }
                            boolean hasAddedColumns = false;
                            Iterator<Entry<String, SchemaTarget>> schemaTargetIter = schemaTargetMap.entrySet().iterator();
                            while (schemaTargetIter.hasNext()) {
                                Map.Entry<String, SchemaTarget> entry = schemaTargetIter.next();
                                String key = entry.getKey();
                                if (columnsMap.get(key) == null) {
                                    hasAddedColumns = true;
                                    break;
                                }
                            }
                            if (hasAddedColumns) {
                                MessageDialog.openInformation(getShell(), "Detect new columns", "There are some new fields to extract, guess your schema manually if you want to apply the update.");
                            }
                            // update
                            RepositoryUpdateManager.updateFileConnection(connectionItem);
                            refreshInFinish(propertiesWizardPage.isNameModifiedByUser());
                            final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {

                                @Override
                                protected void run() throws LoginException, PersistenceException {
                                    factory.save(connectionItem);
                                }
                            };
                            workUnit.setAvoidUnloadResources(true);
                            factory.executeRepositoryWorkUnit(workUnit);
                            closeLockStrategy();
                        }
                        final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {

                            @Override
                            protected void run() throws LoginException, PersistenceException {
                                ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
                            }
                        };
                        workUnit.setAvoidUnloadResources(true);
                        factory.executeRepositoryWorkUnit(workUnit);
                    }
                });
            }
        };
        IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                try {
                    ISchedulingRule schedulingRule = workspace.getRoot();
                    // the update the project files need to be done in the workspace runnable to avoid all
                    // notification
                    // of changes before the end of the modifications.
                    workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
        try {
            new ProgressMonitorDialog(null).run(true, true, iRunnableWithProgress);
        } catch (InvocationTargetException e) {
            ExceptionHandler.process(e);
        } catch (InterruptedException e) {
        //
        }
        return true;
    } else {
        return false;
    }
}
Also used : Set(java.util.Set) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Entry(java.util.Map.Entry) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) JSONXPathLoopDescriptor(org.talend.repository.model.json.JSONXPathLoopDescriptor) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SchemaTarget(org.talend.repository.model.json.SchemaTarget) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) EList(org.eclipse.emf.common.util.EList) CoreException(org.eclipse.core.runtime.CoreException) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IWizardPage(org.eclipse.jface.wizard.IWizardPage) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with IWizardPage

use of org.eclipse.jface.wizard.IWizardPage in project azure-tools-for-java by Microsoft.

the class AzureWizardDialog method backPressed.

@Override
protected void backPressed() {
    IWizardPage page = getCurrentPage().getPreviousPage();
    if (page == null) {
        // should never happen since we have already visited the page
        return;
    }
    sendTelemetryOnAction("Previos");
    super.backPressed();
}
Also used : IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Example 9 with IWizardPage

use of org.eclipse.jface.wizard.IWizardPage in project azure-tools-for-java by Microsoft.

the class AzureWizardDialog method nextPressed.

@Override
protected void nextPressed() {
    IWizardPage page = getCurrentPage().getNextPage();
    if (page == null) {
        // something must have happened getting the next page
        return;
    }
    sendTelemetryOnAction("Next");
    super.nextPressed();
}
Also used : IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Example 10 with IWizardPage

use of org.eclipse.jface.wizard.IWizardPage in project cubrid-manager by CUBRID.

the class VolumeSizeValidator method pageChanged.

public void pageChanged(PageChangedEvent event) {
    IWizardPage page = (IWizardPage) event.getSelectedPage();
    if (page.getName().equals(PAGENAME)) {
        GeneralInfoPage generalInfoPage = (GeneralInfoPage) getWizard().getPage(GeneralInfoPage.PAGENAME);
        pageSize = generalInfoPage.getPageSize();
        String volumeSize = volumeSizeText.getText();
        if (volumeSize.trim().equals("")) {
            volumeSizeText.setText(generalInfoPage.getDefaultDatVolumeSize());
        }
        if (!isAddedDefaultVolume) {
            addDefaultVolume(generalInfoPage);
            isAddedDefaultVolume = true;
        }
        changeVolumeName();
        /*Update Page number*/
        for (Map<String, String> map : volumeTableList) {
            String totalSize = map.get("2");
            long pageNum = CreateDatabaseWizard.calcVolumePageNum(totalSize, pageSize);
            map.put("3", String.valueOf(pageNum));
        }
    }
}
Also used : IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Aggregations

IWizardPage (org.eclipse.jface.wizard.IWizardPage)36 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Control (org.eclipse.swt.widgets.Control)4 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)3 DBClasses (com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IPageChangedListener (org.eclipse.jface.dialogs.IPageChangedListener)3 IPageChangingListener (org.eclipse.jface.dialogs.IPageChangingListener)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 IOpenListener (org.eclipse.jface.viewers.IOpenListener)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 OpenEvent (org.eclipse.jface.viewers.OpenEvent)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 WizardPage (org.eclipse.jface.wizard.WizardPage)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2