Search in sources :

Example 1 with VERSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION in project m2e-core-tests by tesla.

the class ExcludeArtifactRefactoringTest method hasExclusionSet.

/*
   * The editor has the given exclusion set
   */
protected static boolean hasExclusionSet(MavenPomEditor editor, final ArtifactKey dependencyKey, final ArtifactKey excluded) throws Exception {
    final boolean[] found = new boolean[1];
    found[0] = false;
    performOnDOMDocument(new OperationTuple(editor.getDocument(), document -> {
        Element dep = findChild(findChild(document.getDocumentElement(), DEPENDENCIES), DEPENDENCY, childEquals(GROUP_ID, dependencyKey.getGroupId()), childEquals(ARTIFACT_ID, dependencyKey.getArtifactId()), childEquals(VERSION, dependencyKey.getVersion()));
        if (dep != null) {
            Element exclusion = findChild(findChild(dep, EXCLUSIONS), EXCLUSION, childEquals(GROUP_ID, excluded.getGroupId()), childEquals(ARTIFACT_ID, excluded.getArtifactId()));
            found[0] = exclusion != null;
        }
    }, true));
    return found[0];
}
Also used : ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) ParentGatherer(org.eclipse.m2e.core.ui.internal.util.ParentGatherer) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) CoreException(org.eclipse.core.runtime.CoreException) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) PartInitException(org.eclipse.ui.PartInitException) After(org.junit.After) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) AbstractMavenProjectTestCase(org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase) PomEdits.childEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childEquals) Assert.fail(org.junit.Assert.fail) Change(org.eclipse.ltk.core.refactoring.Change) PomResourceImpl(org.eclipse.m2e.model.edit.pom.util.PomResourceImpl) RefactoringStatusEntry(org.eclipse.ltk.core.refactoring.RefactoringStatusEntry) NLS(org.eclipse.osgi.util.NLS) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) MavenPomEditor(org.eclipse.m2e.editor.pom.MavenPomEditor) EXCLUSIONS(org.eclipse.m2e.core.ui.internal.editing.PomEdits.EXCLUSIONS) Status(org.eclipse.core.runtime.Status) Display(org.eclipse.swt.widgets.Display) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) List(java.util.List) Resource(org.eclipse.emf.ecore.resource.Resource) Model(org.eclipse.m2e.model.edit.pom.Model) EXCLUSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.EXCLUSION) DEPENDENCY(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCY) Dependency(org.eclipse.m2e.model.edit.pom.Dependency) Exclusion(org.eclipse.m2e.model.edit.pom.Exclusion) URI(org.eclipse.emf.common.util.URI) HashMap(java.util.HashMap) ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IDocument(org.eclipse.jface.text.IDocument) IProject(org.eclipse.core.resources.IProject) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) IFile(org.eclipse.core.resources.IFile) PomResourceFactoryImpl(org.eclipse.m2e.model.edit.pom.util.PomResourceFactoryImpl) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) DEPENDENCIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCIES) Element(org.w3c.dom.Element) StructuredModelManager(org.eclipse.wst.sse.core.StructuredModelManager) ParentHierarchyEntry(org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) Assert.assertEquals(org.junit.Assert.assertEquals) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) Element(org.w3c.dom.Element)

Example 2 with VERSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION in project m2e-core by eclipse-m2e.

the class OverviewPage method addSelectedModules.

private void addSelectedModules(Object[] result, boolean updateParentSection) {
    final String[] vals = new String[3];
    try {
        performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
            Element root = document.getDocumentElement();
            String grid = getTextValue(findChild(root, GROUP_ID));
            Element parent = findChild(root, PARENT);
            if (grid == null) {
                grid = getTextValue(findChild(parent, GROUP_ID));
            }
            String artifactId = getTextValue(findChild(root, ARTIFACT_ID));
            String version = getTextValue(findChild(root, VERSION));
            if (version == null) {
                version = getTextValue(findChild(parent, VERSION));
            }
            vals[0] = grid;
            vals[1] = artifactId;
            vals[2] = version;
        }, true));
    } catch (Exception ex) {
        LOG.error("Error getting values from document", ex);
    }
    final String parentGroupId = vals[0];
    final String parentArtifactId = vals[1];
    final String parentVersion = vals[2];
    final IPath projectPath = getProject().getLocation();
    for (Object selection : result) {
        IContainer container = null;
        IFile pomFile = null;
        if (selection instanceof IFile) {
            pomFile = (IFile) selection;
            if (!IMavenConstants.POM_FILE_NAME.equals(pomFile.getName())) {
                continue;
            }
            container = pomFile.getParent();
        } else if (selection instanceof IContainer && !selection.equals(getProject())) {
            container = (IContainer) selection;
            pomFile = container.getFile(new Path(IMavenConstants.POM_FILE_NAME));
        }
        if (pomFile == null || !pomFile.exists() || container == null) {
            continue;
        }
        IPath resultPath = container.getLocation();
        String path = resultPath.makeRelativeTo(projectPath).toString();
        if (updateParentSection) {
            final String relativePath = projectPath.makeRelativeTo(resultPath).toString();
            try {
                performOnDOMDocument(new OperationTuple(pomFile, (Operation) document -> {
                    Element root = document.getDocumentElement();
                    Element parent = getChild(root, PARENT);
                    setText(getChild(parent, GROUP_ID), parentGroupId);
                    setText(getChild(parent, ARTIFACT_ID), parentArtifactId);
                    setText(getChild(parent, VERSION), parentVersion);
                    setText(getChild(parent, RELATIVE_PATH), relativePath);
                    Element grId = findChild(root, GROUP_ID);
                    String grIdText = getTextValue(grId);
                    if (grIdText != null && grIdText.equals(parentGroupId)) {
                        removeChild(root, grId);
                    }
                    Element ver = findChild(root, VERSION);
                    String verText = getTextValue(ver);
                    if (verText != null && verText.equals(parentVersion)) {
                        removeChild(root, ver);
                    }
                }));
            } catch (Exception e) {
                LOG.error("Error updating parent reference in file:" + pomFile, e);
            }
        }
        createNewModule(path);
    }
}
Also used : Notification(org.eclipse.emf.common.notify.Notification) MavenModuleWizard(org.eclipse.m2e.core.ui.internal.wizards.MavenModuleWizard) DND(org.eclipse.swt.dnd.DND) CoreException(org.eclipse.core.runtime.CoreException) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) RELATIVE_PATH(org.eclipse.m2e.core.ui.internal.editing.PomEdits.RELATIVE_PATH) Document(org.w3c.dom.Document) Composite(org.eclipse.swt.widgets.Composite) SCM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SCM) PomEdits.removeChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild) Text(org.eclipse.swt.widgets.Text) M2EUIUtils(org.eclipse.m2e.core.ui.internal.util.M2EUIUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Window(org.eclipse.jface.window.Window) NAME(org.eclipse.m2e.core.ui.internal.editing.PomEdits.NAME) PomEdits.createElementWithText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElementWithText) MavenImages(org.eclipse.m2e.core.ui.internal.MavenImages) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) CI_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CI_MANAGEMENT) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Operation(org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation) SelectionListener(org.eclipse.swt.events.SelectionListener) ISSUE_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ISSUE_MANAGEMENT) URL(org.eclipse.m2e.core.ui.internal.editing.PomEdits.URL) PARENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PARENT) StringLabelProvider(org.eclipse.m2e.editor.composites.StringLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PomEdits(org.eclipse.m2e.core.ui.internal.editing.PomEdits) PomEdits.getChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild) ArrayList(java.util.ArrayList) IContainer(org.eclipse.core.resources.IContainer) IMavenConstants(org.eclipse.m2e.core.internal.IMavenConstants) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) INCEPTION_YEAR(org.eclipse.m2e.core.ui.internal.editing.PomEdits.INCEPTION_YEAR) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) MavenRepositorySearchDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) LinkedHashSet(java.util.LinkedHashSet) Section(org.eclipse.ui.forms.widgets.Section) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StackLayout(org.eclipse.swt.custom.StackLayout) ListEditorContentProvider(org.eclipse.m2e.editor.composites.ListEditorContentProvider) FormUtils.setText(org.eclipse.m2e.editor.pom.FormUtils.setText) PROPERTIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PROPERTIES) Plugin(org.apache.maven.model.Plugin) ModifyListener(org.eclipse.swt.events.ModifyListener) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MODULES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULES) MavenEditorImages(org.eclipse.m2e.editor.MavenEditorImages) GridLayout(org.eclipse.swt.layout.GridLayout) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) LoggerFactory(org.slf4j.LoggerFactory) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) JarFile(java.util.jar.JarFile) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) MavenModuleSelectionDialog(org.eclipse.m2e.editor.dialogs.MavenModuleSelectionDialog) PomEdits.getTextValue(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getTextValue) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) MavenPluginActivator(org.eclipse.m2e.core.internal.MavenPluginActivator) IPath(org.eclipse.core.runtime.IPath) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) TAG(org.eclipse.m2e.core.ui.internal.editing.PomEdits.TAG) Artifact(org.apache.maven.artifact.Artifact) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) PomEdits.setText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText) CCombo(org.eclipse.swt.custom.CCombo) Messages(org.eclipse.m2e.editor.internal.Messages) PomEdits.format(org.eclipse.m2e.core.ui.internal.editing.PomEdits.format) NLS(org.eclipse.osgi.util.NLS) WidthGroup(org.eclipse.m2e.core.ui.internal.wizards.WidthGroup) Display(org.eclipse.swt.widgets.Display) IManagedForm(org.eclipse.ui.forms.IManagedForm) MODULE(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULE) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) PomEdits.textEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.textEquals) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SYSTEM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SYSTEM) Label(org.eclipse.swt.widgets.Label) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PomEdits.findChilds(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChilds) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CONNECTION) ORGANIZATION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ORGANIZATION) Image(org.eclipse.swt.graphics.Image) PACKAGING(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PACKAGING) HashSet(java.util.HashSet) ProposalUtil(org.eclipse.m2e.core.ui.internal.util.ProposalUtil) JarEntry(java.util.jar.JarEntry) DESCRIPTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DESCRIPTION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) Node(org.w3c.dom.Node) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) FormUtils.nvl(org.eclipse.m2e.editor.pom.FormUtils.nvl) ICellModifier(org.eclipse.jface.viewers.ICellModifier) Packaging(org.eclipse.m2e.core.ui.internal.search.util.Packaging) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Action(org.eclipse.jface.action.Action) PomEdits.childAt(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childAt) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Element(org.w3c.dom.Element) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IndexedArtifactFile(org.eclipse.m2e.core.internal.index.IndexedArtifactFile) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) DEV_CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEV_CONNECTION) Control(org.eclipse.swt.widgets.Control) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Element(org.w3c.dom.Element) Operation(org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation) IContainer(org.eclipse.core.resources.IContainer) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 with VERSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION in project m2e-core by eclipse-m2e.

the class OverviewPage method createParentsection.

private void createParentsection(FormToolkit toolkit, Composite composite, WidthGroup widthGroup) {
    parentSection = // 
    toolkit.createSection(// 
    composite, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
    parentSection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    parentSection.setText(Messages.OverviewPage_section_parent);
    // $NON-NLS-1$ //$NON-NLS-2$
    parentSection.setData("name", "parentSection");
    parentSelectAction = new Action(Messages.OverviewPage_action_selectParent, MavenEditorImages.SELECT_ARTIFACT) {

        @Override
        public void run() {
            // calculate current list of artifacts for the project - that's the current parent..
            Set<ArtifactKey> current = new HashSet<>();
            String parentGroup = parentGroupIdText.getText();
            String parentArtifact = parentArtifactIdText.getText();
            String parentVersion = parentVersionText.getText();
            if (parentGroup != null && parentArtifact != null && parentVersion != null) {
                current.add(new ArtifactKey(parentGroup, parentArtifact, parentVersion, null));
            }
            MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchParentDialog(getEditorSite().getShell(), Messages.OverviewPage_searchDialog_selectParent, getPomEditor().getMavenProject(), getProject());
            if (parentGroup != null && parentGroup.trim().length() != 0) {
                // chances are we will get good match by adding the groupid here..
                dialog.setQuery(parentGroupIdText.getText());
            } else if (artifactGroupIdText.getText() != null && artifactGroupIdText.getText().trim().length() != 0) {
                // chances are we will get good match by adding the groupid here..
                dialog.setQuery(artifactGroupIdText.getText());
            }
            if (dialog.open() == Window.OK) {
                IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
                if (af != null) {
                    String grid = nvl(af.group);
                    String ver = nvl(af.version);
                    parentGroupIdText.setText(grid);
                    parentArtifactIdText.setText(nvl(af.artifact));
                    parentVersionText.setText(ver);
                    // promote good practices ->
                    if (grid.equals(artifactGroupIdText.getText())) {
                        // if the groupId is the same, just remove it in child.
                        // $NON-NLS-1$
                        artifactGroupIdText.setText("");
                    }
                    if (ver.equals(artifactVersionText.getText())) {
                        // if the version is the same, just remove it in child.
                        // $NON-NLS-1$
                        artifactVersionText.setText("");
                    }
                    parentSection.setExpanded(true);
                }
            }
        }
    };
    parentSelectAction.setEnabled(false);
    parentOpenAction = new Action(Messages.OverviewPage_job_open, MavenEditorImages.PARENT_POM) {

        @Override
        public void run() {
            final String groupId = parentGroupIdText.getText();
            final String artifactId = parentArtifactIdText.getText();
            final String version = parentVersionText.getText();
            new Job(NLS.bind(Messages.OverviewPage_job, new Object[] { groupId, artifactId, version })) {

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    OpenPomAction.openEditor(groupId, artifactId, version, getPomEditor().getMavenProject(), monitor);
                    return Status.OK_STATUS;
                }
            }.schedule();
        }
    };
    parentOpenAction.setEnabled(false);
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.add(parentOpenAction);
    toolBarManager.add(parentSelectAction);
    Composite toolbarComposite = toolkit.createComposite(parentSection);
    GridLayout toolbarLayout = new GridLayout(1, true);
    toolbarLayout.marginHeight = 0;
    toolbarLayout.marginWidth = 0;
    toolbarComposite.setLayout(toolbarLayout);
    toolbarComposite.setBackground(null);
    toolBarManager.createControl(toolbarComposite);
    parentSection.setTextClient(toolbarComposite);
    Composite parentComposite = toolkit.createComposite(parentSection, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginBottom = 5;
    gridLayout.marginWidth = 1;
    gridLayout.marginHeight = 2;
    parentComposite.setLayout(gridLayout);
    parentSection.setClient(parentComposite);
    Label parentGroupIdLabel = toolkit.createLabel(parentComposite, Messages.OverviewPage_lblGroupId2, SWT.NONE);
    parentGroupIdText = toolkit.createText(parentComposite, null, SWT.NONE);
    GridData gd_parentGroupIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_parentGroupIdText.horizontalIndent = 4;
    parentGroupIdText.setLayoutData(gd_parentGroupIdText);
    // $NON-NLS-1$ //$NON-NLS-2$
    parentGroupIdText.setData("name", "parentGroupId");
    ProposalUtil.addGroupIdProposal(getProject(), parentGroupIdText, Packaging.POM);
    M2EUIUtils.addRequiredDecoration(parentGroupIdText);
    createEvaluatorInfo(parentGroupIdText);
    setElementValueProvider(parentGroupIdText, new ElementValueProvider(PomEdits.PARENT, PomEdits.GROUP_ID));
    setModifyListener(parentGroupIdText);
    final Label parentArtifactIdLabel = toolkit.createLabel(parentComposite, Messages.OverviewPage_lblArtifactId, SWT.NONE);
    parentArtifactIdText = toolkit.createText(parentComposite, null, SWT.NONE);
    GridData gd_parentArtifactIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_parentArtifactIdText.horizontalIndent = 4;
    parentArtifactIdText.setLayoutData(gd_parentArtifactIdText);
    // $NON-NLS-1$ //$NON-NLS-2$
    parentArtifactIdText.setData("name", "parentArtifactId");
    ProposalUtil.addArtifactIdProposal(getProject(), parentGroupIdText, parentArtifactIdText, Packaging.POM);
    M2EUIUtils.addRequiredDecoration(parentArtifactIdText);
    createEvaluatorInfo(parentArtifactIdText);
    setElementValueProvider(parentArtifactIdText, new ElementValueProvider(PomEdits.PARENT, PomEdits.ARTIFACT_ID));
    setModifyListener(parentArtifactIdText);
    Label parentVersionLabel = toolkit.createLabel(parentComposite, Messages.OverviewPage_lblVersion2, SWT.NONE);
    parentVersionLabel.setLayoutData(new GridData());
    parentVersionText = toolkit.createText(parentComposite, null, SWT.NONE);
    GridData parentVersionTextData = new GridData(SWT.LEFT, SWT.CENTER, true, false);
    parentVersionTextData.horizontalIndent = 4;
    parentVersionTextData.widthHint = 200;
    parentVersionText.setLayoutData(parentVersionTextData);
    // $NON-NLS-1$ //$NON-NLS-2$
    parentVersionText.setData("name", "parentVersion");
    ProposalUtil.addVersionProposal(getProject(), null, /**
     * null because we don't want expressions from parent pom here
     */
    parentGroupIdText, parentArtifactIdText, parentVersionText, Packaging.POM);
    M2EUIUtils.addRequiredDecoration(parentVersionText);
    createEvaluatorInfo(parentVersionText);
    setElementValueProvider(parentVersionText, new ElementValueProvider(PomEdits.PARENT, PomEdits.VERSION));
    setModifyListener(parentVersionText);
    ModifyListener ml = e -> {
        // apparently the loadParent() method also participates in the enablement logic from time to time..
        String text1 = parentArtifactIdText.getText().trim();
        String text2 = parentGroupIdText.getText().trim();
        String text3 = parentVersionText.getText().trim();
        if (text1.length() > 0 && text2.length() > 0 && text3.length() > 0) {
            parentOpenAction.setEnabled(true);
        } else {
            parentOpenAction.setEnabled(false);
        }
    };
    parentArtifactIdText.addModifyListener(ml);
    parentVersionText.addModifyListener(ml);
    parentGroupIdText.addModifyListener(ml);
    Label parentRealtivePathLabel = toolkit.createLabel(parentComposite, Messages.OverviewPage_lblRelPath, SWT.NONE);
    parentRelativePathText = toolkit.createText(parentComposite, null, SWT.NONE);
    GridData gd_parentRelativePathText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_parentRelativePathText.horizontalIndent = 4;
    parentRelativePathText.setLayoutData(gd_parentRelativePathText);
    // $NON-NLS-1$ //$NON-NLS-2$
    parentRelativePathText.setData("name", "parentRelativePath");
    createEvaluatorInfo(parentRelativePathText);
    setElementValueProvider(parentRelativePathText, new ElementValueProvider(PomEdits.PARENT, PomEdits.RELATIVE_PATH));
    setModifyListener(parentRelativePathText);
    widthGroup.addControl(parentGroupIdLabel);
    widthGroup.addControl(parentArtifactIdLabel);
    widthGroup.addControl(parentVersionLabel);
    widthGroup.addControl(parentRealtivePathLabel);
    toolkit.paintBordersFor(parentComposite);
    parentComposite.setTabList(new Control[] { parentGroupIdText, parentArtifactIdText, parentVersionText, parentRelativePathText });
}
Also used : MavenRepositorySearchDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog) Notification(org.eclipse.emf.common.notify.Notification) MavenModuleWizard(org.eclipse.m2e.core.ui.internal.wizards.MavenModuleWizard) DND(org.eclipse.swt.dnd.DND) CoreException(org.eclipse.core.runtime.CoreException) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) RELATIVE_PATH(org.eclipse.m2e.core.ui.internal.editing.PomEdits.RELATIVE_PATH) Document(org.w3c.dom.Document) Composite(org.eclipse.swt.widgets.Composite) SCM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SCM) PomEdits.removeChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild) Text(org.eclipse.swt.widgets.Text) M2EUIUtils(org.eclipse.m2e.core.ui.internal.util.M2EUIUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Window(org.eclipse.jface.window.Window) NAME(org.eclipse.m2e.core.ui.internal.editing.PomEdits.NAME) PomEdits.createElementWithText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElementWithText) MavenImages(org.eclipse.m2e.core.ui.internal.MavenImages) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) CI_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CI_MANAGEMENT) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Operation(org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation) SelectionListener(org.eclipse.swt.events.SelectionListener) ISSUE_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ISSUE_MANAGEMENT) URL(org.eclipse.m2e.core.ui.internal.editing.PomEdits.URL) PARENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PARENT) StringLabelProvider(org.eclipse.m2e.editor.composites.StringLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PomEdits(org.eclipse.m2e.core.ui.internal.editing.PomEdits) PomEdits.getChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild) ArrayList(java.util.ArrayList) IContainer(org.eclipse.core.resources.IContainer) IMavenConstants(org.eclipse.m2e.core.internal.IMavenConstants) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) INCEPTION_YEAR(org.eclipse.m2e.core.ui.internal.editing.PomEdits.INCEPTION_YEAR) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) MavenRepositorySearchDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) LinkedHashSet(java.util.LinkedHashSet) Section(org.eclipse.ui.forms.widgets.Section) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StackLayout(org.eclipse.swt.custom.StackLayout) ListEditorContentProvider(org.eclipse.m2e.editor.composites.ListEditorContentProvider) FormUtils.setText(org.eclipse.m2e.editor.pom.FormUtils.setText) PROPERTIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PROPERTIES) Plugin(org.apache.maven.model.Plugin) ModifyListener(org.eclipse.swt.events.ModifyListener) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MODULES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULES) MavenEditorImages(org.eclipse.m2e.editor.MavenEditorImages) GridLayout(org.eclipse.swt.layout.GridLayout) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) LoggerFactory(org.slf4j.LoggerFactory) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) JarFile(java.util.jar.JarFile) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) MavenModuleSelectionDialog(org.eclipse.m2e.editor.dialogs.MavenModuleSelectionDialog) PomEdits.getTextValue(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getTextValue) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) MavenPluginActivator(org.eclipse.m2e.core.internal.MavenPluginActivator) IPath(org.eclipse.core.runtime.IPath) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) TAG(org.eclipse.m2e.core.ui.internal.editing.PomEdits.TAG) Artifact(org.apache.maven.artifact.Artifact) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) PomEdits.setText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText) CCombo(org.eclipse.swt.custom.CCombo) Messages(org.eclipse.m2e.editor.internal.Messages) PomEdits.format(org.eclipse.m2e.core.ui.internal.editing.PomEdits.format) NLS(org.eclipse.osgi.util.NLS) WidthGroup(org.eclipse.m2e.core.ui.internal.wizards.WidthGroup) Display(org.eclipse.swt.widgets.Display) IManagedForm(org.eclipse.ui.forms.IManagedForm) MODULE(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULE) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) PomEdits.textEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.textEquals) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SYSTEM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SYSTEM) Label(org.eclipse.swt.widgets.Label) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PomEdits.findChilds(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChilds) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CONNECTION) ORGANIZATION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ORGANIZATION) Image(org.eclipse.swt.graphics.Image) PACKAGING(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PACKAGING) HashSet(java.util.HashSet) ProposalUtil(org.eclipse.m2e.core.ui.internal.util.ProposalUtil) JarEntry(java.util.jar.JarEntry) DESCRIPTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DESCRIPTION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) Node(org.w3c.dom.Node) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) FormUtils.nvl(org.eclipse.m2e.editor.pom.FormUtils.nvl) ICellModifier(org.eclipse.jface.viewers.ICellModifier) Packaging(org.eclipse.m2e.core.ui.internal.search.util.Packaging) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Action(org.eclipse.jface.action.Action) PomEdits.childAt(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childAt) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Element(org.w3c.dom.Element) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IndexedArtifactFile(org.eclipse.m2e.core.internal.index.IndexedArtifactFile) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) DEV_CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEV_CONNECTION) Control(org.eclipse.swt.widgets.Control) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) Action(org.eclipse.jface.action.Action) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) Composite(org.eclipse.swt.widgets.Composite) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GridLayout(org.eclipse.swt.layout.GridLayout) IndexedArtifactFile(org.eclipse.m2e.core.internal.index.IndexedArtifactFile) GridData(org.eclipse.swt.layout.GridData) Job(org.eclipse.core.runtime.jobs.Job)

Example 4 with VERSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION in project m2e-core by eclipse-m2e.

the class OverviewPage method loadThis.

private void loadThis(final int mask) {
    Display.getDefault().asyncExec(() -> {
        removeNotifyListener(parentGroupIdText);
        removeNotifyListener(parentArtifactIdText);
        removeNotifyListener(parentVersionText);
        removeNotifyListener(parentRelativePathText);
        removeNotifyListener(artifactGroupIdText);
        removeNotifyListener(artifactIdText);
        removeNotifyListener(artifactVersionText);
        removeNotifyListener(artifactPackagingCombo);
        removeNotifyListener(projectNameText);
        removeNotifyListener(projectDescriptionText);
        removeNotifyListener(projectUrlText);
        removeNotifyListener(inceptionYearText);
        removeNotifyListener(organizationNameText);
        removeNotifyListener(organizationUrlText);
        removeNotifyListener(scmUrlText);
        removeNotifyListener(scmConnectionText);
        removeNotifyListener(scmDevConnectionText);
        removeNotifyListener(scmTagText);
        removeNotifyListener(ciManagementUrlCombo);
        removeNotifyListener(ciManagementSystemCombo);
        removeNotifyListener(issueManagementUrlCombo);
        removeNotifyListener(issueManagementSystemCombo);
        try {
            performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
                Element root = document.getDocumentElement();
                String pack = nvl(getTextValue(findChild(root, PACKAGING)));
                // $NON-NLS-1$ //$NON-NLS-2$
                pack = "".equals(pack) ? "jar" : pack;
                if ((mask & RELOAD_BASE) != 0) {
                    setText(artifactGroupIdText, nvl(getTextValue(findChild(root, GROUP_ID))));
                    setText(artifactIdText, nvl(getTextValue(findChild(root, ARTIFACT_ID))));
                    setText(artifactVersionText, nvl(getTextValue(findChild(root, VERSION))));
                    setText(artifactPackagingCombo, pack);
                    String name = getTextValue(findChild(root, NAME));
                    setText(projectNameText, nvl(name));
                    String desc = getTextValue(findChild(root, DESCRIPTION));
                    setText(projectDescriptionText, nvl(desc));
                    String url = getTextValue(findChild(root, URL));
                    setText(projectUrlText, nvl(url));
                    String incep = getTextValue(findChild(root, INCEPTION_YEAR));
                    setText(inceptionYearText, nvl(incep));
                    boolean expandProjectSection = name != null || desc != null || url != null || incep != null;
                    projectSectionData.grabExcessVerticalSpace = expandProjectSection;
                    projectSection.setExpanded(expandProjectSection);
                }
                if ((mask & RELOAD_PARENT) != 0) {
                    // parent section
                    Element parent = findChild(root, PARENT);
                    String parentGrId = getTextValue(findChild(parent, GROUP_ID));
                    String parentArtId = getTextValue(findChild(parent, ARTIFACT_ID));
                    String parentVers = getTextValue(findChild(parent, VERSION));
                    setText(parentGroupIdText, nvl(parentGrId));
                    setText(parentArtifactIdText, nvl(parentArtId));
                    setText(parentVersionText, nvl(parentVers));
                    setText(parentRelativePathText, nvl(getTextValue(findChild(parent, RELATIVE_PATH))));
                    parentSelectAction.setEnabled(!isReadOnly());
                    // only enable when all 3 coordinates are actually present.
                    parentOpenAction.setEnabled(root != null && parentGrId != null && parentArtId != null && parentVers != null);
                    parentSection.setExpanded(parent != null);
                }
                if ((mask & RELOAD_ORG) != 0) {
                    // organization section
                    Element org = findChild(root, ORGANIZATION);
                    setText(organizationNameText, nvl(getTextValue(findChild(org, NAME))));
                    setText(organizationUrlText, nvl(getTextValue(findChild(org, URL))));
                    organizationSection.setExpanded(org != null);
                }
                if ((mask & RELOAD_SCM) != 0) {
                    // scm section
                    Element scm = findChild(root, SCM);
                    setText(scmUrlText, nvl(getTextValue(findChild(scm, URL))));
                    setText(scmConnectionText, nvl(getTextValue(findChild(scm, CONNECTION))));
                    setText(scmDevConnectionText, nvl(getTextValue(findChild(scm, DEV_CONNECTION))));
                    setText(scmTagText, nvl(getTextValue(findChild(scm, TAG))));
                    scmSection.setExpanded(scm != null);
                }
                if ((mask & RELOAD_CI) != 0) {
                    // ci section
                    Element ci = findChild(root, CI_MANAGEMENT);
                    setText(ciManagementSystemCombo, nvl(getTextValue(findChild(ci, SYSTEM))));
                    setText(ciManagementUrlCombo, nvl(getTextValue(findChild(ci, URL))));
                    ciManagementSection.setExpanded(ci != null);
                }
                if ((mask & RELOAD_IM) != 0) {
                    // issue management
                    Element im = findChild(root, ISSUE_MANAGEMENT);
                    setText(issueManagementSystemCombo, nvl(getTextValue(findChild(im, SYSTEM))));
                    setText(issueManagementUrlCombo, nvl(getTextValue(findChild(im, URL))));
                    issueManagementSection.setExpanded(im != null);
                }
                if ((mask & RELOAD_MODULES) != 0) {
                    // modules section..
                    List<Element> moduleEls = findChilds(findChild(root, MODULES), MODULE);
                    List<String> modules = new ArrayList<>();
                    for (Element moduleEl : moduleEls) {
                        String text = getTextValue(moduleEl);
                        if (text != null) {
                            modules.add(text);
                        }
                    }
                    loadModules(modules, pack);
                    // #335337 no editing of packaging when there are modules, results in error anyway
                    artifactPackagingCombo.setEnabled(modules.isEmpty());
                }
                if ((mask & RELOAD_PROPERTIES) != 0) {
                    propertiesSection.refresh();
                    Element props = findChild(root, PROPERTIES);
                    propertiesSection.setExpanded(props != null);
                // TODO used to check teh model's empty state as well, not done now..
                }
            }, true));
        } catch (Exception e) {
            LOG.error("Failed to populate overview panel", e);
        }
        addNotifyListener(artifactGroupIdText);
        addNotifyListener(artifactIdText);
        addNotifyListener(artifactVersionText);
        addNotifyListener(artifactPackagingCombo);
        addNotifyListener(projectNameText);
        addNotifyListener(projectDescriptionText);
        addNotifyListener(projectUrlText);
        addNotifyListener(inceptionYearText);
        addNotifyListener(parentGroupIdText);
        addNotifyListener(parentArtifactIdText);
        addNotifyListener(parentVersionText);
        addNotifyListener(parentRelativePathText);
        addNotifyListener(organizationNameText);
        addNotifyListener(organizationUrlText);
        addNotifyListener(scmUrlText);
        addNotifyListener(scmConnectionText);
        addNotifyListener(scmDevConnectionText);
        addNotifyListener(scmTagText);
        addNotifyListener(ciManagementUrlCombo);
        addNotifyListener(ciManagementSystemCombo);
        addNotifyListener(issueManagementUrlCombo);
        addNotifyListener(issueManagementSystemCombo);
    });
}
Also used : Notification(org.eclipse.emf.common.notify.Notification) MavenModuleWizard(org.eclipse.m2e.core.ui.internal.wizards.MavenModuleWizard) DND(org.eclipse.swt.dnd.DND) CoreException(org.eclipse.core.runtime.CoreException) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) RELATIVE_PATH(org.eclipse.m2e.core.ui.internal.editing.PomEdits.RELATIVE_PATH) Document(org.w3c.dom.Document) Composite(org.eclipse.swt.widgets.Composite) SCM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SCM) PomEdits.removeChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild) Text(org.eclipse.swt.widgets.Text) M2EUIUtils(org.eclipse.m2e.core.ui.internal.util.M2EUIUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Window(org.eclipse.jface.window.Window) NAME(org.eclipse.m2e.core.ui.internal.editing.PomEdits.NAME) PomEdits.createElementWithText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElementWithText) MavenImages(org.eclipse.m2e.core.ui.internal.MavenImages) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) CI_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CI_MANAGEMENT) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Operation(org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation) SelectionListener(org.eclipse.swt.events.SelectionListener) ISSUE_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ISSUE_MANAGEMENT) URL(org.eclipse.m2e.core.ui.internal.editing.PomEdits.URL) PARENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PARENT) StringLabelProvider(org.eclipse.m2e.editor.composites.StringLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PomEdits(org.eclipse.m2e.core.ui.internal.editing.PomEdits) PomEdits.getChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild) ArrayList(java.util.ArrayList) IContainer(org.eclipse.core.resources.IContainer) IMavenConstants(org.eclipse.m2e.core.internal.IMavenConstants) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) INCEPTION_YEAR(org.eclipse.m2e.core.ui.internal.editing.PomEdits.INCEPTION_YEAR) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) MavenRepositorySearchDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) LinkedHashSet(java.util.LinkedHashSet) Section(org.eclipse.ui.forms.widgets.Section) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StackLayout(org.eclipse.swt.custom.StackLayout) ListEditorContentProvider(org.eclipse.m2e.editor.composites.ListEditorContentProvider) FormUtils.setText(org.eclipse.m2e.editor.pom.FormUtils.setText) PROPERTIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PROPERTIES) Plugin(org.apache.maven.model.Plugin) ModifyListener(org.eclipse.swt.events.ModifyListener) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MODULES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULES) MavenEditorImages(org.eclipse.m2e.editor.MavenEditorImages) GridLayout(org.eclipse.swt.layout.GridLayout) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) LoggerFactory(org.slf4j.LoggerFactory) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) JarFile(java.util.jar.JarFile) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) MavenModuleSelectionDialog(org.eclipse.m2e.editor.dialogs.MavenModuleSelectionDialog) PomEdits.getTextValue(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getTextValue) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) MavenPluginActivator(org.eclipse.m2e.core.internal.MavenPluginActivator) IPath(org.eclipse.core.runtime.IPath) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) TAG(org.eclipse.m2e.core.ui.internal.editing.PomEdits.TAG) Artifact(org.apache.maven.artifact.Artifact) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) PomEdits.setText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText) CCombo(org.eclipse.swt.custom.CCombo) Messages(org.eclipse.m2e.editor.internal.Messages) PomEdits.format(org.eclipse.m2e.core.ui.internal.editing.PomEdits.format) NLS(org.eclipse.osgi.util.NLS) WidthGroup(org.eclipse.m2e.core.ui.internal.wizards.WidthGroup) Display(org.eclipse.swt.widgets.Display) IManagedForm(org.eclipse.ui.forms.IManagedForm) MODULE(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULE) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) PomEdits.textEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.textEquals) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SYSTEM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SYSTEM) Label(org.eclipse.swt.widgets.Label) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PomEdits.findChilds(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChilds) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CONNECTION) ORGANIZATION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ORGANIZATION) Image(org.eclipse.swt.graphics.Image) PACKAGING(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PACKAGING) HashSet(java.util.HashSet) ProposalUtil(org.eclipse.m2e.core.ui.internal.util.ProposalUtil) JarEntry(java.util.jar.JarEntry) DESCRIPTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DESCRIPTION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) Node(org.w3c.dom.Node) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) FormUtils.nvl(org.eclipse.m2e.editor.pom.FormUtils.nvl) ICellModifier(org.eclipse.jface.viewers.ICellModifier) Packaging(org.eclipse.m2e.core.ui.internal.search.util.Packaging) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Action(org.eclipse.jface.action.Action) PomEdits.childAt(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childAt) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Element(org.w3c.dom.Element) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IndexedArtifactFile(org.eclipse.m2e.core.internal.index.IndexedArtifactFile) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) DEV_CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEV_CONNECTION) Control(org.eclipse.swt.widgets.Control) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with VERSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION in project m2e-core by eclipse-m2e.

the class MavenPomEditorPage method updateParentAction.

private void updateParentAction() {
    if (selectParentAction != null) {
        final boolean[] ret = new boolean[1];
        try {
            performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
                Element parent = findChild(document.getDocumentElement(), PARENT);
                String g = getTextValue(findChild(parent, GROUP_ID));
                String a = getTextValue(findChild(parent, ARTIFACT_ID));
                String v = getTextValue(findChild(parent, VERSION));
                ret[0] = g != null && a != null && v != null;
            }, true));
        } catch (Exception e) {
            ret[0] = false;
        }
        selectParentAction.setEnabled(ret[0]);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) CoreException(org.eclipse.core.runtime.CoreException) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Point(org.eclipse.swt.graphics.Point) FormHoverProvider(org.eclipse.m2e.editor.internal.FormHoverProvider) PomEdits.getTextValue(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getTextValue) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) IPath(org.eclipse.core.runtime.IPath) MavenProject(org.apache.maven.project.MavenProject) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) Composite(org.eclipse.swt.widgets.Composite) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) Method(java.lang.reflect.Method) PomEdits.removeChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild) PomEdits.setText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText) CCombo(org.eclipse.swt.custom.CCombo) Text(org.eclipse.swt.widgets.Text) Messages(org.eclipse.m2e.editor.internal.Messages) ModifyEvent(org.eclipse.swt.events.ModifyEvent) NLS(org.eclipse.osgi.util.NLS) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) MenuManager(org.eclipse.jface.action.MenuManager) Assert(org.eclipse.core.runtime.Assert) Status(org.eclipse.core.runtime.Status) IManagedForm(org.eclipse.ui.forms.IManagedForm) IMavenProjectRegistry(org.eclipse.m2e.core.project.IMavenProjectRegistry) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) SWT(org.eclipse.swt.SWT) FieldDecorationRegistry(org.eclipse.jface.fieldassist.FieldDecorationRegistry) FormPage(org.eclipse.ui.forms.editor.FormPage) SelectionListener(org.eclipse.swt.events.SelectionListener) InputHistory(org.eclipse.m2e.core.ui.internal.dialogs.InputHistory) IModelStateListener(org.eclipse.wst.sse.core.internal.provisional.IModelStateListener) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) PARENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PARENT) PomEdits(org.eclipse.m2e.core.ui.internal.editing.PomEdits) IMessageProvider(org.eclipse.jface.dialogs.IMessageProvider) IMavenConstants(org.eclipse.m2e.core.internal.IMavenConstants) IProject(org.eclipse.core.resources.IProject) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) Node(org.w3c.dom.Node) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) IFile(org.eclipse.core.resources.IFile) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) IMarker(org.eclipse.core.resources.IMarker) FormUtils.isEmpty(org.eclipse.m2e.editor.pom.FormUtils.isEmpty) Logger(org.slf4j.Logger) Combo(org.eclipse.swt.widgets.Combo) Viewer(org.eclipse.jface.viewers.Viewer) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Action(org.eclipse.jface.action.Action) Consumer(java.util.function.Consumer) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Element(org.w3c.dom.Element) AbstractTextEditor(org.eclipse.ui.texteditor.AbstractTextEditor) ModifyListener(org.eclipse.swt.events.ModifyListener) IResource(org.eclipse.core.resources.IResource) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) Menu(org.eclipse.swt.widgets.Menu) MavenEditorImages(org.eclipse.m2e.editor.MavenEditorImages) Control(org.eclipse.swt.widgets.Control) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Element(org.w3c.dom.Element) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IFile (org.eclipse.core.resources.IFile)5 CoreException (org.eclipse.core.runtime.CoreException)5 IStatus (org.eclipse.core.runtime.IStatus)5 Status (org.eclipse.core.runtime.Status)5 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)5 ARTIFACT_ID (org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID)5 GROUP_ID (org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID)5 OperationTuple (org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple)5 VERSION (org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION)5 PomEdits.findChild (org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild)5 PomEdits.performOnDOMDocument (org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument)5 NLS (org.eclipse.osgi.util.NLS)5 Element (org.w3c.dom.Element)5 IPath (org.eclipse.core.runtime.IPath)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Job (org.eclipse.core.runtime.jobs.Job)4 Action (org.eclipse.jface.action.Action)4 List (java.util.List)3 ArtifactKey (org.eclipse.m2e.core.embedder.ArtifactKey)3 Display (org.eclipse.swt.widgets.Display)3