Example usage for org.eclipse.jface.dialogs MessageDialog WARNING

List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog WARNING.

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.

Click Source Link

Document

Constant for the warning image, or a simple dialog with the warning image and a single OK button (value 4).

Usage

From source file:org.bbaw.pdr.ae.view.editorlite.view.PersonAspectEditor.java

License:Open Source License

public boolean deleteAspect(Aspect deleteAspect) {
    if (deleteAspect != null) {
        if (new UserRichtsChecker().mayDelete(deleteAspect)) {

            String message = NLMessages.getString("DeleteAspectHandler_warning1");
            message += NLMessages.getString("DeleteAspectHandler_warning2");
            message += NLMessages.getString("DeleteAspectHandler_warning3") + deleteAspect.getNotification();
            message += NLMessages.getString("DeleteAspectHandler_lb_id") + deleteAspect.getPdrId().toString();
            MessageDialog messageDialog = new MessageDialog(PersonAspectEditor.this.getParentShell(),
                    NLMessages.getString("DeleteAspectHandler_title"), null, message, MessageDialog.WARNING,
                    new String[] { NLMessages.getString("Handler_delete"),
                            NLMessages.getString("Handler_cancel") },
                    1);/*from  ww w. ja  v a 2s  .c  om*/
            if (messageDialog.open() == 0) {
                IDBManager dbm = _facade.getDBManager();
                try {
                    dbm.delete(deleteAspect.getPdrId(), "aspect");
                } catch (Exception ee) {
                    // TODO Auto-generated catch block
                    ee.printStackTrace();
                } //$NON-NLS-1$ //$NON-NLS-2$
                _facade.deleteAspect(deleteAspect);
                _currentAspects.remove(deleteAspect);
                _currentPerson.getAspectIds().remove(deleteAspect.getPdrId());
                _invalidAspects.remove(deleteAspect);
                _selectedAspectEditor.setSelected(false, true);
                _selectedAspectEditor = null;
                validate();

                return true;

            }
        } else {

            MessageDialog.openInformation(PersonAspectEditor.this.getParentShell(),
                    NLMessages.getString("Commands_no_rights_delete"),
                    NLMessages.getString("Command_no_rights_delete_aspect_message")); //$NON-NLS-1$
        }
    }

    return false;
}

From source file:org.bbaw.pdr.ae.view.main.commands.DeleteAspectHandler.java

License:Open Source License

/**
 * execute method./*  ww  w.j  a  v a2s  .  c  o m*/
 * @param event to be executed.
 * @throws ExecutionException ee.
 * @return null.
 */

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {
    if (_facade.getCurrentAspect() != null) {
        if (new UserRichtsChecker().mayDelete(_facade.getCurrentAspect())) {

            String message = NLMessages.getString("DeleteAspectHandler_warning1");
            message += NLMessages.getString("DeleteAspectHandler_warning2");
            message += NLMessages.getString("DeleteAspectHandler_warning3")
                    + _facade.getCurrentAspect().getNotification();
            message += NLMessages.getString("DeleteAspectHandler_lb_id")
                    + _facade.getCurrentAspect().getPdrId().toString();
            MessageDialog messageDialog = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("DeleteAspectHandler_title"), null, message, MessageDialog.WARNING,
                    new String[] { NLMessages.getString("Handler_delete"),
                            NLMessages.getString("Handler_cancel") },
                    1);
            if (messageDialog.open() == 0) {
                IDBManager dbm = _facade.getDBManager();
                try {
                    dbm.delete(_facade.getCurrentAspect().getPdrId(), "aspect");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } //$NON-NLS-1$ //$NON-NLS-2$
                _facade.deleteAspect(_facade.getCurrentAspect());
            }
        } else {
            MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("Commands_no_rights_delete"),
                    NLMessages.getString("Command_no_rights_delete_aspect_message")); //$NON-NLS-1$
        }
    }
    return null;
}

From source file:org.bbaw.pdr.ae.view.main.commands.DeletePersonHandler.java

License:Open Source License

/**
 * execute method./*from  w  ww .j a  v a  2  s . com*/
 * @param event to be executed.
 * @throws ExecutionException ee.
 * @return null.
 */

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {
    if (_facade.getCurrentPerson() != null) {
        if (new UserRichtsChecker().mayDelete(_facade.getCurrentPerson())) {
            Person p = _facade.getCurrentPerson();
            Vector<Aspect> belongingToAspects = new Vector<Aspect>();
            boolean toOtherPerson = false;
            PDRObjectsProvider oProvider = new PDRObjectsProvider();
            oProvider.setInput(p);

            for (Aspect a : oProvider.getAspects()) {
                toOtherPerson = false;
                if (a != null && a.getRelationDim() != null && a.getRelationDim().getRelationStms() != null) {
                    for (RelationStm rStm : a.getRelationDim().getRelationStms()) {
                        if (rStm.getRelations() != null && (!rStm.getSubject().equals(a.getPdrId())
                                && !rStm.getRelations().firstElement().getObject().equals(p.getPdrId()))) {
                            toOtherPerson = true;
                            break;
                        }
                    }
                    if (!toOtherPerson) {
                        belongingToAspects.add(a);
                    }
                }
            }

            String message = NLMessages.getString("DeletePersonHandler_warning0");
            message += "\n";
            message += belongingToAspects.size() + " Aspects belong only to this person."
                    + "\nDo you really want to delete this person and all aspects that belong only to this person?";
            message += NLMessages.getString("DeletePersonHandler_warning2") + p.getDisplayName();
            message += NLMessages.getString("DeletePersonHandler_lb_id") + p.getPdrId().toString();
            MessageDialog messageDialog = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("DeletePersonHandler_title"), null, message, MessageDialog.WARNING,
                    new String[] { NLMessages.getString("DeletePersonHandler_delete_person_allaspects"),
                            NLMessages.getString("DeletePersonHandler_delete_only_person"),
                            NLMessages.getString("Handler_cancel") },
                    2);
            int returnCode = messageDialog.open();
            if (returnCode == 0) {
                IDBManager dbm = _facade.getDBManager();
                for (Aspect a : belongingToAspects) {
                    try {
                        dbm.delete(a.getPdrId(), "aspect");
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    _facade.deleteAspectFromLoadedAspects(a);
                }
                try {
                    dbm.delete(p.getPdrId(), "person");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } //$NON-NLS-1$ //$NON-NLS-2$
                _facade.deletePersonFromAllPersons(p);
            } else if (returnCode == 1) {
                IDBManager dbm = _facade.getDBManager();
                // find and delete all aspects that contain the person's
                // name.
                for (Aspect a : belongingToAspects) {
                    if (a != null && a.getSemanticDim() != null
                            && a.getSemanticDim().getSemanticStms() != null) {
                        for (SemanticStm sStm : a.getSemanticDim().getSemanticStms()) {
                            if (_facade.isPersonNameTag(sStm.getLabel())) {
                                try {
                                    dbm.delete(a.getPdrId(), "aspect");
                                } catch (Exception e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                                _facade.deleteAspectFromLoadedAspects(a);
                                break;
                            }
                        }

                    }
                }
                try {
                    dbm.delete(p.getPdrId(), "person");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } //$NON-NLS-1$ //$NON-NLS-2$
                _facade.deletePersonFromAllPersons(p);

            }
        } else {
            MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("Commands_no_rights_delete"),
                    NLMessages.getString("Command_no_rights_delete_person_message")); //$NON-NLS-1$
        }
    }
    return null;
}

From source file:org.bbaw.pdr.ae.view.main.commands.DeleteReferenceHandler.java

License:Open Source License

/**
 * execute method./*from w ww .j a va 2  s .  co m*/
 * @param event to be executed.
 * @throws ExecutionException ee.
 * @return null.
 */

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {

    if (_facade.getCurrentReference() != null) {
        if (new UserRichtsChecker().mayDelete(_facade.getCurrentReference())) {

            String message = NLMessages.getString("DeleteReferenceHandler_warning0");
            message += NLMessages.getString("DeleteReferenceHandler_warning1");
            message += NLMessages.getString("DeleteReferenceHandler_warning2")
                    + _facade.getCurrentReference().getDisplayNameLong();
            message += NLMessages.getString("DeleteReferenceHandler_ln_id")
                    + _facade.getCurrentReference().getPdrId().toString();
            MessageDialog messageDialog = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("DeleteReferenceHandler_title"), null, message, MessageDialog.WARNING,
                    new String[] { NLMessages.getString("Handler_delete"),
                            NLMessages.getString("Handler_cancel") },
                    1);
            if (messageDialog.open() == 0) {
                IDBManager dbm = _facade.getDBManager();
                try {
                    dbm.delete(_facade.getCurrentReference().getPdrId(), "reference");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } //$NON-NLS-1$ //$NON-NLS-2$
                _facade.deleteReference(_facade.getCurrentReference());
            }
        } else {
            MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    NLMessages.getString("Commands_no_rights_delete"),
                    NLMessages.getString("Command_no_rights_delete_reference_message")); //$NON-NLS-1$
        }
    }

    return null;
}

From source file:org.bbaw.pdr.ae.view.main.commands.ExportReferenceModsTemplatesHandler.java

License:Open Source License

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {
    String message = "Export Reference Templates";
    IWorkbench workbench = PlatformUI.getWorkbench();
    Display display = workbench.getDisplay();
    Shell shell = new Shell(display);
    MessageDialog messageDialog = new MessageDialog(shell, "Export Reference Templates", null, //$NON-NLS-1$
            message, MessageDialog.INFORMATION,
            new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); //$NON-NLS-1$ //$NON-NLS-2$
    if (messageDialog.open() == 0) {
        IFileSaveHandling fileHandling = CommonExtensions.getFileSaveAndLoadFactory().createFileSaveHandling();
        String selectedDirectory = null;
        String fileName = "ReferenceTemplate" + Facade.getInstanz().getCurrentDateAsString();
        if (fileHandling.isLocalFileSystem()) {
            String lastLoc = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID,
                    "LAST_EXPORT_DIR", null, null);
            selectedDirectory = fileHandling.createFileSaveDialog(shell, fileName, lastLoc,
                    "Export Reference Templates", "Export Reference Templates");
            CommonActivator.getDefault().getPreferenceStore().setValue("LAST_EXPORT_DIR", selectedDirectory);
        } else {//  ww w. ja  va 2s . c o  m
            selectedDirectory = AEConstants.TEMP_DOWNLOAD_DIR + AEConstants.FS;
        }
        if (selectedDirectory != null) {
            IDBManager dbm = Facade.getInstanz().getDBManager();
            try {
                dbm.writeToLocalReferenceTemplateBackup(selectedDirectory);
                String info = "Export Reference Templates Successful";
                MessageDialog infoDialog = new MessageDialog(shell, "Export Reference Templates Successful",
                        null, info, MessageDialog.INFORMATION,
                        new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$
                infoDialog.open();
                if (!fileHandling.isLocalFileSystem()) {
                    fileHandling.createFileDownloadDialog(selectedDirectory + fileName, fileName,
                            "Export Reference Templates",
                            "Click link to download exported Reference Templates");
                }
            } catch (Exception e) {
                e.printStackTrace();

                String info = "Export Reference Templates Unsuccessful";
                MessageDialog infoDialog = new MessageDialog(shell, "Export Reference Templates Unsuccessful",
                        null, info, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_ok") }, //$NON-NLS-1$
                        0);
                infoDialog.open();
                return Status.OK_STATUS;
            }

        }

    }
    return null;
}

From source file:org.bbaw.pdr.ae.view.main.editors.ReferenceGenreEditor.java

License:Open Source License

@Override
protected final Control createDialogArea(final Composite parent) {

    parent.setSize(300, 200);//from  w w  w  . java2  s  .  c o  m
    _deletedTemplates.clear();
    SashForm mainSForm = new SashForm(parent, SWT.HORIZONTAL);
    mainSForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (AEVIEWConstants.IS_SMALL_MONITOR_DIMENSION) {
        ((GridData) mainSForm.getLayoutData()).minimumHeight = 350;
    } else {
        ((GridData) mainSForm.getLayoutData()).minimumHeight = 600;
    }
    ((GridData) mainSForm.getLayoutData()).minimumWidth = 800;

    _mainComposite = new Composite(mainSForm, SWT.NONE);
    _mainComposite.setLayoutData(new GridData());
    ((GridData) _mainComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _mainComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _mainComposite.getLayoutData()).grabExcessVerticalSpace = true;
    ((GridData) _mainComposite.getLayoutData()).verticalAlignment = SWT.FILL;
    _mainComposite.setLayout(new GridLayout());
    ((GridLayout) _mainComposite.getLayout()).numColumns = 1;
    ((GridLayout) _mainComposite.getLayout()).makeColumnsEqualWidth = false;

    Composite upperComposite = new Composite(_mainComposite, SWT.NONE);
    upperComposite.setLayoutData(new GridData());
    ((GridData) upperComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) upperComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    upperComposite.setLayout(new GridLayout());
    ((GridLayout) upperComposite.getLayout()).numColumns = 3;
    ((GridLayout) upperComposite.getLayout()).makeColumnsEqualWidth = false;

    Label newLabel = new Label(upperComposite, SWT.NONE);
    newLabel.setLayoutData(new GridData());
    newLabel.setText(NLMessages.getString("Editor_new_genre"));

    _genreText = new Text(upperComposite, SWT.BORDER);
    _genreText.setLayoutData(new GridData());
    ((GridData) _genreText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _genreText.getLayoutData()).horizontalAlignment = SWT.FILL;
    // @SuppressWarnings({ "unchecked", "rawtypes" })
    // final Vector<String> genres = new
    // Vector(Arrays.asList(_facade.getReferenceGenres()));
    _genreText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(final KeyEvent e) {
        }

        @Override
        public void keyReleased(final KeyEvent e) {

            //            System.out.println("genre text " + _genreText.getText()); //$NON-NLS-1$
            if (_facade.getReferenceModsTemplates().containsKey(_genreText.getText())) {
                //               System.out.println("checking zwei"); //$NON-NLS-1$
                setMessage(NLMessages.getString("Editor_message_genre_exists"), SWT.ERROR);
                _newButton.setEnabled(false);
            } else {
                setMessage(""); //$NON-NLS-1$
                _newButton.setEnabled(_genreText.getText().trim().length() > 0);
            }

        }

    });

    _newButton = new Button(upperComposite, SWT.PUSH);
    _newButton.setText(NLMessages.getString("Editor_new"));
    _newButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {

            createNewGenre(_genreText.getText().trim());
        }
    });
    _newButton.pack();
    _newButton.setEnabled(false);
    upperComposite.layout();
    upperComposite.pack();

    _editorComposite = new Composite(_mainComposite, SWT.NONE);
    _editorComposite.setLayoutData(new GridData());
    ((GridData) _editorComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _editorComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _editorComposite.getLayoutData()).grabExcessVerticalSpace = true;
    ((GridData) _editorComposite.getLayoutData()).verticalAlignment = SWT.FILL;
    _editorComposite.setLayout(new GridLayout());
    ((GridLayout) _editorComposite.getLayout()).numColumns = 1;
    ((GridLayout) _editorComposite.getLayout()).makeColumnsEqualWidth = false;

    _genreTableViewer = new TableViewer(_editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);

    String[] titles = { "Displayname" }; //$NON-NLS-1$ //$NON-NLS-2$
    int[] bounds = { 180 };

    for (int i = 0; i < titles.length; i++) {
        TableViewerColumn column = new TableViewerColumn(_genreTableViewer, SWT.NONE);
        column.getColumn().setText(titles[i]);
        column.getColumn().setWidth(bounds[i]);
        column.getColumn().setResizable(false);
        column.getColumn().setMoveable(true);
        // column.getColumn().addSelectionListener(getSelectionAdapter(_genreTableViewer,
        // column.getColumn(), i));

    }
    // _genreTableViewer.setComparator(new PdrObjectViewComparator());

    Table table = _genreTableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(false);
    table.setLayoutData(new GridData());
    ((GridData) table.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) table.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) table.getLayoutData()).verticalAlignment = SWT.FILL;
    ((GridData) table.getLayoutData()).grabExcessVerticalSpace = true;

    _genreTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection selection = _genreTableViewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            if (_currentTemplate != null) {
                _lastTemplate = _currentTemplate;
                if (_sourceEditor.getCurrentReference() != null) {
                    _lastTemplate.setRefTemplate(_sourceEditor.getCurrentReference());
                }
            }
            _currentTemplate = (ReferenceModsTemplate) obj;
            if (_currentTemplate != null) {
                loadValues();
            }

        }
    });
    _genreTableViewer.setContentProvider(new RefTemplateContentProvider(true));
    _genreTableViewer.setLabelProvider(new RefTemplateLabelProvider());
    _genreTableViewer.setComparator(null);
    _genreTableViewer.setInput(_facade.getReferenceModsTemplates());

    _genreTableViewer.refresh();
    _editorComposite.layout();

    Composite lowerLeftComposite = new Composite(_mainComposite, SWT.NONE);
    lowerLeftComposite.setLayoutData(new GridData());
    ((GridData) lowerLeftComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) lowerLeftComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    lowerLeftComposite.setLayout(new GridLayout());
    ((GridLayout) lowerLeftComposite.getLayout()).numColumns = 2;
    ((GridLayout) lowerLeftComposite.getLayout()).makeColumnsEqualWidth = false;

    _deleteButton = new Button(lowerLeftComposite, SWT.PUSH);
    _deleteButton.setText(NLMessages.getString("Editor_delete"));
    _deleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            String message = NLMessages.getString("Editor_delete_refTemplate");
            message += "\n";
            message += NLMessages.getString("Editor_delte_refTemplate_warning") + "\n"
                    + NLMessages.getString("Editor_delte_refTemplate_warning2") + "\n\n"
                    + NLMessages.getString("Editor_delte_refTemplate_warning3");
            MessageDialog messageDialog = new MessageDialog(_parentShell,
                    NLMessages.getString("Editor_delete_refTemplate"), null, message, MessageDialog.WARNING,
                    new String[] { NLMessages.getString("Editor_delete"),
                            NLMessages.getString("Editor_cancel") },
                    1);
            if (messageDialog.open() == 0) {
                _deletedTemplates.add(_currentTemplate.getValue());
                _facade.getReferenceModsTemplates().remove(_currentTemplate.getValue());

                _currentTemplate = _lastTemplate;
                _genreTableViewer.setInput(_facade.getReferenceModsTemplates());
                _genreTableViewer.refresh();
                if (_currentTemplate != null) {
                    StructuredSelection sel = new StructuredSelection(_currentTemplate);
                    _genreTableViewer.setSelection(sel);
                    loadValues();
                }
            }
        }
    });
    _deleteButton.pack();

    Button exportButton = new Button(lowerLeftComposite, SWT.PUSH);
    exportButton.setText("Export");
    exportButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent ee) {
            IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                    .getService(IHandlerService.class);
            try {
                handlerService.executeCommand("org.bbaw.pdr.ae.view.main.commands.ExportReferenceModsTemplates", //$NON-NLS-1$
                        null);
            } catch (ExecutionException e) {
                e.printStackTrace();
            } catch (NotDefinedException e) {
                e.printStackTrace();
            } catch (NotEnabledException e) {
                e.printStackTrace();
            } catch (NotHandledException e) {
                e.printStackTrace();
            }
        }
    });
    exportButton.pack();
    upperComposite.layout();
    upperComposite.pack();

    TabFolder mainTabFolder = new TabFolder(mainSForm, SWT.TOP | SWT.FILL);
    GridData gridData2 = new GridData();
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.horizontalSpan = 1;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    gridData2.horizontalAlignment = SWT.FILL;
    mainTabFolder.setLayoutData(gridData2);

    TabItem genreFormTabItem = new TabItem(mainTabFolder, SWT.NONE);
    genreFormTabItem.setText(NLMessages.getString("Editor_genre_formular")); //$NON-NLS-1$

    Composite rightComposite = new Composite(mainTabFolder, SWT.NONE);
    rightComposite.setLayoutData(new GridData());
    ((GridData) rightComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) rightComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    rightComposite.setLayout(new GridLayout());
    ((GridLayout) rightComposite.getLayout()).numColumns = 1;
    ((GridLayout) rightComposite.getLayout()).makeColumnsEqualWidth = false;

    genreFormTabItem.setControl(rightComposite);

    Composite topRightComposite = new Composite(rightComposite, SWT.NONE);
    topRightComposite.setLayoutData(new GridData());
    ((GridData) topRightComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) topRightComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    topRightComposite.setLayout(new GridLayout());
    ((GridLayout) topRightComposite.getLayout()).numColumns = 6;
    ((GridLayout) topRightComposite.getLayout()).makeColumnsEqualWidth = false;

    Label genreLabelL = new Label(topRightComposite, SWT.NONE);
    genreLabelL.setLayoutData(new GridData());
    genreLabelL.setText(NLMessages.getString("Editor_genre_label"));

    _genreLabelText = new Text(topRightComposite, SWT.BORDER);
    _genreLabelText.setLayoutData(new GridData());
    ((GridData) _genreLabelText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _genreLabelText.getLayoutData()).horizontalAlignment = SWT.FILL;

    _genreLabelText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(final KeyEvent e) {
        }

        @Override
        public void keyReleased(final KeyEvent e) {

            //            System.out.println("genre text " + _genreText.getText()); //$NON-NLS-1$
            if (_facade.getReferenceModsTemplates().containsKey(_genreLabelText.getText())) {
                setMessage(NLMessages.getString("Editor_message_genre_exists"), SWT.ERROR);
            } else {
                setMessage(""); //$NON-NLS-1$
                _currentTemplate.setLabel(_genreLabelText.getText());
                _genreTableViewer.refresh();

            }

        }

    });
    Label genreValueL = new Label(topRightComposite, SWT.NONE);
    genreValueL.setLayoutData(new GridData());
    genreValueL.setText(NLMessages.getString("Editor_genre_value"));

    _genreValueText = new Text(topRightComposite, SWT.BORDER);
    _genreValueText.setLayoutData(new GridData());
    ((GridData) _genreValueText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _genreValueText.getLayoutData()).horizontalAlignment = SWT.FILL;
    _genreValueText.setEditable(false);
    _genreValueText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(final KeyEvent e) {
        }

        @Override
        public void keyReleased(final KeyEvent e) {

            //            System.out.println("genre text " + _genreText.getText()); //$NON-NLS-1$
            if (_facade.getReferenceModsTemplates().containsKey(_genreValueText.getText())) {
                setMessage(NLMessages.getString("Editor_message_genre_exists"), SWT.ERROR);
            } else {
                setMessage(""); //$NON-NLS-1$
                _currentTemplate.setLabel(_genreValueText.getText());
                _genreTableViewer.refresh();

            }

        }

    });
    Label ignoreLabel = new Label(topRightComposite, SWT.NONE);
    ignoreLabel.setText(NLMessages.getString("Editor_ignore"));
    ignoreLabel.setLayoutData(new GridData());

    _ignoreButton = new Button(topRightComposite, SWT.CHECK);
    _ignoreButton.setLayoutData(new GridData());
    // _ignoreButton.setEnabled(_userRichtsChecker.maySetConfigIgnored());
    ((GridData) _ignoreButton.getLayoutData()).horizontalSpan = 1;
    _ignoreButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent se) {
            _currentTemplate.setIgnore(_ignoreButton.getSelection());
            _genreTableViewer.refresh();

        }
    }); // SelectionListener

    Composite lowerRightComposite = new Composite(rightComposite, SWT.NONE);
    lowerRightComposite.setLayoutData(new GridData());
    ((GridData) lowerRightComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) lowerRightComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    lowerRightComposite.setLayout(new GridLayout());
    ((GridLayout) lowerRightComposite.getLayout()).numColumns = 1;
    ((GridLayout) lowerRightComposite.getLayout()).makeColumnsEqualWidth = false;

    _sourceEditor = new SourceEditorDialog(_parentShell, null, true);
    _sourceEditor.create();
    _sourceEditor.createDialogArea(lowerRightComposite);

    TabItem docuTabItem = new TabItem(mainTabFolder, SWT.NONE);
    docuTabItem.setText(NLMessages.getString("Editor_genre_documentation")); //$NON-NLS-1$

    Composite docuComposite = new Composite(mainTabFolder, SWT.NONE);
    docuComposite.setLayoutData(new GridData());
    ((GridData) docuComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) docuComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    docuComposite.setLayout(new GridLayout());
    ((GridLayout) docuComposite.getLayout()).numColumns = 1;
    ((GridLayout) docuComposite.getLayout()).makeColumnsEqualWidth = false;

    docuTabItem.setControl(docuComposite);

    Label docuLabelDE = new Label(docuComposite, SWT.NONE);
    docuLabelDE.setLayoutData(new GridData());
    ((GridData) docuLabelDE.getLayoutData()).horizontalAlignment = SWT.LEFT;
    docuLabelDE.setText("Deutsch"); //$NON-NLS-1$

    _docuTextDE = new Text(docuComposite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    _docuTextDE.setLayoutData(new GridData());
    ((GridData) _docuTextDE.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _docuTextDE.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _docuTextDE.getLayoutData()).heightHint = 50;

    _docuTextDE.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_currentTemplate.getDocumentation() == null) {
                _currentTemplate.setDocumentation(new HashMap<String, String>());
            }
            _currentTemplate.getDocumentation().put("de", _docuTextDE.getText()); //$NON-NLS-1$
        }
    });

    Label docuLabelEN = new Label(docuComposite, SWT.NONE);
    docuLabelEN.setLayoutData(new GridData());
    docuLabelEN.setText("English"); //$NON-NLS-1$

    _docuTextEN = new Text(docuComposite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    _docuTextEN.setLayoutData(new GridData());
    ((GridData) _docuTextEN.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _docuTextEN.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _docuTextEN.getLayoutData()).heightHint = 50;

    _docuTextEN.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_currentTemplate.getDocumentation() == null) {
                _currentTemplate.setDocumentation(new HashMap<String, String>());
            }
            _currentTemplate.getDocumentation().put("en", _docuTextEN.getText()); //$NON-NLS-1$
        }
    });

    Label docuLabelIT = new Label(docuComposite, SWT.NONE);
    docuLabelIT.setLayoutData(new GridData());
    ((GridData) docuLabelIT.getLayoutData()).horizontalAlignment = SWT.LEFT;
    docuLabelIT.setText("Italiano"); //$NON-NLS-1$

    _docuTextIT = new Text(docuComposite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    _docuTextIT.setLayoutData(new GridData());
    ((GridData) _docuTextIT.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _docuTextIT.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _docuTextIT.getLayoutData()).heightHint = 50;

    _docuTextIT.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_currentTemplate.getDocumentation() == null) {
                _currentTemplate.setDocumentation(new HashMap<String, String>());
            }
            _currentTemplate.getDocumentation().put("de", _docuTextIT.getText()); //$NON-NLS-1$
        }
    });
    Label docuLabelFR = new Label(docuComposite, SWT.NONE);
    docuLabelFR.setLayoutData(new GridData());
    ((GridData) docuLabelFR.getLayoutData()).horizontalAlignment = SWT.LEFT;
    docuLabelFR.setText("Francais"); //$NON-NLS-1$

    _docuTextFR = new Text(docuComposite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    _docuTextFR.setLayoutData(new GridData());
    ((GridData) _docuTextFR.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _docuTextFR.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _docuTextFR.getLayoutData()).heightHint = 50;

    _docuTextFR.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_currentTemplate.getDocumentation() == null) {
                _currentTemplate.setDocumentation(new HashMap<String, String>());
            }
            _currentTemplate.getDocumentation().put("de", _docuTextFR.getText()); //$NON-NLS-1$
        }
    });
    _docuTextDE.setEnabled(false);
    _docuTextEN.setEnabled(false);
    _docuTextIT.setEnabled(false);
    _docuTextFR.setEnabled(false);

    TabItem iconTabItem = new TabItem(mainTabFolder, SWT.NONE);
    iconTabItem.setText(NLMessages.getString("Editor_genre_icon")); //$NON-NLS-1$

    Composite iconComposite = new Composite(mainTabFolder, SWT.NONE);
    iconComposite.setLayoutData(new GridData());
    ((GridData) iconComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) iconComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) iconComposite.getLayoutData()).grabExcessVerticalSpace = true;
    ((GridData) iconComposite.getLayoutData()).verticalAlignment = SWT.FILL;
    iconComposite.setLayout(new GridLayout());
    ((GridLayout) iconComposite.getLayout()).numColumns = 8;
    ((GridLayout) iconComposite.getLayout()).makeColumnsEqualWidth = true;
    ((GridLayout) iconComposite.getLayout()).marginHeight = 12;
    ((GridLayout) iconComposite.getLayout()).marginWidth = 12;
    ((GridLayout) iconComposite.getLayout()).horizontalSpacing = 35;

    ((GridLayout) iconComposite.getLayout()).verticalSpacing = 35;

    iconTabItem.setControl(iconComposite);

    Label iconLabel = new Label(iconComposite, SWT.NONE);
    iconLabel.setLayoutData(new GridData());
    ((GridData) iconLabel.getLayoutData()).horizontalAlignment = SWT.LEFT;
    ((GridData) iconLabel.getLayoutData()).horizontalSpan = 8;

    iconLabel.setText(NLMessages.getString("Editor_genre_icon_info"));
    SelectionListener iconListener = new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final String ico = (String) ((Button) e.getSource()).getData("icon"); //$NON-NLS-1$
            if (_currentTemplate != null) {
                _currentTemplate.setImageString(ico);
                _genreTableViewer.refresh();
            }

        }
    };
    _iconButtons = new Button[_icons.length];
    for (int i = 0; i < _icons.length; i++) {
        String icon = _icons[i];

        _iconButtons[i] = new Button(iconComposite, SWT.RADIO | SWT.CENTER);
        _iconButtons[i].setData("icon", icon); //$NON-NLS-1$
        _iconButtons[i].setImage(_imageReg.get(icon));
        _iconButtons[i].addSelectionListener(iconListener);
        _iconButtons[i].setLayoutData(new GridData());
        _iconButtons[i].pack();
    }
    iconComposite.layout();
    mainSForm.setWeights(new int[] { 1, 3 });

    _editorComposite.layout();
    parent.pack();
    return parent;
}

From source file:org.bbaw.pdr.ae.view.main.preferences.GeneralPage.java

License:Open Source License

private boolean checkRestart() {

    MessageDialog messageDialog = new MessageDialog(null, NLMessages.getString("Handler_restart_titel"), null,
            NLMessages.getString("Handler_restart_message"), MessageDialog.WARNING,
            new String[] { NLMessages.getString("Handler_restart"), NLMessages.getString("Handler_cancel") },
            0);//from w  w w.  j  a  v  a 2s .c  o m
    if (messageDialog.open() == 0) {
        IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                .getService(IHandlerService.class);
        try {
            handlerService.executeCommand("org.eclipse.ui.file.restartWorkbench", null); //$NON-NLS-1$
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (NotDefinedException e) {
            e.printStackTrace();
        } catch (NotEnabledException e) {
            e.printStackTrace();
        } catch (NotHandledException e) {
            e.printStackTrace();
        }
    }

    return true;
}

From source file:org.bonitasoft.studio.actors.ui.wizard.ManageOrganizationWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*from w  ww  .j  a  va 2  s  . c o  m*/
        getContainer().run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(Messages.saveOrganization, IProgressMonitor.UNKNOWN);
                for (Organization organization : organizationsWorkingCopy) {
                    monitor.subTask(Messages.validatingOrganizationContent);
                    String errorMessage = isOrganizationValid(organization);
                    if (errorMessage != null) {
                        throw new InterruptedException(organization.getName() + ": " + errorMessage);
                    }
                    String fileName = organization.getName() + "."
                            + OrganizationRepositoryStore.ORGANIZATION_EXT;
                    IRepositoryFileStore file = store.getChild(fileName);
                    Organization oldOrga = null;
                    if (file == null) {
                        file = store.createRepositoryFileStore(fileName);
                    } else {
                        oldOrga = (Organization) file.getContent();
                    }
                    if (oldOrga != null) {
                        RefactorActorMappingsOperation refactorOp = new RefactorActorMappingsOperation(oldOrga,
                                organization);
                        refactorOp.run(monitor);
                    }
                    file.save(organization);
                }
                for (Organization orga : organizations) {
                    boolean exists = false;
                    for (Organization orgCopy : organizationsWorkingCopy) {
                        if (orgCopy.getName().equals(orga.getName())) {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists) {
                        IRepositoryFileStore f = store
                                .getChild(orga.getName() + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
                        if (f != null) {
                            f.delete();
                        }
                    }
                }
                monitor.done();
            }
        });
    } catch (InterruptedException e) {
        openErrorStatusDialog(e.getMessage());
        return false;
    } catch (InvocationTargetException e) {
        BonitaStudioLog.error(e);
        return false;
    }
    IPreferenceStore preferenceStore = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore();
    String pref = preferenceStore.getString(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION);
    boolean publishOrganization = preferenceStore.getBoolean(ActorsPreferenceConstants.PUBLISH_ORGANIZATION);
    if (publishOrganization && MessageDialogWithToggle.ALWAYS.equals(pref)) {
        try {
            publishOrganization(preferenceStore);
        } catch (InvocationTargetException e) {
            BonitaStudioLog.error(e);

        } catch (InterruptedException e) {
            BonitaStudioLog.error(e);
        }
    } else {
        if (MessageDialogWithToggle.NEVER.equals(pref) && activeOrganizationHasBeenModified) {
            String[] buttons = { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
            MessageDialogWithToggle mdwt = new MessageDialogWithToggle(Display.getDefault().getActiveShell(),
                    Messages.organizationHasBeenModifiedTitle, null,
                    Messages.bind(Messages.organizationHasBeenModifiedMessage, activeOrganization.getName()),
                    MessageDialog.WARNING, buttons, 0, Messages.doNotDisplayAgain, false);
            mdwt.setPrefStore(preferenceStore);
            mdwt.setPrefKey(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION);
            int index = mdwt.open();
            if (index == 2) {
                try {
                    publishOrganization(preferenceStore);
                    if (mdwt.getToggleState()) {
                        preferenceStore.setDefault(ActorsPreferenceConstants.PUBLISH_ORGANIZATION, true);
                    }
                } catch (InvocationTargetException e) {
                    BonitaStudioLog.error(e);

                } catch (InterruptedException e) {
                    BonitaStudioLog.error(e);
                }
            } else {
                if (mdwt.getToggleState()) {
                    preferenceStore.setDefault(ActorsPreferenceConstants.PUBLISH_ORGANIZATION, false);
                    preferenceStore.setDefault(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION,
                            MessageDialogWithToggle.ALWAYS);
                }
            }
        }

    }
    return true;
}

From source file:org.carrot2.workbench.core.ui.SearchEditor.java

License:Open Source License

/**
 * Show a dialog prompting for file name and options and save the result to an XML
 * file.// ww w  . j a  v a  2  s.  com
 */
public void doSaveAs() {
    if (isDirty() || this.searchJob.getState() == Job.RUNNING) {
        final MessageDialog dialog = new MessageDialog(getEditorSite().getShell(), "Modified parameters", null,
                "Search parameters" + " have been changed. Save stale results?", MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);

        if (dialog.open() == MessageDialog.CANCEL) {
            return;
        }
    }

    SaveOptions newOptions = saveOptions;
    if (newOptions == null) {
        newOptions = SaveOptions.getGlobalOrDefault();
        newOptions.fileName = FileDialogs.sanitizeFileName(getFullInputTitle(getSearchResult())) + ".xml";
    }

    final Shell shell = this.getEditorSite().getShell();
    if (new SearchEditorSaveAsDialog(shell, newOptions).open() == Window.OK) {
        this.saveOptions = newOptions;
        doSave(saveOptions);
    }
}

From source file:org.celllife.idart.gui.stockOnHand.StockOnHandGui.java

License:Open Source License

private void populateStockGUI() {

    if (localStockCenter == null) {
        getLog().info("Tried to retrieve stock list, but localPharmay is null");
        return;/* w ww  .j  ava 2 s .  c om*/
    }

    final List<DrugDetail> dataList = new ArrayList<DrugDetail>();
    final List<Drug> drugList = DrugManager.getAllDrugs(getHSession());
    final String parmacy = cmbPharmacy.getText();

    try {
        new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Calculating stock values", drugList.size());
                for (Drug drug : drugList) {
                    if (monitor.isCanceled()) {
                        throw new OperationCanceledException("Calculation cancelled");
                    }
                    monitor.subTask("Calculating values for " + drug.getName());
                    DrugDetail dd = StockManager.getDrugDetail(getHSession(), drug,
                            AdministrationManager.getStockCenter(getHSession(), parmacy));

                    dataList.add(dd);
                    monitor.worked(1);
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        showMessage(MessageDialog.ERROR, Messages.getString("common.error"), //$NON-NLS-1$
                Messages.getString("stockOnHand.error")); //$NON-NLS-1$
    } catch (InterruptedException e) {
        showMessage(MessageDialog.WARNING, Messages.getString("common.warning"), //$NON-NLS-1$
                Messages.getString("stockOnHand.warning")); //$NON-NLS-1$
    }

    tblStockTable.setInput(dataList);

    tblStockTable.refresh();
    tblStockTable.expandAll();

}