Search in sources :

Example 46 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class RepositoryService method isloginDialogDisabled.

private boolean isloginDialogDisabled() {
    //$NON-NLS-1$
    boolean reload = Boolean.parseBoolean(System.getProperty("talend.project.reload"));
    PreferenceManipulator preferenceManipulator = new PreferenceManipulator();
    ConnectionBean lastBean = null;
    if (reload) {
        final ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
        instance.forceReadConnections();
        final String lastConncetion = ConnectionUserPerReader.getInstance().readLastConncetion();
        for (ConnectionBean bean : instance.readConnections()) {
            if (bean.getName().equals(lastConncetion)) {
                lastBean = bean;
                break;
            }
        }
    }
    if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND)) {
        //$NON-NLS-1$
        boolean deleteProjectIfExist = ArrayUtils.contains(Platform.getApplicationArgs(), "--deleteProjectIfExist");
        IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
        brandingService.getBrandingConfiguration().setUseProductRegistration(false);
        ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
        //$NON-NLS-1$ //$NON-NLS-2$
        String projectName = getAppArgValue("-project", "AUTO_LOGIN_PROJECT");
        //$NON-NLS-1$
        String language = getAppArgValue("-language", ECodeLanguage.JAVA.getName());
        //$NON-NLS-1$ //$NON-NLS-2$
        String login = getAppArgValue("-login", "auto@login.com");
        //$NON-NLS-1$ //$NON-NLS-2$
        String password = getAppArgValue("-loginPass", "");
        //$NON-NLS-1$
        String tacURL = getAppArgValue("-tacURL", null);
        // if tacURL is null, the branch will be no useful.
        //$NON-NLS-1$
        String branch = getAppArgValue("-branch", null);
        // if tacURL is not null, will be remote
        final boolean isRemote = tacURL != null;
        if (reload && lastBean != null) {
            final String lastProject = preferenceManipulator.getLastProject();
            if (lastProject != null) {
                projectName = lastProject;
            }
            final String lastUser = lastBean.getUser();
            if (lastUser != null) {
                login = lastUser;
            }
            final String lastPass = lastBean.getPassword();
            if (lastPass != null) {
                password = lastPass;
            }
        }
        User userInfo = PropertiesFactoryImpl.eINSTANCE.createUser();
        userInfo.setLogin(login);
        try {
            userInfo.setPassword(PasswordHelper.encryptPasswd(password));
        } catch (NoSuchAlgorithmException e) {
            ExceptionHandler.process(e);
        }
        LoginHelper.isAutoLogonFailed = false;
        try {
            ConnectionBean bean = null;
            if (reload && lastBean != null) {
                // reload
                bean = lastBean;
            } else {
                if (tacURL != null && isRemote) {
                    // remote
                    bean = ConnectionBean.getDefaultRemoteConnectionBean();
                    bean.setUser(login);
                    bean.setPassword(password);
                    bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, tacURL);
                } else {
                    bean = ConnectionBean.getDefaultConnectionBean();
                }
            }
            Context ctx = CorePlugin.getContext();
            RepositoryContext repositoryContext = new RepositoryContext();
            ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
            repositoryContext.setUser(userInfo);
            repositoryContext.setClearPassword(password);
            repositoryContext.setFields(bean.getDynamicFields());
            repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
            Project project = null;
            for (Project p : repositoryFactory.readProject()) {
                if (p.getLabel().equals(projectName) || p.getTechnicalLabel().equals(projectName)) {
                    project = p;
                    break;
                }
            }
            if (!reload) {
                if (deleteProjectIfExist && project != null) {
                    IWorkspace workspace = ResourcesPlugin.getWorkspace();
                    IProject eclipseProject = workspace.getRoot().getProject(project.getTechnicalLabel());
                    if (eclipseProject.exists()) {
                        eclipseProject.delete(true, new NullProgressMonitor());
                    }
                }
                if (!isRemote && (project == null || deleteProjectIfExist)) {
                    Project projectInfor = //$NON-NLS-1$
                    ProjectHelper.createProject(//$NON-NLS-1$
                    projectName, //$NON-NLS-1$
                    "", language, userInfo);
                    project = repositoryFactory.createProject(projectInfor);
                }
            } else {
                if (project != null && !project.getEmfProject().isLocal() && repositoryFactory.isLocalConnectionProvider()) {
                    List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
                    IRepositoryFactory remoteFactory = null;
                    for (IRepositoryFactory rf : rfList) {
                        if (!rf.isLocalConnectionProvider()) {
                            remoteFactory = rf;
                            break;
                        }
                    }
                    if (remoteFactory != null) {
                        repositoryFactory.setRepositoryFactoryFromProvider(remoteFactory);
                        repositoryFactory.getRepositoryContext().setOffline(true);
                    }
                }
            }
            if (!repositoryFactory.isLocalConnectionProvider()) {
                ProjectManager.getInstance().setMainProjectBranch(project, preferenceManipulator.getLastSVNBranch(new JSONObject(project.getEmfProject().getUrl()).getString("location"), project.getTechnicalLabel()));
            }
            if (project != null && reload && lastBean != null && repositoryFactory.getRepositoryContext().isOffline()) {
                if (PluginChecker.isSVNProviderPluginLoaded()) {
                    ISVNProviderService svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
                    if (svnProviderService.isSVNProject(project)) {
                        String projectUrl = svnProviderService.getProjectUrl(project);
                        String lastBranch = preferenceManipulator.getLastSVNBranch(projectUrl, project.getTechnicalLabel());
                        ProjectManager.getInstance().setMainProjectBranch(project, lastBranch);
                    }
                }
            }
            if (project == null) {
                //$NON-NLS-1$
                throw new LoginException(Messages.getString("RepositoryService.projectNotFound", projectName));
            }
            repositoryContext.setProject(project);
            repositoryFactory.logOnProject(project, new NullProgressMonitor());
        } catch (final PersistenceException e) {
            if (e instanceof OperationCancelException) {
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getLocalizedMessage());
                    }
                });
            } else {
                MessageBoxExceptionHandler.process(e, new Shell());
            }
            repositoryFactory.logOffProject();
            LoginHelper.isAutoLogonFailed = true;
        } catch (LoginException e) {
            MessageBoxExceptionHandler.process(e, new Shell());
            repositoryFactory.logOffProject();
            LoginHelper.isAutoLogonFailed = true;
        } catch (BusinessException e) {
            MessageBoxExceptionHandler.process(e, new Shell());
            repositoryFactory.logOffProject();
            LoginHelper.isAutoLogonFailed = true;
        } catch (CoreException e) {
            MessageBoxExceptionHandler.process(e, new Shell());
            repositoryFactory.logOffProject();
            LoginHelper.isAutoLogonFailed = true;
        } catch (JSONException e) {
            ExceptionHandler.process(e);
            LoginHelper.isAutoLogonFailed = true;
        }
        if (LoginHelper.isAutoLogonFailed) {
            LoginHelper.isRestart = true;
        }
        return true;
    }
    return false;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RepositoryContext(org.talend.core.context.RepositoryContext) PreferenceManipulator(org.talend.core.prefs.PreferenceManipulator) User(org.talend.core.model.properties.User) OperationCancelException(org.talend.commons.exception.OperationCancelException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Shell(org.eclipse.swt.widgets.Shell) BusinessException(org.talend.commons.exception.BusinessException) ConnectionUserPerReader(org.talend.repository.ui.login.connections.ConnectionUserPerReader) IContext(org.talend.core.model.process.IContext) RepositoryContext(org.talend.core.context.RepositoryContext) Context(org.talend.core.context.Context) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ISVNProviderService(org.talend.core.services.ISVNProviderService) JSONException(org.talend.utils.json.JSONException) IBrandingService(org.talend.core.ui.branding.IBrandingService) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) JSONObject(org.talend.utils.json.JSONObject) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) ConnectionBean(org.talend.core.model.general.ConnectionBean)

Example 47 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class CreateSandboxProjectDialog method configureShell.

@Override
protected void configureShell(final Shell newShell) {
    super.configureShell(newShell);
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String fullProductName = brandingService.getFullProductName();
    //$NON-NLS-1$
    newShell.setText(Messages.getString("CreateSandboxProjectDialog.Title", fullProductName));
}
Also used : IBrandingService(org.talend.core.ui.branding.IBrandingService)

Example 48 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class NewImportProjectWizardPage method createControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);
    // Name
    Label nameLab = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    nameLab.setText(Messages.getString("NewProjectWizardPage.name"));
    nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // TechnicalName (for information only)
    Label technicalNameLab = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    technicalNameLab.setText(Messages.getString("NewProjectWizardPage.technicalName"));
    technicalNameText = new Text(container, SWT.BORDER);
    technicalNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    technicalNameText.setEnabled(false);
    // Description
    Label descriptionLab = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    descriptionLab.setText(Messages.getString("NewProjectWizardPage.comment"));
    descriptionLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    descriptionText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 60;
    descriptionText.setLayoutData(data);
    // Language
    Label languageLab = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    languageLab.setText(Messages.getString("NewProjectWizardPage.language"));
    languageLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    Composite radioContainer = new Composite(container, SWT.NONE);
    radioContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL + GridData.VERTICAL_ALIGN_BEGINNING));
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    radioContainer.setLayout(gridLayout);
    languageJavaRadio = new Button(radioContainer, SWT.RADIO);
    languageJavaRadio.setText(ECodeLanguage.JAVA.getName());
    languageJavaRadio.setSelection(true);
    languagePerlRadio = new Button(radioContainer, SWT.RADIO);
    languagePerlRadio.setText(ECodeLanguage.PERL.getName() + " (deprecated)");
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String[] availableLanguages = brandingService.getBrandingConfiguration().getAvailableLanguages();
    if (availableLanguages.length != 2) {
        if (ArrayUtils.contains(availableLanguages, ECodeLanguage.JAVA.getName())) {
            languagePerlRadio.setVisible(false);
            languageJavaRadio.setVisible(false);
            languageJavaRadio.setSelection(true);
            languageLab.setVisible(false);
        }
        if (ArrayUtils.contains(availableLanguages, ECodeLanguage.PERL.getName())) {
            languagePerlRadio.setSelection(true);
            languageJavaRadio.setVisible(false);
            languageJavaRadio.setVisible(false);
            languageLab.setVisible(false);
        }
    }
    // languageCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
    // languageCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // languageCombo.setItems(new String[] { ECodeLanguage.PERL.getName(), ECodeLanguage.JAVA.getName() });
    // languageCombo.select(0);
    setControl(container);
    addListeners();
    setPageComplete(false);
    init();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) IBrandingService(org.talend.core.ui.branding.IBrandingService)

Example 49 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method run.

@Override
public void run() {
    // Refresh Navigator view before export operation, see bug 4595
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    Messages.getString("ExportCommandAction.refreshWorkspace")) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(ExportProjectsAsAction.this.getToolTipText(), IProgressMonitor.UNKNOWN);
            try {
                ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
                e.printStackTrace();
            }
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.setPriority(Job.BUILD);
    job.schedule();
    initializeExternalLibraries();
    Shell activeShell = Display.getCurrent().getActiveShell();
    TalendZipFileExportWizard docWizard = new TalendZipFileExportWizard();
    WizardDialog dialog = new WizardDialog(activeShell, docWizard);
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (brandingService.isPoweredbyTalend()) {
        //$NON-NLS-1$
        docWizard.setWindowTitle(Messages.getString("ExportProjectsAsAction.actionTitle"));
    } else {
        docWizard.setWindowTitle(Messages.getString("ExportProjectsAsAction.actionTitleForOthers", //$NON-NLS-1$
        brandingService.getShortProductName()));
    }
    dialog.create();
    dialog.open();
    clearExternalLibraries();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) TalendZipFileExportWizard(org.talend.repository.ui.wizards.newproject.copyfromeclipse.TalendZipFileExportWizard) IBrandingService(org.talend.core.ui.branding.IBrandingService) Job(org.eclipse.core.runtime.jobs.Job) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

IBrandingService (org.talend.core.ui.branding.IBrandingService)49 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)10 Composite (org.eclipse.swt.widgets.Composite)9 File (java.io.File)8 Button (org.eclipse.swt.widgets.Button)7 Shell (org.eclipse.swt.widgets.Shell)7 Path (org.eclipse.core.runtime.Path)6 URL (java.net.URL)5 Point (org.eclipse.swt.graphics.Point)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Bundle (org.osgi.framework.Bundle)5 Project (org.talend.core.model.general.Project)5 CoreException (org.eclipse.core.runtime.CoreException)4 Text (org.eclipse.swt.widgets.Text)4 BusinessException (org.talend.commons.exception.BusinessException)4 IComponent (org.talend.core.model.components.IComponent)4 ConnectionBean (org.talend.core.model.general.ConnectionBean)4 IOException (java.io.IOException)3 ResourceBundle (java.util.ResourceBundle)3