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());
}
}
}
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());
}
}
}
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();
}
}
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;
}
};
}
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();
}
}
Aggregations