Project

General

Profile

« Previous | Next » 

Revision 8481f952

Added by Andreas Müller almost 4 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/RichTextWithLabelElement.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.ui.element;
5 5

  
6
import java.awt.Point;
7

  
8
import org.eclipse.jface.dialogs.MessageDialog;
9 6
import org.eclipse.jface.layout.GridDataFactory;
10
import org.eclipse.jface.viewers.CellEditor.LayoutData;
11 7
//import org.eclipse.nebula.widgets.richtext.RichTextEditor;
12 8
//import org.eclipse.nebula.widgets.richtext.RichTextEditorConfiguration;
13 9
//import org.eclipse.nebula.widgets.richtext.toolbar.ToolbarButton;
14 10
//import org.eclipse.nebula.widgets.richtext.toolbar.ToolbarConfiguration;
15 11
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.KeyAdapter;
17
import org.eclipse.swt.events.KeyEvent;
18
import org.eclipse.swt.events.ModifyEvent;
19
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.events.SelectionAdapter;
21
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.graphics.Color;
23 12
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.layout.RowLayout;
25
import org.eclipse.swt.widgets.Button;
26 13
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28 14
import org.eclipse.swt.widgets.Label;
29
import org.eclipse.swt.widgets.Listener;
30 15
import org.eclipse.swt.widgets.Text;
31
import org.eclipse.ui.forms.widgets.TableWrapData;
32
import org.eclipse.ui.forms.widgets.TableWrapLayout;
33

  
34
import eu.etaxonomy.cdm.common.CdmUtils;
35
import eu.etaxonomy.taxeditor.preference.Resources;
36 16

  
37 17
/**
38 18
 * @author n.hoffmann
39
 * @version $Id: $
40 19
 */
41 20
public class RichTextWithLabelElement{ //extends AbstractCdmFormElement implements ModifyListener, IEnableableFormElement,
42 21
   //     ISelectable {
43 22

  
44
    
45 23
    //protected RichTextEditor richtextEditor;
46 24
    private Label label;
47 25
    private boolean buttonVisible = true;
......
86 64
            boolean isMultiLine, int style, Composite layoutComposite) {
87 65
    	layoutComposite.setLayout(new GridLayout(1, true));
88 66

  
89
		
67

  
90 68
//		ToolbarConfiguration toolBarConfig = new ToolbarConfiguration();
91
//		
69
//
92 70
//		RichTextEditorConfiguration config = new RichTextEditorConfiguration();
93 71
//		config.setMinSize(800, 600);
94
//		
72
//
95 73
//		final RichTextEditor editor = new RichTextEditor(layoutComposite, config);
96 74
//		GridDataFactory.fillDefaults().grab(true, true).applyTo(editor);
97 75
//		//editor.setText(initialText);
......
101 79
				SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
102 80
		GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 100).applyTo(htmlOutput);
103 81
		htmlOutput.setEditable(true);
104
		
105
		
106
		
82

  
83

  
84

  
107 85
//		editor.addModifyListener(new ModifyListener() {
108 86
//
109 87
//			@Override
......
119 97
//			public void keyPressed(KeyEvent e) {
120 98
//				org.eclipse.swt.graphics.Point point = htmlOutput.getSelection();
121 99
//				htmlOutput.setText(htmlOutput.getText() + " - " + point.x + ":"+point.y);
122
//			
100
//
123 101
//			}
124 102
//		});
125 103

  
......
133 111
//		});
134 112

  
135 113
		// add additional controls for showing interactions
136
	
137
//    	  createControlPanel(layoutComposite, editor, textHeight); 
138
        	 
114

  
115
//    	  createControlPanel(layoutComposite, editor, textHeight);
116

  
139 117
    }
140
    
141
//    protected void createControlPanel(Composite parent, final RichTextEditor editor, int textHeight) { 
142
//    	  Composite controlPanel = new Composite(parent, SWT.NONE); 
118

  
119
//    protected void createControlPanel(Composite parent, final RichTextEditor editor, int textHeight) {
120
//    	  Composite controlPanel = new Composite(parent, SWT.NONE);
143 121
//    	  TableWrapLayout layout;
144 122
//    	  layout = LayoutConstants.LAYOUT(3, false);
145
//    	  controlPanel.setLayout(layout); 
146
//    	  GridDataFactory.fillDefaults().grab(true, false).applyTo(controlPanel); 
147
//    	 
148
//    	  Label inputLabel = new Label(controlPanel, SWT.NONE); 
149
//    	  inputLabel.setText("Text to set:"); 
150
//    //	  GridDataFactory.fillDefaults().applyTo(inputLabel); 
151
//    	 
152
//    	  Text input = new Text(controlPanel, SWT.BORDER); 
123
//    	  controlPanel.setLayout(layout);
124
//    	  GridDataFactory.fillDefaults().grab(true, false).applyTo(controlPanel);
125
//
126
//    	  Label inputLabel = new Label(controlPanel, SWT.NONE);
127
//    	  inputLabel.setText("Text to set:");
128
//    //	  GridDataFactory.fillDefaults().applyTo(inputLabel);
129
//
130
//    	  Text input = new Text(controlPanel, SWT.BORDER);
153 131
//    	  TableWrapData layoutData;
154 132
//    	  if(isMultiLine){
155 133
//              layoutData = LayoutConstants.FILL_HORIZONTALLY(2, 1);
......
158 136
//              layoutData = LayoutConstants.FILL();
159 137
//          }
160 138
//    	  input.setLayoutData(layoutData);
161
//    //	  GridDataFactory.fillDefaults().grab(true, false).applyTo(input); 
162
//    	 
163
//    	  input.addKeyListener(new KeyAdapter() { 
164
//    	   @Override 
165
//    	   public void keyPressed(KeyEvent e) { 
166
//    	    if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { 
167
//    	     editor.setText(input.getText()); 
168
//    	    } 
169
//    	   } 
170
//    	  }); 
171
//    	 
172
//    	  Button setButton = new Button(controlPanel, SWT.PUSH); 
173
//    	  setButton.setText("Set Text"); 
174
//    	//  GridDataFactory.defaultsFor(setButton).applyTo(setButton); 
175
//    	 
176
//    	  setButton.addSelectionListener(new SelectionAdapter() { 
177
//    	   @Override 
178
//    	   public void widgetSelected(SelectionEvent e) { 
179
//    	    editor.setText(input.getText()); 
180
//    	   } 
181
//    	  }); 
182
//    	 
183
//    	  Composite buttonPanel = new Composite(controlPanel, SWT.NONE); 
184
//    	  buttonPanel.setLayout(new RowLayout()); 
185
//    	 // GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(buttonPanel); 
186
//    	 
187
//    	  Button getButton = new Button(buttonPanel, SWT.PUSH); 
188
//    	  getButton.setText("Get text"); 
189
//    	  getButton.addSelectionListener(new SelectionAdapter() { 
190
//    	   @Override 
191
//    	   public void widgetSelected(SelectionEvent e) { 
192
//    	    MessageDialog.openInformation(null, "Editor Input", 
193
//    	      editor.getText()); 
194
//    	   } 
195
//    	  }); 
196
//    	 
197
//    	  final Button enableButton = new Button(buttonPanel, SWT.PUSH); 
198
//    	  enableButton.setText("Disable"); 
199
//    	  enableButton.addSelectionListener(new SelectionAdapter() { 
200
//    	   @Override 
201
//    	   public void widgetSelected(SelectionEvent e) { 
202
//    	    boolean editable = editor.isEditable(); 
203
//    	    editor.setEditable(!editable); 
204
//    	 
205
//    	    enableButton.setText(editable ? "Enable" : "Disable"); 
206
//    	   } 
207
//    	  }); 
208
//    	 
209
//    	  final Button updateButton = new Button(buttonPanel, SWT.PUSH); 
210
//    	  updateButton.setText("Update Toolbar"); 
211
//    	 
212
//    	  final ToolbarButton button = new ToolbarButton("javaButton", 
213
//    	    "myJavaCommand", "Execute Java", "other", 
214
//    	    null) { 
215
//    	 
216
//    	   @Override 
217
//    	   public Object execute() { 
218
//    	    MessageDialog.openInformation(null, "Information", 
219
//    	      "Java callback: " + editor.getSelectedHTML()); 
220
//    	 
221
//    	    editor.insertHTML("<em>" + editor.getSelectedHTML() + "</em>"); 
222
//    	    return null; 
223
//    	   } 
224
//    	  }; 
225
//    	 
226
//    	  updateButton.addSelectionListener(new SelectionAdapter() { 
227
//    	   @Override 
228
//    	   public void widgetSelected(SelectionEvent e) { 
229
//    	    if (!buttonVisible) { 
230
//    	     editor.addToolbarButton(button); 
231
//    	    } else { 
232
//    	     editor.removeToolbarButton(button); 
233
//    	    } 
234
//    	    buttonVisible = !buttonVisible; 
235
//    	    editor.updateToolbar(); 
236
//    	   } 
237
//    	  }); 
238
//    	 
239
//    	  Button setFocusButton = new Button(buttonPanel, SWT.PUSH); 
240
//    	  setFocusButton.setText("Set Focus"); 
241
//    	  setFocusButton.addSelectionListener(new SelectionAdapter() { 
242
//    	   @Override 
243
//    	   public void widgetSelected(SelectionEvent e) { 
244
//    	    editor.setFocus(); 
245
//    	   } 
246
//    	  }); 
247
//    	 
248
//    	 } 
139
//    //	  GridDataFactory.fillDefaults().grab(true, false).applyTo(input);
140
//
141
//    	  input.addKeyListener(new KeyAdapter() {
142
//    	   @Override
143
//    	   public void keyPressed(KeyEvent e) {
144
//    	    if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
145
//    	     editor.setText(input.getText());
146
//    	    }
147
//    	   }
148
//    	  });
149
//
150
//    	  Button setButton = new Button(controlPanel, SWT.PUSH);
151
//    	  setButton.setText("Set Text");
152
//    	//  GridDataFactory.defaultsFor(setButton).applyTo(setButton);
153
//
154
//    	  setButton.addSelectionListener(new SelectionAdapter() {
155
//    	   @Override
156
//    	   public void widgetSelected(SelectionEvent e) {
157
//    	    editor.setText(input.getText());
158
//    	   }
159
//    	  });
160
//
161
//    	  Composite buttonPanel = new Composite(controlPanel, SWT.NONE);
162
//    	  buttonPanel.setLayout(new RowLayout());
163
//    	 // GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(buttonPanel);
164
//
165
//    	  Button getButton = new Button(buttonPanel, SWT.PUSH);
166
//    	  getButton.setText("Get text");
167
//    	  getButton.addSelectionListener(new SelectionAdapter() {
168
//    	   @Override
169
//    	   public void widgetSelected(SelectionEvent e) {
170
//    	    MessageDialog.openInformation(null, "Editor Input",
171
//    	      editor.getText());
172
//    	   }
173
//    	  });
174
//
175
//    	  final Button enableButton = new Button(buttonPanel, SWT.PUSH);
176
//    	  enableButton.setText("Disable");
177
//    	  enableButton.addSelectionListener(new SelectionAdapter() {
178
//    	   @Override
179
//    	   public void widgetSelected(SelectionEvent e) {
180
//    	    boolean editable = editor.isEditable();
181
//    	    editor.setEditable(!editable);
182
//
183
//    	    enableButton.setText(editable ? "Enable" : "Disable");
184
//    	   }
185
//    	  });
186
//
187
//    	  final Button updateButton = new Button(buttonPanel, SWT.PUSH);
188
//    	  updateButton.setText("Update Toolbar");
189
//
190
//    	  final ToolbarButton button = new ToolbarButton("javaButton",
191
//    	    "myJavaCommand", "Execute Java", "other",
192
//    	    null) {
193
//
194
//    	   @Override
195
//    	   public Object execute() {
196
//    	    MessageDialog.openInformation(null, "Information",
197
//    	      "Java callback: " + editor.getSelectedHTML());
198
//
199
//    	    editor.insertHTML("<em>" + editor.getSelectedHTML() + "</em>");
200
//    	    return null;
201
//    	   }
202
//    	  };
203
//
204
//    	  updateButton.addSelectionListener(new SelectionAdapter() {
205
//    	   @Override
206
//    	   public void widgetSelected(SelectionEvent e) {
207
//    	    if (!buttonVisible) {
208
//    	     editor.addToolbarButton(button);
209
//    	    } else {
210
//    	     editor.removeToolbarButton(button);
211
//    	    }
212
//    	    buttonVisible = !buttonVisible;
213
//    	    editor.updateToolbar();
214
//    	   }
215
//    	  });
216
//
217
//    	  Button setFocusButton = new Button(buttonPanel, SWT.PUSH);
218
//    	  setFocusButton.setText("Set Focus");
219
//    	  setFocusButton.addSelectionListener(new SelectionAdapter() {
220
//    	   @Override
221
//    	   public void widgetSelected(SelectionEvent e) {
222
//    	    editor.setFocus();
223
//    	   }
224
//    	  });
225
//
226
//    	 }
249 227
//
250 228
//    protected void initLabel(CdmFormFactory formFactory, String labelString, boolean isMultiLine, Composite layoutComposite) {
251 229
//        if (labelString != null) {
......
262 240
//        }
263 241
//    }
264 242
//
265
//   
266
//    
243
//
244
//
267 245
//
268 246
//    /** {@inheritDoc} */
269 247
//    @Override
......
281 259
//	@Override
282 260
//	public void setIrrelevant(boolean irrelevant) {
283 261
//		// TODO Auto-generated method stub
284
//		
262
//
285 263
//	}
286 264
//
287 265
//	@Override
288 266
//	public void setEnabled(boolean enabled) {
289 267
//		// TODO Auto-generated method stub
290
//		
268
//
291 269
//	}
292 270
//
293 271
//	@Override
......
299 277
//	@Override
300 278
//	public void modifyText(ModifyEvent e) {
301 279
//		// TODO Auto-generated method stub
302
//		
280
//
303 281
//	}
304 282

  
305
   
283

  
306 284
}

Also available in: Unified diff