Search in sources :

Example 31 with MessageDialog

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

the class ComponentProjectPreferencePage method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
     */
public void propertyChange(PropertyChangeEvent event) {
    super.propertyChange(event);
    MessageDialog warningMessageDialog = new MessageDialog(getFieldEditorParent().getShell(), //$NON-NLS-1$
    Messages.getString("ComponentProjectPreferencePage.Warning"), //$NON-NLS-1$
    null, //$NON-NLS-1$
    Messages.getString("ComponentProjectPreferencePage.WarningMSG"), //$NON-NLS-1$
    MessageDialog.WARNING, new String[] { Messages.getString("ComponentProjectPreferencePage.ButtonLabel0") }, //$NON-NLS-1$
    0);
    warningMessageDialog.open();
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 32 with MessageDialog

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

the class ImportDemoProjectItemsPage method performFinish.

public boolean performFinish() {
    List<DemoProjectBean> checkedElements = getCheckedElements();
    final List<ResourcesManager> finalCheckManagers = getResourceManagers(checkedElements);
    String warnMessage = populateExistItemRecords(finalCheckManagers);
    if (!warnMessage.equals("")) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("ImportDemoProjectPage.overwrite"), null, warnMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    ProgressDialog progressDialog = new ProgressDialog(getShell()) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitorWrap = new EventLoopProgressMonitor(monitor);
            try {
                for (ResourcesManager resManager : finalCheckManagers) {
                    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, monitorWrap);
                    // clearOverWriteErrorMessages(projectRecords, overwrite);
                    importManager.importItemRecords(monitorWrap, resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            monitorWrap.done();
            if (monitor.isCanceled()) {
                MessageDialog.openInformation(getShell(), Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProjectCancel"), Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedIncompletely"));
                return;
            } else {
                MessageDialog.openInformation(getShell(), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProject"), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedSuccessfully"));
            }
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
    } catch (InterruptedException e) {
    // Nothing to do
    }
    return true;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 33 with MessageDialog

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

the class PaletteSettingPage method setComponentVisible.

/**
     * set the selected component as visible or not
     * 
     * @param selection
     * @param b
     */
protected void setComponentVisible(ISelection selection, boolean visible) {
    IStructuredSelection sel = (IStructuredSelection) selection;
    Set<IPaletteItem> items = new HashSet<IPaletteItem>();
    for (Iterator iterator = sel.iterator(); iterator.hasNext(); ) {
        IPaletteItem entry = (IPaletteItem) iterator.next();
        retrieveAllEntry(items, entry);
    }
    Set<IComponent> usedComponents = getComponentsUsedInProject(ProjectManager.getInstance().getCurrentProject());
    boolean isUsed = false;
    for (IPaletteItem item : items) {
        if (!visible && item instanceof ComponentPaletteItem) {
            if (usedComponents.contains(((ComponentPaletteItem) item).getComponent())) {
                isUsed = true;
                continue;
            }
        }
        setComponentVisible(item, visible);
    }
    if (isUsed) {
        MessageDialog messageDialog = new MessageDialog(getShell(), //$NON-NLS-1$
        Messages.getString("PaletteSettingPage.paletteSettings"), //$NON-NLS-1$
        null, //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("PaletteSettingPage.selection1") + "\n" + //$NON-NLS-1$
        Messages.getString("PaletteSettingPage.selection2"), //$NON-NLS-1$
        MessageDialog.INFORMATION, new String[] { "OK" }, //$NON-NLS-1$
        0);
        messageDialog.open();
    }
    refreshViewer();
}
Also used : ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) IComponent(org.talend.core.model.components.IComponent) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) HashSet(java.util.HashSet)

Example 34 with MessageDialog

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

the class EditQueriesAction method doRun.

@Override
protected void doRun() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    if (repositoryNode == null && selection != null) {
        repositoryNode = (RepositoryNode) selection.getFirstElement();
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    IRepositoryViewObject nodeObject = repositoryNode.getObject();
    boolean locked = false;
    if (!factory.getRepositoryContext().isEditableAsReadOnly()) {
        if (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
            locked = true;
        }
    }
    // Avoid to delete node which is locked.
    if (locked || RepositoryManager.isOpenedItemInEditor(nodeObject)) {
        final String title = "Impossible to edit queries";
        String nodeName = nodeObject.getRepositoryObjectType().getLabel();
        final String message = "item is already locked by another user.";
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                MessageDialog dialog = new MessageDialog(new Shell(), title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                dialog.open();
            }
        });
        return;
    }
    DatabaseConnectionItem dbConnectionItem = null;
    boolean readOnly = false;
    ConnectionParameters connParameters = new ConnectionParameters();
    if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(repositoryNode.getObject().getLabel());
        connParameters.setRepositoryId(repositoryNode.getObject().getId());
        //$NON-NLS-1$
        connParameters.setQuery("");
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_QUERY) {
        QueryRepositoryObject queryRepositoryObject = (QueryRepositoryObject) repositoryNode.getObject();
        readOnly = SubItemHelper.isDeleted(queryRepositoryObject.getAbstractMetadataObject());
        dbConnectionItem = (DatabaseConnectionItem) queryRepositoryObject.getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setQueryObject(queryRepositoryObject.getQuery());
        connParameters.setQuery(queryRepositoryObject.getQuery().getValue());
        // first open Sql Builder,set true
        connParameters.setFirstOpenSqlBuilder(true);
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setMetadataTable((MetadataTableRepositoryObject) repositoryNode.getObject());
        //$NON-NLS-1$
        connParameters.setQuery("");
    }
    IRepositoryView viewPart = getViewPart();
    Display display = null;
    if (viewPart != null) {
        display = viewPart.getViewer().getControl().getDisplay();
    } else {
        display = Display.getCurrent();
        if (display == null) {
            display = Display.getDefault();
        }
    }
    Shell parentShell = new Shell(display);
    TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
    Connection connection = dbConnectionItem.getConnection();
    String selectedContext = null;
    if (connection.isContextMode()) {
        ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
        if (contextItem != null && connection.isContextMode()) {
            ContextSetsSelectionDialog setsDialog = new ContextSetsSelectionDialog(null, contextItem, false);
            setsDialog.open();
            selectedContext = setsDialog.getSelectedContext();
        }
    }
    SQLBuilderDialog dial = new SQLBuilderDialog(parentShell, repositoryNode, selectedContext);
    dial.setReadOnly(readOnly);
    if (connection instanceof DatabaseConnection) {
        IMetadataConnection imetadataConnection = ConvertionHelper.convert(connection, true);
        connParameters.setSchema(imetadataConnection.getSchema() == null ? "" : imetadataConnection.getSchema());
        UIUtils.checkConnection(parentShell, imetadataConnection);
    }
    connParameters.setNodeReadOnly(readOnly);
    connParameters.setFromRepository(true);
    dial.setConnParameters(connParameters);
    dial.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.refreshView();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ConnectionParameters(org.talend.core.sqlbuilder.util.ConnectionParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Shell(org.eclipse.swt.widgets.Shell) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) ContextSetsSelectionDialog(org.talend.metadata.managment.ui.wizard.metadata.ContextSetsSelectionDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SQLBuilderDialog(org.talend.sqlbuilder.ui.SQLBuilderDialog) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) Display(org.eclipse.swt.widgets.Display)

Example 35 with MessageDialog

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

the class JobletContainer method setPropertyValue.

@Override
public void setPropertyValue(String id, Object value) {
    if (id.equals(EParameterName.COLLAPSED.getName())) {
        // outputs.clear();
        for (IConnection conn : node.getOutgoingConnections()) {
            outputs.add(conn);
        }
        // inputs.clear();
        for (IConnection conn : node.getIncomingConnections()) {
            inputs.add(conn);
        }
        if (needchangeLock) {
            if (!((Boolean) value)) {
                if (!new JobletUtil().isRed(this)) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    if (service != null) {
                        service.lockJoblet(this.getNode());
                    }
                }
            } else {
                IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                if (service != null) {
                    service.unlockJoblet(node, true);
                }
            }
        }
        needchangeLock = true;
        refreshJobletNodes(false, (Boolean) value);
        if (!canCollapse()) {
            Shell shell = Display.getCurrent().getActiveShell();
            MessageDialog dlg = new MessageDialog(new Shell(shell), "ERROR", null, "Please attach connection correctly!", MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
            dlg.open();
            return;
        }
        super.setPropertyValue(id, value);
        transferLocation(false);
        updateJobletContainer();
        if (node.isJoblet()) {
            refreshJobletConnections();
        }
        fireStructureChange(EParameterName.COLLAPSED.getName(), this);
    } else if (id.equals(UPDATE_JOBLET_DISPLAY)) {
        updateJobletDisplay();
    } else {
        super.setPropertyValue(id, value);
    }
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) Shell(org.eclipse.swt.widgets.Shell) IConnection(org.talend.core.model.process.IConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)44 Shell (org.eclipse.swt.widgets.Shell)13 CoreException (org.eclipse.core.runtime.CoreException)7 File (java.io.File)5 IPath (org.eclipse.core.runtime.IPath)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IFile (org.eclipse.core.resources.IFile)4 Point (org.eclipse.swt.graphics.Point)4 Composite (org.eclipse.swt.widgets.Composite)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Path (org.eclipse.core.runtime.Path)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 CombinedQueryEditorComposite (com.cubrid.common.ui.query.control.CombinedQueryEditorComposite)2 URI (java.net.URI)2 LinkedList (java.util.LinkedList)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 IProject (org.eclipse.core.resources.IProject)2