Search in sources :

Example 1 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method finish.

// protected String getDestinationValueSU() {
//        return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    // TODO
    if (treeViewer != null) {
        treeViewer.removeCheckStateListener(checkStateListener);
    }
    saveWidgetValues();
    if (manager == null) {
        manager = createJobScriptsManager();
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    if (ensureLog4jSettingIsValid()) {
        MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    JobExportType jobExportType = getCurrentExportType1();
    if (JobExportType.POJO.equals(jobExportType)) {
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                buildJobWithMaven(JobExportType.POJO, monitor);
            }
        };
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    } else {
        List<ContextParameterType> contextEditableResultValuesList = null;
        if (manager != null) {
            contextEditableResultValuesList = manager.getContextEditableResultValuesList();
        }
        if (nodes.length == 1) {
            RepositoryNode node = nodes[0];
            if (node.getType() == ENodeType.SYSTEM_FOLDER) {
                manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
            } else {
                manager.setTopFolderName(getDefaultFileNameWithType());
            }
        } else {
            manager.setTopFolderName(getDefaultFileNameWithType());
        }
        // for feature:11976, recover back the old default manager value with ContextParameters
        if (contextEditableResultValuesList == null) {
            manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
        } else {
            manager.setContextEditableResultValuesList(contextEditableResultValuesList);
        }
        manager.setMultiNodes(isMultiNodes());
        // achen modify to fix bug 0006222
        IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    }
    // see bug 7181
    if (zipOption != null && zipOption.equals("true")) {
        // unzip
        try {
            String zipFile;
            if (manager != null) {
                zipFile = manager.getDestinationPath();
            } else {
                zipFile = getDestinationValue();
                int separatorIndex = zipFile.lastIndexOf(File.separator);
                if (separatorIndex == -1) {
                    //$NON-NLS-1$
                    String userDir = System.getProperty("user.dir");
                    zipFile = userDir + File.separator + zipFile;
                }
            }
            // Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
            File file = new File(zipFile);
            if (file.exists()) {
                ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
            }
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e, getShell());
            return false;
        }
    }
    if (treeViewer != null) {
        treeViewer.dispose();
    }
    // end
    return true;
}
Also used : JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobExportType(org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 2 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class AbstractElementPropertySectionController method openSQLBuilder.

/**
     * DOC qzhang Comment method "openSQLBuilder".
     *
     * @param repositoryType
     * @param propertyName
     * @param query
     */
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
    if (repositoryType.equals(EmfComponent.BUILTIN)) {
        connParameters.setQuery(query);
        if (connParameters.isShowConfigParamDialog()) {
            if (!isUseExistingConnection()) {
                initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
            } else {
                initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
            }
        }
        // add for bug TDI-20335
        if (part == null) {
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
            sqlBuilder.open();
        } else {
            openSqlBuilderBuildIn(connParameters, propertyName);
        }
    } else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
        //$NON-NLS-1$
        String repositoryName2 = "";
        String repositoryId = null;
        IElementParameter memoParam = elem.getElementParameter(propertyName);
        IElementParameter repositoryParam = null;
        for (IElementParameter param : elem.getElementParameters()) {
            if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
                repositoryParam = param;
                break;
            }
        }
        // in case no database property found, take the first property (to keep compatibility with old code)
        if (repositoryParam == null) {
            for (IElementParameter param : elem.getElementParameters()) {
                if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                    repositoryParam = param;
                    break;
                }
            }
        }
        if (repositoryParam != null) {
            IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            String value = (String) itemFromRepository.getValue();
            repositoryId = value;
            // for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
            // if (key.equals(value)) {
            // repositoryName2 =
            // this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
            // }
            // }
            /* get connection item dynamictly,not from cache ,see 16969 */
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(value);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        repositoryName2 = property.getLabel();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
        // When no repository avaiable on "Repository" mode, open a MessageDialog.
        if (repositoryName2 == null || repositoryName2.length() == 0) {
            MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "NoRepositoryDialog.Text"));
            return null;
        }
        // Part maybe not exist
        //$NON-NLS-1$
        String processName = "";
        //$NON-NLS-1$
        String key = "";
        if (elem instanceof Node) {
            processName = ((Node) elem).getProcess().getName();
            key = processName + ((Node) elem).getUniqueName();
        } else if (elem instanceof IProcess) {
            processName = ((IProcess) elem).getName();
            key = processName;
        }
        key += repositoryName2;
        final Dialog builderDialog = sqlbuilers.get(key);
        if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
            builderDialog.getShell().setActive();
        } else {
            connParameters.setRepositoryName(repositoryName2);
            if (repositoryId != null) {
                connParameters.setRepositoryId(repositoryId);
            }
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            String nodeLabel = null;
            if (elem instanceof Node) {
                nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
            }
            TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            connParameters.setQuery(query);
            // first open Sql Builder,set true
            connParameters.setFirstOpenSqlBuilder(true);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
            sqlbuilers.put(key, sqlBuilder);
            if (Window.OK == sqlBuilder.open()) {
                if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
                    String sql = connParameters.getQuery();
                    // modified by hyWang
                    if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
                        sql = QueryUtil.checkAndAddQuotes(sql);
                    }
                    return sql;
                }
            }
        }
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProcess(org.talend.core.model.process.IProcess) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class JavaProcessorUtilities method handleMissingJarsForProcess.

/**
     * 
     * Added by Marvin Wang on Nov 7, 2012.
     * 
     * @param missingJarsForRoutines
     * @param missingJarsForProcess
     * @param missingJars
     * @throws BusinessException
     */
private static void handleMissingJarsForProcess(Set<String> missingJarsForRoutines, final Set<String> missingJarsForProcess, String missingJars) throws ProcessorException {
    //$NON-NLS-1$
    final StringBuffer sb = new StringBuffer("");
    if (missingJarsForProcess.size() > 0) {
        //$NON-NLS-1$
        sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.forProcess"));
        for (String missingJar : missingJarsForProcess) {
            sb.append(missingJar);
            //$NON-NLS-1$
            sb.append(", ");
        }
        if (missingJarsForRoutines.size() > 0) {
            // subForMsg(sb.toString());
            //$NON-NLS-1$
            sb.append("\r\n\r\n\r\n");
            //$NON-NLS-1$
            sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.note"));
            //$NON-NLS-1$
            sb.append("\r\n");
            //$NON-NLS-1$
            sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.onlyforroutine"));
            //$NON-NLS-1$
            sb.append("\r\n");
            for (String missingJar : missingJarsForRoutines) {
                sb.append(missingJar);
                //$NON-NLS-1$
                sb.append(", ");
            }
            subForMsg(sb.toString());
        } else {
            subForMsg(sb.toString());
        }
        if (!CommonsPlugin.isHeadless()) {
            Display display = DisplayUtils.getDisplay();
            if (display != null) {
                display.syncExec(new Runnable() {

                    @Override
                    public void run() {
                        // fix for TDI-24906
                        MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), Messages.getString("JavaProcessorUtilities.msg.missingjar.warningtitle"), null, subForMsg(sb.toString()), 4, new String[] { IDialogConstants.OK_LABEL }, 0) {

                            /*
                                 * (non-Javadoc)
                                 * 
                                 * @see org.eclipse.jface.window.Window#setShellStyle(int)
                                 */
                            @Override
                            protected void setShellStyle(int newShellStyle) {
                                super.setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
                            }
                        };
                        dialog.open();
                    }
                });
            }
        } else {
            throw new ProcessorException(missingJars);
        }
    } else {
        if (missingJarsForRoutines.size() > 0) {
            //$NON-NLS-1$
            sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.onlyforroutine"));
            for (String missingJar : missingJarsForRoutines) {
                sb.append(missingJar);
                //$NON-NLS-1$
                sb.append(", ");
            }
            CommonExceptionHandler.warn(subForMsg(sb.toString()));
        }
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Display(org.eclipse.swt.widgets.Display)

Example 4 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class CreateNodeContainerCommand method execute.

@Override
public void execute() {
    if (this.location != null) {
        this.nodeContainer.getNode().setLocation(this.location);
    }
    updatePaletteRecentlyUsedList();
    AbstractProcessProvider provider = AbstractProcessProvider.findProcessProviderFromPID(nodeContainer.getNode().getComponent().getPluginExtension());
    IElementParameter ep = nodeContainer.getNode().getElementParameter(EParameterName.UNIQUE_NAME.getName());
    process.addUniqueNodeName(ep.getValue().toString());
    if (provider == null || (provider != null && provider.containNodeInMemoryNotProcess())) {
        this.process.addNodeContainer(this.nodeContainer);
        process.checkStartNodes();
        nodeContainer.getNode().checkAndRefreshNode();
        refreshRelatedNodes();
        // }
        if (nodeContainer.getNode().getComponent().getComponentType() == EComponentType.JOBLET) {
            IUpdateItemType jobletContextType = UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
            if (jobletContextType != null) {
                process.getUpdateManager().update(jobletContextType);
            }
        }
    } else {
        String name = provider.getComponentProcess().getName() + " " + provider.getComponentProcess().getVersion();
        MessageDialog warningMessageDialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Can't create node", null, "Joblet process " + name + " is not saved. Please save it first", MessageDialog.OK, new String[] { "OK" }, 0);
        warningMessageDialog.open();
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider)

Example 5 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project cubrid-manager by CUBRID.

the class QueryEditorDNDController method openConfirmDialog.

/**
	 *
	 * Open confirm dialog
	 *
	 * @return the button id
	 */
private int openConfirmDialog() {
    String title = com.cubrid.common.ui.common.Messages.titleConfirm;
    String[] buttons = new String[] { Messages.btnYes, Messages.btnNo, Messages.cancel };
    MessageDialog dialog = new MessageDialog(editor.getSite().getShell(), title, null, Messages.changeDbConfirm, MessageDialog.QUESTION, buttons, 0) {

        protected void buttonPressed(int buttonId) {
            switch(buttonId) {
                case 0:
                    setReturnCode(0);
                    close();
                    break;
                case 1:
                    setReturnCode(1);
                    close();
                    break;
                case 2:
                    setReturnCode(2);
                    close();
                    break;
                default:
                    break;
            }
        }
    };
    return dialog.open();
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)127 Shell (org.eclipse.swt.widgets.Shell)25 CoreException (org.eclipse.core.runtime.CoreException)15 IPath (org.eclipse.core.runtime.IPath)13 ArrayList (java.util.ArrayList)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 Composite (org.eclipse.swt.widgets.Composite)10 File (java.io.File)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Point (org.eclipse.swt.graphics.Point)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 IStatus (org.eclipse.core.runtime.IStatus)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 Path (org.eclipse.core.runtime.Path)4