Bug 354561 - [Dialogs][Wizards]Impossible to reinitialize the Structured Selection in WizardResourceImportPage abstract class in package org.eclipse.ui.dialogs
Summary: [Dialogs][Wizards]Impossible to reinitialize the Structured Selection in Wiza...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 3.6.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: api
Depends on:
Blocks:
 
Reported: 2011-08-11 17:56 EDT by Mircea Luchian CLA
Modified: 2019-11-14 03:52 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mircea Luchian CLA 2011-08-11 17:56:11 EDT
Build Identifier: M20110210-1200 Eclipse 3.6.2

I utilize the org.eclipse.ui.internal.wizards.datatransfer.WizardArchiveFileResourceImportPage1 class to import a zip file in my custom made IDE. This Page is put in an import wizard, but it is preceded by a project creation page that creates the project before this wizard page page is displayed (all in the same wizard). With this new structured selection (the new project), I would like to reinitialize my WizardArchiveFileResourceImportPage1 so that the "Into folder" selection appears updated with the newly created project. 

Extending the WizardArchiveFileResourceImportPage class (extends WizardFileSystemResourceImportPage1 which in turns extendsWizardResourceImportPage) in my own page does not achieve anything as the "Into folder" value is embedded in the super class WizardResourceImportPage so i cannot reinitialize it programmatically. 

I propose to add an "init" function to WizardResourceImportPage that will do the following and will be accessible by the subclasses in the hierarchy structure: 

    protected void reinitializeCurrentResourceSelection(IStructuredSelection selection) {
        //Initialize to null
        currentResourceSelection = null;
        if (selection.size() == 1)
        {
            Object firstElement = selection.getFirstElement();
            if (firstElement instanceof IAdaptable)
            {
                Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
                if (resource != null)
                {
                    currentResourceSelection = (IResource) resource;
                }
            }
        }

        if (currentResourceSelection != null)
        {
            if (currentResourceSelection.getType() == IResource.FILE)
            {
                currentResourceSelection = currentResourceSelection.getParent();
            }

            if (!currentResourceSelection.isAccessible())
            {
                currentResourceSelection = null;
            }
        }
        containerNameField.setText(currentResourceSelection.getFullPath().makeRelative().toString());
    }

Reproducible: Always

Steps to Reproduce:
see above
Comment 1 Lars Vogel CLA 2019-11-14 03:52:02 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.