Search in sources :

Example 1 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project tdi-studio-se by Talend.

the class OpenExistVersionProcessAction method doRun.

@Override
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;
    IPath path = RepositoryNodeUtilities.getPath(node);
    String originalName = node.getObject().getLabel();
    RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
    repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
    OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj);
    WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.setPageSize(300, 250);
    //$NON-NLS-1$
    dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog"));
    if (dialog.open() == Dialog.OK) {
        refresh(node);
        // refresh the corresponding editor's name
        IEditorPart part = getCorrespondingEditor(node);
        if (part != null && part instanceof IUIRefresher) {
            ((IUIRefresher) part).refreshName();
        } else {
            processRoutineRenameOperation(originalName, node, path);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) RepositoryObject(org.talend.core.model.repository.RepositoryObject) OpenExistVersionProcessWizard(org.talend.designer.core.ui.wizards.OpenExistVersionProcessWizard) ISelection(org.eclipse.jface.viewers.ISelection) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IUIRefresher(org.talend.core.services.IUIRefresher)

Example 2 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project tdi-studio-se by Talend.

the class SaveAsSQLPatternAction method run.

@Override
public void run() {
    SaveAsSQLPatternWizard processWizard = new SaveAsSQLPatternWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            SQLPatternItem sqlpatternItem = processWizard.getSQLPatternItem();
            // get the IFile
            ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
            // only for talend java version
            ISQLPatternSynchronizer sqlPatternSynchronizer = service.getSQLPatternSynchronizer();
            IFile file = sqlPatternSynchronizer.getSQLPatternFile(sqlpatternItem);
            if (file == null) {
                return;
            }
            // Set readonly to false since created job will always be editable.
            RepositoryEditorInput repositoryEditorInput = new RepositoryEditorInput(file, sqlpatternItem);
            IWorkbenchPage page = getActivePage();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(repositoryEditorInput.getItem().getProperty().getId(), false);
            repositoryEditorInput.setRepositoryNode(repositoryNode);
            // here really do the normal save as function
            IDocumentProvider provider = ((StandAloneTalendJavaEditor) this.editorPart).getDocumentProvider();
            provider.aboutToChange(repositoryEditorInput);
            provider.saveDocument(null, repositoryEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
            provider.changed(repositoryEditorInput);
            // copy back from the *.java file to *.item file.
            // @see:StandAloneTalendJavaEditor.doSave(IProgressMonitor monitor)
            ByteArray byteArray = sqlpatternItem.getContent();
            byteArray.setInnerContentFromFile(repositoryEditorInput.getFile());
            IProxyRepositoryFactory repFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
            repFactory.save(sqlpatternItem);
            // close the old editor
            page.closeEditor(this.editorPart, false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            page.openEditor(repositoryEditorInput, StandAloneTalendJavaEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "SQLTemplate could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : SaveAsSQLPatternWizard(org.talend.designer.core.ui.wizards.SaveAsSQLPatternWizard) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISQLPatternSynchronizer(org.talend.designer.codegen.ISQLPatternSynchronizer) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) StandAloneTalendJavaEditor(org.talend.designer.core.ui.editor.StandAloneTalendJavaEditor) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ByteArray(org.talend.core.model.properties.ByteArray) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project tdi-studio-se by Talend.

the class SaveAsRoutineAction method run.

@Override
public void run() {
    SaveAsRoutineWizard processWizard = new SaveAsRoutineWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            RoutineItem routineItem = processWizard.getRoutineItem();
            // get the IFile
            ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
            ITalendSynchronizer routineSynchronizer = null;
            switch(LanguageManager.getCurrentLanguage()) {
                case JAVA:
                    routineSynchronizer = service.createJavaRoutineSynchronizer();
                    break;
                case PERL:
                    routineSynchronizer = service.createPerlRoutineSynchronizer();
                    break;
                default:
            }
            IFile file = routineSynchronizer.getFile(routineItem);
            if (file == null) {
                return;
            }
            // Set readonly to false since created job will always be editable.
            RoutineEditorInput routineEditorInput = new RoutineEditorInput(file, routineItem);
            IWorkbenchPage page = getActivePage();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(routineEditorInput.getItem().getProperty().getId(), false);
            routineEditorInput.setRepositoryNode(repositoryNode);
            // here really do the normal save as function
            IDocumentProvider provider = ((AbstractTextEditor) this.editorPart).getDocumentProvider();
            provider.aboutToChange(routineEditorInput);
            provider.saveDocument(null, routineEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
            provider.changed(routineEditorInput);
            // copy back from the *.java file to *.item file.
            // @see:StandAloneTalendJavaEditor.doSave(IProgressMonitor monitor)
            ByteArray byteArray = routineItem.getContent();
            byteArray.setInnerContentFromFile(routineEditorInput.getFile());
            IProxyRepositoryFactory repFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
            repFactory.save(routineItem);
            // close the old editor
            page.closeEditor(this.editorPart, false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            switch(LanguageManager.getCurrentLanguage()) {
                case JAVA:
                    page.openEditor(routineEditorInput, StandAloneTalendJavaEditor.ID, true);
                    break;
                default:
            }
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Routine could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RoutineItem(org.talend.core.model.properties.RoutineItem) RoutineEditorInput(org.talend.repository.ui.actions.routines.RoutineEditorInput) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) AbstractTextEditor(org.eclipse.ui.texteditor.AbstractTextEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ByteArray(org.talend.core.model.properties.ByteArray) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SaveAsRoutineWizard(org.talend.designer.core.ui.wizards.SaveAsRoutineWizard) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 4 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project tdi-studio-se by Talend.

the class UpdateDocumentationAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    DocumentationUpdateWizard docWizard = new DocumentationUpdateWizard(PlatformUI.getWorkbench(), node.getObject(), getPath());
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), docWizard);
    dlg.open();
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode) WizardDialog(org.eclipse.jface.wizard.WizardDialog) DocumentationUpdateWizard(org.talend.metadata.managment.ui.wizard.documentation.DocumentationUpdateWizard)

Example 5 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project tdi-studio-se by Talend.

the class CreateFTPConnectionAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.AContextualAction#doRun()
     */
@Override
protected void doRun() {
    RepositoryNode dbConnectionNode = getCurrentRepositoryNode();
    if (isToolbar()) {
        if (dbConnectionNode != null && dbConnectionNode.getContentType() != ERepositoryObjectType.METADATA_FILE_FTP) {
            dbConnectionNode = null;
        }
        if (dbConnectionNode == null) {
            dbConnectionNode = getRepositoryNodeForDefault(ERepositoryObjectType.METADATA_FILE_FTP);
        }
    }
    RepositoryNode metadataNode = dbConnectionNode.getParent();
    if (metadataNode != null) {
        // Force focus to the repositoryView and open Metadata and DbConnection nodes
        IRepositoryView viewPart = getViewPart();
        if (viewPart != null) {
            viewPart.setFocus();
            viewPart.expand(metadataNode, true);
            viewPart.expand(dbConnectionNode, true);
        }
    }
    FTPConnection connection = null;
    IPath pathToSave = null;
    // Define the RepositoryNode, by default Metadata/DbConnection
    RepositoryNode node = dbConnectionNode;
    ISelection selection = null;
    // When the userSelection is an element of metadataNode, use it !
    if (!isToolbar()) {
        Object userSelection = ((IStructuredSelection) getSelection()).getFirstElement();
        if (userSelection instanceof RepositoryNode) {
            switch(((RepositoryNode) userSelection).getType()) {
                case REPOSITORY_ELEMENT:
                case SIMPLE_FOLDER:
                case SYSTEM_FOLDER:
                    node = (RepositoryNode) userSelection;
                    break;
            }
        }
        selection = getSelection();
    }
    boolean creation = false;
    // Define the repositoryObject DatabaseConnection and his pathToSave
    switch(node.getType()) {
        case REPOSITORY_ELEMENT:
            // pathToSave = null;
            connection = (FTPConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
            creation = false;
            break;
        case SIMPLE_FOLDER:
            pathToSave = RepositoryNodeUtilities.getPath(node);
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
        case SYSTEM_FOLDER:
            //$NON-NLS-1$
            pathToSave = new Path("");
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
    }
    // Init the content of the Wizard
    init(node);
    FTPWizard ftpWizard;
    if (isToolbar()) {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, node, getExistingNames());
        ftpWizard.setToolBar(true);
    } else {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, selection, getExistingNames());
    }
    // Open the Wizard
    WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), ftpWizard);
    wizardDialog.setPageSize(700, 550);
    wizardDialog.create();
    wizardDialog.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.expand(dbConnectionNode, true);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) FTPConnectionItem(org.talend.core.model.properties.FTPConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) FTPWizard(org.talend.repository.ftp.ui.wizards.FTPWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

WizardDialog (org.eclipse.jface.wizard.WizardDialog)404 Shell (org.eclipse.swt.widgets.Shell)80 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)48 CoreException (org.eclipse.core.runtime.CoreException)34 ISelection (org.eclipse.jface.viewers.ISelection)34 Wizard (org.eclipse.jface.wizard.Wizard)34 IWorkbench (org.eclipse.ui.IWorkbench)31 Composite (org.eclipse.swt.widgets.Composite)24 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)24 IOException (java.io.IOException)23 ArrayList (java.util.ArrayList)23 IStatus (org.eclipse.core.runtime.IStatus)23 Display (org.eclipse.swt.widgets.Display)23 IProject (org.eclipse.core.resources.IProject)22 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)21 Button (org.eclipse.swt.widgets.Button)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)20 Status (org.eclipse.core.runtime.Status)20 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)19 IRepositoryNode (org.talend.repository.model.IRepositoryNode)19