Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-02-21 13:31:42 +0000
committerMilos Kleint2011-02-22 20:23:29 +0000
commit27bd166e23352ee0c70e09ec6a2dc0d3044487af (patch)
treea5a11bcce5c905c1c73117a2a3996cad756c8067 /org.eclipse.m2e.editor
parent29e2fc24b109e0531f9bdddf6f53a5a78d29f24d (diff)
downloadm2e-core-27bd166e23352ee0c70e09ec6a2dc0d3044487af.tar.gz
m2e-core-27bd166e23352ee0c70e09ec6a2dc0d3044487af.tar.xz
m2e-core-27bd166e23352ee0c70e09ec6a2dc0d3044487af.zip
remove unused code
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/BuildComposite.java705
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ReportingComposite.java887
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/RepositoriesComposite.java1287
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamComposite.java630
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamLabelProvider.java65
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/BuildPage.java600
6 files changed, 0 insertions, 4174 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/BuildComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/BuildComposite.java
deleted file mode 100644
index a755dea2..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/BuildComposite.java
+++ /dev/null
@@ -1,705 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import static org.eclipse.m2e.editor.pom.FormUtils.setButton;
-import static org.eclipse.m2e.editor.pom.FormUtils.setText;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.editor.internal.Messages;
-import org.eclipse.m2e.editor.pom.FormUtils;
-import org.eclipse.m2e.editor.pom.MavenPomEditorPage;
-import org.eclipse.m2e.editor.pom.ValueProvider;
-import org.eclipse.m2e.model.edit.pom.BuildBase;
-import org.eclipse.m2e.model.edit.pom.PomFactory;
-import org.eclipse.m2e.model.edit.pom.PomPackage;
-import org.eclipse.m2e.model.edit.pom.Resource;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * @author Eugene Kuleshov
- */
-public class BuildComposite extends Composite {
-
- protected static PomPackage POM_PACKAGE = PomPackage.eINSTANCE;
-
- private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
-
- MavenPomEditorPage parent;
-
- // controls
- Text defaultGoalText;
- Text directoryText;
- Text finalNameText;
-
- ListEditorComposite<String> filtersEditor;
-
- ListEditorComposite<Resource> resourcesEditor;
- ListEditorComposite<Resource> testResourcesEditor;
-
- Text resourceDirectoryText;
- Text resourceTargetPathText;
- ListEditorComposite<String> resourceIncludesEditor;
- ListEditorComposite<String> resourceExcludesEditor;
-
- Button resourceFilteringButton;
- Section resourceDetailsSection;
-
- // model
- Resource currentResource;
-
- boolean changingSelection = false;
-
- ValueProvider<BuildBase> buildProvider;
-
-
- public BuildComposite(Composite parent, int flags) {
- super(parent, flags);
-
- toolkit.adapt(this);
-
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.makeColumnsEqualWidth = true;
- setLayout(layout);
-
- createBuildSection();
- }
-
- private void createBuildSection() {
- SashForm horizontalSash = new SashForm(this, SWT.NONE);
- toolkit.adapt(horizontalSash);
- horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Section buildSection = toolkit.createSection(horizontalSash, ExpandableComposite.TITLE_BAR);
- buildSection.setText(Messages.BuildComposite_section_build);
-
- Composite composite = toolkit.createComposite(buildSection, SWT.NONE);
- GridLayout compositeLayout = new GridLayout(2, false);
- compositeLayout.marginWidth = 1;
- compositeLayout.marginHeight = 2;
- composite.setLayout(compositeLayout);
- toolkit.paintBordersFor(composite);
- buildSection.setClient(composite);
-
- toolkit.createLabel(composite, Messages.BuildComposite_lblDefaultGoal, SWT.NONE);
-
- defaultGoalText = toolkit.createText(composite, null, SWT.NONE);
- defaultGoalText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildComposite_lblDirectory, SWT.NONE);
-
- directoryText = toolkit.createText(composite, null, SWT.NONE);
- directoryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildComposite_lblFinalName, SWT.NONE);
-
- finalNameText = toolkit.createText(composite, null, SWT.NONE);
- finalNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label filtersLabel = toolkit.createLabel(composite, Messages.BuildComposite_lblFilters, SWT.NONE);
- filtersLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
-
- filtersEditor = new ListEditorComposite<String>(composite, SWT.NONE);
- GridData filtersEditorData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
- filtersEditorData.heightHint = 47;
- filtersEditor.setLayoutData(filtersEditorData);
- toolkit.adapt(filtersEditor);
- toolkit.paintBordersFor(filtersEditor);
-
- filtersEditor.setContentProvider(new ListEditorContentProvider<String>());
- filtersEditor.setLabelProvider(new StringLabelProvider(MavenEditorImages.IMG_FILTER));
-
- filtersEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- boolean created = false;
- BuildBase build = createBuildBase(compoundCommand, editingDomain);
- EList<String> filters = build.getFilters();
-
- String filter = "?";
-
- Command addCommand = AddCommand.create(editingDomain, build, POM_PACKAGE.getBuildBase_Filters(), filter);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(created) {
- filtersEditor.setInput(filters);
- }
- filtersEditor.setSelection(Collections.singletonList(filter));
- }
- });
-
- filtersEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<String> selection = filtersEditor.getSelection();
- for(String filter : selection) {
- Command removeCommand = RemoveCommand.create(editingDomain, buildProvider.getValue(), //
- POM_PACKAGE.getBuildBase_Filters(), filter);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
-
- filtersEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- int n = filtersEditor.getViewer().getTable().getSelectionIndex();
- EList<String> filters = buildProvider.getValue().getFilters();
- if(!value.equals(filters.get(n))) {
- EditingDomain editingDomain = parent.getEditingDomain();
- Command command = SetCommand.create(editingDomain, buildProvider.getValue(), //
- POM_PACKAGE.getBuildBase_Filters(), value, n);
- editingDomain.getCommandStack().execute(command);
- filtersEditor.refresh();
- }
- }
- });
-
- ///
-
- SashForm verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
-
- createResourceSection(verticalSash);
- createTestResourcesSection(verticalSash);
-
- verticalSash.setWeights(new int[] {1, 1});
-
- createResourceDetailsSection(horizontalSash);
-
- horizontalSash.setWeights(new int[] {1, 1, 1});
- }
-
- private void createResourceDetailsSection(SashForm horizontalSash) {
- resourceDetailsSection = toolkit.createSection(horizontalSash, ExpandableComposite.TITLE_BAR);
- resourceDetailsSection.setText(Messages.BuildComposite_sectionResourceDetails);
-
- Composite resourceDetailsComposite = toolkit.createComposite(resourceDetailsSection, SWT.NONE);
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginWidth = 1;
- gridLayout.marginHeight = 2;
- resourceDetailsComposite.setLayout(gridLayout);
- toolkit.paintBordersFor(resourceDetailsComposite);
- resourceDetailsSection.setClient(resourceDetailsComposite);
-
- Label resourceDirectoryLabel = toolkit.createLabel(resourceDetailsComposite, Messages.BuildComposite_lblDirectory, SWT.NONE);
- resourceDirectoryLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-
- resourceDirectoryText = toolkit.createText(resourceDetailsComposite, null, SWT.NONE);
- resourceDirectoryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label resourceTargetPathLabel = toolkit.createLabel(resourceDetailsComposite, Messages.BuildComposite_lblTargetPath, SWT.NONE);
- resourceTargetPathLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-
- resourceTargetPathText = toolkit.createText(resourceDetailsComposite, null, SWT.NONE);
- resourceTargetPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- resourceFilteringButton = toolkit.createButton(resourceDetailsComposite, Messages.BuildComposite_btnFiltering, SWT.CHECK);
- resourceFilteringButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
-
- Label includesLabel = toolkit.createLabel(resourceDetailsComposite, Messages.BuildComposite_lblIncludes, SWT.NONE);
- includesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
-
- resourceIncludesEditor = new ListEditorComposite<String>(resourceDetailsComposite, SWT.NONE);
- GridData includesEditorData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
- includesEditorData.heightHint = 60;
- resourceIncludesEditor.setLayoutData(includesEditorData);
- toolkit.adapt(resourceIncludesEditor);
- toolkit.paintBordersFor(resourceIncludesEditor);
-
- resourceIncludesEditor.setContentProvider(new ListEditorContentProvider<String>());
- resourceIncludesEditor.setLabelProvider(new StringLabelProvider(MavenEditorImages.IMG_INCLUDE));
-
- resourceIncludesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- boolean created = false;
- EList<String> includes = currentResource.getIncludes();
-
-
- String include = "?";
- Command addCommand = AddCommand.create(editingDomain, currentResource, POM_PACKAGE.getResource_Includes(), include);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
- if(created) {
- resourceIncludesEditor.setInput(includes);
- }
- resourceIncludesEditor.setSelection(Collections.singletonList(include));
- }
- });
-
- resourceIncludesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<String> selection = resourceIncludesEditor.getSelection();
- for(String include : selection) {
- Command removeCommand = RemoveCommand.create(editingDomain, currentResource, //
- POM_PACKAGE.getResource_Includes(), include);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
-
- resourceIncludesEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- int n = resourceIncludesEditor.getViewer().getTable().getSelectionIndex();
- EList<String> includes = currentResource.getIncludes();
- if(!value.equals(includes.get(n))) {
- EditingDomain editingDomain = parent.getEditingDomain();
- Command command = SetCommand.create(editingDomain, currentResource, //
- POM_PACKAGE.getResource_Includes(), value, n);
- editingDomain.getCommandStack().execute(command);
- resourceIncludesEditor.refresh();
- }
- }
- });
-
- Label excludesLabel = toolkit.createLabel(resourceDetailsComposite, Messages.BuildComposite_lblExcludes, SWT.NONE);
- excludesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
-
- resourceExcludesEditor = new ListEditorComposite<String>(resourceDetailsComposite, SWT.NONE);
- GridData excludesEditorData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
- excludesEditorData.heightHint = 60;
- resourceExcludesEditor.setLayoutData(excludesEditorData);
- toolkit.adapt(resourceExcludesEditor);
- toolkit.paintBordersFor(resourceExcludesEditor);
-
- resourceExcludesEditor.setContentProvider(new ListEditorContentProvider<String>());
- resourceExcludesEditor.setLabelProvider(new StringLabelProvider(MavenEditorImages.IMG_EXCLUDE));
-
- resourceExcludesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- boolean created = false;
- EList<String> excludes = currentResource.getExcludes();
-
- String exclude = "?";
- Command addCommand = AddCommand.create(editingDomain, currentResource, POM_PACKAGE.getResource_Excludes(), exclude);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(created) {
- resourceExcludesEditor.setInput(excludes);
- }
- resourceExcludesEditor.setSelection(Collections.singletonList(exclude));
- }
- });
-
- resourceExcludesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<String> selection = resourceExcludesEditor.getSelection();
- for(String exclude : selection) {
- Command removeCommand = RemoveCommand.create(editingDomain, currentResource, //
- POM_PACKAGE.getResource_Excludes(), exclude);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
-
- resourceExcludesEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- int n = resourceExcludesEditor.getViewer().getTable().getSelectionIndex();
- EList<String> excludes = currentResource.getExcludes();
- if(!value.equals(excludes.get(n))) {
- EditingDomain editingDomain = parent.getEditingDomain();
- Command command = SetCommand.create(editingDomain, currentResource, //
- POM_PACKAGE.getResource_Excludes(), value, n);
- editingDomain.getCommandStack().execute(command);
- resourceExcludesEditor.refresh();
- }
- }
- });
-
- }
-
- private void createResourceSection(SashForm verticalSash) {
- Section resourcesSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- resourcesSection.setText(Messages.BuildComposite_sectionResources);
-
- resourcesEditor = new ListEditorComposite<Resource>(resourcesSection, SWT.NONE);
- resourcesSection.setClient(resourcesEditor);
- toolkit.adapt(resourcesEditor);
- toolkit.paintBordersFor(resourcesEditor);
-
- resourcesEditor.setContentProvider(new ListEditorContentProvider<Resource>());
- resourcesEditor.setLabelProvider(new ResourceLabelProvider());
-
- resourcesEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Resource> selection = resourcesEditor.getSelection();
- loadResourceDetails(selection.size()==1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- try {
- testResourcesEditor.setSelection(Collections.<Resource>emptyList());
- } finally {
- changingSelection = false;
- }
- }
- }
- });
-
- resourcesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- boolean created = false;
- BuildBase build = createBuildBase(compoundCommand, editingDomain);
- EList<Resource> resources = build.getResources();
-
- Resource resource = PomFactory.eINSTANCE.createResource();
- Command addCommand = AddCommand.create(editingDomain, build, POM_PACKAGE.getBuildBase_Resources(), resource);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(created) {
- resourcesEditor.setInput(resources);
- }
- resourcesEditor.setSelection(Collections.singletonList(resource));
- resourceDirectoryText.setFocus();
- }
- });
-
- resourcesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Resource> selection = resourcesEditor.getSelection();
- for(Resource resource : selection) {
- Command removeCommand = RemoveCommand.create(editingDomain, buildProvider.getValue(), //
- POM_PACKAGE.getBuildBase_Resources(), resource);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
- }
-
- private void createTestResourcesSection(SashForm verticalSash) {
- Section testResourcesSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- testResourcesSection.setText(Messages.BuildComposite_sectionTestResources);
- toolkit.adapt(verticalSash, true, true);
-
- testResourcesEditor = new ListEditorComposite<Resource>(testResourcesSection, SWT.NONE);
- testResourcesSection.setClient(testResourcesEditor);
- toolkit.adapt(testResourcesEditor);
- toolkit.paintBordersFor(testResourcesEditor);
-
- testResourcesEditor.setContentProvider(new ListEditorContentProvider<Resource>());
- testResourcesEditor.setLabelProvider(new ResourceLabelProvider());
-
- testResourcesEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Resource> selection = testResourcesEditor.getSelection();
- loadResourceDetails(selection.size()==1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- try {
- resourcesEditor.setSelection(Collections.<Resource>emptyList());
- } finally {
- changingSelection = false;
- }
- }
- }
- });
-
- testResourcesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- boolean created = false;
- BuildBase build = createBuildBase(compoundCommand, editingDomain);
- EList<Resource> testResources = build.getTestResources();
-
- Resource resource = PomFactory.eINSTANCE.createResource();
- Command addCommand = AddCommand.create(editingDomain, build, POM_PACKAGE.getBuildBase_TestResources(), resource);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(created) {
- testResourcesEditor.setInput(testResources);
- }
- testResourcesEditor.setSelection(Collections.singletonList(resource));
- resourceDirectoryText.setFocus();
- }
- });
-
- testResourcesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Resource> selection = testResourcesEditor.getSelection();
- for(Resource resource : selection) {
- Command removeCommand = RemoveCommand.create(editingDomain, buildProvider.getValue(), //
- POM_PACKAGE.getBuildBase_TestResources(), resource);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
- }
-
- public void loadData(MavenPomEditorPage editorPage, ValueProvider<BuildBase> buildProvider) {
- this.parent = editorPage;
- this.buildProvider = buildProvider;
-
- loadBuild();
- loadResources();
- loadTestResources();
-
- loadResourceDetails(null);
-
- filtersEditor.setReadOnly(parent.isReadOnly());
- resourcesEditor.setReadOnly(parent.isReadOnly());
- testResourcesEditor.setReadOnly(parent.isReadOnly());
-
- resourceIncludesEditor.setReadOnly(parent.isReadOnly());
- resourceExcludesEditor.setReadOnly(parent.isReadOnly());
- }
-
- public void updateView(MavenPomEditorPage editorPage, Notification notification) {
- Object object = notification.getNotifier();
-
- Object feature = notification.getFeature();
-
- if(object instanceof BuildBase) {
- loadBuild();
- }
-
- if(feature == PomPackage.Literals.BUILD_BASE__FILTERS) {
- filtersEditor.refresh();
- }
-
- if(feature == PomPackage.Literals.BUILD_BASE__RESOURCES) {
- resourcesEditor.refresh();
- }
-
- if(feature == PomPackage.Literals.BUILD_BASE__TEST_RESOURCES) {
- testResourcesEditor.refresh();
- }
-
- if(object instanceof Resource) {
- resourcesEditor.refresh();
- testResourcesEditor.refresh();
- if(object == currentResource) {
- Object notificationObject = MavenPomEditorPage.getFromNotification(notification);
- if(notificationObject == null || notificationObject instanceof Resource) {
- loadResourceDetails((Resource) notificationObject);
- }
- }
- }
-
- if(feature == PomPackage.Literals.RESOURCE__INCLUDES) {
- resourceIncludesEditor.refresh();
- }
-
- if(feature == PomPackage.Literals.RESOURCE__EXCLUDES) {
- resourceExcludesEditor.refresh();
- }
-
- // XXX handle other notification types
- }
-
- private void loadBuild() {
- if(parent != null) {
- parent.removeNotifyListener(defaultGoalText);
- parent.removeNotifyListener(directoryText);
- parent.removeNotifyListener(finalNameText);
- }
-
- BuildBase build = buildProvider.getValue();
- if(build!=null) {
- setText(defaultGoalText, build.getDefaultGoal());
- setText(directoryText, build.getDirectory());
- setText(finalNameText, build.getFinalName());
- } else {
- setText(defaultGoalText, ""); //$NON-NLS-1$
- setText(directoryText, ""); //$NON-NLS-1$
- setText(finalNameText, ""); //$NON-NLS-1$
- }
-
- filtersEditor.setInput(build == null //
- || build.getFilters() == null ? null : build.getFilters());
-
- parent.setModifyListener(defaultGoalText, buildProvider, POM_PACKAGE.getBuildBase_DefaultGoal(), ""); //$NON-NLS-1$
- parent.setModifyListener(directoryText, buildProvider, POM_PACKAGE.getBuildBase_Directory(), ""); //$NON-NLS-1$
- parent.setModifyListener(finalNameText, buildProvider, POM_PACKAGE.getBuildBase_FinalName(), ""); //$NON-NLS-1$
- }
-
- private void loadResources() {
- BuildBase build = buildProvider.getValue();
- resourcesEditor.setInput(build == null //
- || build.getResources() == null ? null : build.getResources());
- }
-
- private void loadTestResources() {
- BuildBase build = buildProvider.getValue();
- testResourcesEditor.setInput(build == null //
- || build.getTestResources() == null ? null : build.getTestResources());
- }
-
- void loadResourceDetails(Resource resource) {
- if(changingSelection) {
- return;
- }
-
- currentResource = resource;
-
- if(parent != null) {
- parent.removeNotifyListener(resourceDirectoryText);
- parent.removeNotifyListener(resourceTargetPathText);
- parent.removeNotifyListener(resourceFilteringButton);
- }
-
- if(resource == null) {
- FormUtils.setEnabled(resourceDetailsSection, false);
-
- setText(resourceDirectoryText, ""); //$NON-NLS-1$
- setText(resourceTargetPathText, ""); //$NON-NLS-1$
- setButton(resourceFilteringButton, false);
-
- resourceIncludesEditor.setInput(null);
- resourceExcludesEditor.setInput(null);
-
- return;
- }
-
- FormUtils.setEnabled(resourceDetailsSection, true);
- FormUtils.setReadonly(resourceDetailsSection, parent.isReadOnly());
-
- setText(resourceDirectoryText, resource.getDirectory());
- setText(resourceTargetPathText, resource.getTargetPath());
- setButton(resourceFilteringButton, "true".equals(resource.getFiltering()));
-
- resourceIncludesEditor.setInput(resource.getIncludes()==null ? null : resource.getIncludes());
- resourceExcludesEditor.setInput(resource.getExcludes()==null ? null : resource.getExcludes());
-
- ValueProvider<Resource> provider = new ValueProvider.DefaultValueProvider<Resource>(resource);
- parent.setModifyListener(resourceDirectoryText, provider, POM_PACKAGE.getResource_Directory(), ""); //$NON-NLS-1$
- parent.setModifyListener(resourceTargetPathText, provider, POM_PACKAGE.getResource_TargetPath(), ""); //$NON-NLS-1$
- parent.setModifyListener(resourceFilteringButton, provider, POM_PACKAGE.getResource_Filtering(), "false");
-
- parent.registerListeners();
- }
-
- BuildBase createBuildBase(CompoundCommand compoundCommand, EditingDomain editingDomain) {
- BuildBase build = buildProvider.getValue();
- if(build == null) {
- build = buildProvider.create(editingDomain, compoundCommand);
- }
- return build;
- }
-
- /**
- * Label provider for {@link Resource}
- */
- public class ResourceLabelProvider extends LabelProvider {
-
- public String getText(Object element) {
- if(element instanceof Resource) {
- return ((Resource) element).getDirectory();
- }
- return super.getText(element);
- }
-
- public Image getImage(Object element) {
- return MavenEditorImages.IMG_RESOURCE;
- }
-
- }
-
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ReportingComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ReportingComposite.java
deleted file mode 100644
index 6081cf01..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ReportingComposite.java
+++ /dev/null
@@ -1,887 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import static org.eclipse.m2e.editor.pom.FormUtils.nvl;
-import static org.eclipse.m2e.editor.pom.FormUtils.setButton;
-import static org.eclipse.m2e.editor.pom.FormUtils.setText;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.m2e.core.index.IndexedArtifactFile;
-import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction;
-import org.eclipse.m2e.core.ui.internal.actions.OpenUrlAction;
-import org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog;
-import org.eclipse.m2e.core.ui.internal.search.util.Packaging;
-import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
-import org.eclipse.m2e.core.ui.internal.util.ProposalUtil;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.editor.composites.PluginsComposite.PluginFilter;
-import org.eclipse.m2e.editor.internal.Messages;
-import org.eclipse.m2e.editor.pom.FormUtils;
-import org.eclipse.m2e.editor.pom.MavenPomEditorPage;
-import org.eclipse.m2e.editor.pom.SearchControl;
-import org.eclipse.m2e.editor.pom.SearchMatcher;
-import org.eclipse.m2e.editor.pom.ValueProvider;
-import org.eclipse.m2e.model.edit.pom.PomFactory;
-import org.eclipse.m2e.model.edit.pom.PomPackage;
-import org.eclipse.m2e.model.edit.pom.ReportPlugin;
-import org.eclipse.m2e.model.edit.pom.ReportSet;
-import org.eclipse.m2e.model.edit.pom.Reporting;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-
-
-/**
- * @author Eugene Kuleshov
- * @author Dmitry Platonoff
- */
-public class ReportingComposite extends Composite {
-
- protected static PomPackage POM_PACKAGE = PomPackage.eINSTANCE;
-
- FormToolkit toolkit = new FormToolkit(Display.getCurrent());
-
- MavenPomEditorPage editorPage;
-
- Text outputFolderText;
-
- Text groupIdText;
-
- Text artifactIdText;
-
- Text versionText;
-
- Button pluginInheritedButton;
-
- Hyperlink pluginConfigureButton;
-
- ListEditorComposite<ReportSet> reportSetsEditor;
-
- ListEditorComposite<String> reportsEditor;
-
- ListEditorComposite<ReportPlugin> reportPluginsEditor;
-
- Section pluginDetailsSection;
-
- Button reportSetInheritedButton;
-
- Hyperlink reportSetConfigureButton;
-
- Button excludeDefaultsButton;
-
- Section reportSetDetailsSection;
-
- Section reportSetsSection;
-
- Action openWebPageAction;
-
-// Action reportPluginAddAction;
-
- Action reportPluginSelectAction;
-
- ViewerFilter searchFilter;
-
- SearchControl searchControl;
-
- SearchMatcher searchMatcher;
-
- // model
-
- ValueProvider<Reporting> reportingProvider;
-
- ReportPlugin currentReportPlugin = null;
-
- ReportSet currentReportSet = null;
-
-
- public ReportingComposite(Composite parent, MavenPomEditorPage page, int style) {
- super(parent, style);
- this.editorPage = page;
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 0;
- setLayout(gridLayout);
- toolkit.adapt(this);
-
- SashForm horizontalSash = new SashForm(this, SWT.NONE);
- horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- toolkit.adapt(horizontalSash, true, true);
-
- createContentSection(horizontalSash);
-
- Composite verticalSash = toolkit.createComposite(horizontalSash);
- GridLayout reportingPluginDetailsLayout = new GridLayout();
- reportingPluginDetailsLayout.marginWidth = 0;
- reportingPluginDetailsLayout.marginHeight = 0;
- verticalSash.setLayout(reportingPluginDetailsLayout);
-
- createPluginDetailsSection(verticalSash);
- createReportSetDetails(verticalSash);
-
- horizontalSash.setWeights(new int[] {1, 1});
- }
-
- private void createContentSection(SashForm horizontalSash) {
- Composite composite_1 = toolkit.createComposite(horizontalSash, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- composite_1.setLayout(gridLayout);
- toolkit.paintBordersFor(composite_1);
-
- Section contentSection = toolkit.createSection(composite_1, ExpandableComposite.TITLE_BAR);
- contentSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- contentSection.setText(Messages.ReportingComposite_section_Content);
-
- Composite composite = toolkit.createComposite(contentSection, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- contentSection.setClient(composite);
- toolkit.paintBordersFor(composite);
-
- toolkit.createLabel(composite, Messages.ReportingComposite_lblOutputFolder, SWT.NONE);
-
- outputFolderText = toolkit.createText(composite, null, SWT.NONE);
- outputFolderText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- excludeDefaultsButton = toolkit.createButton(composite, Messages.ReportingComposite_btnExcludeDefaults, SWT.CHECK);
- excludeDefaultsButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
-
- Section reportingPluginsSection = toolkit.createSection(composite_1, ExpandableComposite.TITLE_BAR);
- reportingPluginsSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
- reportingPluginsSection.setText(Messages.ReportingComposite_sectionReportingPlugins);
-
- reportPluginsEditor = new ListEditorComposite<ReportPlugin>(reportingPluginsSection, SWT.NONE, true);
- reportingPluginsSection.setClient(reportPluginsEditor);
- toolkit.paintBordersFor(reportPluginsEditor);
- toolkit.adapt(reportPluginsEditor);
-
- final ReportPluginsLabelProvider labelProvider = new ReportPluginsLabelProvider();
- reportPluginsEditor.setLabelProvider(labelProvider);
- reportPluginsEditor.setContentProvider(new ListEditorContentProvider<ReportPlugin>());
-
- reportPluginsEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<ReportPlugin> selection = reportPluginsEditor.getSelection();
- updateReportPluginDetails(selection.size() == 1 ? selection.get(0) : null);
- }
- });
-
- reportPluginsEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- createReportingPlugin(null, null, null);
- }
- });
-
- reportPluginsEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
- Reporting reporting = reportingProvider.getValue();
-
- if(reporting != null) {
- List<ReportPlugin> pluginList = reportPluginsEditor.getSelection();
- for(ReportPlugin reportPlugin : pluginList) {
- Command removeCommand = RemoveCommand.create(editingDomain, reporting, POM_PACKAGE
- .getReporting_Plugins(), reportPlugin);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateContent(reporting);
- }
- }
- });
-
- reportPluginsEditor.setAddButtonListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e){
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchPluginDialog(getShell(), //
- Messages.ReportingComposite_searchDialog_addPlugin, editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), false);
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
- if(af != null) {
- createReportingPlugin(af.group, af.artifact, af.version);
- }
- }
- }
- });
-// reportPluginAddAction = new Action("Add Report Plugin", MavenEditorImages.ADD_PLUGIN) {
-// public void run() {
-//
-// }
-// };
-// reportPluginAddAction.setEnabled(false);
-// toolBarManager.add(reportPluginAddAction);
-// toolBarManager.add(new Separator());
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
-
- toolBarManager.add(new Action(Messages.ReportingComposite_action_showGroupId, MavenEditorImages.SHOW_GROUP) {
- {
- setChecked(true);
- }
- public int getStyle() {
- return AS_CHECK_BOX;
- }
- public void run() {
- labelProvider.setShowGroupId(isChecked());
- reportPluginsEditor.getViewer().refresh();
- }
- });
-
- toolBarManager.add(new Action(Messages.ReportingComposite_action_filter, MavenEditorImages.FILTER) {
- {
- setChecked(true);
- }
- public int getStyle() {
- return AS_CHECK_BOX;
- }
- public void run() {
- TableViewer viewer = reportPluginsEditor.getViewer();
- if(isChecked()) {
- viewer.addFilter(searchFilter);
- } else {
- viewer.removeFilter(searchFilter);
- }
- viewer.refresh();
- if(isChecked()) {
- searchControl.getSearchText().setFocus();
- }
- }
- });
-
- Composite toolbarComposite = toolkit.createComposite(reportingPluginsSection);
- GridLayout toolbarLayout = new GridLayout(1, true);
- toolbarLayout.marginHeight = 0;
- toolbarLayout.marginWidth = 0;
- toolbarComposite.setLayout(toolbarLayout);
- toolbarComposite.setBackground(null);
-
- toolBarManager.createControl(toolbarComposite);
- reportingPluginsSection.setTextClient(toolbarComposite);
-
- }
-
- private void createPluginDetailsSection(Composite verticalSash) {
- pluginDetailsSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- pluginDetailsSection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- pluginDetailsSection.setText(Messages.ReportingComposite_section_reportingPluginDetails);
-
- Composite pluginDetailsComposite = toolkit.createComposite(pluginDetailsSection, SWT.NONE);
- GridLayout gridLayout_1 = new GridLayout(2, false);
- gridLayout_1.marginWidth = 2;
- gridLayout_1.marginHeight = 2;
- pluginDetailsComposite.setLayout(gridLayout_1);
- pluginDetailsSection.setClient(pluginDetailsComposite);
- toolkit.paintBordersFor(pluginDetailsComposite);
-
- toolkit.createLabel(pluginDetailsComposite, Messages.ReportingComposite_lblGroupId, SWT.NONE);
-
- groupIdText = toolkit.createText(pluginDetailsComposite, null, SWT.NONE);
- GridData gd_groupIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_groupIdText.horizontalIndent = 4;
- groupIdText.setLayoutData(gd_groupIdText);
- groupIdText.setData("name", "groupIdText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addGroupIdProposal(editorPage.getProject(), groupIdText, Packaging.ALL);
- M2EUIUtils.addRequiredDecoration(groupIdText);
-
- Hyperlink artifactIdHyperlink = toolkit.createHyperlink(pluginDetailsComposite, Messages.ReportingComposite_lblArtifactId, SWT.NONE);
- artifactIdHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- final String groupId = groupIdText.getText();
- final String artifactId = artifactIdText.getText();
- final String version = versionText.getText();
- new Job("Opening " + groupId + ":" + artifactId + ":" + version) {
- protected IStatus run(IProgressMonitor arg0) {
- OpenPomAction.openEditor(groupId, artifactId, version, null);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- });
-
- artifactIdText = toolkit.createText(pluginDetailsComposite, null, SWT.NONE);
- GridData gd_artifactIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_artifactIdText.horizontalIndent = 4;
- artifactIdText.setLayoutData(gd_artifactIdText);
- artifactIdText.setData("name", "artifactIdText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addArtifactIdProposal(editorPage.getProject(), groupIdText, artifactIdText, Packaging.ALL);
- M2EUIUtils.addRequiredDecoration(artifactIdText);
-
- toolkit.createLabel(pluginDetailsComposite, Messages.ReportingComposite_lblVersion, SWT.NONE);
-
- versionText = toolkit.createText(pluginDetailsComposite, null, SWT.NONE);
- GridData gd_versionText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_versionText.horizontalIndent = 4;
- versionText.setLayoutData(gd_versionText);
- versionText.setData("name", "versionText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addVersionProposal(editorPage.getProject(), editorPage.getPomEditor().getMavenProject(), groupIdText, artifactIdText, versionText, Packaging.ALL);
-
- Composite pluginConfigureComposite = toolkit.createComposite(pluginDetailsComposite, SWT.NONE);
- GridData pluginConfigureCompositeData = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1);
- pluginConfigureComposite.setLayoutData(pluginConfigureCompositeData);
- GridLayout pluginConfigureCompositeLayout = new GridLayout(2, false);
- pluginConfigureCompositeLayout.marginWidth = 0;
- pluginConfigureCompositeLayout.marginHeight = 0;
- pluginConfigureComposite.setLayout(pluginConfigureCompositeLayout);
- toolkit.paintBordersFor(pluginConfigureComposite);
-
- pluginInheritedButton = toolkit.createButton(pluginConfigureComposite, Messages.ReportingComposite_btnInherited, SWT.CHECK);
- pluginInheritedButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- pluginConfigureButton = toolkit.createHyperlink(pluginConfigureComposite, Messages.ReportingComposite_link_Configuration, SWT.NONE);
- pluginConfigureButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- pluginConfigureButton.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- if(currentReportPlugin != null) {
- EObject element = currentReportPlugin.getConfiguration();
- editorPage.getPomEditor().showInSourceEditor(element == null ? currentReportPlugin : element);
- }
- }
- });
- pluginDetailsComposite.setTabList(new Control[] {groupIdText, artifactIdText, versionText, pluginConfigureComposite});
-
- openWebPageAction = new Action(Messages.ReportingComposite_action_openWeb, MavenEditorImages.WEB_PAGE) {
- public void run() {
- final String groupId = groupIdText.getText();
- final String artifactId = artifactIdText.getText();
- final String version = versionText.getText();
- new Job("Opening " + groupId + ":" + artifactId + ":" + version) {
- protected IStatus run(IProgressMonitor monitor) {
- OpenUrlAction.openBrowser(OpenUrlAction.ID_PROJECT, groupId, artifactId, version, monitor);
- return Status.OK_STATUS;
- }
- }.schedule();
-
- }
- };
- openWebPageAction.setEnabled(false);
-
- reportPluginSelectAction = new Action(Messages.ReportingComposite_action_selectReportingPlugin, MavenEditorImages.SELECT_PLUGIN) {
- public void run() {
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchPluginDialog(getShell(), //
- Messages.ReportingComposite_searchDialog_addPlugin, editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), false);
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
- if(af != null) {
- groupIdText.setText(nvl(af.group));
- artifactIdText.setText(nvl(af.artifact));
- versionText.setText(nvl(af.version));
- }
- }
- }
- };
- reportPluginSelectAction.setEnabled(false);
-
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBarManager.add(reportPluginSelectAction);
- toolBarManager.add(new Separator());
- toolBarManager.add(openWebPageAction);
-
- Composite toolbarComposite = toolkit.createComposite(pluginDetailsSection);
- GridLayout toolbarLayout = new GridLayout(1, true);
- toolbarLayout.marginHeight = 0;
- toolbarLayout.marginWidth = 0;
- toolbarComposite.setLayout(toolbarLayout);
- toolbarComposite.setBackground(null);
-
- toolBarManager.createControl(toolbarComposite);
- pluginDetailsSection.setTextClient(toolbarComposite);
-
- }
-
- private void createReportSetDetails(Composite verticalSash) {
- reportSetsSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- reportSetsSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- reportSetsSection.setText(Messages.ReportingComposite_section_reportSets);
-
- reportSetsEditor = new ListEditorComposite<ReportSet>(reportSetsSection, SWT.NONE);
- reportSetsSection.setClient(reportSetsEditor);
- toolkit.paintBordersFor(reportSetsEditor);
- toolkit.adapt(reportSetsEditor);
-
- reportSetsEditor.setContentProvider(new ListEditorContentProvider<ReportSet>());
- reportSetsEditor.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- if(element instanceof ReportSet) {
- ReportSet reportSet = (ReportSet) element;
- String id = reportSet.getId();
- return id == null || id.length() == 0 ? "?" : id;
- }
- return ""; //$NON-NLS-1$
- }
-
- public Image getImage(Object element) {
- // TODO add icon for report set
- return null;
- }
- });
-
- reportSetsEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<ReportSet> selection = reportSetsEditor.getSelection();
- updateReportSetDetails(selection.size() == 1 ? selection.get(0) : null);
- }
- });
-
- reportSetsEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if(currentReportPlugin == null) {
- return;
- }
-
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
- boolean reportSetsCreated = false;
-
- ReportSet reportSet = PomFactory.eINSTANCE.createReportSet();
- Command addReportSet = AddCommand.create(editingDomain, currentReportPlugin, POM_PACKAGE.getReportPlugin_ReportSets(),
- reportSet);
- compoundCommand.append(addReportSet);
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(reportSetsCreated) {
- updateReportPluginDetails(currentReportPlugin);
- }
- reportSetsEditor.setSelection(Collections.singletonList(reportSet));
- }
- });
-
- reportSetsEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if(currentReportPlugin == null) {
- return;
- }
-
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
-
- List<ReportSet> reportSetList = reportSetsEditor.getSelection();
- for(ReportSet reportSet : reportSetList) {
- Command removeCommand = RemoveCommand.create(editingDomain, currentReportPlugin, POM_PACKAGE
- .getReportPlugin_ReportSets(), reportSet);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateReportPluginDetails(currentReportPlugin);
- }
- });
-
- reportSetsEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- if(element instanceof ReportSet) {
- String id = ((ReportSet) element).getId();
- return id == null ? "" : id; //$NON-NLS-1$
- }
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- EditingDomain editingDomain = editorPage.getEditingDomain();
- if(!value.equals(currentReportSet.getId())) {
- Command command = SetCommand.create(editingDomain, currentReportSet, POM_PACKAGE.getReportSet_Id(), value);
- editingDomain.getCommandStack().execute(command);
- }
- }
- });
-
- reportSetDetailsSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- reportSetDetailsSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- reportSetDetailsSection.setText(Messages.ReportingComposite_section_reportSetReports);
-
- Composite reportSetDetailsComposite = toolkit.createComposite(reportSetDetailsSection, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 1;
- gridLayout.marginHeight = 1;
- reportSetDetailsComposite.setLayout(gridLayout);
- reportSetDetailsSection.setClient(reportSetDetailsComposite);
- toolkit.paintBordersFor(reportSetDetailsComposite);
-
- reportsEditor = new ListEditorComposite<String>(reportSetDetailsComposite, SWT.NONE);
- reportsEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- toolkit.paintBordersFor(reportsEditor);
- toolkit.adapt(reportsEditor);
-
- reportsEditor.setContentProvider(new ListEditorContentProvider<String>());
- reportsEditor.setLabelProvider(new StringLabelProvider(MavenEditorImages.IMG_REPORT));
-
- reportsEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if(currentReportSet == null) {
- return;
- }
-
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
- Command addReport = AddCommand.create(editingDomain, currentReportSet, POM_PACKAGE.getReportSet_Reports(), "?");
- compoundCommand.append(addReport);
- editingDomain.getCommandStack().execute(compoundCommand);
-
- reportsEditor.refresh();
- }
- });
-
- reportsEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if(currentReportSet == null) {
- return;
- }
-
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
- List<String> reportList = reportsEditor.getSelection();
- for(String report : reportList) {
- Command removeCommand = RemoveCommand.create(editingDomain, currentReportSet, POM_PACKAGE.getReportSet_Reports(),
- report);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
-
- reportsEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- EditingDomain editingDomain = editorPage.getEditingDomain();
- Command command = SetCommand.create(editingDomain, currentReportSet, POM_PACKAGE
- .getReportSet_Reports(), value, reportsEditor.getViewer().getTable().getSelectionIndex());
- editingDomain.getCommandStack().execute(command);
- }
- });
-
- Composite reportSetConfigureComposite = toolkit.createComposite(reportSetDetailsComposite, SWT.NONE);
- reportSetConfigureComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false));
- GridLayout reportSetConfigureCompositeLayout = new GridLayout();
- reportSetConfigureCompositeLayout.numColumns = 2;
- reportSetConfigureCompositeLayout.marginWidth = 0;
- reportSetConfigureCompositeLayout.marginHeight = 0;
- reportSetConfigureComposite.setLayout(reportSetConfigureCompositeLayout);
- toolkit.paintBordersFor(reportSetConfigureComposite);
-
- reportSetInheritedButton = toolkit.createButton(reportSetConfigureComposite, Messages.ReportingComposite_btnInherited, SWT.CHECK);
- reportSetInheritedButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- reportSetConfigureButton = toolkit.createHyperlink(reportSetConfigureComposite, Messages.ReportingComposite_link_Configuration, SWT.NONE);
- reportSetConfigureButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
- reportSetConfigureButton.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- if(currentReportSet != null) {
- EObject element = currentReportSet.getConfiguration();
- editorPage.getPomEditor().showInSourceEditor(element == null ? currentReportSet : element);
- }
- }
- });
-
- // XXX implement editor actions
- }
-
- protected void updateReportPluginDetails(ReportPlugin reportPlugin) {
- currentReportPlugin = reportPlugin;
-
- if(editorPage != null) {
- editorPage.removeNotifyListener(groupIdText);
- editorPage.removeNotifyListener(artifactIdText);
- editorPage.removeNotifyListener(versionText);
- editorPage.removeNotifyListener(pluginInheritedButton);
- }
-
- if(editorPage == null || reportPlugin == null) {
- FormUtils.setEnabled(pluginDetailsSection, false);
- FormUtils.setEnabled(reportSetsSection, false);
- reportPluginSelectAction.setEnabled(false);
- openWebPageAction.setEnabled(false);
-
- setText(groupIdText, ""); //$NON-NLS-1$
- setText(artifactIdText, ""); //$NON-NLS-1$
- setText(versionText, ""); //$NON-NLS-1$
-
- pluginInheritedButton.setSelection(false);
-
- reportSetsEditor.setInput(null);
-
- updateReportSetDetails(null);
-
- return;
- }
-
- FormUtils.setEnabled(pluginDetailsSection, true);
- FormUtils.setEnabled(reportSetsSection, true);
- FormUtils.setReadonly(pluginDetailsSection, editorPage.isReadOnly());
- FormUtils.setReadonly(reportSetsSection, editorPage.isReadOnly());
- reportPluginSelectAction.setEnabled(!editorPage.isReadOnly());
- openWebPageAction.setEnabled(true);
-
- setText(groupIdText, reportPlugin.getGroupId());
- setText(artifactIdText, reportPlugin.getArtifactId());
- setText(versionText, reportPlugin.getVersion());
-
- pluginInheritedButton.setSelection(Boolean.parseBoolean(reportPlugin.getInherited()));
-
- ValueProvider<ReportPlugin> provider = new ValueProvider.DefaultValueProvider<ReportPlugin>(reportPlugin);
- editorPage.setModifyListener(groupIdText, provider, POM_PACKAGE.getReportPlugin_GroupId(), ""); //$NON-NLS-1$
- editorPage.setModifyListener(artifactIdText, provider, POM_PACKAGE.getReportPlugin_ArtifactId(), ""); //$NON-NLS-1$
- editorPage.setModifyListener(versionText, provider, POM_PACKAGE.getReportPlugin_Version(), ""); //$NON-NLS-1$
- editorPage.setModifyListener(pluginInheritedButton, provider, POM_PACKAGE.getReportPlugin_Inherited(), "false");
- editorPage.registerListeners();
-
- reportSetsEditor.setInput(reportPlugin.getReportSets());
-
- updateReportSetDetails(null);
- }
-
- protected void updateReportSetDetails(ReportSet reportSet) {
- if(editorPage != null) {
- editorPage.removeNotifyListener(reportSetInheritedButton);
- }
-
- currentReportSet = reportSet;
-
- if(reportSet == null || editorPage == null) {
- FormUtils.setEnabled(reportSetDetailsSection, false);
- reportSetInheritedButton.setSelection(false);
- reportsEditor.setInput(null);
- return;
- }
-
- FormUtils.setEnabled(reportSetDetailsSection, true);
- FormUtils.setReadonly(reportSetDetailsSection, editorPage.isReadOnly());
-
- reportSetInheritedButton.setSelection(Boolean.parseBoolean(reportSet.getInherited()));
- ValueProvider<ReportSet> provider = new ValueProvider.DefaultValueProvider<ReportSet>(reportSet);
- editorPage.setModifyListener(reportSetInheritedButton, provider, POM_PACKAGE.getReportSet_Inherited(), "false");
- editorPage.registerListeners();
-
- reportsEditor.setInput(reportSet.getReports());
- }
-
- public void loadData(MavenPomEditorPage editorPage, ValueProvider<Reporting> reportingProvider) {
- this.editorPage = editorPage;
- this.reportingProvider = reportingProvider;
-
-// reportPluginAddAction.setEnabled(!parent.getPomEditor().isReadOnly());
-
- updateContent(reportingProvider.getValue());
- }
-
- void updateContent(Reporting reporting) {
- if(editorPage != null) {
- editorPage.removeNotifyListener(outputFolderText);
- editorPage.removeNotifyListener(excludeDefaultsButton);
- }
-
- if(reporting == null) {
- setText(outputFolderText,""); //$NON-NLS-1$
- setButton(excludeDefaultsButton, false);
- reportPluginsEditor.setInput(null);
- } else {
- setText(outputFolderText,reporting.getOutputDirectory());
- setButton(excludeDefaultsButton, "true".equals(reporting.getExcludeDefaults()));
- reportPluginsEditor.setInput(reporting.getPlugins());
- }
-
- editorPage.setModifyListener(outputFolderText, reportingProvider, POM_PACKAGE.getReporting_OutputDirectory(), ""); //$NON-NLS-1$
- editorPage.setModifyListener(excludeDefaultsButton, reportingProvider, POM_PACKAGE.getReporting_ExcludeDefaults(), "false");
- editorPage.registerListeners();
-
- updateReportPluginDetails(null);
- }
-
- public void updateView(MavenPomEditorPage editorPage, Notification notification) {
- EObject object = (EObject) notification.getNotifier();
- Object feature = notification.getFeature();
-
- if (feature == PomPackage.Literals.MODEL__REPORTING) {
- updateContent(reportingProvider.getValue());
- }
-
- if(object instanceof Reporting || feature == PomPackage.Literals.REPORTING__PLUGINS) {
- reportPluginsEditor.refresh();
- } else if(object instanceof ReportPlugin) {
- reportPluginsEditor.refresh();
-
- Object notificationObject = MavenPomEditorPage.getFromNotification(notification);
- if(object == currentReportPlugin && (notificationObject == null || notificationObject instanceof ReportPlugin)) {
- updateReportPluginDetails((ReportPlugin) notificationObject);
- }
- } else if(feature == PomPackage.Literals.REPORT_PLUGIN__REPORT_SETS || object instanceof ReportSet) {
- reportSetsEditor.refresh();
- } else if(feature == PomPackage.Literals.REPORT_SET__REPORTS) {
- reportsEditor.refresh();
- }
- }
-
- void createReportingPlugin(String groupId, String artifactId, String version) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = editorPage.getEditingDomain();
-
- boolean reportsCreated = false;
-
- Reporting reporting = reportingProvider.getValue();
- if(reporting == null) {
- reporting = reportingProvider.create(editingDomain, compoundCommand);
- reportsCreated = true;
- }
-
-
- ReportPlugin reportPlugin = PomFactory.eINSTANCE.createReportPlugin();
- reportPlugin.setGroupId(groupId);
- reportPlugin.setArtifactId(artifactId);
- reportPlugin.setVersion(version);
-
- Command addReportPlugin = AddCommand.create(editingDomain, reporting,
- POM_PACKAGE.getReporting_Plugins(), reportPlugin);
- compoundCommand.append(addReportPlugin);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- if(reportsCreated) {
- updateContent(reporting);
- } else {
- updateReportPluginDetails(reportPlugin);
- }
- reportPluginsEditor.setSelection(Collections.singletonList(reportPlugin));
- groupIdText.setFocus();
- }
-
- public void setSearchControl(SearchControl searchControl) {
- if(this.searchControl!=null) {
- return;
- }
-
- this.searchMatcher = new SearchMatcher(searchControl);
- this.searchFilter = new PluginFilter(searchMatcher);
- this.searchControl = searchControl;
- this.searchControl.getSearchText().addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- selectPlugins(reportPluginsEditor, reportingProvider);
- updateReportPluginDetails(null);
- }
-
- private void selectPlugins(ListEditorComposite<ReportPlugin> editor, ValueProvider<Reporting> provider) {
- List<ReportPlugin> plugins = new ArrayList<ReportPlugin>();
- Reporting value = provider.getValue();
- if(value != null) {
- for(ReportPlugin p : value.getPlugins()) {
- if(searchMatcher.isMatchingArtifact(p.getGroupId(), p.getArtifactId())) {
- plugins.add(p);
- }
- }
- }
- editor.setSelection(plugins);
- editor.refresh();
- }
- });
- //we add filter here as the default behaviour is to filter..
- TableViewer viewer = reportPluginsEditor.getViewer();
- viewer.addFilter(searchFilter);
-
- }
-
- final class ReportPluginsLabelProvider extends LabelProvider {
-
- private boolean showGroupId = true;
-
- public void setShowGroupId(boolean showGroupId) {
- this.showGroupId = showGroupId;
- }
-
- public String getText(Object element) {
- if(element instanceof ReportPlugin) {
- ReportPlugin reportPlugin = (ReportPlugin) element;
-
- String groupId = reportPlugin.getGroupId();
- String artifactId = reportPlugin.getArtifactId();
- String version = reportPlugin.getVersion();
-
- String label = ""; //$NON-NLS-1$
-
- if(showGroupId) {
- label = (groupId == null ? "?" : groupId) + " : ";
- }
-
- label += artifactId == null ? "?" : artifactId;
-
- if(version != null) {
- label += " : " + version;
- }
-
- return label;
- }
- return super.getText(element);
- }
-
- public Image getImage(Object element) {
- return MavenEditorImages.IMG_PLUGIN;
- }
-
- }
-
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/RepositoriesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/RepositoriesComposite.java
deleted file mode 100644
index 736cf576..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/RepositoriesComposite.java
+++ /dev/null
@@ -1,1287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import static org.eclipse.m2e.editor.pom.FormUtils.isEmpty;
-import static org.eclipse.m2e.editor.pom.FormUtils.nvl;
-import static org.eclipse.m2e.editor.pom.FormUtils.setButton;
-import static org.eclipse.m2e.editor.pom.FormUtils.setText;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction;
-import org.eclipse.m2e.core.ui.internal.wizards.WidthGroup;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.editor.internal.Messages;
-import org.eclipse.m2e.editor.pom.FormUtils;
-import org.eclipse.m2e.editor.pom.MavenPomEditorPage;
-import org.eclipse.m2e.editor.pom.ValueProvider;
-import org.eclipse.m2e.model.edit.pom.DeploymentRepository;
-import org.eclipse.m2e.model.edit.pom.DistributionManagement;
-import org.eclipse.m2e.model.edit.pom.Model;
-import org.eclipse.m2e.model.edit.pom.PomFactory;
-import org.eclipse.m2e.model.edit.pom.PomPackage;
-import org.eclipse.m2e.model.edit.pom.Relocation;
-import org.eclipse.m2e.model.edit.pom.Repository;
-import org.eclipse.m2e.model.edit.pom.RepositoryPolicy;
-import org.eclipse.m2e.model.edit.pom.Site;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-
-
-/**
- * @author Eugene Kuleshov
- */
-public class RepositoriesComposite extends Composite {
-
- static PomPackage POM_PACKAGE = PomPackage.eINSTANCE;
-
- MavenPomEditorPage parent;
-
- FormToolkit toolkit = new FormToolkit(Display.getCurrent());
-
- // controls
-
- ListEditorComposite<Repository> repositoriesEditor;
-
- ListEditorComposite<Repository> pluginRepositoriesEditor;
-
- Section repositoryDetailsSection;
-
- Section releaseRepositorySection;
-
- Section snapshotRepositorySection;
-
- Section projectSiteSection;
-
- Section relocationSection;
-
- Text repositoryIdText;
-
- Text repositoryNameText;
-
- Text repositoryUrlText;
-
- CCombo repositoryLayoutCombo;
-
- Button releasesEnabledButton;
-
- CCombo releasesUpdatePolicyCombo;
-
- CCombo releasesChecksumPolicyCombo;
-
- Label releasesChecksumPolicyLabel;
-
- Label releasesUpdatePolicyLabel;
-
- Button snapshotsEnabledButton;
-
- CCombo snapshotsUpdatePolicyCombo;
-
- CCombo snapshotsChecksumPolicyCombo;
-
- Label snapshotsChecksumPolicyLabel;
-
- Label snapshotsUpdatePolicyLabel;
-
- Text projectSiteIdText;
-
- Text projectSiteNameText;
-
- Text projectSiteUrlText;
-
- Text projectDownloadUrlText;
-
- Text relocationGroupIdText;
-
- Text relocationArtifactIdText;
-
- Text relocationVersionText;
-
- Text relocationMessageText;
-
- Text snapshotRepositoryIdText;
-
- Text snapshotRepositoryNameText;
-
- Text snapshotRepositoryUrlText;
-
- CCombo snapshotRepositoryLayoutCombo;
-
- Button snapshotRepositoryUniqueVersionButton;
-
- Text releaseRepositoryIdText;
-
- Text releaseRepositoryNameText;
-
- Text releaseRepositoryUrlText;
-
- CCombo releaseRepositoryLayoutCombo;
-
- Button releaseRepositoryUniqueVersionButton;
-
- WidthGroup leftWidthGroup = new WidthGroup();
-
- WidthGroup rightWidthGroup = new WidthGroup();
-
- Composite projectSiteComposite;
-
- Composite releaseDistributionRepositoryComposite;
-
- Composite relocationComposite;
-
- Composite snapshotRepositoryComposite;
-
- boolean changingSelection = false;
-
- // model
-
- // Model model;
- Repository currentRepository;
-
- Model model;
-
- ValueProvider<DistributionManagement> distributionManagementProvider;
-
- public RepositoriesComposite(Composite parent, int flags) {
- super(parent, flags);
-
- toolkit.adapt(this);
-
- GridLayout gridLayout = new GridLayout(1, true);
- gridLayout.marginWidth = 0;
- setLayout(gridLayout);
-
- SashForm horizontalSash = new SashForm(this, SWT.NONE);
- horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- SashForm verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
- toolkit.adapt(verticalSash, true, true);
-
- createRepositoriesSection(verticalSash);
- createPluginRepositoriesSection(verticalSash);
-
- verticalSash.setWeights(new int[] {1, 1});
-
- createRepositoryDetailsSection(horizontalSash);
-
- toolkit.adapt(horizontalSash, true, true);
- horizontalSash.setWeights(new int[] {1, 1});
-
- SashForm repositoriesSash = new SashForm(this, SWT.NONE);
- repositoriesSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- toolkit.adapt(repositoriesSash, true, true);
-
- createReleaseRepositorySection(repositoriesSash);
- createSnapshotRepositorySection(repositoriesSash);
-
- repositoriesSash.setWeights(new int[] {1, 1});
-
- SashForm projectSiteSash = new SashForm(this, SWT.NONE);
- projectSiteSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- toolkit.adapt(projectSiteSash, true, true);
-
- createProjectSiteSection(projectSiteSash);
- createRelocationSection(projectSiteSash);
-
- projectSiteSash.setWeights(new int[] {1, 1});
- }
-
- public void dispose() {
- // projectSiteComposite.removeControlListener(leftWidthGroup);
- // releaseDistributionRepositoryComposite.removeControlListener(leftWidthGroup);
-
- // snapshotRepositoryComposite.removeControlListener(rightWidthGroup);
- // relocationComposite.removeControlListener(rightWidthGroup);
-
- super.dispose();
- }
-
- private void createRepositoriesSection(SashForm verticalSash) {
- Section repositoriesSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR | ExpandableComposite.COMPACT);
- repositoriesSection.setText(Messages.RepositoriesComposite_section_repositories);
-
- repositoriesEditor = new ListEditorComposite<Repository>(repositoriesSection, SWT.NONE);
-
- repositoriesEditor.setLabelProvider(new RepositoryLabelProvider());
- repositoriesEditor.setContentProvider(new ListEditorContentProvider<Repository>());
-
- repositoriesEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Repository> selection = repositoriesEditor.getSelection();
- updateRepositoryDetailsSection(selection.size() == 1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- pluginRepositoriesEditor.setSelection(Collections.<Repository> emptyList());
- changingSelection = false;
- }
- }
- });
-
- repositoriesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- Repository repository = PomFactory.eINSTANCE.createRepository();
- Command addCommand = AddCommand.create(editingDomain, model, POM_PACKAGE.getModel_Repositories(),
- repository);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- repositoriesEditor.setSelection(Collections.singletonList(repository));
- updateRepositoryDetailsSection(repository);
- repositoryIdText.setFocus();
- }
- });
-
- repositoriesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Repository> list = repositoriesEditor.getSelection();
- for(Repository repository : list) {
- Command removeCommand = RemoveCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_Repositories(), repository);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateRepositoryDetailsSection(null);
- }
- });
-
- toolkit.paintBordersFor(repositoriesEditor);
- toolkit.adapt(repositoriesEditor);
- repositoriesSection.setClient(repositoriesEditor);
- }
-
- private void createPluginRepositoriesSection(SashForm verticalSash) {
- Section pluginRepositoriesSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR | ExpandableComposite.COMPACT);
- pluginRepositoriesSection.setText(Messages.RepositoriesComposite_section_pluginRepositories);
-
- pluginRepositoriesEditor = new ListEditorComposite<Repository>(pluginRepositoriesSection, SWT.NONE);
-
- pluginRepositoriesEditor.setLabelProvider(new RepositoryLabelProvider());
- pluginRepositoriesEditor.setContentProvider(new ListEditorContentProvider<Repository>());
-
- pluginRepositoriesEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Repository> selection = pluginRepositoriesEditor.getSelection();
- updateRepositoryDetailsSection(selection.size() == 1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- repositoriesEditor.setSelection(Collections.<Repository> emptyList());
- changingSelection = false;
- }
- }
- });
-
- pluginRepositoriesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- Repository pluginRepository = PomFactory.eINSTANCE.createRepository();
- Command addCommand = AddCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_PluginRepositories(), pluginRepository);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- pluginRepositoriesEditor.setSelection(Collections.singletonList(pluginRepository));
- updateRepositoryDetailsSection(pluginRepository);
- repositoryIdText.setFocus();
- }
- });
-
- pluginRepositoriesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Repository> list = pluginRepositoriesEditor.getSelection();
- for(Repository repository : list) {
- Command removeCommand = RemoveCommand.create(editingDomain, model,
- POM_PACKAGE.getModel_PluginRepositories(), repository);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateRepositoryDetailsSection(null);
- }
- });
-
- toolkit.paintBordersFor(pluginRepositoriesEditor);
- toolkit.adapt(pluginRepositoriesEditor);
- pluginRepositoriesSection.setClient(pluginRepositoriesEditor);
- }
-
- private void createRepositoryDetailsSection(Composite parent) {
- repositoryDetailsSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
- repositoryDetailsSection.setText(Messages.RepositoriesComposite_section_repositoryDetails);
-
- Composite repositoryDetailsComposite = toolkit.createComposite(repositoryDetailsSection);
- repositoryDetailsComposite.setLayout(new GridLayout(2, false));
- repositoryDetailsSection.setClient(repositoryDetailsComposite);
- toolkit.paintBordersFor(repositoryDetailsComposite);
-
- Label idLabel = new Label(repositoryDetailsComposite, SWT.NONE);
- idLabel.setText(Messages.RepositoriesComposite_lblId);
-
- repositoryIdText = toolkit.createText(repositoryDetailsComposite, ""); //$NON-NLS-1$
- GridData gd_repositoryIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_repositoryIdText.widthHint = 100;
- repositoryIdText.setLayoutData(gd_repositoryIdText);
-
- Label nameLabel = new Label(repositoryDetailsComposite, SWT.NONE);
- nameLabel.setText(Messages.RepositoriesComposite_lblName);
-
- repositoryNameText = toolkit.createText(repositoryDetailsComposite, ""); //$NON-NLS-1$
- repositoryNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Hyperlink repositoryUrlHyperlink = toolkit.createHyperlink(repositoryDetailsComposite, Messages.RepositoriesComposite_lblUrl, SWT.NONE);
- repositoryUrlHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(repositoryUrlText.getText());
- }
- });
-
- repositoryUrlText = toolkit.createText(repositoryDetailsComposite, ""); //$NON-NLS-1$
- GridData gd_repositoryUrlText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_repositoryUrlText.widthHint = 100;
- repositoryUrlText.setLayoutData(gd_repositoryUrlText);
-
- Label layoutLabel = new Label(repositoryDetailsComposite, SWT.NONE);
- layoutLabel.setText(Messages.RepositoriesComposite_lblLayout);
-
- repositoryLayoutCombo = new CCombo(repositoryDetailsComposite, SWT.FLAT);
- repositoryLayoutCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- repositoryLayoutCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- repositoryLayoutCombo.setItems(new String[] {"default", "legacy"});
-
- Composite composite = new Composite(repositoryDetailsComposite, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
- toolkit.adapt(composite, true, true);
- toolkit.paintBordersFor(composite);
- GridLayout compositeLayout = new GridLayout();
- compositeLayout.marginBottom = 2;
- compositeLayout.marginWidth = 2;
- compositeLayout.marginHeight = 0;
- compositeLayout.numColumns = 2;
- composite.setLayout(compositeLayout);
-
- releasesEnabledButton = toolkit.createButton(composite, Messages.RepositoriesComposite_btnEnableRelease, SWT.CHECK | SWT.FLAT);
- GridData releasesEnabledButtonData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1);
- releasesEnabledButtonData.verticalIndent = 5;
- releasesEnabledButton.setLayoutData(releasesEnabledButtonData);
- releasesEnabledButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean isEnabled = releasesEnabledButton.getSelection();
- releasesUpdatePolicyLabel.setEnabled(isEnabled);
- releasesUpdatePolicyCombo.setEnabled(isEnabled);
- releasesChecksumPolicyLabel.setEnabled(isEnabled);
- releasesChecksumPolicyCombo.setEnabled(isEnabled);
- }
- });
-
- releasesUpdatePolicyLabel = new Label(composite, SWT.NONE);
- releasesUpdatePolicyLabel.setText(Messages.RepositoriesComposite_lblUpdatePolicy);
- GridData releasesUpdatePolicyLabelData = new GridData();
- releasesUpdatePolicyLabelData.horizontalIndent = 15;
- releasesUpdatePolicyLabel.setLayoutData(releasesUpdatePolicyLabelData);
-
- releasesUpdatePolicyCombo = new CCombo(composite, SWT.FLAT);
- releasesUpdatePolicyCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- releasesUpdatePolicyCombo.setItems(new String[] {"daily", "always", "interval:30", "never"});
- releasesUpdatePolicyCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- toolkit.adapt(releasesUpdatePolicyCombo, true, true);
-
- releasesChecksumPolicyLabel = new Label(composite, SWT.NONE);
- releasesChecksumPolicyLabel.setText(Messages.RepositoriesComposite_lblChecksumPolicy);
- GridData releasesChecksumPolicyLabelData = new GridData();
- releasesChecksumPolicyLabelData.horizontalIndent = 15;
- releasesChecksumPolicyLabel.setLayoutData(releasesChecksumPolicyLabelData);
-
- releasesChecksumPolicyCombo = new CCombo(composite, SWT.READ_ONLY | SWT.FLAT);
- toolkit.adapt(releasesChecksumPolicyCombo, true, true);
- releasesChecksumPolicyCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- releasesChecksumPolicyCombo.setItems(new String[] {"ignore", "fail", "warn"});
- releasesChecksumPolicyCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
-
- snapshotsEnabledButton = toolkit.createButton(composite, Messages.RepositoriesComposite_btnEnableSnapshots, SWT.CHECK | SWT.FLAT);
- GridData snapshotsEnabledButtonData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1);
- snapshotsEnabledButtonData.verticalIndent = 5;
- snapshotsEnabledButton.setLayoutData(snapshotsEnabledButtonData);
- snapshotsEnabledButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean isEnabled = releasesEnabledButton.getSelection();
- snapshotsUpdatePolicyLabel.setEnabled(isEnabled);
- snapshotsUpdatePolicyCombo.setEnabled(isEnabled);
- snapshotsChecksumPolicyLabel.setEnabled(isEnabled);
- snapshotsChecksumPolicyCombo.setEnabled(isEnabled);
- }
- });
-
- snapshotsUpdatePolicyLabel = new Label(composite, SWT.NONE);
- snapshotsUpdatePolicyLabel.setText(Messages.RepositoriesComposite_lblUpdatePolicy);
- GridData snapshotsUpdatePolicyLabelData = new GridData();
- snapshotsUpdatePolicyLabelData.horizontalIndent = 15;
- snapshotsUpdatePolicyLabel.setLayoutData(snapshotsUpdatePolicyLabelData);
-
- snapshotsUpdatePolicyCombo = new CCombo(composite, SWT.FLAT);
- snapshotsUpdatePolicyCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- snapshotsUpdatePolicyCombo.setItems(new String[] {"daily", "always", "interval:30", "never"});
- snapshotsUpdatePolicyCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- toolkit.adapt(snapshotsUpdatePolicyCombo, true, true);
- toolkit.paintBordersFor(snapshotsUpdatePolicyCombo);
-
- snapshotsChecksumPolicyLabel = new Label(composite, SWT.NONE);
- snapshotsChecksumPolicyLabel.setText(Messages.RepositoriesComposite_lblChecksumPolicy);
- GridData checksumPolicyLabelData = new GridData();
- checksumPolicyLabelData.horizontalIndent = 15;
- snapshotsChecksumPolicyLabel.setLayoutData(checksumPolicyLabelData);
- toolkit.adapt(snapshotsChecksumPolicyLabel, true, true);
-
- snapshotsChecksumPolicyCombo = new CCombo(composite, SWT.READ_ONLY | SWT.FLAT);
- snapshotsChecksumPolicyCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- snapshotsChecksumPolicyCombo.setItems(new String[] {"ignore", "fail", "warn"});
- snapshotsChecksumPolicyCombo.setLayoutData(new GridData());
- toolkit.adapt(snapshotsChecksumPolicyCombo, true, true);
- toolkit.paintBordersFor(snapshotsChecksumPolicyCombo);
- repositoryDetailsComposite.setTabList(new Control[] {repositoryIdText, repositoryNameText, repositoryUrlText, repositoryLayoutCombo, composite});
-
- updateRepositoryDetailsSection(null);
- }
-
- private void createRelocationSection(SashForm sashForm) {
- relocationSection = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- relocationSection.setText(Messages.RepositoriesComposite_sectionRelocation);
-
- relocationComposite = toolkit.createComposite(relocationSection, SWT.NONE);
- relocationComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(relocationComposite);
- relocationSection.setClient(relocationComposite);
- relocationComposite.addControlListener(rightWidthGroup);
-
- Label relocationGroupIdLabel = toolkit.createLabel(relocationComposite, Messages.RepositoriesComposite_lblGroupId, SWT.NONE);
- rightWidthGroup.addControl(relocationGroupIdLabel);
-
- relocationGroupIdText = toolkit.createText(relocationComposite, null, SWT.NONE);
- GridData gd_relocationGroupIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_relocationGroupIdText.widthHint = 100;
- relocationGroupIdText.setLayoutData(gd_relocationGroupIdText);
-
- Hyperlink relocationArtifactIdHyperlink = toolkit.createHyperlink(relocationComposite, Messages.RepositoriesComposite_lblArtifactid, SWT.NONE);
- relocationArtifactIdHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- final String groupId = relocationGroupIdText.getText();
- final String artifactId = relocationArtifactIdText.getText();
- final String version = relocationVersionText.getText();
- new Job("Opening " + groupId + ":" + artifactId + ":" + version) {
- protected IStatus run(IProgressMonitor arg0) {
- OpenPomAction.openEditor(groupId, artifactId, version, null);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- });
-
- rightWidthGroup.addControl(relocationArtifactIdHyperlink);
-
- relocationArtifactIdText = toolkit.createText(relocationComposite, null, SWT.NONE);
- GridData gd_relocationArtifactIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_relocationArtifactIdText.widthHint = 100;
- relocationArtifactIdText.setLayoutData(gd_relocationArtifactIdText);
-
- Label relocationVersionLabel = toolkit.createLabel(relocationComposite, Messages.RepositoriesComposite_lblVersion, SWT.NONE);
- rightWidthGroup.addControl(relocationVersionLabel);
-
- relocationVersionText = toolkit.createText(relocationComposite, null, SWT.NONE);
- GridData gd_relocationVersionText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_relocationVersionText.widthHint = 100;
- relocationVersionText.setLayoutData(gd_relocationVersionText);
-
- Label relocationMessageLabel = toolkit.createLabel(relocationComposite, Messages.RepositoriesComposite_lblMessage, SWT.NONE);
- rightWidthGroup.addControl(relocationMessageLabel);
-
- relocationMessageText = toolkit.createText(relocationComposite, null, SWT.NONE);
- GridData gd_relocationMessageText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_relocationMessageText.widthHint = 100;
- relocationMessageText.setLayoutData(gd_relocationMessageText);
- relocationComposite.setTabList(new Control[] {relocationGroupIdText, relocationArtifactIdText, relocationVersionText, relocationMessageText});
- }
-
- private void createProjectSiteSection(SashForm sashForm) {
- projectSiteSection = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- projectSiteSection.setText(Messages.RepositoriesComposite_section_projectSite);
-
- projectSiteComposite = toolkit.createComposite(projectSiteSection, SWT.NONE);
- projectSiteComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(projectSiteComposite);
- projectSiteSection.setClient(projectSiteComposite);
- projectSiteComposite.addControlListener(leftWidthGroup);
-
- Label siteIdLabel = toolkit.createLabel(projectSiteComposite, Messages.RepositoriesComposite_lblSiteId, SWT.NONE);
- leftWidthGroup.addControl(siteIdLabel);
-
- projectSiteIdText = toolkit.createText(projectSiteComposite, null, SWT.NONE);
- GridData gd_projectSiteIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_projectSiteIdText.widthHint = 100;
- projectSiteIdText.setLayoutData(gd_projectSiteIdText);
-
- Label siteNameLabel = toolkit.createLabel(projectSiteComposite, Messages.RepositoriesComposite_lblName, SWT.NONE);
- leftWidthGroup.addControl(siteNameLabel);
-
- projectSiteNameText = toolkit.createText(projectSiteComposite, null, SWT.NONE);
- GridData gd_projectSiteNameText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_projectSiteNameText.widthHint = 100;
- projectSiteNameText.setLayoutData(gd_projectSiteNameText);
-
- Hyperlink projectSiteUrlHyperlink = toolkit.createHyperlink(projectSiteComposite, Messages.RepositoriesComposite_lblUrl2, SWT.NONE);
- projectSiteUrlHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(projectSiteUrlText.getText());
- }
- });
- leftWidthGroup.addControl(projectSiteUrlHyperlink);
-
- projectSiteUrlText = toolkit.createText(projectSiteComposite, null, SWT.NONE);
- GridData gd_projectSiteUrlText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_projectSiteUrlText.widthHint = 100;
- projectSiteUrlText.setLayoutData(gd_projectSiteUrlText);
- sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- toolkit.adapt(sashForm, true, true);
-
- Hyperlink projectDownloadUrlHyperlink = toolkit.createHyperlink(projectSiteComposite, Messages.RepositoriesComposite_lblDownload, SWT.NONE);
- projectDownloadUrlHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(projectDownloadUrlText.getText());
- }
- });
- leftWidthGroup.addControl(projectDownloadUrlHyperlink);
-
- projectDownloadUrlText = toolkit.createText(projectSiteComposite, null, SWT.NONE);
- GridData gd_projectDownloadUrlText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_projectDownloadUrlText.widthHint = 100;
- projectDownloadUrlText.setLayoutData(gd_projectDownloadUrlText);
- projectSiteComposite.setTabList(new Control[] {projectSiteIdText, projectSiteNameText, projectSiteUrlText, projectDownloadUrlText});
- }
-
- private void createSnapshotRepositorySection(SashForm distributionManagementSash) {
- snapshotRepositorySection = toolkit.createSection(distributionManagementSash, //
- ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- snapshotRepositorySection.setText(Messages.RepositoriesComposite_section_snapshotDistRepo);
-
- snapshotRepositoryComposite = toolkit.createComposite(snapshotRepositorySection, SWT.NONE);
- snapshotRepositoryComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(snapshotRepositoryComposite);
- snapshotRepositorySection.setClient(snapshotRepositoryComposite);
- snapshotRepositoryComposite.addControlListener(rightWidthGroup);
-
- Label snapshotRepositoryIdLabel = toolkit.createLabel(snapshotRepositoryComposite, Messages.RepositoriesComposite_lblRepoId, SWT.NONE);
- rightWidthGroup.addControl(snapshotRepositoryIdLabel);
-
- snapshotRepositoryIdText = toolkit.createText(snapshotRepositoryComposite, null, SWT.NONE);
- GridData gd_snapshotRepositoryIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_snapshotRepositoryIdText.widthHint = 100;
- snapshotRepositoryIdText.setLayoutData(gd_snapshotRepositoryIdText);
-
- Label snapshotRepositoryNameLabel = toolkit.createLabel(snapshotRepositoryComposite, Messages.RepositoriesComposite_lblName, SWT.NONE);
- rightWidthGroup.addControl(snapshotRepositoryNameLabel);
-
- snapshotRepositoryNameText = toolkit.createText(snapshotRepositoryComposite, null, SWT.NONE);
- GridData gd_snapshotRepositoryNameText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_snapshotRepositoryNameText.widthHint = 100;
- snapshotRepositoryNameText.setLayoutData(gd_snapshotRepositoryNameText);
-
- Hyperlink snapshotRepositoryUrlHyperlink = toolkit.createHyperlink(snapshotRepositoryComposite, Messages.RepositoriesComposite_lblUrl2, SWT.NONE);
- snapshotRepositoryUrlHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(snapshotRepositoryUrlText.getText());
- }
- });
- rightWidthGroup.addControl(snapshotRepositoryUrlHyperlink);
-
- snapshotRepositoryUrlText = toolkit.createText(snapshotRepositoryComposite, null, SWT.NONE);
- GridData gd_snapshotRepositoryUrlText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_snapshotRepositoryUrlText.widthHint = 100;
- snapshotRepositoryUrlText.setLayoutData(gd_snapshotRepositoryUrlText);
-
- Label snapshotRepositoryLayoutLabel = toolkit.createLabel(snapshotRepositoryComposite, Messages.RepositoriesComposite_lblLayout, SWT.NONE);
- snapshotRepositoryLayoutLabel.setLayoutData(new GridData());
- rightWidthGroup.addControl(snapshotRepositoryLayoutLabel);
-
- snapshotRepositoryLayoutCombo = new CCombo(snapshotRepositoryComposite, SWT.FLAT);
- snapshotRepositoryLayoutCombo.setItems(new String[] {"default", "legacy"});
- snapshotRepositoryLayoutCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- snapshotRepositoryLayoutCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- toolkit.adapt(snapshotRepositoryLayoutCombo, true, true);
- new Label(snapshotRepositoryComposite, SWT.NONE);
-
- snapshotRepositoryUniqueVersionButton = toolkit.createButton(snapshotRepositoryComposite, //
- Messages.RepositoriesComposite_btnUniqueVersion, SWT.CHECK);
- snapshotRepositoryUniqueVersionButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- snapshotRepositoryComposite.setTabList(new Control[] {snapshotRepositoryIdText, snapshotRepositoryNameText, snapshotRepositoryUrlText, snapshotRepositoryLayoutCombo, snapshotRepositoryUniqueVersionButton});
- }
-
- private void createReleaseRepositorySection(SashForm distributionManagementSash) {
- releaseRepositorySection = toolkit.createSection(distributionManagementSash, //
- ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- releaseRepositorySection.setText(Messages.RepositoriesComposite_section_releaseDistRepo);
-
- releaseDistributionRepositoryComposite = toolkit.createComposite(releaseRepositorySection, SWT.NONE);
- releaseDistributionRepositoryComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(releaseDistributionRepositoryComposite);
- releaseRepositorySection.setClient(releaseDistributionRepositoryComposite);
- releaseDistributionRepositoryComposite.addControlListener(leftWidthGroup);
-
- Label releaseRepositoryIdLabel = toolkit.createLabel(releaseDistributionRepositoryComposite, Messages.RepositoriesComposite_lblRepoId, SWT.NONE);
- leftWidthGroup.addControl(releaseRepositoryIdLabel);
-
- releaseRepositoryIdText = toolkit.createText(releaseDistributionRepositoryComposite, null, SWT.NONE);
- GridData gd_releaseRepositoryIdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_releaseRepositoryIdText.widthHint = 100;
- releaseRepositoryIdText.setLayoutData(gd_releaseRepositoryIdText);
-
- Label releaseRepositoryNameLabel = toolkit.createLabel(releaseDistributionRepositoryComposite, Messages.RepositoriesComposite_lblName, SWT.NONE);
- leftWidthGroup.addControl(releaseRepositoryNameLabel);
-
- releaseRepositoryNameText = toolkit.createText(releaseDistributionRepositoryComposite, null, SWT.NONE);
- GridData gd_releaseRepositoryNameText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_releaseRepositoryNameText.widthHint = 100;
- releaseRepositoryNameText.setLayoutData(gd_releaseRepositoryNameText);
-
- Hyperlink releaseRepositoryUrlHyperlink = toolkit.createHyperlink(releaseDistributionRepositoryComposite, Messages.RepositoriesComposite_lblUrl2,
- SWT.NONE);
- releaseRepositoryUrlHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(releaseRepositoryUrlText.getText());
- }
- });
- leftWidthGroup.addControl(releaseRepositoryUrlHyperlink);
-
- releaseRepositoryUrlText = toolkit.createText(releaseDistributionRepositoryComposite, null, SWT.NONE);
- GridData gd_releaseRepositoryUrlText = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd_releaseRepositoryUrlText.widthHint = 100;
- releaseRepositoryUrlText.setLayoutData(gd_releaseRepositoryUrlText);
-
- Label releaseRepositoryLayoutLabel = toolkit.createLabel(releaseDistributionRepositoryComposite, Messages.RepositoriesComposite_lblLayout,
- SWT.NONE);
- releaseRepositoryLayoutLabel.setLayoutData(new GridData());
- leftWidthGroup.addControl(releaseRepositoryLayoutLabel);
-
- releaseRepositoryLayoutCombo = new CCombo(releaseDistributionRepositoryComposite, SWT.FLAT);
- releaseRepositoryLayoutCombo.setItems(new String[] {"default", "legacy"});
- releaseRepositoryLayoutCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- releaseRepositoryLayoutCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- toolkit.adapt(releaseRepositoryLayoutCombo, true, true);
- new Label(releaseDistributionRepositoryComposite, SWT.NONE);
-
- releaseRepositoryUniqueVersionButton = toolkit.createButton(releaseDistributionRepositoryComposite,
- Messages.RepositoriesComposite_btnUniqueVersion, SWT.CHECK);
- releaseRepositoryUniqueVersionButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- releaseDistributionRepositoryComposite.setTabList(new Control[] {releaseRepositoryIdText, releaseRepositoryNameText, releaseRepositoryUrlText, releaseRepositoryLayoutCombo, releaseRepositoryUniqueVersionButton});
- }
-
- public void loadData(MavenPomEditorPage editorPage, Model model,
- ValueProvider<DistributionManagement> distributionManagementProvider) {
- this.parent = editorPage;
- this.model = model;
- this.distributionManagementProvider = distributionManagementProvider;
-
- loadRepositories();
- loadPluginRepositories();
-
- loadReleaseDistributionRepository();
- loadSnapshotDistributionRepository();
- loadProjectSite();
- loadRelocation();
-
- registerReleaseRepositoryListeners();
- registerSnapshotRepositoryListeners();
- registerProjectListeners();
- registerRelocationListeners();
-
- repositoriesEditor.setReadOnly(parent.isReadOnly());
- pluginRepositoriesEditor.setReadOnly(parent.isReadOnly());
-
- expandSections();
- }
-
- private void expandSections() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- if(dm != null) {
- boolean isRepositoriesExpanded = false;
-
- if(dm.getRepository() != null) {
- DeploymentRepository r = dm.getRepository();
- isRepositoriesExpanded |= !isEmpty(r.getId()) || !isEmpty(r.getName()) || !isEmpty(r.getUrl())
- || !isEmpty(r.getLayout()) || !isEmpty(r.getUniqueVersion());
- }
-
- if(dm.getSnapshotRepository() != null) {
- DeploymentRepository r = dm.getSnapshotRepository();
- isRepositoriesExpanded |= !isEmpty(r.getId()) || !isEmpty(r.getName()) || !isEmpty(r.getUrl())
- || !isEmpty(r.getLayout()) || !isEmpty(r.getUniqueVersion());
- }
-
- releaseRepositorySection.setExpanded(isRepositoriesExpanded);
- snapshotRepositorySection.setExpanded(isRepositoriesExpanded);
-
- boolean isSiteExpanded = false;
-
- Site s = dm.getSite();
- if(s != null) {
- isSiteExpanded |= !isEmpty(s.getId()) || !isEmpty(s.getName()) || !isEmpty(s.getUrl())
- || !isEmpty(dm.getDownloadUrl());
- } else {
- isSiteExpanded |= !isEmpty(dm.getDownloadUrl());
- }
-
- if(dm.getRelocation() != null) {
- Relocation r = dm.getRelocation();
- isSiteExpanded |= !isEmpty(r.getGroupId()) || !isEmpty(r.getArtifactId()) || !isEmpty(r.getVersion())
- || !isEmpty(r.getMessage());
- }
-
- projectSiteSection.setExpanded(isSiteExpanded);
- relocationSection.setExpanded(isSiteExpanded);
-
- } else {
- releaseRepositorySection.setExpanded(false);
- snapshotRepositorySection.setExpanded(false);
- projectSiteSection.setExpanded(false);
- relocationSection.setExpanded(false);
- }
-
- relocationSection.addExpansionListener(new ExpansionAdapter() {
- boolean isExpanding = false;
-
- public void expansionStateChanged(ExpansionEvent e) {
- if(!isExpanding) {
- isExpanding = true;
- projectSiteSection.setExpanded(relocationSection.isExpanded());
- isExpanding = false;
- }
- }
- });
- projectSiteSection.addExpansionListener(new ExpansionAdapter() {
- boolean isExpanding = false;
-
- public void expansionStateChanged(ExpansionEvent e) {
- if(!isExpanding) {
- isExpanding = true;
- relocationSection.setExpanded(projectSiteSection.isExpanded());
- isExpanding = false;
- }
- }
- });
-
- releaseRepositorySection.addExpansionListener(new ExpansionAdapter() {
- boolean isExpanding = false;
-
- public void expansionStateChanged(ExpansionEvent e) {
- if(!isExpanding) {
- isExpanding = true;
- snapshotRepositorySection.setExpanded(releaseRepositorySection.isExpanded());
- isExpanding = false;
- }
- }
- });
- snapshotRepositorySection.addExpansionListener(new ExpansionAdapter() {
- boolean isExpanding = false;
-
- public void expansionStateChanged(ExpansionEvent e) {
- if(!isExpanding) {
- isExpanding = true;
- releaseRepositorySection.setExpanded(snapshotRepositorySection.isExpanded());
- isExpanding = false;
- }
- }
- });
- }
-
- private void registerReleaseRepositoryListeners() {
- ValueProvider<DeploymentRepository> repositoryProvider = new ValueProvider.ParentValueProvider<DeploymentRepository>(
- releaseRepositoryIdText, releaseRepositoryNameText, releaseRepositoryUrlText) {
- public DeploymentRepository getValue() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- return dm == null ? null : dm.getRepository();
- }
-
- public DeploymentRepository create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- DistributionManagement dm = createDistributionManagement(editingDomain, compoundCommand);
- DeploymentRepository r = dm.getRepository();
- if(r == null) {
- r = PomFactory.eINSTANCE.createDeploymentRepository();
- Command command = SetCommand.create(editingDomain, dm, POM_PACKAGE.getDistributionManagement_Repository(), r);
- compoundCommand.append(command);
- }
- return r;
- }
- };
- parent.setModifyListener(releaseRepositoryIdText, repositoryProvider, POM_PACKAGE.getDeploymentRepository_Id(), ""); //$NON-NLS-1$
- parent.setModifyListener(releaseRepositoryNameText, repositoryProvider, POM_PACKAGE.getDeploymentRepository_Name(),
- ""); //$NON-NLS-1$
- parent.setModifyListener(releaseRepositoryUrlText, repositoryProvider, POM_PACKAGE.getDeploymentRepository_Url(),
- ""); //$NON-NLS-1$
- parent.setModifyListener(releaseRepositoryLayoutCombo, repositoryProvider, POM_PACKAGE
- .getDeploymentRepository_Layout(), "default");
- parent.setModifyListener(releaseRepositoryUniqueVersionButton, repositoryProvider, POM_PACKAGE
- .getDeploymentRepository_UniqueVersion(), "true");
- }
-
- private void registerSnapshotRepositoryListeners() {
- ValueProvider<DeploymentRepository> repositoryProvider = new ValueProvider.ParentValueProvider<DeploymentRepository>(
- snapshotRepositoryIdText, snapshotRepositoryNameText, snapshotRepositoryUrlText) {
- public DeploymentRepository getValue() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- return dm == null ? null : dm.getSnapshotRepository();
- }
-
- public DeploymentRepository create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- DistributionManagement dm = createDistributionManagement(editingDomain, compoundCommand);
- DeploymentRepository r = dm.getSnapshotRepository();
- if(r == null) {
- r = PomFactory.eINSTANCE.createDeploymentRepository();
- Command command = SetCommand.create(editingDomain, dm, POM_PACKAGE
- .getDistributionManagement_SnapshotRepository(), r);
- compoundCommand.append(command);
- }
- return r;
- }
- };
- parent
- .setModifyListener(snapshotRepositoryIdText, repositoryProvider, POM_PACKAGE.getDeploymentRepository_Id(), ""); //$NON-NLS-1$
- parent.setModifyListener(snapshotRepositoryNameText, repositoryProvider,
- POM_PACKAGE.getDeploymentRepository_Name(), ""); //$NON-NLS-1$
- parent.setModifyListener(snapshotRepositoryUrlText, repositoryProvider, POM_PACKAGE.getDeploymentRepository_Url(),
- ""); //$NON-NLS-1$
- parent.setModifyListener(snapshotRepositoryLayoutCombo, repositoryProvider, POM_PACKAGE
- .getDeploymentRepository_Layout(), "default");
- parent.setModifyListener(snapshotRepositoryUniqueVersionButton, repositoryProvider, POM_PACKAGE
- .getDeploymentRepository_UniqueVersion(), "true");
- }
-
- private void registerProjectListeners() {
- //do not use ParentValueProvider here as it renders the other providers useless (siteProvider etc)
- ValueProvider<DistributionManagement> dmProvider = new ValueProvider.DefaultValueProvider<DistributionManagement>(distributionManagementProvider.getValue())
- {
- public DistributionManagement getValue() {
- return distributionManagementProvider.getValue();
- }
-
- public DistributionManagement create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- return createDistributionManagement(editingDomain, compoundCommand);
- }
- };
- parent.setModifyListener(projectDownloadUrlText, dmProvider, POM_PACKAGE.getDistributionManagement_DownloadUrl(),
- ""); //$NON-NLS-1$
-
- ValueProvider<Site> siteProvider = new ValueProvider.ParentValueProvider<Site>(projectSiteIdText,
- projectSiteNameText, projectSiteUrlText) {
- public Site getValue() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- return dm == null ? null : dm.getSite();
- }
-
- public Site create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- DistributionManagement dm = createDistributionManagement(editingDomain, compoundCommand);
- Site s = dm.getSite();
- if(s == null) {
- s = PomFactory.eINSTANCE.createSite();
- Command command = SetCommand.create(editingDomain, dm, POM_PACKAGE.getDistributionManagement_Site(), s);
- compoundCommand.append(command);
- }
- return s;
- }
- };
- parent.setModifyListener(projectSiteIdText, siteProvider, POM_PACKAGE.getSite_Id(), ""); //$NON-NLS-1$
- parent.setModifyListener(projectSiteNameText, siteProvider, POM_PACKAGE.getSite_Name(), ""); //$NON-NLS-1$
- parent.setModifyListener(projectSiteUrlText, siteProvider, POM_PACKAGE.getSite_Url(), ""); //$NON-NLS-1$
- }
-
- private void registerRelocationListeners() {
- ValueProvider<Relocation> relocationProvider = new ValueProvider.ParentValueProvider<Relocation>(
- relocationGroupIdText, relocationArtifactIdText, relocationVersionText, relocationMessageText) {
- public Relocation getValue() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- return dm == null ? null : dm.getRelocation();
- }
-
- public Relocation create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- DistributionManagement dm = createDistributionManagement(editingDomain, compoundCommand);
- Relocation r = dm.getRelocation();
- if(r == null) {
- r = PomFactory.eINSTANCE.createRelocation();
- Command command = SetCommand.create(editingDomain, dm, POM_PACKAGE.getDistributionManagement_Relocation(), r);
- compoundCommand.append(command);
- }
- return r;
- }
- };
- parent.setModifyListener(relocationGroupIdText, relocationProvider, POM_PACKAGE.getRelocation_GroupId(), ""); //$NON-NLS-1$
- parent.setModifyListener(relocationArtifactIdText, relocationProvider, POM_PACKAGE.getRelocation_ArtifactId(), ""); //$NON-NLS-1$
- parent.setModifyListener(relocationVersionText, relocationProvider, POM_PACKAGE.getRelocation_Version(), ""); //$NON-NLS-1$
- parent.setModifyListener(relocationMessageText, relocationProvider, POM_PACKAGE.getRelocation_Message(), ""); //$NON-NLS-1$
- }
-
- private void loadReleaseDistributionRepository() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- DeploymentRepository repository = dm == null ? null : dm.getRepository();
- if(repository != null) {
- setText(releaseRepositoryIdText, repository.getId());
- setText(releaseRepositoryNameText, repository.getName());
- setText(releaseRepositoryUrlText, repository.getUrl());
- setText(releaseRepositoryLayoutCombo, "".equals(nvl(repository.getLayout())) ? "default" : nvl(repository.getLayout())); //$NON-NLS-1$ //$NON-NLS-2$
- setButton(releaseRepositoryUniqueVersionButton, "true".equals(repository.getUniqueVersion()));
- } else {
- setText(releaseRepositoryIdText, ""); //$NON-NLS-1$
- setText(releaseRepositoryNameText, ""); //$NON-NLS-1$
- setText(releaseRepositoryUrlText, ""); //$NON-NLS-1$
- setText(releaseRepositoryLayoutCombo, ""); //$NON-NLS-1$
- setButton(releaseRepositoryUniqueVersionButton, true); // default
- }
- }
-
- private void loadSnapshotDistributionRepository() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- DeploymentRepository repository = dm == null ? null : dm.getSnapshotRepository();
- if(repository != null) {
- setText(snapshotRepositoryIdText, repository.getId());
- setText(snapshotRepositoryNameText, repository.getName());
- setText(snapshotRepositoryUrlText, repository.getUrl());
- setText(snapshotRepositoryLayoutCombo, "".equals(nvl(repository.getLayout())) ? "default" : nvl(repository.getLayout())); //$NON-NLS-1$ //$NON-NLS-2$
- setButton(snapshotRepositoryUniqueVersionButton, "true".equals(repository.getUniqueVersion()));
- } else {
- setText(snapshotRepositoryIdText, ""); //$NON-NLS-1$
- setText(snapshotRepositoryNameText, ""); //$NON-NLS-1$
- setText(snapshotRepositoryUrlText, ""); //$NON-NLS-1$
- setText(snapshotRepositoryLayoutCombo, ""); //$NON-NLS-1$
- setButton(snapshotRepositoryUniqueVersionButton, true); // default
- }
- }
-
- private void loadProjectSite() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- Site site = dm == null ? null : dm.getSite();
- if(site != null) {
- setText(projectSiteIdText, site.getId());
- setText(projectSiteNameText, site.getName());
- setText(projectSiteUrlText, site.getUrl());
- } else {
- setText(projectSiteIdText, ""); //$NON-NLS-1$
- setText(projectSiteNameText, ""); //$NON-NLS-1$
- setText(projectSiteUrlText, ""); //$NON-NLS-1$
- }
-
- setText(projectDownloadUrlText, dm == null ? null : dm.getDownloadUrl());
- }
-
- private void loadRelocation() {
- DistributionManagement dm = distributionManagementProvider.getValue();
- Relocation relocation = dm == null ? null : dm.getRelocation();
- if(relocation != null) {
- setText(relocationGroupIdText, relocation.getGroupId());
- setText(relocationArtifactIdText, relocation.getArtifactId());
- setText(relocationVersionText, relocation.getVersion());
- setText(relocationMessageText, relocation.getMessage());
- } else {
- setText(relocationGroupIdText, ""); //$NON-NLS-1$
- setText(relocationArtifactIdText, ""); //$NON-NLS-1$
- setText(relocationVersionText, ""); //$NON-NLS-1$
- setText(relocationMessageText, ""); //$NON-NLS-1$
- }
- }
-
- private void loadRepositories() {
- repositoriesEditor.setInput(model.getRepositories());
- repositoriesEditor.setReadOnly(parent.isReadOnly());
- changingSelection = true;
- updateRepositoryDetailsSection(null);
- changingSelection = false;
- }
-
- private void loadPluginRepositories() {
- pluginRepositoriesEditor.setInput(model.getPluginRepositories());
- pluginRepositoriesEditor.setReadOnly(parent.isReadOnly());
- changingSelection = true;
- updateRepositoryDetailsSection(null);
- changingSelection = false;
- }
-
- public void updateView(MavenPomEditorPage editorPage, Notification notification) {
- EObject object = (EObject) notification.getNotifier();
- Object feature = notification.getFeature();
- if(PomPackage.Literals.MODEL__REPOSITORIES == feature) {
- repositoriesEditor.refresh();
- }
-
- if(PomPackage.Literals.MODEL__PLUGIN_REPOSITORIES == feature) {
- pluginRepositoriesEditor.refresh();
- }
-
- if(object instanceof Repository) {
- repositoriesEditor.refresh();
- pluginRepositoriesEditor.refresh();
-
- Object notificationObject = MavenPomEditorPage.getFromNotification(notification);
- if(currentRepository == object && (notificationObject == null || notificationObject instanceof Repository)) {
- updateRepositoryDetailsSection((Repository) notificationObject);
- }
- }
-
- if(object instanceof DistributionManagement) {
- if(object == distributionManagementProvider.getValue()) {
- loadProjectSite();
- loadRelocation();
- loadReleaseDistributionRepository();
- loadSnapshotDistributionRepository();
- }
- }
-
- if(object instanceof Site) {
- if(object.eContainer() == distributionManagementProvider.getValue()) {
- loadProjectSite();
- }
- }
-
- if(object instanceof Relocation) {
- if(object.eContainer() == distributionManagementProvider.getValue()) {
- loadRelocation();
- }
- }
-
- if(object instanceof DeploymentRepository) {
- if(object.eContainer() == distributionManagementProvider.getValue()) {
- loadReleaseDistributionRepository();
- loadSnapshotDistributionRepository();
- }
- }
-
- // XXX
- }
-
- protected void updateRepositoryDetailsSection(final Repository repository) {
- if(changingSelection) {
- return;
- }
-// if(repository != null && currentRepository == repository) {
-// return;
-// }
- currentRepository = repository;
-
- if(parent != null) {
- parent.removeNotifyListener(repositoryIdText);
- parent.removeNotifyListener(repositoryNameText);
- parent.removeNotifyListener(repositoryUrlText);
- parent.removeNotifyListener(repositoryLayoutCombo);
-
- parent.removeNotifyListener(releasesEnabledButton);
- parent.removeNotifyListener(releasesChecksumPolicyCombo);
- parent.removeNotifyListener(releasesUpdatePolicyCombo);
-
- parent.removeNotifyListener(snapshotsEnabledButton);
- parent.removeNotifyListener(snapshotsChecksumPolicyCombo);
- parent.removeNotifyListener(snapshotsUpdatePolicyCombo);
- }
-
- if(repository == null) {
- FormUtils.setEnabled(repositoryDetailsSection, false);
-
- setText(repositoryIdText, ""); //$NON-NLS-1$
- setText(repositoryNameText, ""); //$NON-NLS-1$
- setText(repositoryLayoutCombo, ""); //$NON-NLS-1$
- setText(repositoryUrlText, ""); //$NON-NLS-1$
-
- setButton(releasesEnabledButton, false);
- setText(releasesChecksumPolicyCombo, ""); //$NON-NLS-1$
- setText(releasesUpdatePolicyCombo, ""); //$NON-NLS-1$
-
- setButton(snapshotsEnabledButton, false);
- setText(snapshotsChecksumPolicyCombo, ""); // move into listener //$NON-NLS-1$
- setText(snapshotsUpdatePolicyCombo, ""); //$NON-NLS-1$
-
- // XXX swap repository details panel
-
- return;
- }
-
-// repositoryIdText.setEnabled(true);
-// repositoryNameText.setEnabled(true);
-// repositoryLayoutCombo.setEnabled(true);
-// repositoryUrlText.setEnabled(true);
-// releasesEnabledButton.setEnabled(true);
-// snapshotsEnabledButton.setEnabled(true);
-
- setText(repositoryIdText, repository.getId());
- setText(repositoryNameText, repository.getName());
- setText(repositoryLayoutCombo, "".equals(nvl(repository.getLayout())) ? "default" : nvl(repository.getLayout()));//$NON-NLS-1$ //$NON-NLS-2$
- setText(repositoryUrlText, repository.getUrl());
-
- {
- RepositoryPolicy releases = repository.getReleases();
- if(releases != null) {
- setButton(releasesEnabledButton, releases.getEnabled() == null || "true".equals(releases.getEnabled()));
- setText(releasesChecksumPolicyCombo, releases.getChecksumPolicy());
- setText(releasesUpdatePolicyCombo, releases.getUpdatePolicy());
- } else {
- setButton(releasesEnabledButton, true);
- }
- boolean isReleasesEnabled = releasesEnabledButton.getSelection();
- releasesChecksumPolicyCombo.setEnabled(isReleasesEnabled);
- releasesUpdatePolicyCombo.setEnabled(isReleasesEnabled);
- releasesChecksumPolicyLabel.setEnabled(isReleasesEnabled);
- releasesUpdatePolicyLabel.setEnabled(isReleasesEnabled);
- }
-
- {
- RepositoryPolicy snapshots = repository.getSnapshots();
- if(snapshots != null) {
- setButton(snapshotsEnabledButton, snapshots.getEnabled() == null || "true".equals(snapshots.getEnabled()));
- setText(snapshotsChecksumPolicyCombo, snapshots.getChecksumPolicy());
- setText(snapshotsUpdatePolicyCombo, snapshots.getUpdatePolicy());
- } else {
- setButton(snapshotsEnabledButton, true);
- }
- boolean isSnapshotsEnabled = snapshotsEnabledButton.getSelection();
- snapshotsChecksumPolicyCombo.setEnabled(isSnapshotsEnabled);
- snapshotsUpdatePolicyCombo.setEnabled(isSnapshotsEnabled);
- snapshotsChecksumPolicyLabel.setEnabled(isSnapshotsEnabled);
- snapshotsUpdatePolicyLabel.setEnabled(isSnapshotsEnabled);
- }
-
- FormUtils.setEnabled(repositoryDetailsSection, true);
- FormUtils.setReadonly(repositoryDetailsSection, parent.isReadOnly());
-
- ValueProvider<Repository> repositoryProvider = new ValueProvider.DefaultValueProvider<Repository>(repository);
- parent.setModifyListener(repositoryIdText, repositoryProvider, POM_PACKAGE.getRepository_Id(), ""); //$NON-NLS-1$
- parent.setModifyListener(repositoryNameText, repositoryProvider, POM_PACKAGE.getRepository_Name(), ""); //$NON-NLS-1$
- parent.setModifyListener(repositoryUrlText, repositoryProvider, POM_PACKAGE.getRepository_Url(), ""); //$NON-NLS-1$
- parent.setModifyListener(repositoryLayoutCombo, repositoryProvider, POM_PACKAGE.getRepository_Layout(), "default");
-
- ValueProvider<RepositoryPolicy> releasesProvider = new ValueProvider.ParentValueProvider<RepositoryPolicy>(
- releasesEnabledButton, releasesChecksumPolicyCombo, releasesUpdatePolicyCombo) {
- public RepositoryPolicy getValue() {
- return repository.getReleases();
- }
-
- public RepositoryPolicy create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- RepositoryPolicy policy = getValue();
- if(policy == null) {
- policy = PomFactory.eINSTANCE.createRepositoryPolicy();
- Command command = SetCommand.create(editingDomain, repository, POM_PACKAGE.getRepository_Releases(), policy);
- compoundCommand.append(command);
- }
- return policy;
- }
- };
- parent
- .setModifyListener(releasesEnabledButton, releasesProvider, POM_PACKAGE.getRepositoryPolicy_Enabled(), "true");
- parent.setModifyListener(releasesChecksumPolicyCombo, releasesProvider, POM_PACKAGE
- .getRepositoryPolicy_ChecksumPolicy(), ""); //$NON-NLS-1$
- parent.setModifyListener(releasesUpdatePolicyCombo, releasesProvider, POM_PACKAGE
- .getRepositoryPolicy_UpdatePolicy(), ""); //$NON-NLS-1$
-
- ValueProvider<RepositoryPolicy> snapshotsProvider = new ValueProvider.ParentValueProvider<RepositoryPolicy>(
- snapshotsEnabledButton, snapshotsChecksumPolicyCombo, snapshotsUpdatePolicyCombo) {
- public RepositoryPolicy getValue() {
- return repository.getSnapshots();
- }
-
- public RepositoryPolicy create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- RepositoryPolicy policy = getValue();
- if(policy == null) {
- policy = PomFactory.eINSTANCE.createRepositoryPolicy();
- Command command = SetCommand.create(editingDomain, repository, POM_PACKAGE.getRepository_Snapshots(), policy);
- compoundCommand.append(command);
- }
- return policy;
- }
- };
- parent.setModifyListener(snapshotsEnabledButton, snapshotsProvider, POM_PACKAGE.getRepositoryPolicy_Enabled(),
- "true");
- parent.setModifyListener(snapshotsChecksumPolicyCombo, snapshotsProvider, POM_PACKAGE
- .getRepositoryPolicy_ChecksumPolicy(), ""); //$NON-NLS-1$
- parent.setModifyListener(snapshotsUpdatePolicyCombo, snapshotsProvider, POM_PACKAGE
- .getRepositoryPolicy_UpdatePolicy(), ""); //$NON-NLS-1$
- }
-
- DistributionManagement createDistributionManagement(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- DistributionManagement dm = distributionManagementProvider.getValue();
- if(dm == null) {
- dm = distributionManagementProvider.create(editingDomain, compoundCommand);
- }
- return dm;
- }
-
- /**
- * Repository label provider
- */
- public class RepositoryLabelProvider extends LabelProvider {
-
- public String getText(Object element) {
- if(element instanceof Repository) {
- Repository r = (Repository) element;
- return (isEmpty(r.getId()) ? "?" : r.getId()) + " : " + (isEmpty(r.getUrl()) ? "?" : r.getUrl());
- }
- return super.getText(element);
- }
-
- public Image getImage(Object element) {
- return MavenEditorImages.IMG_REPOSITORY;
- }
-
- }
-
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamComposite.java
deleted file mode 100644
index b18d2ee3..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamComposite.java
+++ /dev/null
@@ -1,630 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import static org.eclipse.m2e.editor.pom.FormUtils.setText;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.m2e.core.ui.internal.wizards.WidthGroup;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.editor.internal.Messages;
-import org.eclipse.m2e.editor.pom.FormUtils;
-import org.eclipse.m2e.editor.pom.MavenPomEditorPage;
-import org.eclipse.m2e.editor.pom.PropertiesSection;
-import org.eclipse.m2e.editor.pom.ValueProvider;
-import org.eclipse.m2e.model.edit.pom.Contributor;
-import org.eclipse.m2e.model.edit.pom.Developer;
-import org.eclipse.m2e.model.edit.pom.Model;
-import org.eclipse.m2e.model.edit.pom.PomFactory;
-import org.eclipse.m2e.model.edit.pom.PomPackage;
-import org.eclipse.m2e.model.edit.pom.PropertyElement;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-
-
-/**
- * @author Dmitry Platonoff
- */
-public class TeamComposite extends Composite {
-
- protected static PomPackage POM_PACKAGE = PomPackage.eINSTANCE;
-
- private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
-
- MavenPomEditorPage parent;
-
- // controls
-
- Model model;
-
- ListEditorComposite<Developer> developersEditor;
-
- ListEditorComposite<Contributor> contributorsEditor;
-
- Composite detailsComposite;
-
- Text userIdText;
-
- Text userNameText;
-
- Text userEmailText;
-
- Text userUrlText;
-
- CCombo userTimezoneText;
-
- Text organizationNameText;
-
- Text organizationUrlText;
-
- ListEditorComposite<String> rolesEditor;
-
- Label userIdLabel;
-
- // model
- EObject currentSelection;
-
- boolean changingSelection = false;
-
- private PropertiesSection propertiesSection;
-
- public TeamComposite(MavenPomEditorPage editorPage, Composite composite, int flags) {
- super(composite, flags);
- this.parent = editorPage;
- createComposite();
- }
-
- private void createComposite() {
- GridLayout gridLayout = new GridLayout();
- gridLayout.makeColumnsEqualWidth = true;
- gridLayout.marginWidth = 0;
- setLayout(gridLayout);
- toolkit.adapt(this);
-
- SashForm horizontalSash = new SashForm(this, SWT.NONE);
- horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- toolkit.adapt(horizontalSash, true, true);
-
- SashForm verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
- toolkit.adapt(verticalSash, true, true);
-
- createDevelopersSection(toolkit, verticalSash);
- createContributorsSection(toolkit, verticalSash);
-
- verticalSash.setWeights(new int[] {1, 1});
-
- createDetailsPanel(toolkit, horizontalSash);
-
- horizontalSash.setWeights(new int[] {1, 1});
- }
-
- private void createDevelopersSection(FormToolkit toolkit, SashForm verticalSash) {
- Section developersSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- developersSection.setText(Messages.TeamComposite_section_developers);
-
- developersEditor = new ListEditorComposite<Developer>(developersSection, SWT.NONE);
-
- developersEditor.setContentProvider(new ListEditorContentProvider<Developer>());
- developersEditor.setLabelProvider(new TeamLabelProvider());
-
- developersEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- Developer developer = PomFactory.eINSTANCE.createDeveloper();
- Command addDependencyCommand = AddCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_Developers(), developer);
- compoundCommand.append(addDependencyCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- developersEditor.setSelection(Collections.singletonList(developer));
- updateDetails(developer);
- userIdText.setFocus();
- }
- });
-
- developersEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Developer> developerList = developersEditor.getSelection();
- for(Developer developer : developerList) {
- Command removeCommand = RemoveCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_Developers(), developer);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateDetails(null);
- }
- });
-
- developersEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Developer> selection = developersEditor.getSelection();
- updateDetails(selection.size() == 1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- try {
- contributorsEditor.setSelection(Collections.<Contributor> emptyList());
- } finally {
- changingSelection = false;
- }
- }
- }
- });
-
- developersSection.setClient(developersEditor);
- toolkit.paintBordersFor(developersEditor);
- toolkit.adapt(developersEditor);
- }
-
- private void createContributorsSection(FormToolkit toolkit, SashForm verticalSash) {
- Section contributorsSection = toolkit.createSection(verticalSash, ExpandableComposite.TITLE_BAR);
- contributorsSection.setText(Messages.TeamComposite_section_contributors);
-
- contributorsEditor = new ListEditorComposite<Contributor>(contributorsSection, SWT.NONE);
- contributorsEditor.setContentProvider(new ListEditorContentProvider<Contributor>());
- contributorsEditor.setLabelProvider(new TeamLabelProvider());
-
- contributorsEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- Contributor contributor = PomFactory.eINSTANCE.createContributor();
- Command addDependencyCommand = AddCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_Contributors(), contributor);
- compoundCommand.append(addDependencyCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- contributorsEditor.setSelection(Collections.singletonList(contributor));
- updateDetails(contributor);
- userNameText.setFocus();
- }
- });
-
- contributorsEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- List<Contributor> contributorList = contributorsEditor.getSelection();
- for(Contributor contributor : contributorList) {
- Command removeCommand = RemoveCommand.create(editingDomain, model, POM_PACKAGE
- .getModel_Contributors(), contributor);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateDetails(null);
- }
- });
-
- contributorsEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Contributor> selection = contributorsEditor.getSelection();
- updateDetails(selection.size() == 1 ? selection.get(0) : null);
-
- if(!selection.isEmpty()) {
- changingSelection = true;
- try {
- developersEditor.setSelection(Collections.<Developer> emptyList());
- } finally {
- changingSelection = false;
- }
- }
- }
- });
-
- contributorsSection.setClient(contributorsEditor);
- toolkit.paintBordersFor(contributorsEditor);
- toolkit.adapt(contributorsEditor);
- }
-
- private void createDetailsPanel(FormToolkit toolkit, SashForm horizontalSash) {
- detailsComposite = toolkit.createComposite(horizontalSash, SWT.NONE);
- GridLayout detailsCompositeGridLayout = new GridLayout();
- detailsCompositeGridLayout.marginLeft = 5;
- detailsCompositeGridLayout.marginWidth = 0;
- detailsCompositeGridLayout.marginHeight = 0;
- detailsComposite.setLayout(detailsCompositeGridLayout);
- toolkit.paintBordersFor(detailsComposite);
-
- Section userDetailsSection = toolkit.createSection(detailsComposite, ExpandableComposite.TITLE_BAR);
- GridData gd_userDetailsSection = new GridData(SWT.FILL, SWT.CENTER, true, false);
- userDetailsSection.setLayoutData(gd_userDetailsSection);
- userDetailsSection.setText(Messages.TeamComposite_section_userdetails);
-
- Composite userDetailsComposite = toolkit.createComposite(userDetailsSection, SWT.NONE);
- userDetailsComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(userDetailsComposite);
- userDetailsSection.setClient(userDetailsComposite);
-
- userIdLabel = toolkit.createLabel(userDetailsComposite, Messages.TeamComposite_lblId, SWT.NONE);
-
- userIdText = toolkit.createText(userDetailsComposite, null, SWT.NONE);
- userIdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label userNameLabel = toolkit.createLabel(userDetailsComposite, Messages.TeamComposite_lblName, SWT.NONE);
-
- userNameText = toolkit.createText(userDetailsComposite, null, SWT.NONE);
- userNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label userEmailLabel = toolkit.createLabel(userDetailsComposite, Messages.TeamComposite_lblEmail, SWT.NONE);
-
- userEmailText = toolkit.createText(userDetailsComposite, null, SWT.NONE);
- userEmailText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Hyperlink userUrlLabel = toolkit.createHyperlink(userDetailsComposite, Messages.TeamComposite_lblUrl, SWT.NONE);
- userUrlLabel.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(userUrlText.getText());
- }
- });
-
- userUrlText = toolkit.createText(userDetailsComposite, null, SWT.NONE);
- userUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label userTimezoneLabel = toolkit.createLabel(userDetailsComposite, Messages.TeamComposite_lblTimezone, SWT.NONE);
-
- userTimezoneText = new CCombo(userDetailsComposite, SWT.FLAT);
- userTimezoneText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- userTimezoneText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
-
- Section organizationSection = toolkit.createSection(detailsComposite, ExpandableComposite.TITLE_BAR);
- organizationSection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- organizationSection.setText(Messages.TeamComposite_section_organization);
-
- Composite organizationComposite = toolkit.createComposite(organizationSection, SWT.NONE);
- organizationComposite.setLayout(new GridLayout(2, false));
- toolkit.paintBordersFor(organizationComposite);
- organizationSection.setClient(organizationComposite);
-
- Label organizationNameLabel = toolkit.createLabel(organizationComposite, Messages.TeamComposite_lblName, SWT.NONE);
-
- organizationNameText = toolkit.createText(organizationComposite, null, SWT.NONE);
- organizationNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Hyperlink organizationUrlLabel = toolkit.createHyperlink(organizationComposite, Messages.TeamComposite_lblUrl, SWT.NONE);
- organizationUrlLabel.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- FormUtils.openHyperlink(organizationUrlText.getText());
- }
- });
-
- organizationUrlText = toolkit.createText(organizationComposite, null, SWT.NONE);
- organizationUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- WidthGroup widthGroup = new WidthGroup();
- widthGroup.addControl(userIdLabel);
- widthGroup.addControl(userNameLabel);
- widthGroup.addControl(userEmailLabel);
- widthGroup.addControl(userUrlLabel);
- widthGroup.addControl(userTimezoneLabel);
- widthGroup.addControl(organizationNameLabel);
- widthGroup.addControl(organizationUrlLabel);
- userDetailsComposite.addControlListener(widthGroup);
- userDetailsComposite.setTabList(new Control[] {userIdText, userNameText, userEmailText, userUrlText, userTimezoneText});
- organizationComposite.addControlListener(widthGroup);
- organizationComposite.setTabList(new Control[] {organizationNameText, organizationUrlText});
-
- createRolesSection(toolkit, detailsComposite);
- createPropertiesSection(toolkit, detailsComposite);
- }
-
- private void createRolesSection(FormToolkit toolkit, Composite detailsComposite) {
- Section rolesSection = toolkit.createSection(detailsComposite, ExpandableComposite.TITLE_BAR);
- rolesSection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- rolesSection.setText(Messages.TeamComposite_section_roles);
-
- rolesEditor = new ListEditorComposite<String>(rolesSection, SWT.NONE);
- toolkit.paintBordersFor(rolesEditor);
- toolkit.adapt(rolesEditor);
- rolesSection.setClient(rolesEditor);
-
- rolesEditor.setContentProvider(new ListEditorContentProvider<String>());
- rolesEditor.setLabelProvider(new StringLabelProvider(MavenEditorImages.IMG_ROLE));
-
- rolesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- EObject parentObject = currentSelection;
- EStructuralFeature feature = null;
- if(currentSelection != null) {
- if(currentSelection instanceof Contributor) {
- feature = POM_PACKAGE.getContributor_Roles();
- } else if(currentSelection instanceof Developer) {
- feature = POM_PACKAGE.getDeveloper_Roles();
- }
- }
-
- Command addRoleCommand = AddCommand.create(editingDomain, parentObject, feature, "?");
- compoundCommand.append(addRoleCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- updateRoles((EList<String>)parentObject.eGet(feature));
- }
- });
-
- rolesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = parent.getEditingDomain();
-
- EObject parentObject = currentSelection;
- EStructuralFeature feature = null;
- if(currentSelection != null) {
- if(currentSelection instanceof Contributor) {
- feature = POM_PACKAGE.getContributor_Roles();
- } else if(currentSelection instanceof Developer) {
- feature = POM_PACKAGE.getDeveloper_Roles();
- }
- }
- List<String> roleList = rolesEditor.getSelection();
- for(String role : roleList) {
- Command removeCommand = RemoveCommand.create(editingDomain, parentObject, feature, role);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- }
- });
-
- rolesEditor.setCellModifier(new ICellModifier() {
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return element;
- }
-
- public void modify(Object element, String property, Object value) {
- int n = rolesEditor.getViewer().getTable().getSelectionIndex();
- if(!value.equals(getRoles().get(n))) {
- EditingDomain editingDomain = parent.getEditingDomain();
- EObject parentObject = currentSelection;
- EStructuralFeature feature = null;
- if(currentSelection != null) {
- if(currentSelection instanceof Contributor) {
- feature = POM_PACKAGE.getContributor_Roles();
- } else if(currentSelection instanceof Developer) {
- feature = POM_PACKAGE.getDeveloper_Roles();
- }
- }
- Command command = SetCommand.create(editingDomain, parentObject,
- feature, value, n);
- editingDomain.getCommandStack().execute(command);
- }
- }
- });
-
- }
-
- private void createPropertiesSection(FormToolkit toolkit, Composite composite) {
- propertiesSection = new PropertiesSection(toolkit, composite, parent.getEditingDomain());
- }
-
- public void loadContributors() {
- changingSelection = true;
- contributorsEditor.setInput(model.getContributors());
- changingSelection = false;
- }
-
- void loadDevelopers() {
- changingSelection = true;
- developersEditor.setInput(model.getDevelopers());
- changingSelection = false;
- }
-
- protected void updateDetails(EObject eo) {
- if(changingSelection) {
- return;
- }
-
- this.currentSelection = eo;
-
- if(parent != null) {
- parent.removeNotifyListener(userIdText);
- parent.removeNotifyListener(userNameText);
- parent.removeNotifyListener(userEmailText);
- parent.removeNotifyListener(userUrlText);
- parent.removeNotifyListener(userTimezoneText);
- parent.removeNotifyListener(organizationNameText);
- parent.removeNotifyListener(organizationUrlText);
- }
-
- if(parent == null || eo == null) {
- FormUtils.setEnabled(detailsComposite, false);
-
- setText(userIdText, ""); //$NON-NLS-1$
- setText(userNameText, ""); //$NON-NLS-1$
- setText(userEmailText, ""); //$NON-NLS-1$
- setText(userUrlText, ""); //$NON-NLS-1$
- setText(userTimezoneText, ""); //$NON-NLS-1$
-
- setText(organizationNameText, ""); //$NON-NLS-1$
- setText(organizationUrlText, ""); //$NON-NLS-1$
-
- rolesEditor.setInput(null);
-
- return;
- }
-
- FormUtils.setEnabled(detailsComposite, true);
- FormUtils.setReadonly(detailsComposite, parent.isReadOnly());
-
- EList<String> roles = null;
- if(eo instanceof Contributor) {
- Contributor contributor = (Contributor) eo;
- updateContributorDetails(contributor);
- roles = contributor.getRoles();
- propertiesSection.setModel(contributor, POM_PACKAGE.getContributor_Properties());
- } else if(eo instanceof Developer) {
- Developer developer = (Developer) eo;
- updateDeveloperDetails(developer);
- roles = developer.getRoles();
- propertiesSection.setModel(developer, POM_PACKAGE.getDeveloper_Properties());
- }
-
- parent.registerListeners();
-
- updateRoles(roles);
- }
-
- protected void updateContributorDetails(Contributor contributor) {
- setText(userIdText, ""); //$NON-NLS-1$
- setText(userNameText, contributor.getName());
- setText(userEmailText, contributor.getEmail());
- setText(userUrlText, contributor.getUrl());
- setText(userTimezoneText, contributor.getTimezone());
- setText(organizationNameText, contributor.getOrganization());
- setText(organizationUrlText, contributor.getOrganizationUrl());
-
- userIdLabel.setEnabled(false);
- userIdText.setEnabled(false);
-
- ValueProvider<Contributor> contributorProvider = new ValueProvider.DefaultValueProvider<Contributor>(contributor);
- parent.setModifyListener(userNameText, contributorProvider, POM_PACKAGE.getContributor_Name(), ""); //$NON-NLS-1$
- parent.setModifyListener(userEmailText, contributorProvider, POM_PACKAGE.getContributor_Email(), ""); //$NON-NLS-1$
- parent.setModifyListener(userUrlText, contributorProvider, POM_PACKAGE.getContributor_Url(), ""); //$NON-NLS-1$
- parent.setModifyListener(userTimezoneText, contributorProvider, POM_PACKAGE.getContributor_Timezone(), ""); //$NON-NLS-1$
- parent.setModifyListener(organizationNameText, contributorProvider, POM_PACKAGE.getContributor_Organization(), ""); //$NON-NLS-1$
- parent
- .setModifyListener(organizationUrlText, contributorProvider, POM_PACKAGE.getContributor_OrganizationUrl(), ""); //$NON-NLS-1$
- }
-
- protected void updateDeveloperDetails(Developer developer) {
- setText(userIdText, developer.getId());
- setText(userNameText, developer.getName());
- setText(userEmailText, developer.getEmail());
- setText(userUrlText, developer.getUrl());
- setText(userTimezoneText, developer.getTimezone());
- setText(organizationNameText, developer.getOrganization());
- setText(organizationUrlText, developer.getOrganizationUrl());
-
- ValueProvider<Developer> developerProvider = new ValueProvider.DefaultValueProvider<Developer>(developer);
- parent.setModifyListener(userIdText, developerProvider, POM_PACKAGE.getDeveloper_Id(), ""); //$NON-NLS-1$
- parent.setModifyListener(userNameText, developerProvider, POM_PACKAGE.getDeveloper_Name(), ""); //$NON-NLS-1$
- parent.setModifyListener(userEmailText, developerProvider, POM_PACKAGE.getDeveloper_Email(), ""); //$NON-NLS-1$
- parent.setModifyListener(userUrlText, developerProvider, POM_PACKAGE.getDeveloper_Url(), ""); //$NON-NLS-1$
- parent.setModifyListener(userTimezoneText, developerProvider, POM_PACKAGE.getDeveloper_Timezone(), ""); //$NON-NLS-1$
- parent.setModifyListener(organizationNameText, developerProvider, POM_PACKAGE.getDeveloper_Organization(), ""); //$NON-NLS-1$
- parent.setModifyListener(organizationUrlText, developerProvider, POM_PACKAGE.getDeveloper_OrganizationUrl(), ""); //$NON-NLS-1$
- }
-
- public void updateView(Notification notification) {
- EObject object = (EObject) notification.getNotifier();
- Object feature = notification.getFeature();
-
- if(feature == PomPackage.Literals.MODEL__DEVELOPERS) {
- developersEditor.refresh();
- } else if(feature == PomPackage.Literals.MODEL__CONTRIBUTORS) {
- contributorsEditor.refresh();
- } else {
- Object notificationObject = MavenPomEditorPage.getFromNotification(notification);
- if(object instanceof Contributor) {
- contributorsEditor.refresh();
-
- if(object == currentSelection)
- updateDetails(object);
- } else if(object instanceof Developer) {
- developersEditor.refresh();
-
- if(object == currentSelection)
- updateDetails(object);
- } else if(feature == PomPackage.Literals.DEVELOPER__ROLES || feature == PomPackage.Literals.CONTRIBUTOR__ROLES) {
- EList<String> roles = (EList<String>)object.eGet((EStructuralFeature)feature);
- if(object == getRoles()) {
- updateRoles(roles);
- }
- }
- }
- }
-
- public void loadData(Model model) {
- this.model = model;
- loadDevelopers();
- loadContributors();
-
- developersEditor.setReadOnly(parent.isReadOnly());
- contributorsEditor.setReadOnly(parent.isReadOnly());
-
- updateDetails(null);
- }
-
- protected EList<String> getRoles() {
- if(currentSelection != null) {
- if(currentSelection instanceof Contributor) {
- return ((Contributor) currentSelection).getRoles();
- } else if(currentSelection instanceof Developer) {
- return ((Developer) currentSelection).getRoles();
- }
- }
- return null;
- }
-
- protected void updateRoles(EList<String> roles) {
- rolesEditor.setInput(roles);
- }
-
- protected EList<PropertyElement> getProperties() {
- if(currentSelection != null) {
- if(currentSelection instanceof Contributor) {
- return ((Contributor) currentSelection).getProperties();
- } else if(currentSelection instanceof Developer) {
- return ((Developer) currentSelection).getProperties();
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamLabelProvider.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamLabelProvider.java
deleted file mode 100644
index e45ba6a8..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/TeamLabelProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.model.edit.pom.Contributor;
-import org.eclipse.m2e.model.edit.pom.Developer;
-import org.eclipse.swt.graphics.Image;
-
-
-/**
- * Label provider for Developer and Contributor elements
- *
- * @author Dmitry Platonoff
- */
-public class TeamLabelProvider extends LabelProvider {
-
- @Override
- public String getText(Object element) {
- if(element instanceof Developer) {
- Developer developer = (Developer) element;
- return getText(developer.getName(), developer.getEmail(), developer.getOrganization());
- }
- else if(element instanceof Contributor) {
- Contributor contributor = (Contributor) element;
- return getText(contributor.getName(), contributor.getEmail(), contributor.getOrganization());
- }
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element) {
- return MavenEditorImages.IMG_PERSON;
- }
-
- private String getText(String name, String email, String organization) {
- StringBuilder sb = new StringBuilder();
-
- sb.append(isEmpty(name) ? "?" : name);
-
- if(!isEmpty(email)) {
- sb.append(" <").append(email).append('>');
- }
-
- if(!isEmpty(organization)) {
- sb.append(", ").append(organization);
- }
-
- return sb.toString();
- }
-
- private boolean isEmpty(String s) {
- return s == null || s.trim().length() == 0;
- }
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/BuildPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/BuildPage.java
deleted file mode 100644
index 4b3cc219..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/BuildPage.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.pom;
-
-import static org.eclipse.m2e.editor.pom.FormUtils.nvl;
-import static org.eclipse.m2e.editor.pom.FormUtils.setText;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.window.Window;
-import org.eclipse.m2e.core.core.IMavenConstants;
-import org.eclipse.m2e.core.index.IndexedArtifactFile;
-import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction;
-import org.eclipse.m2e.core.ui.internal.actions.OpenUrlAction;
-import org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog;
-import org.eclipse.m2e.core.ui.internal.search.util.Packaging;
-import org.eclipse.m2e.core.ui.internal.util.ProposalUtil;
-import org.eclipse.m2e.editor.MavenEditorImages;
-import org.eclipse.m2e.editor.composites.BuildComposite;
-import org.eclipse.m2e.editor.composites.DependencyLabelProvider;
-import org.eclipse.m2e.editor.composites.ListEditorComposite;
-import org.eclipse.m2e.editor.composites.ListEditorContentProvider;
-import org.eclipse.m2e.editor.internal.Messages;
-import org.eclipse.m2e.model.edit.pom.Build;
-import org.eclipse.m2e.model.edit.pom.BuildBase;
-import org.eclipse.m2e.model.edit.pom.Extension;
-import org.eclipse.m2e.model.edit.pom.PomFactory;
-import org.eclipse.m2e.model.edit.pom.PomPackage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * @author Eugene Kuleshov
- */
-public class BuildPage extends MavenPomEditorPage {
-
- // controls
- Text extensionGroupIdText;
- Text sourceText;
- Text outputText;
- Text testSourceText;
- Text testOutputText;
- Text scriptsSourceText;
-
- ListEditorComposite<Extension> extensionsEditor;
- BuildComposite buildComposite;
- Text extensionArtifactIdText;
- Text extensionVersionText;
- Button extensionSelectButton;
- Section foldersSection;
- Section extensionsSection;
- Section extensionDetailsSection;
-
- Extension currentExtension;
- protected boolean expandingTopSections;
- private Action extensionSelectAction;
- private Action extensionAddAction;
- private Action openWebPageAction;
-
-
- public BuildPage(MavenPomEditor pomEditor) {
- super(pomEditor, IMavenConstants.PLUGIN_ID + ".pom.build", Messages.BuildPage_title); //$NON-NLS-1$
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- FormToolkit toolkit = managedForm.getToolkit();
- ScrolledForm form = managedForm.getForm();
- form.setText(Messages.BuildPage_form);
- // form.setExpandHorizontal(true);
-
- Composite body = form.getBody();
- GridLayout gridLayout = new GridLayout(3, true);
- gridLayout.horizontalSpacing = 3;
- body.setLayout(gridLayout);
- toolkit.paintBordersFor(body);
-
- SashForm buildSash = new SashForm(body, SWT.NONE);
- buildSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
- GridLayout buildSashLayout = new GridLayout();
- buildSashLayout.horizontalSpacing = 3;
- buildSashLayout.marginWidth = 0;
- buildSashLayout.marginHeight = 0;
- buildSashLayout.numColumns = 3;
- buildSash.setLayout(buildSashLayout);
- toolkit.adapt(buildSash);
-
- createFoldersSection(buildSash, toolkit);
- createExtensionsSection(buildSash, toolkit);
- createExtensionDetailsSection(buildSash, toolkit);
-
- buildComposite = new BuildComposite(body, SWT.NONE);
- GridData buildCompositeData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
- buildCompositeData.heightHint = 270;
- buildComposite.setLayoutData(buildCompositeData);
- toolkit.adapt(buildComposite);
-
-// form.pack();
-
- super.createFormContent(managedForm);
- }
-
- private void createFoldersSection(Composite buildSash, FormToolkit toolkit) {
- foldersSection = toolkit.createSection(buildSash, //
- ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- foldersSection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- foldersSection.setText(Messages.BuildPage_section_folders);
- foldersSection.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- if(!expandingTopSections) {
- expandingTopSections = true;
- extensionsSection.setExpanded(foldersSection.isExpanded());
- extensionDetailsSection.setExpanded(foldersSection.isExpanded());
- expandingTopSections = false;
- }
- }
- });
-
- Composite composite = toolkit.createComposite(foldersSection, SWT.NONE);
- GridLayout compositeLayout = new GridLayout(2, false);
- compositeLayout.marginWidth = 2;
- compositeLayout.marginHeight = 2;
- composite.setLayout(compositeLayout);
- toolkit.paintBordersFor(composite);
- foldersSection.setClient(composite);
-
- toolkit.createLabel(composite, Messages.BuildPage_lblSources, SWT.NONE);
-
- sourceText = toolkit.createText(composite, null, SWT.NONE);
- sourceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildPage_lblOutput, SWT.NONE);
-
- outputText = toolkit.createText(composite, null, SWT.NONE);
- outputText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildPage_lblTestSources, SWT.NONE);
-
- testSourceText = toolkit.createText(composite, null, SWT.NONE);
- testSourceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildPage_lblTestOutput, SWT.NONE);
-
- testOutputText = toolkit.createText(composite, null, SWT.NONE);
- testOutputText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- toolkit.createLabel(composite, Messages.BuildPage_lblScripts, SWT.NONE);
-
- scriptsSourceText = toolkit.createText(composite, null, SWT.NONE);
- scriptsSourceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- }
-
- private void createExtensionsSection(Composite buildSash, FormToolkit toolkit) {
- extensionsSection = toolkit.createSection(buildSash, //
- ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- extensionsSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- extensionsSection.setText(Messages.BuildPage_section_extensions);
- extensionsSection.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- if(!expandingTopSections) {
- expandingTopSections = true;
- foldersSection.setExpanded(extensionsSection.isExpanded());
- extensionDetailsSection.setExpanded(extensionsSection.isExpanded());
- expandingTopSections = false;
- }
- }
- });
-
- extensionsEditor = new ListEditorComposite<Extension>(extensionsSection, SWT.NONE);
- toolkit.paintBordersFor(extensionsEditor);
- toolkit.adapt(extensionsEditor);
- extensionsSection.setClient(extensionsEditor);
-
- final DependencyLabelProvider labelProvider = new DependencyLabelProvider();
- extensionsEditor.setLabelProvider(labelProvider);
- extensionsEditor.setContentProvider(new ListEditorContentProvider<Extension>());
-
- extensionsEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Extension> selection = extensionsEditor.getSelection();
- updateExtensionDetails(selection.size()==1 ? selection.get(0) : null);
- }
- });
-
- extensionsEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- createExtension(null, null, null);
- }
- });
-
- extensionsEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = getEditingDomain();
-
- List<Extension> list = extensionsEditor.getSelection();
- for(Extension extension : list) {
- Command removeCommand = RemoveCommand.create(editingDomain, model.getBuild(), //
- POM_PACKAGE.getBuild_Extensions(), extension);
- compoundCommand.append(removeCommand);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- updateExtensionDetails(null);
- }
- });
-
- extensionAddAction = new Action(Messages.BuildPage_action_addExtension, MavenEditorImages.ADD_ARTIFACT) {
- public void run() {
- // XXX calculate list available extensions
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchDependencyDialog(getEditorSite().getShell(), //
- Messages.BuildPage_searchDialog_addExtension, getPomEditor().getMavenProject(), getProject(), false );
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
- if(af != null) {
- createExtension(af.group, af.artifact, af.version);
- }
- }
- }
- };
- extensionAddAction.setEnabled(false);
-
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBarManager.add(extensionAddAction);
- toolBarManager.add(new Separator());
-
- toolBarManager.add(new Action(Messages.BuildPage_action_showGroupId, MavenEditorImages.SHOW_GROUP) {
- {
- setChecked(true);
- }
- public int getStyle() {
- return AS_CHECK_BOX;
- }
- public void run() {
- labelProvider.setShowGroupId(isChecked());
- extensionsEditor.getViewer().refresh();
- }
- });
-
- Composite toolbarComposite = toolkit.createComposite(extensionsSection);
- GridLayout toolbarLayout = new GridLayout(1, true);
- toolbarLayout.marginHeight = 0;
- toolbarLayout.marginWidth = 0;
- toolbarComposite.setLayout(toolbarLayout);
- toolbarComposite.setBackground(null);
-
- toolBarManager.createControl(toolbarComposite);
- extensionsSection.setTextClient(toolbarComposite);
- }
-
- private void createExtensionDetailsSection(Composite buildSash, FormToolkit toolkit) {
- extensionDetailsSection = toolkit.createSection(buildSash, //
- ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
- extensionDetailsSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- extensionDetailsSection.setText(Messages.BuildPage_section_extensionDetails);
- extensionDetailsSection.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- if(!expandingTopSections) {
- expandingTopSections = true;
- foldersSection.setExpanded(extensionDetailsSection.isExpanded());
- extensionsSection.setExpanded(extensionDetailsSection.isExpanded());
- expandingTopSections = false;
- }
- }
- });
-
- Composite extensionDetialsComposite = toolkit.createComposite(extensionDetailsSection, SWT.NONE);
- GridLayout extensionDetialsCompositeLayout = new GridLayout(2, false);
- extensionDetialsCompositeLayout.marginWidth = 2;
- extensionDetialsCompositeLayout.marginHeight = 2;
- extensionDetialsComposite.setLayout(extensionDetialsCompositeLayout);
- toolkit.paintBordersFor(extensionDetialsComposite);
- extensionDetailsSection.setClient(extensionDetialsComposite);
-
- toolkit.createLabel(extensionDetialsComposite, Messages.BuildPage_lblGroupId);
-
- extensionGroupIdText = toolkit.createText(extensionDetialsComposite, null, SWT.FLAT);
- extensionGroupIdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- extensionGroupIdText.setData("name", "extensionGroupIdText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addGroupIdProposal(getProject(), extensionGroupIdText, Packaging.ALL);
-
- Hyperlink extensionArtifactIdHyperlink = toolkit.createHyperlink(extensionDetialsComposite, Messages.BuildPage_lblArtifactId, SWT.NONE);
- extensionArtifactIdHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- final String groupId = extensionGroupIdText.getText();
- final String artifactId = extensionArtifactIdText.getText();
- final String version = extensionVersionText.getText();
- new Job("Opening " + groupId + ":" + artifactId + ":" + version) {
- protected IStatus run(IProgressMonitor arg0) {
- OpenPomAction.openEditor(groupId, artifactId, version, null);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- });
-
- extensionArtifactIdText = toolkit.createText(extensionDetialsComposite, null, SWT.FLAT);
- extensionArtifactIdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- extensionArtifactIdText.setData("name", "extensionArtifactIdText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addArtifactIdProposal(getProject(), extensionGroupIdText, extensionArtifactIdText, Packaging.ALL);
-
- toolkit.createLabel(extensionDetialsComposite, Messages.BuildPage_lblVersion);
-
- extensionVersionText = toolkit.createText(extensionDetialsComposite, null, SWT.FLAT);
- extensionVersionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- extensionVersionText.setData("name", "extensionVersionText"); //$NON-NLS-1$ //$NON-NLS-2$
- ProposalUtil.addVersionProposal(getProject(), getPomEditor().getMavenProject(), extensionGroupIdText, extensionArtifactIdText, extensionVersionText, Packaging.ALL);
- extensionDetialsComposite.setTabList(new Control[] {extensionGroupIdText, extensionArtifactIdText, extensionVersionText});
-
-// extensionSelectButton = toolkit.createButton(extensionDetialsComposite, "Select...", SWT.FLAT);
-// extensionSelectButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
-// extensionSelectButton.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// // TODO calculate current list of artifacts for the project
-// Set<Dependency> artifacts = Collections.emptySet();
-// MavenRepositorySearchDialog dialog = new MavenRepositorySearchDialog(getEditorSite().getShell(), //
-// "Add Dependency", IndexManager.SEARCH_ARTIFACT, artifacts);
-// if(dialog.open() == Window.OK) {
-// IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
-// if(af != null) {
-// extensionGroupIdText.setText(nvl(af.group));
-// extensionArtifactIdText.setText(nvl(af.artifact));
-// extensionVersionText.setText(nvl(af.version));
-// }
-// }
-// }
-// });
-
- extensionSelectAction = new Action(Messages.BuildPage_action_selectExtension, MavenEditorImages.SELECT_ARTIFACT) {
- public void run() {
- // XXX calculate list available extensions
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchDependencyDialog(getEditorSite().getShell(), //
- Messages.BuildPage_searchDialog_selectExtension, getPomEditor().getMavenProject(), getProject(), false );
-
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
- if(af != null) {
- extensionGroupIdText.setText(nvl(af.group));
- extensionArtifactIdText.setText(nvl(af.artifact));
- extensionVersionText.setText(nvl(af.version));
- }
- }
- }
- };
- extensionSelectAction.setEnabled(false);
-
- openWebPageAction = new Action(Messages.BuildPage_action_openWeb, MavenEditorImages.WEB_PAGE) {
- public void run() {
- final String groupId = extensionGroupIdText.getText();
- final String artifactId = extensionArtifactIdText.getText();
- final String version = extensionVersionText.getText();
- new Job("Opening " + groupId + ":" + artifactId + ":" + version) {
- protected IStatus run(IProgressMonitor monitor) {
- OpenUrlAction.openBrowser(OpenUrlAction.ID_PROJECT, groupId, artifactId, version, monitor);
- return Status.OK_STATUS;
- }
- }.schedule();
-
- }
- };
- openWebPageAction.setEnabled(false);
-
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBarManager.add(extensionSelectAction);
- toolBarManager.add(new Separator());
- toolBarManager.add(openWebPageAction);
-
- Composite toolbarComposite = toolkit.createComposite(extensionDetailsSection);
- GridLayout toolbarLayout = new GridLayout(1, true);
- toolbarLayout.marginHeight = 0;
- toolbarLayout.marginWidth = 0;
- toolbarComposite.setLayout(toolbarLayout);
- toolbarComposite.setBackground(null);
-
- toolBarManager.createControl(toolbarComposite);
- extensionDetailsSection.setTextClient(toolbarComposite);
- }
-
- public void loadData() {
- loadBuild();
- loadBuildBase();
-
- extensionsEditor.setReadOnly(isReadOnly());
-
- updateExtensionDetails(null);
- }
-
- void updateExtensionDetails(Extension extension) {
- currentExtension = extension;
-
- removeNotifyListener(extensionGroupIdText);
- removeNotifyListener(extensionArtifactIdText);
- removeNotifyListener(extensionVersionText);
-
- if(extension==null) {
- FormUtils.setEnabled(extensionDetailsSection, false);
- extensionSelectAction.setEnabled(false);
- openWebPageAction.setEnabled(false);
-
- setText(extensionGroupIdText, ""); //$NON-NLS-1$
- setText(extensionArtifactIdText, ""); //$NON-NLS-1$
- setText(extensionVersionText, ""); //$NON-NLS-1$
-
- return;
- }
-
- FormUtils.setEnabled(extensionDetailsSection, true);
- FormUtils.setReadonly(extensionDetailsSection, isReadOnly());
- extensionSelectAction.setEnabled(!isReadOnly());
- openWebPageAction.setEnabled(true);
-
- setText(extensionGroupIdText, extension.getGroupId());
- setText(extensionArtifactIdText, extension.getArtifactId());
- setText(extensionVersionText, extension.getVersion());
-
- ValueProvider<Extension> extensionProvider = new ValueProvider.DefaultValueProvider<Extension>(extension);
- setModifyListener(extensionGroupIdText, extensionProvider, POM_PACKAGE.getExtension_GroupId(), ""); //$NON-NLS-1$
- setModifyListener(extensionArtifactIdText, extensionProvider, POM_PACKAGE.getExtension_ArtifactId(), ""); //$NON-NLS-1$
- setModifyListener(extensionVersionText, extensionProvider, POM_PACKAGE.getExtension_Version(), ""); //$NON-NLS-1$
-
- registerListeners();
- }
-
- private void loadBuild() {
- removeNotifyListener(sourceText);
- removeNotifyListener(outputText);
- removeNotifyListener(testSourceText);
- removeNotifyListener(testOutputText);
- removeNotifyListener(scriptsSourceText);
-
- Build build = model == null ? null : model.getBuild();
- if(build==null) {
- setText(sourceText, ""); //$NON-NLS-1$
- setText(outputText, ""); //$NON-NLS-1$
- setText(testSourceText, ""); //$NON-NLS-1$
- setText(testOutputText, ""); //$NON-NLS-1$
- setText(scriptsSourceText, ""); //$NON-NLS-1$
-
- extensionsEditor.setInput(null);
-
- } else {
- setText(sourceText, build.getSourceDirectory());
- setText(outputText, build.getOutputDirectory());
- setText(testSourceText, build.getTestSourceDirectory());
- setText(testOutputText, build.getTestOutputDirectory());
- setText(scriptsSourceText, build.getScriptSourceDirectory());
-
- extensionsEditor.setInput(build.getExtensions() == null ? null : build.getExtensions());
- }
-
- FormUtils.setReadonly(foldersSection, isReadOnly());
- FormUtils.setReadonly(extensionsSection, isReadOnly());
- extensionAddAction.setEnabled(!isReadOnly());
-
- updateExtensionDetails(null);
-
- ValueProvider<Build> modelProvider = new ValueProvider.ParentValueProvider<Build>(sourceText, outputText, testSourceText, testOutputText, scriptsSourceText) {
- public Build getValue() {
- return model.getBuild();
- }
- public Build create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- Build build = model.getBuild();
- if(build==null) {
- build = PomFactory.eINSTANCE.createBuild();
- Command command = SetCommand.create(editingDomain, model, POM_PACKAGE.getModel_Build(), build);
- compoundCommand.append(command);
- }
- return build;
- }
- };
- setModifyListener(sourceText, modelProvider, POM_PACKAGE.getBuild_SourceDirectory(), ""); //$NON-NLS-1$
- setModifyListener(outputText, modelProvider, POM_PACKAGE.getBuild_OutputDirectory(), ""); //$NON-NLS-1$
- setModifyListener(testSourceText, modelProvider, POM_PACKAGE.getBuild_TestSourceDirectory(), ""); //$NON-NLS-1$
- setModifyListener(testOutputText, modelProvider, POM_PACKAGE.getBuild_TestOutputDirectory(), ""); //$NON-NLS-1$
- setModifyListener(scriptsSourceText, modelProvider, POM_PACKAGE.getBuild_ScriptSourceDirectory(), ""); //$NON-NLS-1$
-
- loadBuildBase();
- }
-
- private void loadBuildBase() {
- ValueProvider<BuildBase> buildProvider = new ValueProvider<BuildBase>() {
- public Build getValue() {
- return model.getBuild();
- }
- public Build create(EditingDomain editingDomain, CompoundCommand compoundCommand) {
- Build build = PomFactory.eINSTANCE.createBuild();
- Command command = SetCommand.create(editingDomain, model, POM_PACKAGE.getModel_Build(), build);
- compoundCommand.append(command);
- return build;
- }
- };
- buildComposite.loadData(this, buildProvider);
- }
-
- protected void doUpdate(Notification notification){
- EObject object = (EObject) notification.getNotifier();
- Object feature = notification.getFeature();
- if (object instanceof Build) {
- loadBuild();
- }
- if (object instanceof BuildBase) {
- loadBuildBase();
- }
-
- if (feature == PomPackage.Literals.BUILD__EXTENSIONS) {
- extensionsEditor.refresh();
- }
-
- if (object instanceof Extension) {
- extensionsEditor.refresh();
- if(currentExtension==object) {
- updateExtensionDetails(currentExtension);
- }
- }
-
- if(buildComposite!=null) {
- buildComposite.updateView(this, notification);
- }
- }
-
- public void updateView(final Notification notification) {
- Display.getDefault().asyncExec(new Runnable(){
- public void run(){
- doUpdate(notification);
- }
- });
- }
-
- void createExtension(String groupId, String artifactId, String version) {
- CompoundCommand compoundCommand = new CompoundCommand();
- EditingDomain editingDomain = getEditingDomain();
-
- Build build = model.getBuild();
- if(build == null) {
- build = PomFactory.eINSTANCE.createBuild();
- Command command = SetCommand.create(editingDomain, model, POM_PACKAGE.getModel_Build(), build);
- compoundCommand.append(command);
- }
-
- Extension extension = PomFactory.eINSTANCE.createExtension();
- extension.setGroupId(groupId);
- extension.setArtifactId(artifactId);
- extension.setVersion(version);
-
- Command addCommand = AddCommand.create(editingDomain, build, //
- POM_PACKAGE.getBuild_Extensions(), extension);
- compoundCommand.append(addCommand);
-
- editingDomain.getCommandStack().execute(compoundCommand);
-
- extensionsEditor.setSelection(Collections.singletonList(extension));
- extensionGroupIdText.setFocus();
- }
-}
-

Back to the top