blob: ab2618afde83d2ea627d4a392329fe1fc028c67f (
plain) (
blame)
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
61
62
63
64
65
66
67
68
69
70
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
* 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.properties.widgets;
import java.util.HashMap;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.infra.gmfdiag.css.handler.ResetStyleHandler;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.Activator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
public class ResetStyleWidget implements SelectionListener {
private Button button;
public ResetStyleWidget(Composite parent, int style) {
button = new Button(parent, SWT.PUSH);
button.addSelectionListener(this);
button.setText("Default style");
button.setToolTipText("Resets the properties which have been customized outside of the Style support. The default style will be applied");
}
public void widgetSelected(SelectionEvent event) {
if(event.widget != button) {
return;
}
ResetStyleHandler handler = new ResetStyleHandler();
try {
handler.execute(new ExecutionEvent(null, new HashMap<String, String>(), event, null));
} catch (ExecutionException ex) {
Activator.log.error(ex);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
//Nothing
}
public void setText(String text) {
button.setText(text);
}
public String getText() {
return button.getText();
}
public void setToolTipText(String tooltip) {
button.setToolTipText(tooltip);
}
public String getToolTipText() {
return button.getToolTipText();
}
}
|