Search in sources :

Example 1 with ModuleSpecifierProposalLabelProvider

use of org.eclipse.n4js.ui.wizard.contentproposal.ModuleSpecifierContentProposalProviderFactory.ModuleSpecifierProposalLabelProvider in project n4js by eclipse.

the class WorkspaceWizardPage method setupContentProposal.

private void setupContentProposal(WorkspaceWizardPageForm wizardForm) {
    // Get the active binding's content assist key strokes
    KeyStroke keyInitiator = getActiveContentAssistBinding();
    // If unbound don't configure the content proposal
    if (null == keyInitiator) {
        return;
    }
    // Setup project content proposal
    ContentProposalAdapter projectAdapter = new ContentProposalAdapter(wizardForm.getProjectText(), new TextContentAdapter(), projectContentProposalProvider, keyInitiator, null);
    projectAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    ImageDescriptor projectSymbol = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
    projectAdapter.setLabelProvider(new SimpleImageContentProposalLabelProvider(projectSymbol));
    createContentProposalDecoration(wizardForm.getProjectText());
    sourceFolderContentProposalAdapter = new ContentProposalAdapter(wizardForm.getSourceFolderText(), new TextContentAdapter(), null, keyInitiator, null);
    sourceFolderContentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    sourceFolderContentProposalAdapter.setLabelProvider(new SimpleImageContentProposalLabelProvider(ImageDescriptorCache.ImageRef.SRC_FOLDER.asImageDescriptor().orNull()));
    createContentProposalDecoration(wizardForm.getSourceFolderText());
    moduleSpecifierContentProposalAdapter = new ContentProposalAdapter(wizardForm.getModuleSpecifierText().getInternalText(), new TextContentAdapter(), null, keyInitiator, null);
    wizardForm.getModuleSpecifierText().createDecoration(contentProposalDecorationImage);
    // Update proposal context whenever the model changes
    model.addPropertyChangeListener(evt -> {
        if (evt.getPropertyName() == WorkspaceWizardModel.PROJECT_PROPERTY || evt.getPropertyName() == WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY) {
            updateProposalContext();
        }
    });
    updateProposalContext();
    moduleSpecifierContentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    moduleSpecifierContentProposalAdapter.setLabelProvider(new ModuleSpecifierProposalLabelProvider());
}
Also used : ModuleSpecifierProposalLabelProvider(org.eclipse.n4js.ui.wizard.contentproposal.ModuleSpecifierContentProposalProviderFactory.ModuleSpecifierProposalLabelProvider) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) SimpleImageContentProposalLabelProvider(org.eclipse.n4js.ui.wizard.contentproposal.SimpleImageContentProposalLabelProvider) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Aggregations

KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)1 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)1 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 ModuleSpecifierProposalLabelProvider (org.eclipse.n4js.ui.wizard.contentproposal.ModuleSpecifierContentProposalProviderFactory.ModuleSpecifierProposalLabelProvider)1 SimpleImageContentProposalLabelProvider (org.eclipse.n4js.ui.wizard.contentproposal.SimpleImageContentProposalLabelProvider)1