Search in sources :

Example 1 with TreePopulator

use of org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator in project tdi-studio-se by Talend.

the class JSONFileStep1Form method initialize.

/**
     * 
     * Initialize value, forceFocus first field.
     */
@Override
protected void initialize() {
    getConnection().setInputModel(true);
    availableJSONTreeViewer = new TreeViewer(availableJSONTree);
    this.xmlTreePopulator = new TreePopulator(availableJSONTreeViewer);
    // this.xmlTreePopulator.configureDefaultTreeViewer();
    this.jsonTreePopulator = new JsonTreePopulator(availableJSONTreeViewer);
    // this.jsonTreePopulator.configureDefaultTreeViewer();
    this.availableJSONTreeViewer.setUseHashlookup(true);
    // add init of CheckBoxIsGuess and Determine the Initialize checkFileXsdorJSON
    // if (getConnection().getXsdFilePath() != null) {
    // fileFieldXsd.setText(getConnection().getXsdFilePath().replace("\\\\", "\\"));
    // // init the fileViewer
    // this.treePopulator.populateTree(fileFieldXsd.getText(), treeNode);
    // checkFieldsValue();
    // }
    EJsonReadbyMode eJsonReadbyMode = null;
    if (getConnection().getReadbyMode() != null) {
        eJsonReadbyMode = EJsonReadbyMode.getEJsonReadbyModeByValue(getConnection().getReadbyMode());
    }
    if (eJsonReadbyMode == null) {
        eJsonReadbyMode = getDefaultJsonReadbyMode();
    }
    // JSONFileStep1Form.this.wizard.setReadbyMode(readbyCombo.getText());
    readbyCombo.setText(eJsonReadbyMode.getDisplayName());
    getConnection().setReadbyMode(eJsonReadbyMode.getValue());
    JSONFileStep1Form.this.wizard.setReadbyMode(eJsonReadbyMode.getValue());
    if (getConnection().getJSONFilePath() != null) {
        //$NON-NLS-1$ //$NON-NLS-2$
        fileFieldJSON.setText(getConnection().getJSONFilePath().replace("\\\\", "\\"));
        // init the fileViewer
        checkFieldsValue();
        String jsonFilePath = fileFieldJSON.getText();
        if (isContextMode()) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
            jsonFilePath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, fileFieldJSON.getText()));
        }
        File file = new File(jsonFilePath);
        if (!file.exists() && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0) {
            initFileContent();
            jsonFilePath = tempJSONXsdPath;
        }
        String tempxml = null;
        tempxml = getFilePath4Populate(jsonFilePath);
        switchPopulator(JSONFileStep1Form.this.wizard.getReadbyMode(), tempxml);
    }
    // Fields to the Group Delimited File Settings
    if (getConnection().getEncoding() != null && !getConnection().getEncoding().equals("")) {
        //$NON-NLS-1$
        encodingCombo.setText(getConnection().getEncoding());
    } else {
        encodingCombo.select(0);
    }
    encodingCombo.clearSelection();
    // if (getConnection().getMaskXPattern() != null) {
    // fieldMaskXPattern.setText(getConnection().getMaskXPattern().replace("\\\\", "\\"));
    // }
    adaptFormToEditable();
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator) AbstractTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.AbstractTreePopulator) TreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator) TreeViewer(org.eclipse.jface.viewers.TreeViewer) EJsonReadbyMode(org.talend.repository.ui.wizards.metadata.connection.files.json.EJsonReadbyMode) JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator) File(java.io.File)

Example 2 with TreePopulator

use of org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator in project tdi-studio-se by Talend.

the class JSONFileOutputStep1Form method initialize.

@Override
protected void initialize() {
    getConnection().setInputModel(false);
    this.treePopulator = new TreePopulator(availableJSONTree);
    if (getConnection().getJSONFilePath() != null) {
        jsonFilePath.setText(getConnection().getJSONFilePath().replace("\\\\", "\\"));
        checkFieldsValue();
        String jsonXmlPath = jsonFilePath.getText();
        if (isContextMode()) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
            jsonXmlPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, jsonFilePath.getText()));
        }
        if (!new File(jsonXmlPath).exists() && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0) {
            initFileContent();
            jsonXmlPath = tempJSONPath;
        }
        if (JSONFileOutputStep1Form.this.tempPath == null) {
            if (jsonXmlPath != null && !jsonXmlPath.equals("")) {
                JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath);
            } else {
                JSONFileOutputStep1Form.this.tempPath = "";
            }
        }
        File file = new File(JSONFileOutputStep1Form.this.tempPath);
        if (file.exists()) {
            valid = this.treePopulator.populateTree(JSONFileOutputStep1Form.this.tempPath, treeNode);
        }
    }
    if (getConnection().getEncoding() != null && !getConnection().getEncoding().equals("")) {
        encodingCombo.setText(getConnection().getEncoding());
    } else {
        encodingCombo.select(0);
    }
    encodingCombo.clearSelection();
    if (getConnection().getOutputFilePath() != null) {
        outputFilePath.setText(getConnection().getOutputFilePath());
    }
    adaptFormToEditable();
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) TreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator) RecordFile(orgomg.cwm.resource.record.RecordFile) File(java.io.File)

Example 3 with TreePopulator

use of org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator in project tdi-studio-se by Talend.

the class JSONFileStep2Form method initTreePopulator.

private void initTreePopulator() {
    if (EJsonReadbyMode.JSONPATH.getValue().equals(this.wizard.getReadbyMode())) {
        this.treePopulator = new JsonTreePopulator(availableJSONTreeViewer);
    } else {
        this.treePopulator = new TreePopulator(availableJSONTreeViewer);
    }
    this.treePopulator.setFilePath(this.wizard.getTempJsonPath());
    this.treePopulator.configureDefaultTreeViewer();
}
Also used : JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator) AbstractTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.AbstractTreePopulator) TreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator) JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator)

Aggregations

TreePopulator (org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator)3 File (java.io.File)2 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)2 AbstractTreePopulator (org.talend.repository.ui.wizards.metadata.connection.files.json.AbstractTreePopulator)2 JsonTreePopulator (org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 EJsonReadbyMode (org.talend.repository.ui.wizards.metadata.connection.files.json.EJsonReadbyMode)1 RecordFile (orgomg.cwm.resource.record.RecordFile)1