-
Notifications
You must be signed in to change notification settings - Fork 98
/
PTURLEditor.java
60 lines (52 loc) · 1.75 KB
/
PTURLEditor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
* Copyright (c) 2012 Laurent CARON
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API
* and implementation
*******************************************************************************/
package org.eclipse.nebula.widgets.opal.propertytable.editor;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.nebula.widgets.opal.commons.ResourceManager;
import org.eclipse.nebula.widgets.opal.dialog.Dialog;
import org.eclipse.swt.SWT;
/**
* This editor is used to edit URL values
*/
public class PTURLEditor extends PTBaseTextEditor {
/**
* @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTBaseTextEditor#addVerifyListeners()
*/
@Override
public void addVerifyListeners() {
text.addListener(SWT.FocusOut, event -> {
try {
new URL(PTURLEditor.this.text.getText());
} catch (final MalformedURLException e) {
Dialog.error(ResourceManager.getLabel(ResourceManager.APPLICATION_ERROR), ResourceManager.getLabel(ResourceManager.VALID_URL));
event.doit = false;
PTURLEditor.this.text.forceFocus();
}
});
}
/**
* @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTBaseTextEditor#convertValue()
*/
@Override
public Object convertValue() {
return text.getText();
}
/**
* @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTBaseTextEditor#getStyle()
*/
@Override
public int getStyle() {
return SWT.NONE;
}
}