Search in sources :

Example 1 with MavenPropertyDialog

use of org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog in project m2e-core by eclipse-m2e.

the class PropertiesSection method createNewProperty.

void createNewProperty() {
    MavenPropertyDialog dialog = new // 
    MavenPropertyDialog(// 
    propertiesSection.getShell(), Messages.PropertiesSection_title_addProperty, "", "", // $NON-NLS-1$//$NON-NLS-2$
    listener);
    if (dialog.open() == IDialogConstants.OK_ID) {
        final String key = dialog.getName();
        final String value = dialog.getValue();
        try {
            page.performEditOperation(document -> {
                Element prop = getChild(document.getDocumentElement(), PROPERTIES, key);
                setText(prop, value);
            }, LOG, "error creating property");
        } finally {
            propertiesEditor.setInput(getProperties());
        }
    }
}
Also used : MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) Element(org.w3c.dom.Element) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement)

Example 2 with MavenPropertyDialog

use of org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog in project m2e-core by eclipse-m2e.

the class PropertiesSection method editProperty.

void editProperty(List<PropertyElement> list) {
    if (list.size() != 1) {
        return;
    }
    final PropertyElement pp = list.get(0);
    MavenPropertyDialog dialog = new // 
    MavenPropertyDialog(// 
    propertiesSection.getShell(), Messages.PropertiesSection_title_editProperty, pp.getName(), pp.getValue(), listener);
    if (dialog.open() == IDialogConstants.OK_ID) {
        final String key = dialog.getName();
        final String value = dialog.getValue();
        try {
            page.performEditOperation(document -> {
                Element properties = getChild(document.getDocumentElement(), PROPERTIES);
                Element old = findChild(properties, pp.getName());
                if (old == null) {
                    // should never happen..
                    old = getChild(properties, pp.getName());
                }
                if (!pp.getName().equals(key)) {
                    Element newElement = document.createElement(key);
                    properties.replaceChild(newElement, old);
                    setText(newElement, pp.getValue());
                    old = newElement;
                }
                if (!pp.getValue().equals(value)) {
                    setText(old, value);
                }
            }, LOG, "error updating property");
        } finally {
            propertiesEditor.setInput(getProperties());
        }
    }
}
Also used : MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) Element(org.w3c.dom.Element) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement)

Example 3 with MavenPropertyDialog

use of org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog in project m2e-core by eclipse-m2e.

the class MavenLaunchMainTab method editProperty.

void editProperty(String name, String value) {
    MavenPropertyDialog dialog = getMavenPropertyDialog(org.eclipse.m2e.internal.launch.Messages.MavenLaunchMainTab_property_dialog_edit_title, name, value);
    if (dialog.open() == IDialogConstants.OK_ID) {
        TableItem[] item = propsTable.getSelection();
        item[0].setText(0, dialog.getName());
        item[0].setText(1, dialog.getValue());
        entriesChanged();
    }
}
Also used : MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) TableItem(org.eclipse.swt.widgets.TableItem)

Example 4 with MavenPropertyDialog

use of org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog in project m2e-core by eclipse-m2e.

the class MavenLaunchMainTab method getMavenPropertyDialog.

private MavenPropertyDialog getMavenPropertyDialog(String title, String initName, String initValue) {
    return new MavenPropertyDialog(getShell(), title, initName, initValue, null) {

        protected Control createDialogArea(Composite parent) {
            Composite comp = (Composite) super.createDialogArea(parent);
            Button variablesButton = new Button(comp, SWT.PUSH);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
            gd.horizontalSpan = 2;
            gd.widthHint = // 
            Math.max(// 
            convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), variablesButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
            variablesButton.setLayoutData(gd);
            variablesButton.setFont(comp.getFont());
            // ;
            variablesButton.setText(Messages.launchPropertyDialogBrowseVariables);
            variablesButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
                StringVariableSelectionDialog variablesDialog = new StringVariableSelectionDialog(getShell());
                if (variablesDialog.open() == IDialogConstants.OK_ID) {
                    String variable = variablesDialog.getVariableExpression();
                    if (variable != null) {
                        valueText.insert(variable.trim());
                    }
                }
            }));
            return comp;
        }
    };
}
Also used : IMavenConfiguration(org.eclipse.m2e.core.embedder.IMavenConfiguration) TableViewer(org.eclipse.jface.viewers.TableViewer) LoggerFactory(org.slf4j.LoggerFactory) TableColumn(org.eclipse.swt.widgets.TableColumn) CoreException(org.eclipse.core.runtime.CoreException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FocusEvent(org.eclipse.swt.events.FocusEvent) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Composite(org.eclipse.swt.widgets.Composite) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) SettingsXmlConfigurationProcessor(org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) List(java.util.List) MavenLaunchConstants(org.eclipse.m2e.actions.MavenLaunchConstants) MavenImages(org.eclipse.m2e.core.ui.internal.MavenImages) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) LaunchingUtils(org.eclipse.m2e.internal.launch.LaunchingUtils) Label(org.eclipse.swt.widgets.Label) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) SelectionListener(org.eclipse.swt.events.SelectionListener) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) Table(org.eclipse.swt.widgets.Table) ArrayList(java.util.ArrayList) Messages(org.eclipse.m2e.internal.launch.Messages) VariablesPlugin(org.eclipse.core.variables.VariablesPlugin) StringVariableSelectionDialog(org.eclipse.debug.ui.StringVariableSelectionDialog) GridData(org.eclipse.swt.layout.GridData) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) Logger(org.slf4j.Logger) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) File(java.io.File) ModifyListener(org.eclipse.swt.events.ModifyListener) IResource(org.eclipse.core.resources.IResource) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) StringVariableSelectionDialog(org.eclipse.debug.ui.StringVariableSelectionDialog) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) GridData(org.eclipse.swt.layout.GridData)

Example 5 with MavenPropertyDialog

use of org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog in project m2e-core by eclipse-m2e.

the class MavenLaunchMainTab method addProperty.

void addProperty() {
    MavenPropertyDialog dialog = getMavenPropertyDialog(org.eclipse.m2e.internal.launch.Messages.MavenLaunchMainTab_property_dialog_title, "", // $NON-NLS-2$
    "");
    if (dialog.open() == IDialogConstants.OK_ID) {
        TableItem item = new TableItem(propsTable, SWT.NONE);
        item.setText(0, dialog.getName());
        item.setText(1, dialog.getValue());
        entriesChanged();
    }
}
Also used : MavenPropertyDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog) TableItem(org.eclipse.swt.widgets.TableItem)

Aggregations

MavenPropertyDialog (org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog)5 TableItem (org.eclipse.swt.widgets.TableItem)3 PomEdits.removeIfNoChildElement (org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement)2 Element (org.w3c.dom.Element)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 SettingsXmlConfigurationProcessor (org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor)1 IResource (org.eclipse.core.resources.IResource)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 VariablesPlugin (org.eclipse.core.variables.VariablesPlugin)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 AbstractLaunchConfigurationTab (org.eclipse.debug.ui.AbstractLaunchConfigurationTab)1 StringVariableSelectionDialog (org.eclipse.debug.ui.StringVariableSelectionDialog)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1