Search in sources :

Example 16 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class Component method addViewParameters.

public void addViewParameters(final List<ElementParameter> listParam, INode node) {
    ElementParameter param;
    IPreferenceStore localComponentProviderStore = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
        IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
        if (service != null) {
            localComponentProviderStore = service.getPreferenceStore();
        }
    }
    String formatId = getNodeFormatIdWithoutFormatType(getName(), getTranslatedFamilyName());
    param = new ElementParameter(node);
    param.setName(EParameterName.LABEL.getName());
    param.setDisplayName(EParameterName.LABEL.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.VIEW);
    param.setNumRow(1);
    param.setReadOnly(false);
    param.setRequired(false);
    param.setShow(true);
    if (formatId != null) {
        if (localComponentProviderStore != null) {
            String label = localComponentProviderStore.getString(IComponentsLocalProviderService.PREFERENCE_TYPE_LABEL);
            if (!"".equals(label)) {
                //$NON-NLS-1$
                param.setValue(label);
            }
        }
    } else {
        // in case label/format is not set in the preferences.
        String label = DesignerPlugin.getDefault().getPreferenceStore().getString(TalendDesignerPrefConstants.DEFAULT_LABEL);
        if (!"".equals(label)) {
            //$NON-NLS-1$
            param.setValue(label);
        }
    }
    param.setDefaultValue(param.getValue());
    listParam.add(param);
    param = new ElementParameter(node);
    param.setName(EParameterName.HINT.getName());
    param.setDisplayName(EParameterName.HINT.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.VIEW);
    param.setNumRow(2);
    param.setReadOnly(false);
    param.setRequired(false);
    param.setShow(true);
    if (formatId != null) {
        if (localComponentProviderStore != null) {
            String label = localComponentProviderStore.getString(IComponentsLocalProviderService.PREFERENCE_TYPE_HINT);
            if (!"".equals(label)) {
                //$NON-NLS-1$
                param.setValue(label);
            }
        }
    } else {
        // in case hint/format is not set in the preferences.
        String label = DesignerPlugin.getDefault().getPreferenceStore().getString(TalendDesignerPrefConstants.DEFAULT_HINT);
        if (!"".equals(label)) {
            //$NON-NLS-1$
            param.setValue(label);
        }
    }
    param.setDefaultValue(param.getValue());
    listParam.add(param);
    param = new ElementParameter(node);
    param.setName(EParameterName.CONNECTION_FORMAT.getName());
    param.setDisplayName(EParameterName.CONNECTION_FORMAT.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.VIEW);
    param.setNumRow(3);
    param.setReadOnly(false);
    param.setRequired(false);
    param.setShow(true);
    if (formatId != null) {
        if (localComponentProviderStore != null) {
            String label = localComponentProviderStore.getString(IComponentsLocalProviderService.PREFERENCE_TYPE_CONNECTION);
            if (!"".equals(label)) {
                //$NON-NLS-1$
                param.setValue(label);
            }
        }
    }
    param.setDefaultValue(param.getValue());
    listParam.add(param);
}
Also used : IComponentsLocalProviderService(org.talend.core.ui.services.IComponentsLocalProviderService) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 17 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createNewComponent.

public void createNewComponent(DropTargetEvent event1) {
    boolean quickCreateInput = event1.detail == DND.DROP_LINK;
    boolean quickCreateOutput = event1.detail == DND.DROP_COPY;
    Iterator iterator = getSelection().iterator();
    List<TempStore> list = new ArrayList<TempStore>();
    List<IComponent> components = new ArrayList<IComponent>();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) obj;
            if (equalsJobInCurrentEditor(sourceNode)) {
                continue;
            }
            Item item = sourceNode.getObject().getProperty().getItem();
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
                ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
                if (testContainerService != null && testContainerService.isTestContainerItem(item)) {
                    continue;
                }
            }
            ERepositoryObjectType type = sourceNode.getObjectType();
            if (!(item instanceof ConnectionItem) && !(item instanceof ProcessItem) && !(item instanceof JobletProcessItem) && !(item instanceof RulesItem) && !(item instanceof LinkRulesItem)) {
                // RulesItem
                return;
            }
            {
            /**
                     * Remove this limitation for feature: TDI-32362, I think it should be ok, don't know why adding
                     * this limitation to forbid to d&d salseforce connection, I keep those code in case this behavior
                     * will cause some bugs when d&d salseforce connection, then maybe need to review
                     */
            // if (item instanceof SalesforceSchemaConnectionItem && type ==
            // ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
            // return;
            // }
            }
            TempStore store = new TempStore();
            store.seletetedNode = sourceNode;
            getAppropriateComponent(item, quickCreateInput, quickCreateOutput, store, type);
            if (store.component != null) {
                list.add(store);
            } else {
                MessageDialog.openInformation(editor.getEditorSite().getShell(), //$NON-NLS-1$
                Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.title"), //$NON-NLS-1$
                Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.content"));
            }
        }
        org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event1.x, event1.y);
        Canvas canvas = (Canvas) editor.getViewer().getControl();
        /*
             * translate to Canvas coordinate
             */
        swtLocation = canvas.toControl(swtLocation);
        org.eclipse.swt.graphics.Point size = canvas.getSize();
        /*
             * translate to Viewport coordinate with zoom
             */
        org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
        /*
             * calcule the view port position. Take into acounte the scroll position
             */
        ProcessPart part = (ProcessPart) editor.getViewer().getRootEditPart().getRoot().getChildren().get(0);
        IFigure targetFigure = part.getFigure();
        translateAbsolateToRelative(targetFigure, draw2dPosition);
        //$NON-NLS-1$
        String lastUniqname = "";
        // creates every node
        for (TempStore store : list) {
            RepositoryNode selectedNode = store.seletetedNode;
            IComponent element = store.component;
            if (!components.contains(element)) {
                components.add(element);
            }
            Node node = new Node(element);
            // for bug4564(metadata label format)
            // IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
            // if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
            // node.setPropertyValue(EParameterName.LABEL.getName(), selectedNode.getObject().getLabel());
            // }
            IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
            if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
                String LabelValue = null;
                RepositoryNode repositoryNode = null;
                repositoryNode = (RepositoryNode) getSelection().getFirstElement();
                // dnd a table
                IElementParameter dbTableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
                boolean hasDbTableField = dbTableParam != null;
                if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE && repositoryNode.getObject() != null && repositoryNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem && hasDbTableField) {
                    LabelValue = DesignerUtilities.getParameterVar(dbTableParam.getName());
                } else if (repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_MR || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_STORM) {
                    // dnd a job
                    LabelValue = DesignerUtilities.getParameterVar(EParameterName.PROCESS);
                } else if (repositoryNode.getObjectType() == ERepositoryObjectType.JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_STREAMING_JOBLET) {
                    LabelValue = element.getName();
                } else if (CorePlugin.getDefault().getDesignerCoreService().getPreferenceStore(TalendDesignerPrefConstants.DEFAULT_LABEL).equals(node.getPropertyValue(EParameterName.LABEL.getName()))) {
                    // dnd a default
                    LabelValue = selectedNode.getObject().getLabel();
                }
                if (LabelValue != null) {
                    node.setPropertyValue(EParameterName.LABEL.getName(), LabelValue);
                }
            }
            processSpecificDBTypeIfSameProduct(store.componentName, node);
            NodeContainer nc = ((Process) node.getProcess()).loadNodeContainer(node, false);
            ;
            // create component on link
            boolean executed = false;
            if (getSelection().size() == 1 && getTargetEditPart() instanceof SubjobContainerPart) {
                executed = createComponentOnLink(node, draw2dPosition);
            }
            if (!executed) {
                // create the node on the design sheet
                execCommandStack(new CreateNodeContainerCommand((Process) editor.getProcess(), nc, draw2dPosition));
            }
            // initialize the propertiesView
            CompoundCommand cc = new CompoundCommand();
            createRefreshingPropertiesCommand(cc, selectedNode, node);
            execCommandStack(cc);
            // for (Command command : commands) {
            // }
            propaHadoopCfgChanges(selectedNode);
            draw2dPosition = draw2dPosition.getCopy();
            draw2dPosition.x += TalendEditor.GRID_SIZE;
            draw2dPosition.y += TalendEditor.GRID_SIZE;
            node.checkNode();
            lastUniqname = node.getUniqueName();
        }
    // setselecte(part, lastUniqname);
    }
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), components);
}
Also used : IComponent(org.talend.core.model.components.IComponent) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) Iterator(java.util.Iterator) IElementParameter(org.talend.core.model.process.IElementParameter) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IFigure(org.eclipse.draw2d.IFigure) Point(org.eclipse.draw2d.geometry.Point) Canvas(org.eclipse.swt.widgets.Canvas) Point(org.eclipse.draw2d.geometry.Point) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 18 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class CodeView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new FillLayout());
    ECodeLanguage language = LanguageManager.getCurrentLanguage();
    ISourceViewer viewer = null;
    final StyledText text;
    int styles = SWT.H_SCROLL | SWT.V_SCROLL;
    document = new Document();
    switch(language) {
        case JAVA:
            IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
            viewer = new JavaSourceViewer(parent, null, null, false, styles, store);
            viewer.setDocument(document);
            JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
            tools.setupJavaDocumentPartitioner(viewer.getDocument(), IJavaPartitions.JAVA_PARTITIONING);
            SimpleJavaSourceViewerConfiguration config = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true);
            viewer.configure(config);
            viewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
            document = viewer.getDocument();
            break;
        // empty since only have java
        default:
    }
    viewer.setEditable(false);
    text = viewer.getTextWidget();
    // getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
    IAction wrapAction = new Action() {

        @Override
        public void run() {
            text.setWordWrap(isChecked());
        }
    };
    //$NON-NLS-1$
    wrapAction.setToolTipText("wrap");
    wrapAction.setChecked(false);
    //$NON-NLS-1$
    wrapAction.setImageDescriptor(ImageDescriptor.createFromFile(DesignerPlugin.class, "/icons/wrap.gif"));
    tbm.add(wrapAction);
    createMenu();
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) StyledText(org.eclipse.swt.custom.StyledText) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) IAction(org.eclipse.jface.action.IAction) JavaTextTools(org.eclipse.jdt.ui.text.JavaTextTools) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) DesignerPlugin(org.talend.designer.core.DesignerPlugin) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 19 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method installViewerConfiguration.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.viewer.ReconcilerViewer#installViewerConfiguration()
     */
@Override
protected void installViewerConfiguration() {
    JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(getDocument(), IJavaPartitions.JAVA_PARTITIONING);
    IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
    configure(new TalendJavaViewerConfiguration((IColorManager) sharedColors, store, this));
}
Also used : JavaTextTools(org.eclipse.jdt.ui.text.JavaTextTools) IColorManager(org.eclipse.jdt.ui.text.IColorManager) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 20 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class ProcessComposite method setProcessContext.

public void setProcessContext(RunProcessContext processContext) {
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    if (this.processContext != null) {
        this.processContext.removePropertyChangeListener(pcl);
    }
    this.processContext = processContext;
    if (processContext != null) {
        processContext.addPropertyChangeListener(pcl);
    }
    // if (argumentsViewer != null) {
    // argumentsViewer.setProcessContext(processContext);
    // }
    boolean disableAll = false;
    if (processContext != null) {
        disableAll = processContext.getProcess().disableRunJobView();
    }
    // && !disableAll);
    if (this.processContext == null) {
        // this.processContext.setMonitorTrace(traceBtn.getSelection());
        processManager.setBooleanTrace(false);
    }
    // watchBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore
    // ().getBoolean(
    // RunProcessPrefsConstants.ISEXECTIMERUN)
    // && !disableAll);
    // saveJobBeforeRunButton.setSelection(RunProcessPlugin.getDefault().
    // getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSAVEBEFORERUN)
    // && !disableAll);
    // clearBeforeExec.setSelection(RunProcessPlugin.getDefault().
    // getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISCLEARBEFORERUN)
    // && !disableAll);
    // saveJobBeforeRunButton.setSelection(processContext != null && processContext.isSaveBeforeRun());
    setRunnable(processContext != null && !processContext.isRunning() && !disableAll);
    if (killBtn != null && !killBtn.isDisposed()) {
        killBtn.setEnabled(processContext != null && processContext.isRunning() && !disableAll);
    }
    // clearBeforeExec.setEnabled(processContext != null);
    // clearBeforeExec.setSelection(processContext != null && processContext.isClearBeforeExec());
    // contextComposite.setProcess(((processContext != null) && !disableAll ? processContext.getProcess() : null));
    fillConsole(processContext != null ? processContext.getMessages() : new ArrayList<IProcessMessage>());
    // remove trace if basic run tab active
    if (processContext != null) {
        processContext.setMonitorTrace(false);
        org.talend.core.model.process.IProcess process = processContext.getProcess();
        List<INode> nodeList = (List<INode>) process.getGraphicalNodes();
        for (INode node : nodeList) {
            for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
                ConnectionTrace traceNode = connection.getConnectionTrace();
                if (traceNode == null) {
                    continue;
                }
                traceNode.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), false);
                if (connection != null && connection.checkTraceShowEnable()) {
                    connection.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), false);
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) Connection(org.talend.designer.core.ui.editor.connections.Connection) ConnectionTrace(org.talend.designer.core.ui.editor.connections.ConnectionTrace) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)673 ArrayList (java.util.ArrayList)52 Test (org.junit.Test)36 File (java.io.File)32 RGB (org.eclipse.swt.graphics.RGB)26 GridData (org.eclipse.swt.layout.GridData)26 IOException (java.io.IOException)23 CoreException (org.eclipse.core.runtime.CoreException)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 Composite (org.eclipse.swt.widgets.Composite)23 List (java.util.List)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)21 Before (org.junit.Before)21 FontData (org.eclipse.swt.graphics.FontData)20 Hashtable (java.util.Hashtable)19 Button (org.eclipse.swt.widgets.Button)18 StyledText (org.eclipse.swt.custom.StyledText)17 Font (org.eclipse.swt.graphics.Font)17 ChainedPreferenceStore (org.eclipse.ui.texteditor.ChainedPreferenceStore)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16