Search in sources :

Example 16 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.

the class TnsEditorDialog method okPressed.

@Override
protected void okPressed() {
    if (treeViewer.getSelection().isEmpty()) {
        MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        //$NON-NLS-1$
        box.setText("WARNING");
        //$NON-NLS-1$
        box.setMessage("Please select a Item.");
        box.open();
        return;
    } else {
        setDBConnectionUseTnsFile();
    }
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 17 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.

the class WebServiceDialog method warningDialog.

private void warningDialog(String title) {
    MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
    //$NON-NLS-1$
    box.setText("WARNING");
    box.setMessage(title);
    box.open();
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 18 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project ACS by ACS-Community.

the class SourcesView method createViewWidgets.

private void createViewWidgets(final Composite parent) {
    _sash = new SashForm(parent, SWT.HORIZONTAL);
    _sash.setLayout(new FillLayout());
    /* Left pane */
    _sourcesComp = new Composite(_sash, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    _sourcesComp.setLayout(layout);
    _listGroup = new Group(_sourcesComp, SWT.SHADOW_ETCHED_IN);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    _listGroup.setLayoutData(gd);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _listGroup.setLayout(gl);
    _listGroup.setText("Sources List");
    _sourcesList = new List(_listGroup, SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    _sourcesList.setLayoutData(gd);
    _sourcesButtonsComp = new Composite(_sourcesComp, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    _sourcesButtonsComp.setLayout(layout);
    _addSourceButton = new Button(_sourcesButtonsComp, SWT.None);
    _addSourceButton.setText("Add");
    _addSourceButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    _deleteSourceButton = new Button(_sourcesButtonsComp, SWT.None);
    _deleteSourceButton.setText("Delete");
    _deleteSourceButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE));
    /* Please change this in the future when more SOURCES will be available */
    _addSourceButton.setEnabled(false);
    _deleteSourceButton.setEnabled(false);
    _sourcesList.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            String source = _sourcesList.getSelection()[0];
            Control c = _compInitial.getChildren()[0];
            if (c instanceof Label) {
                c.dispose();
                _group.setVisible(true);
                _group.layout();
            }
            fillSource(source);
            _compInitial.layout();
        }
    });
    _addSourceButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            InputDialog dialog = new InputDialog(SourcesView.this.getViewSite().getShell(), "New source", "Enter the source name", null, new IInputValidator() {

                public String isValid(String newText) {
                    if (newText.trim().compareTo("") == 0)
                        return "The name is empty";
                    return null;
                }
            });
            dialog.setBlockOnOpen(true);
            dialog.open();
            int returnCode = dialog.getReturnCode();
            if (returnCode == InputDialog.OK) {
                Source newSource = new Source();
                newSource.setSourceId(dialog.getValue());
                try {
                    _sourceManager.addSource(newSource);
                } catch (IllegalOperationException e) {
                    ErrorDialog error = new ErrorDialog(SourcesView.this.getViewSite().getShell(), "Source already exist", "The source " + dialog.getValue() + " already exists in the current configuration", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                    return;
                }
                refreshContents();
                if (_sourcesList.getItems().length != 0) {
                    int lenght = _sourcesList.getItems().length;
                    lenght -= 1;
                    _sourcesList.select(lenght);
                    _descriptionText.setText(_sourcesList.getItem(lenght).toString());
                }
            }
        }
    });
    _deleteSourceButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            boolean choice = MessageDialog.openQuestion(SourcesView.this.getViewSite().getShell(), "Confirmation", "Are you sure you want to delete this Source");
            if (choice == true) {
                String[] tmp = _sourcesList.getSelection();
                if (tmp.length == 0) {
                    MessageBox box = new MessageBox(getViewSite().getShell(), SWT.OK | SWT.ICON_ERROR | SWT.APPLICATION_MODAL);
                    box.setText("Empty selection");
                    box.setMessage("There are no sources selected to be deleted");
                    box.open();
                    return;
                }
                String source = tmp[0];
                try {
                    _sourceManager.deleteSource(_sourceManager.getSource(source));
                } catch (IllegalOperationException e) {
                    ErrorDialog error = new ErrorDialog(SourcesView.this.getViewSite().getShell(), "Cannot delete source", "The source cannot be deleted", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                }
                refreshContents();
                if (_sourcesList.getItems().length != 0) {
                    int lenght = _sourcesList.getItems().length;
                    lenght -= 1;
                    _sourcesList.select(lenght);
                    _sourceNameText.setText(_sourcesList.getItem(lenght).toString());
                }
            }
        }
    });
    /* Right pane */
    _compInitial = new Composite(_sash, SWT.NONE);
    _compInitial.setLayout(new GridLayout());
    new Label(_compInitial, SWT.NONE).setText("Select a source");
    layout = new GridLayout();
    layout.numColumns = 2;
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    _group = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
    _group.setText("Source information");
    _group.setLayout(layout);
    _group.setLayoutData(gd);
    _sourceNameLabel = new Label(_group, SWT.NONE);
    _sourceNameLabel.setText("Source name");
    _sourceNameText = new Text(_group, SWT.BORDER);
    _descriptionLabel = new Label(_group, SWT.NONE);
    _descriptionLabel.setText("Description");
    _descriptionText = new Text(_group, SWT.BORDER);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    _sourceNameText.setLayoutData(gd);
    _descriptionText.setLayoutData(gd);
    _group.setVisible(false);
    _sash.setWeights(new int[] { 3, 5 });
    /* TODO: This is temporal, since there is currently only
		 * one source defined in the AS, and it's hardcoded */
    //setEnabled(false);
    _descriptionText.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event e) {
            updateSource();
        }
    });
    _errorMessageLabel = new Label(_group, SWT.NONE);
    _errorMessageLabel.setText("");
    _errorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    _errorMessageLabel.setLayoutData(gd);
    /* Please change this in the future when more SOURCES will be available */
    _sourceNameText.setEnabled(false);
    _descriptionText.setEnabled(false);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) Source(cern.laser.business.data.Source) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(org.eclipse.swt.widgets.List) SelectionListener(org.eclipse.swt.events.SelectionListener) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 19 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project cubrid-manager by CUBRID.

the class QueryEditorPart method checkActive.

/**
	 * Check whether the activated
	 *
	 * @return boolean
	 */
private boolean checkActive() {
    if (!isAutocommit && isActive) {
        MessageBox mb = new MessageBox(getSite().getShell(), SWT.OK | SWT.ICON_WARNING);
        mb.setText(Messages.info);
        mb.setMessage(Messages.transActive);
        mb.open();
        autoCommitItem.setSelection(false);
        return true;
    }
    return false;
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 20 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLComposite method initialize.

/**
	 * Create the SQL history composite
	 */
public void initialize() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.numColumns = 2;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
    delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
    delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
    delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
    delHistory.setText(Messages.btn_qedit_sql_history_delete);
    delHistory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
                return;
            }
            MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
            messageBox.setMessage(Messages.sql_history_delete_message);
            // remove data ,both view and model
            int buttonID = messageBox.open();
            if (buttonID == SWT.YES) {
                deleteHistory();
            }
        }
    });
    // help messages
    Label helpMsg = new Label(toolBarComposite, SWT.None);
    helpMsg.setText(Messages.recentlyUsedSQLHelp);
    helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
    // create the query result tab folder
    recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
    recentlyUsedSQLTabFolder.setSimple(false);
    recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
    recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
    recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
    recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    //TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
    //tabContextMenuManager.createContextMenu();
    recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
    recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
    recentlyUsedSQLTabItem.setControl(this);
    recentlyUsedSQLTabItem.setShowClose(false);
    final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    createHistoryTable(bottomSash);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
    bottomSash.setWeights(new int[] { 80, 20 });
    logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
    logMessageArea.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            bottomSash.setWeights(new int[] { 80, 20 });
        }

        public void focusGained(FocusEvent e) {
            bottomSash.setWeights(new int[] { 20, 80 });
        }
    });
    CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_sql_history);
    tabItem.setControl(bottomSash);
    tabItem.setShowClose(false);
    recentlyUsedSQLTabFolder.setSelection(tabItem);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FocusEvent(org.eclipse.swt.events.FocusEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)37 ArrayList (java.util.ArrayList)8 Shell (org.eclipse.swt.widgets.Shell)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 IOException (java.io.IOException)4 List (java.util.List)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 File (java.io.File)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 IConnection (org.talend.core.model.process.IConnection)3 Message (ca.uhn.hl7v2.model.Message)2 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2