Project

General

Profile

Revision f03073b9

IDf03073b94c83da569655edb01682d8b6644542d2
Parent 7a676646
Child 5f727043

Added by Patrick Plitzner about 3 years ago

ref #6746 Disable protect titleCache button for feature tree DetailsView

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java
25 25
import org.eclipse.swt.widgets.Label;
26 26
import org.eclipse.swt.widgets.Text;
27 27

  
28
import eu.etaxonomy.taxeditor.model.AbstractUtility;
28 29
import eu.etaxonomy.taxeditor.model.ImageResources;
29 30
import eu.etaxonomy.taxeditor.preference.Resources;
30
import eu.etaxonomy.taxeditor.store.StoreUtil;
31 31

  
32 32
/**
33 33
 * When the button is pressed, this textfield may be edited.
......
39 39
public class ToggleableTextElement extends AbstractCdmFormElement implements SelectionListener, ModifyListener, IEnableableFormElement, ISelectable {
40 40

  
41 41
	private final Text text_cache;
42
	private final Button button_toggle;
42
	private final Button btnToggleProtectTitleCache;
43 43
	private boolean state;
44 44
	private final Set<SelectionListener> selectionListener = new HashSet<SelectionListener>();
45 45
	private final Label label;
......
48 48
	//TODO for RL
49 49
	public void setVisible(boolean b) {
50 50
		text_cache.setVisible(b);
51
		button_toggle.setVisible(b);
51
		btnToggleProtectTitleCache.setVisible(b);
52 52
		label.setVisible(b);
53 53
		container.setVisible(b);
54
	}	
55
	
56
	
57
	/**
58
	 * <p>Constructor for ToggleableTextElement.</p>
59
	 *
60
	 * @param style a int.
61
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
62
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
63
	 * @param labelString a {@link java.lang.String} object.
64
	 * @param initialText a {@link java.lang.String} object.
65
	 * @param initialState a boolean.
66
	 */
54
	}
55

  
67 56
	protected ToggleableTextElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
68 57
			String labelString, String initialText, boolean initialState, int style) {
69 58
		super(formFactory, parentElement);
......
91 80
			}
92 81
		});
93 82

  
94
		button_toggle = formFactory.createButton(container, "Edit", SWT.TOGGLE);
95
		button_toggle.setText("");
96
		button_toggle.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
97
		addControl(button_toggle);
98
		button_toggle.addSelectionListener(this);
83
		btnToggleProtectTitleCache = formFactory.createButton(container, "Edit", SWT.TOGGLE);
84
		btnToggleProtectTitleCache.setText("");
85
		btnToggleProtectTitleCache.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
86
		addControl(btnToggleProtectTitleCache);
87
		btnToggleProtectTitleCache.addSelectionListener(this);
99 88

  
100 89
		setState(initialState);
101 90
	}
102 91

  
103
	/**
104
	 * <p>setText</p>
105
	 *
106
	 * @param text a {@link java.lang.String} object.
107
	 */
108 92
	public void setText(String text){
109 93
		if(text != null){
110 94
			// store current caret position
......
119 103
		}
120 104
	}
121 105

  
122
	/**
123
	 * <p>getText</p>
124
	 *
125
	 * @return a {@link java.lang.String} object.
126
	 */
127 106
	public String getText(){
128 107
		return text_cache.getText();
129 108
	}
130 109

  
131
	/**
132
	 * <p>Setter for the field <code>state</code>.</p>
133
	 *
134
	 * @param state a boolean.
135
	 */
136 110
	private void setState(boolean state) {
137 111
	    if(state){
138
	        button_toggle.setImage(ImageResources.getImage(ImageResources.LOCK_OPEN_ICON));
112
	        btnToggleProtectTitleCache.setImage(ImageResources.getImage(ImageResources.LOCK_OPEN_ICON));
139 113
	    }
140 114
	    else{
141
	        button_toggle.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
115
	        btnToggleProtectTitleCache.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
142 116
	    }
143 117
	   setEnabled(state);
144 118
		this.state = state;
145 119
	}
146 120

  
147
	/** {@inheritDoc} */
148 121
	@Override
149 122
    public void setEnabled(boolean enabled) {
150 123
		text_cache.setEnabled(enabled);
151
       	button_toggle.setGrayed(enabled);
152
		button_toggle.setSelection(enabled);
153
		Color color = enabled ? null : StoreUtil.getColor(Resources.COLOR_TEXT_DISABLED);
154
		
124
       	btnToggleProtectTitleCache.setGrayed(enabled);
125
		btnToggleProtectTitleCache.setSelection(enabled);
126
		Color color = enabled ? null : AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED);
127

  
155 128
		text_cache.setForeground(color);
156 129
	}
157 130

  
158
	/* (non-Javadoc)
159
	 * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled()
160
	 */
161 131
	@Override
162 132
	public boolean isEnabled() {
163 133
	    return text_cache.isEnabled();
164 134
	}
165 135

  
166
	/**
167
	 * <p>Getter for the field <code>state</code>.</p>
168
	 *
169
	 * @return a boolean.
170
	 */
171 136
	public boolean getState(){
172 137
		return state;
173 138
	}
174 139

  
175
	/* (non-Javadoc)
176
	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
177
	 */
178
	/** {@inheritDoc} */
140
    public Button getBtnToggleProtectTitleCache() {
141
        return btnToggleProtectTitleCache;
142
    }
143

  
179 144
	@Override
180 145
    public void widgetSelected(SelectionEvent e) {
181
		setState(button_toggle.getSelection());
146
		setState(btnToggleProtectTitleCache.getSelection());
182 147
		for(SelectionListener listener : selectionListener){
183 148
			listener.widgetSelected(e);
184 149
		}
185 150
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
186 151
	}
187 152

  
188
	/**
189
	 * <p>addSelectionListener</p>
190
	 *
191
	 * @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
192
	 */
193 153
	public void addSelectionListener(SelectionListener listener){
194 154
		selectionListener.add(listener);
195 155
	}
196 156

  
197
	/**
198
	 * <p>removeSelectionListener</p>
199
	 *
200
	 * @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
201
	 */
202 157
	public void removeSelectionListener(SelectionListener listener){
203 158
		selectionListener.remove(listener);
204 159
	}
205 160

  
206
	/** {@inheritDoc} */
207 161
	@Override
208 162
    public void widgetDefaultSelected(SelectionEvent e) {}
209 163

  
210
	/** {@inheritDoc} */
211 164
	@Override
212 165
    public void modifyText(ModifyEvent e) {
213 166
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
214 167
	}
215 168

  
216
	/** {@inheritDoc} */
217 169
	@Override
218 170
    public void setIrrelevant(boolean irrelevant) {
219 171
		String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND;
......
222 174
		text_cache.setBackground(color);
223 175
	}
224 176

  
225
	/** {@inheritDoc} */
226 177
	@Override
227 178
	public void setBackground(Color color) {
228 179
		label.setBackground(color);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureTreeDetailElement.java
32 32
	    toggleable_cache = formFactory.createToggleableTextField(
33 33
                formElement, "Title Cache", entity.getTitleCache(),
34 34
                entity.isProtectedTitleCache(), style);
35
	    toggleable_cache.getBtnToggleProtectTitleCache().setEnabled(false);
35 36
    }
36 37

  
37
	/**
38
	 * {@inheritDoc}
39
	 */
40 38
	@Override
41 39
	protected void updateControlStates() {
42 40
	    super.updateControlStates();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)