Search in sources :

Example 56 with IPreferenceStore

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

the class AbstractLanguageMemoController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
        IControlCreator txtCtrl = new IControlCreator() {

            @Override
            public Control createControl(final Composite parent, final int style) {
                final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                if (display != null) {
                    display.syncExec(new Runnable() {

                        @Override
                        public void run() {
                            IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                            String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                            FontData fontData = new FontData(fontType);
                            Font font = new Font(parent.getDisplay(), fontData);
                            addResourceDisposeListener(colorText, font);
                            colorText.setFont(font);
                        }
                    });
                }
                return colorText;
            }
        };
        DecoratedField dField = null;
        if (param.getNbLines() != 1) {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
        } else {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
        }
        StyledText text = (StyledText) dField.getControl();
        FormData d = (FormData) text.getLayoutData();
        d.height = text.getLineHeight();
        text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
        rowSizeByLine = text.getLineHeight();
        Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
        dField.getLayoutControl().dispose();
        rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
        estimateInitialized = true;
    }
    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
Also used : FormData(org.eclipse.swt.layout.FormData) StyledText(org.eclipse.swt.custom.StyledText) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Display(org.eclipse.swt.widgets.Display)

Example 57 with IPreferenceStore

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

the class ExchangeLoginTask method run.

/* (non-Javadoc)
     * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
     */
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    if (!PluginChecker.isExchangeSystemLoaded() || TalendPropertiesUtil.isHideExchange()) {
        return;
    }
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "Check Exchange") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            // check for Talendforge
            IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
            boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
            IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
            if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
                int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
                if (count < 0) {
                    count = 1;
                }
                ExchangeUser exchangeUser = ProjectManager.getInstance().getCurrentProject().getExchangeUser();
                //$NON-NLS-1$
                boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
                boolean isUserPassRight = true;
                if (isExchangeLogon) {
                    IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
                    if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
                        isUserPassRight = false;
                    }
                }
                if (!isExchangeLogon || !isUserPassRight) {
                    if ((count + 1) % 4 == 0) {
                        // if (Platform.getOS().equals(Platform.OS_LINUX)) {
                        // TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
                        // tfDialog.open();
                        // } else {
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                Project project = ProjectManager.getInstance().getCurrentProject();
                                String userEmail = null;
                                if (project.getAuthor() != null) {
                                    userEmail = project.getAuthor().getLogin();
                                }
                                TalendForgeDialog tfDialog = new TalendForgeDialog(DisplayUtils.getDefaultShell(), userEmail);
                                tfDialog.setBlockOnOpen(true);
                                tfDialog.open();
                            }
                        });
                    }
                    prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
                }
            }
            return org.eclipse.core.runtime.Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.setUser(false);
    job.setPriority(Job.INTERACTIVE);
    // start as soon as possible
    job.schedule();
}
Also used : IBrandingService(org.talend.core.ui.branding.IBrandingService) ExchangeUser(org.talend.core.model.properties.ExchangeUser) Project(org.talend.core.model.general.Project) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IExchangeService(org.talend.core.service.IExchangeService) Job(org.eclipse.core.runtime.jobs.Job) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) TalendForgeDialog(org.talend.registration.wizards.register.TalendForgeDialog)

Example 58 with IPreferenceStore

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

the class TalendEditorPaletteFactory method loadFamilyState.

/**
     * DOC nrousseau Comment method "loadFamilyState".
     * 
     * @param family
     * @return
     */
private static int loadFamilyState(String family) {
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    preferenceStore.setDefault(PALETTE_STATE + family, PaletteDrawer.INITIAL_STATE_CLOSED);
    return preferenceStore.getInt(PALETTE_STATE + family);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 59 with IPreferenceStore

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

the class TalendEditorPaletteFactory method createEntryFrom.

public static TalendCombinedTemplateCreationEntry createEntryFrom(IComponent component) {
    if (component == null) {
        return null;
    }
    String name = component.getName();
    ImageDescriptor imageSmall = component.getIcon16();
    IPreferenceStore store = DesignerPlugin.getDefault().getPreferenceStore();
    ImageDescriptor imageLarge;
    final String string = store.getString(TalendDesignerPrefConstants.LARGE_ICONS_SIZE);
    if (string.equals("24")) {
        //$NON-NLS-1$
        imageLarge = component.getIcon24();
    } else {
        imageLarge = component.getIcon32();
    }
    TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class, component, imageSmall, imageLarge);
    newEntry.setDescription(component.getLongName());
    return newEntry;
}
Also used : ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) TalendCombinedTemplateCreationEntry(org.talend.designer.core.ui.editor.palette.TalendCombinedTemplateCreationEntry)

Example 60 with IPreferenceStore

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

the class DownloadCheckUpdatesDialog method createDialogArea.

/**
     * Create contents of the dialog.
     * 
     * @param parent
     */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_composite.heightHint = 188;
    gd_composite.widthHint = 423;
    composite.setLayoutData(gd_composite);
    Label lblNewLabel = new Label(composite, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_lblNewLabel.heightHint = 92;
    gd_lblNewLabel.widthHint = 406;
    lblNewLabel.setLayoutData(gd_lblNewLabel);
    lblNewLabel.setText("\nThere are newer versions of some items you have downloaded\nfrom the Talend Exchange.");
    Label lblNewLabel_1 = new Label(composite, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    lblNewLabel_1.setText("Total available updates : ");
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    Button btnCheckButton = new Button(composite, SWT.CHECK);
    btnCheckButton.setText("Don't ask again ");
    new Label(composite, SWT.NONE);
    btnCheckButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
            prefStore.setValue(ITalendCorePrefConstants.EXCHANGE_DOWNLOADED_CHECK_UPDATES, true);
            cancelPressed();
        }
    });
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)311 ArrayList (java.util.ArrayList)35 Test (org.junit.Test)23 Hashtable (java.util.Hashtable)19 File (java.io.File)18 Before (org.junit.Before)17 List (java.util.List)14 IPath (org.eclipse.core.runtime.IPath)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IOException (java.io.IOException)12 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)12 IElementParameter (org.talend.core.model.process.IElementParameter)12 CoreException (org.eclipse.core.runtime.CoreException)11 Path (org.eclipse.core.runtime.Path)11 Font (org.eclipse.swt.graphics.Font)11 Point (org.eclipse.swt.graphics.Point)11 Composite (org.eclipse.swt.widgets.Composite)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 IStatus (org.eclipse.core.runtime.IStatus)10 StyledText (org.eclipse.swt.custom.StyledText)10