⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adddatasourcepage.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/dialog/AddDataSourcePage.java,v 1.1.1.1 2004/07/01 09:07:44 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:44 $
 *
 * ====================================================================
 *
 * The NanJing HopeRun(IT-FOREST) Software License, Version 2.0.0
 *
 * Copyright 2003-2004 by NanJing HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and
 *                        IT Forest Corporation
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 */
package com.webpump.ui.dialog;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import com.webpump.ui.datasource.data.DataSource;
import com.webpump.ui.datasource.data.SourceList;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for layout of addpage .
 * 
 * @author luo_sa
 * @version 2.0.0 2004-3-5
 */
public class AddDataSourcePage extends WizardPage {
    

    private String m_strValue;
    
    /** string on the label of the dialog */
    private String m_strLabel;
    
    /** Text in the dialog*/
    private Text m_textValue;
    
    /** description of the dialog */
    private String m_strDescription;
    
    private Object m_object;
    
    /**
     * Constructor
     * 
     * @param strTitle
     * @param strDescription
     * @param strLabel
     * @param strValue
     */
    public AddDataSourcePage(String strTitle, String strDescription, String strLabel, String strValue, Object obj) {
        super("wizardPage");
        m_strLabel = strLabel;
        m_strValue = strValue;
        m_object = obj;
        m_strDescription = strDescription;
        setTitle(strTitle);
        setDescription(strDescription);

    }
    
    /**
     * Create control for the dialog .
     */
    public void createControl(Composite parent) {
        final Composite composite = new Composite(parent, SWT.NONE);
        final GridLayout gridLayout = new GridLayout();
        gridLayout.makeColumnsEqualWidth = true;
        gridLayout.numColumns = 3;
        composite.setLayout(gridLayout);
        setControl(composite);
        
        final Label label = new Label(composite, SWT.NONE);
        label.setText(m_strLabel);
        
        m_textValue = new Text(composite, SWT.BORDER);
        final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        gridData.horizontalSpan = 2;           
        m_textValue.setLayoutData(gridData);
        m_textValue.setText(m_strValue);
        m_textValue.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e){
                if (m_textValue.getText().trim().length() > 0) {
                    if (m_object instanceof SourceList) {
                        int i = 0;
                        for (; i < ((SourceList)m_object).getChild().length; i++) {
                            String str = ((DataSource)((SourceList) m_object).getChild()[i]).toString();
                            if (m_textValue.getText().trim().compareTo(str) == 0)
                                break;
                        }
                        if (i == ((SourceList)m_object).getChild().length) {
                            setPageComplete(true);
                            setDescription(m_strDescription);
                        }else{
                            setPageComplete(false);
                            setDescription(WebpumpIDEPlugin.getResourceString(MacroResource.SAME_WRONG));
                        }
                    }
                                                                                                              

                } else {
                    setPageComplete(false);
                    setDescription(WebpumpIDEPlugin.getResourceString(MacroResource.BLANK_WRONG));
                }
            }
        });
        init();
    }
    
    /**
     * Get value of the text.
     * @return
     */
    public String getValue() {
        String str = m_textValue.getText().trim();
        return str;
    }
    
    /**
     * init the dialog.
     *
     */
    public void init() {
        m_textValue.setText(m_strValue);
        if(m_strValue.length() <= 0) {
            setPageComplete(false);
            setDescription(WebpumpIDEPlugin.getResourceString(MacroResource.BLANK_WRONG));
                
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -