KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > reorg > QualifiedNameComponent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.refactoring.reorg;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.events.ModifyEvent;
15 import org.eclipse.swt.events.ModifyListener;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Label;
21 import org.eclipse.swt.widgets.Text;
22
23 import org.eclipse.jface.dialogs.IDialogSettings;
24
25 import org.eclipse.jdt.internal.corext.refactoring.tagging.IQualifiedNameUpdating;
26
27 import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages;
28
29 public class QualifiedNameComponent extends Composite {
30
31     private static final String JavaDoc PATTERNS= "patterns"; //$NON-NLS-1$
32
private Text fPatterns;
33
34     public QualifiedNameComponent(Composite parent, int style, final IQualifiedNameUpdating refactoring, IDialogSettings settings) {
35         super(parent, style);
36         GridLayout layout= new GridLayout();
37         layout.marginWidth=0; layout.marginHeight= 0;
38         layout.numColumns= 2;
39         setLayout(layout);
40         Label label= new Label(this, SWT.NONE);
41         label.setText(RefactoringMessages.QualifiedNameComponent_patterns_label);
42         fPatterns= new Text(this, SWT.BORDER);
43         fPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
44         label= new Label(this, SWT.NONE);
45         label.setText(RefactoringMessages.QualifiedNameComponent_patterns_description);
46         GridData gd= new GridData(GridData.FILL_HORIZONTAL);
47         gd.horizontalSpan=2;
48         label.setLayoutData(gd);
49         String JavaDoc text= refactoring.getFilePatterns();
50         if (text == null)
51             text= settings.get(PATTERNS);
52         if (text != null) {
53             fPatterns.setText(text);
54             refactoring.setFilePatterns(text);
55         }
56         fPatterns.addModifyListener(new ModifyListener() {
57             public void modifyText(ModifyEvent e) {
58                 refactoring.setFilePatterns(fPatterns.getText());
59             }
60         });
61     }
62     
63     public void setEnabled(boolean enabled) {
64         super.setEnabled(enabled);
65         Control[] children= getChildren();
66         for (int i= 0; i < children.length; i++) {
67             children[i].setEnabled(enabled);
68         }
69     }
70     
71     public void savePatterns(IDialogSettings settings) {
72         settings.put(PATTERNS, fPatterns.getText());
73     }
74 }
75
Popular Tags