Search in sources :

Example 11 with IPageChangedListener

use of org.eclipse.jface.dialogs.IPageChangedListener in project n4js by eclipse.

the class NpmExportWizard method init.

@Override
public void init(IWorkbench targetWorkbench, IStructuredSelection currentSelection) {
    // this.selection = currentSelection;
    List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
    List<IProject> workspaceProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
    // Find all selected projects
    Set<IProject> projects = selectedResources.stream().filter(m -> m instanceof IResource).map(m -> ((IResource) m).getProject()).filter(// only open projects
    p -> p.isOpen()).collect(Collectors.toSet());
    // make the behavior predictable by ordering:
    TreeSet<IProject> sortedProjects = Sets.<IProject>newTreeSet((a, b) -> a.getName().compareToIgnoreCase(b.getName()));
    sortedProjects.addAll(projects);
    // 0) turn into IN4JSProject and give and process further.
    // a) find out which projects fulfill the npm-"exportable"-contract
    // b) give back a list to the user what to export,
    // c) disable things not fullfilling the contract.
    // d) take choosing from the list and pass to exporter in non-ui package.
    // 0)
    List<IN4JSEclipseProject> rawN4jsProjects = Lists.newArrayList();
    iP2in4jsP = HashBiMap.create();
    for (IProject iProject : workspaceProjects) {
        IN4JSEclipseProject mappedIn4jsProject = map2In4js(iProject);
        if (mappedIn4jsProject != null) {
            rawN4jsProjects.add(mappedIn4jsProject);
            iP2in4jsP.put(iProject, mappedIn4jsProject);
        }
    }
    // filter out Non-N4JS-projects from initial selection.
    sortedProjects.retainAll(iP2in4jsP.keySet());
    // filter out all non-N4JS-projects from the workspace projects.
    ArrayList<IProject> filteredWorkspaceProjects = new ArrayList<>(workspaceProjects);
    filteredWorkspaceProjects.retainAll(iP2in4jsP.keySet());
    setWindowTitle("N4JS to npm Export");
    setNeedsProgressMonitor(true);
    Map<IProject, Boolean> selectedProjects = new HashMap<>();
    // Add all workspace projects to list, default selection value is false
    filteredWorkspaceProjects.forEach(project -> selectedProjects.put(project, false));
    // Override selection value for all initially selected projects
    sortedProjects.forEach(project -> selectedProjects.put(project, true));
    // exportPage = new ExportSelectionPage("Export Page", rawN4jsProjects, labelProvider);
    exportPage = new ExportSelectionPage("Export Page", selectedProjects);
    if (runTools())
        toolRunnerPage = new NpmToolRunnerPage("npm Execution Page");
    comparePage = new PackageJsonComparePage("Compare package.json Page");
    pageListener = new IPageChangedListener() {

        @Override
        public void pageChanged(PageChangedEvent event) {
            if (event.getSelectedPage() == comparePage) {
                udpatePackagJasonComparison();
            }
        }
    };
}
Also used : Arrays(java.util.Arrays) WorkbenchPlugin(org.eclipse.ui.internal.WorkbenchPlugin) IN4JSEclipseCore(org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) N4JSActivator(org.eclipse.n4js.ui.internal.N4JSActivator) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) Map(java.util.Map) Diagnostician(org.eclipse.n4js.npmexporter.validation.Diagnostician) BiMap(com.google.common.collect.BiMap) ArchiveException(org.apache.commons.compress.archivers.ArchiveException) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) Wizard(org.eclipse.jface.wizard.Wizard) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) Sets(com.google.common.collect.Sets) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) WizardDialog(org.eclipse.jface.wizard.WizardDialog) NpmExporter(org.eclipse.n4js.npmexporter.NpmExporter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Joiner(com.google.common.base.Joiner) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) IDE(org.eclipse.ui.ide.IDE) MergeResult(org.eclipse.n4js.npmexporter.NpmExporter.MergeResult) URI(org.eclipse.emf.common.util.URI) IWizardPage(org.eclipse.jface.wizard.IWizardPage) ERROR(org.eclipse.core.runtime.IStatus.ERROR) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) IProject(org.eclipse.core.resources.IProject) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) IExportWizard(org.eclipse.ui.IExportWizard) ExecutorService(java.util.concurrent.ExecutorService) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IResourceSetProvider(org.eclipse.xtext.ui.resource.IResourceSetProvider) CompressorException(org.apache.commons.compress.compressors.CompressorException) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) File(java.io.File) HashBiMap(com.google.common.collect.HashBiMap) IResource(org.eclipse.core.resources.IResource) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IWorkbench(org.eclipse.ui.IWorkbench) BufferedReader(java.io.BufferedReader) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) HashMap(java.util.HashMap) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) IProject(org.eclipse.core.resources.IProject) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IResource(org.eclipse.core.resources.IResource)

Example 12 with IPageChangedListener

use of org.eclipse.jface.dialogs.IPageChangedListener in project hale by halestudio.

the class HaleWizardPage method createControl.

/**
 * @see WizardPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    IWizardContainer container = getContainer();
    if (container instanceof IPageChangeProvider) {
        ((IPageChangeProvider) container).addPageChangedListener(changeListener = new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == HaleWizardPage.this) {
                    if (wasShown) {
                        onShowPage(false);
                    } else {
                        wasShown = true;
                        onShowPage(true);
                    }
                }
            }
        });
    }
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new FillLayout());
    createContent(page);
    setControl(page);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) Composite(org.eclipse.swt.widgets.Composite) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 13 with IPageChangedListener

use of org.eclipse.jface.dialogs.IPageChangedListener in project hale by halestudio.

the class ConfigurationWizardPage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    IWizardContainer container = getContainer();
    if (container instanceof IPageChangeProvider) {
        ((IPageChangeProvider) container).addPageChangedListener(new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (currentPage == ConfigurationWizardPage.this) {
                    // try to apply current configuration
                    updateConfiguration(getWizard().getConfiguration());
                    onHidePage();
                }
                currentPage = event.getSelectedPage();
                if (event.getSelectedPage() == ConfigurationWizardPage.this) {
                    onShowPage();
                }
            }
        });
    }
    createContent(parent);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent)

Example 14 with IPageChangedListener

use of org.eclipse.jface.dialogs.IPageChangedListener in project hale by halestudio.

the class WMSWizardPage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    IWizardContainer container = getContainer();
    if (container instanceof IPageChangeProvider) {
        ((IPageChangeProvider) container).addPageChangedListener(new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == WMSWizardPage.this) {
                    onShowPage();
                }
            }
        });
    }
    createContent(parent);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent)

Example 15 with IPageChangedListener

use of org.eclipse.jface.dialogs.IPageChangedListener in project cubrid-manager by CUBRID.

the class ImportDataWizardDialog method createContents.

/**
	 * Overwrite the method. Auto add IPageChangingListener(s);
	 * 
	 * @param parent of the control.
	 * @return Control
	 */
protected Control createContents(Composite parent) {
    Control result = super.createContents(parent);
    IWizardPage[] pages = this.getWizard().getPages();
    for (IWizardPage page : pages) {
        if (page instanceof IPageChangingListener) {
            this.addPageChangingListener((IPageChangingListener) page);
        }
        if (page instanceof IPageChangedListener) {
            this.addPageChangedListener((IPageChangedListener) page);
        }
    }
    return result;
}
Also used : IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) Control(org.eclipse.swt.widgets.Control) IWizardPage(org.eclipse.jface.wizard.IWizardPage) IPageChangingListener(org.eclipse.jface.dialogs.IPageChangingListener)

Aggregations

IPageChangedListener (org.eclipse.jface.dialogs.IPageChangedListener)27 PageChangedEvent (org.eclipse.jface.dialogs.PageChangedEvent)15 IPageChangingListener (org.eclipse.jface.dialogs.IPageChangingListener)6 SafeRunnable (org.eclipse.jface.util.SafeRunnable)6 IPageChangeProvider (org.eclipse.jface.dialogs.IPageChangeProvider)5 IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)5 IWizardPage (org.eclipse.jface.wizard.IWizardPage)4 Composite (org.eclipse.swt.widgets.Composite)3 Control (org.eclipse.swt.widgets.Control)3 TreeSet (java.util.TreeSet)2 PageChangingEvent (org.eclipse.jface.dialogs.PageChangingEvent)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 Point (org.eclipse.swt.graphics.Point)2 IWorkbench (org.eclipse.ui.IWorkbench)2 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)1 WorkflowSelectionProvider (com.centurylink.mdw.plugin.designer.WorkflowSelectionProvider)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 TaskTemplateDocument (com.centurylink.mdw.task.TaskTemplateDocument)1 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)1