001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.tool.service.eclipse.ui;
020:
021: import org.apache.axis2.tool.service.bean.ClassFileSelectionBean;
022: import org.apache.axis2.tool.service.eclipse.plugin.ServiceArchiver;
023: import org.eclipse.swt.SWT;
024: import org.eclipse.swt.events.ModifyEvent;
025: import org.eclipse.swt.events.ModifyListener;
026: import org.eclipse.swt.events.MouseAdapter;
027: import org.eclipse.swt.events.MouseEvent;
028: import org.eclipse.swt.events.SelectionEvent;
029: import org.eclipse.swt.events.SelectionListener;
030: import org.eclipse.swt.layout.GridData;
031: import org.eclipse.swt.layout.GridLayout;
032: import org.eclipse.swt.widgets.Button;
033: import org.eclipse.swt.widgets.Composite;
034: import org.eclipse.swt.widgets.DirectoryDialog;
035: import org.eclipse.swt.widgets.Label;
036: import org.eclipse.swt.widgets.Text;
037:
038: public class ClassFileLocationPage extends AbstractServiceWizardPage {
039:
040: private Text classFileLocationText;
041: private Button filterByClassFilesCheckBox;
042:
043: public ClassFileLocationPage() {
044: super ("page1");
045: }
046:
047: /* (non-Javadoc)
048: * @see org.apache.axis2.tool.service.eclipse.ui.AbstractServiceWizardPage#initializeDefaultSettings()
049: */
050: protected void initializeDefaultSettings() {
051: settings.put(PREF_CLASS_FILE_LOCATION, System
052: .getProperty("user.dir"));
053: settings.put(PREF_FILTER_BY_CLASSES, true);
054:
055: }
056:
057: /* (non-Javadoc)
058: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
059: */
060: public void createControl(Composite parent) {
061: Composite container = new Composite(parent, SWT.NULL);
062: GridLayout layout = new GridLayout();
063: layout.numColumns = 3;
064: layout.verticalSpacing = 9;
065:
066: container.setLayout(layout);
067: GridData gd = new GridData(GridData.FILL_HORIZONTAL);
068: Label lable = new Label(container, SWT.NULL);
069: lable.setText(ServiceArchiver
070: .getResourceString("page1.fileLocationLabel"));
071:
072: classFileLocationText = new Text(container, SWT.BORDER);
073: classFileLocationText.setLayoutData(gd);
074: classFileLocationText.setText(settings
075: .get(PREF_CLASS_FILE_LOCATION));
076: classFileLocationText.addModifyListener(new ModifyListener() {
077: public void modifyText(ModifyEvent e) {
078: handleModify();
079: }
080: });
081:
082: Button browseButton = new Button(container, SWT.PUSH);
083: browseButton.setText(ServiceArchiver
084: .getResourceString("general.browse"));
085: browseButton.addMouseListener(new MouseAdapter() {
086: public void mouseUp(MouseEvent e) {
087: handleBrowse();
088: }
089: });
090:
091: gd = new GridData(GridData.FILL_HORIZONTAL);
092: gd.horizontalSpan = 2;
093: filterByClassFilesCheckBox = new Button(container, SWT.CHECK);
094: filterByClassFilesCheckBox.setLayoutData(gd);
095: filterByClassFilesCheckBox.setText(ServiceArchiver
096: .getResourceString("page1.filter.caption"));
097: filterByClassFilesCheckBox.setSelection(settings
098: .getBoolean(PREF_FILTER_BY_CLASSES));
099: filterByClassFilesCheckBox
100: .addSelectionListener(new SelectionListener() {
101: public void widgetSelected(SelectionEvent e) {
102: settings.put(PREF_FILTER_BY_CLASSES,
103: filterByClassFilesCheckBox
104: .getSelection());
105: }
106:
107: public void widgetDefaultSelected(SelectionEvent e) {
108: }
109: });
110:
111: setControl(container);
112: //call the handle modify method if the setttings are restored
113:
114: if (restoredFromPreviousSettings) {
115: handleModify();
116: }
117: }
118:
119: private void handleBrowse() {
120: DirectoryDialog dirDialog = new DirectoryDialog(this .getShell());
121: dirDialog.setMessage(ServiceArchiver
122: .getResourceString("page1.filedialogTitle"));
123: String returnText = dirDialog.open();
124: if (returnText != null) {
125: this .classFileLocationText.setText(returnText);
126: }
127: }
128:
129: private void handleModify() {
130: String classLocationText = this .classFileLocationText.getText()
131: .trim();
132: settings.put(PREF_CLASS_FILE_LOCATION, classLocationText);
133: //update the wizard
134: ((ServiceArchiveWizard) this .getWizard())
135: .setClassFileLocation(classLocationText);
136:
137: if ("".equals(classLocationText)) {
138: updateStatus(ServiceArchiver
139: .getResourceString("page1.error.filemissing"));
140: } else {
141: updateStatus(null);
142: }
143: }
144:
145: public String getClassFileLocation() {
146: return classFileLocationText.getText();
147: }
148:
149: public ClassFileSelectionBean getBean() {
150: ClassFileSelectionBean pageBean = new ClassFileSelectionBean();
151: pageBean.setFileLocation(this .classFileLocationText.getText());
152: if (filterByClassFilesCheckBox.getSelection()) {
153: pageBean.setFilter(".class");
154: }
155: return pageBean;
156: }
157:
158: protected boolean getWizardComplete() {
159: return false;
160: }
161: }
|