List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:actions.FileScanningAction.java
License:Open Source License
public void scanFiles(String[] files) { try {// w w w .j a va2 s. c om ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.run(true, true, new ScanProgressMonitor(files)); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error", e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(shell, "Cancelled", e.getMessage()); } }
From source file:ag.ion.noa4e.ui.operations.LoadDocumentOperation.java
License:Open Source License
/** * Runs this operation. Progress should be reported to the given progress * monitor. This method is usually invoked by an * <code>IRunnableContext</code>'s <code>run</code> method, which supplies * the progress monitor. A request to cancel the operation should be honored * and acknowledged by throwing <code>InterruptedException</code>. * /* www .j a v a2s . c om*/ * @param progressMonitor * the progress monitor to use to display progress and receive * requests for cancelation * * @exception InvocationTargetException * if the run method must propagate a checked exception, it * should wrap it inside an * <code>InvocationTargetException</code>; runtime exceptions * are automatically wrapped in an * <code>InvocationTargetException</code> by the calling * context * @exception InterruptedException * if the operation detects a request to cancel, using * <code>IProgressMonitor.isCanceled()</code>, it should exit * by throwing <code>InterruptedException</code> * * Joerg Sigle added code for progress monitoring printlns, to examine the stability problems observed in Elexis, * and to implement a watchdog timer that will interrupt a hanging loop after a certain time. * Empirically, the call to internalThread.destroy(); apparently hits the sweet spot. * It changes the user experience of a completely stalled Elexis/OpenOffice/LibreOffice program * into one that may merely be paused for several 10 seconds, and then continue - just as it would be expected. * Even when I opened a document with many interactive elements and lots of macro code which would * require more than one minute in LibreOffice (for whatever reason, same time if opened outside Elexis), * the watchdog would kick in, but the document would still be loaded correctly and work correctly thereafter. * So it seems that the watchdog improves the situation and, give the duration I've told it to wait, * does not have any disadvantageous effects. * In the future, however, I would suggest to review what is actually happening in the interface * to greater depth, i.e. down into the OpenOffice/LibreOffice libraries. I haven't done this so far, * as I did all the work without funding, with other projects pressing, so I stopped - for now - * as son as I saw I had to add the source code of the Office packages into my development system, * and my solution found until now would solve the problem in praxi (I have given it several tests). * Further details in the comprehensive comments I added below and elsewhere in the library. * * @author Joerg Sigle * @date 25.02.2012 * * @author Andreas Brker */ public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException { System.out.println("LoadDocumentOperation: run begins"); System.out.println("LoadDocumentOperation: run 1"); internalThread = new InternalThread(); if (isSubTask) { if (updateProgressMonitor) progressMonitor.subTask(Messages.LoadDocumentOperation_monitor_loading_document); } else { if (updateProgressMonitor) progressMonitor.beginTask(Messages.LoadDocumentOperation_monitor_loading_document, 50); } System.out.println("LoadDocumentOperation: run 2 - about to start internalThread..."); //201210220045js I'd like to ensure that the dialog asking the user whether they want to destroy the internal thread //is actually displayed. That should be done by the SWTHelper module, but nothing happens while e.g. LibreOffice is busy //opening the Status document template and supposedly checking macros or the like. Let me try by lowering the priority //of that thread... Es reicht nicht, um whrend LibreOffice opening Status Vorlage einen Dialog erscheinen zu lassen. //Erst, wenn das ziemlich / ganz durch ist, erscheint der Dialog. Andererseits... das ist ja ohnehin selbstlimitierend, //und ich will *das* eigentlich garnicht unterbrechen. Aber wie ist es denn, wenn ich mal den Formatvorlagen-Dialog //hervorhole und undocke? ... ALSO, witzigerweise ist es *genau* wie bentigt - und sogar noch mehr. //Testcase: Dokument mit Tabelle erstellen, Tabellen-Toolbar undocken (vor jedem Test neu, weil noatext_jsl den //wieder dockt, wenn es ber das stalling hinausgekommen ist, Elexis so schliessen = offener ungedockter Toolbar //wird fr dieses Dokument gespeichert. Elexis schliessen, Elexis ffnen, dasselbe Dokument wieder laden (logs anschauen). //(Es reicht auch: Dokument ffnen, Tabellen-Toolbar abdocken, Briefe-Fenster schliessen = wird gespeichert, Tabellen- //Toolbar abgedockt schliessen, Dokument wieder laden (ohne die Selektion in Briefauswahl verndern zu mssen, //Bei diesem Testverfahren braucht man auch Elexis nicht zu beenden.) //Folge: Ein Stall (wie erwartet, auch mit LibreOffice 3.6.2.2). //Aber: in dem Moment, wo der Watchdog die 40 erreicht, blitzelt es im OO //Fenster (kann sein, die Mens erscheinen), und mein Fehlerdialog erscheint. Und - wenn ich dort [Cancel] drcke //(aktuell fhrt das dazu, dass das destroy NICHT gesendet wird), dann... verschwindet der Dialog, und... //sofort erscheint das geladene Dokument. Die Toolbars werden automatisch gedockt. //Das hat diesmal auch keine Nebenwirkungen (beim Status-Dokument wurden ja die Felder ersetzt), also das doc wird //dadurch eben NICHT mit null zurckgeliefert, wie wenn ich das destroy abgeschickt htte. //Insofern ist: Dialog mit Hinweis auf die mglichen Grnde der Wartezeit zeigen, ohne weitere Auswahlmglichkeit, //und OHNE DANACH DESTROY ZU SENDEN fr den weiteren Verlauf wohl das gnstigste!!! 201210220116js //(Ich weiss noch nicht, ob das auch die Priority auf lowest braucht - wahrscheinlich nicht - aber stren drfte //das wohl kaum, da entweder auf einem Standalone-System die DB-Performance dadurch frei bleibt, oder der Nutzer //sonst wohl keine Nachteile haben sollte, bis zu Zeit fr weitere Forschungen lasse ich das also mal so.) System.out.println("LoadDocumentOperation: Reading priority of internal thread:"); System.out.println("LoadDocumentOperation: internalThread.getPriority()=" + internalThread.getPriority()); System.out.println("LoadDocumentOperation: Changing priority of internal thread:"); internalThread.setPriority(Thread.MIN_PRIORITY); //1 = THREAD_PRIORITY_LOWEST; 10=THREAD_PRIORITY_TIME_CRITICAL System.out.println("LoadDocumentOperation: internalThread.getPriority()=" + internalThread.getPriority()); internalThread.start(); System.out.println("LoadDocumentOperation: run 2.1 - internalThread has been started"); int cyclesWaitedForInternalThreadToComplete = 0; while (!internalThread.done()) { System.out.println("LoadDocumentOperation: run 2.2 - sleep(500) begins"); Thread.sleep(500); System.out.println("LoadDocumentOperation: run 2.3 - sleep(500) ends"); if (!isSubTask) progressMonitor.worked(1); System.out.println("LoadDocumentOperation: run 2.4"); if (progressMonitor.isCanceled()) { /** * This method is deprecated, but ... */ try { System.out.println( "LoadDocumentOperation: run 2.5 - progressMonitor.isCanceled() has been found."); internalThread.stop(); } catch (Throwable throwable) { // do not consume - ThreadDeath System.out.println("LoadDocumentOperation: run 2.6 - internalThrread.stop() threw exception."); } System.out.println("LoadDocumentOperation: run 2.7 - progressMonitor.done() about to occur..."); progressMonitor.done(); System.out.println( "LoadDocumentOperation: run 2.8 - about to throw InterruptException() with message..."); throw new InterruptedException( Messages.LoadDocumentOperation_exception_message_operation_interrupted); } //201202252105js: //Now limit the time we wait for the office application to start. //As it may hang (when a floating dialog window like the F11 Formatvorlagen dialog, or table frame properties) //is open in OpenOffice/LibreOffice, we will now set a limit for the time we want to wait, //and kill the internalThread if that is exceeded. //NOTE: This hanging has absolutely NOTHING to do with the removed sleep(3000) below. //It has occured forever since oo 2.0.3 in all variants of the noatext interface I now, //even after my update to noa 2.2.3 and noa-libre. See my external logs and notes in the code //for the results of my debugging. //NOTE: On an Intel Core i7 vpro notebook, loading a document takes only 1..2 seconds when it works. //To accomodate for significantly slower infrastructure, I'll wait for 20 seconds now before killing the internalThread. //NOTE: internalThread is the one that should take care of the loading, which it normally does, //after having jumped through zillions of references, methods, procedures etc. within the Java and StarOffice library jungle. //NOTE: The NOAText_js and NOAText_jsl implementations of the NOAText plugin, take numerous preconditions //to completely avoid user generated situations where internalThread would be likely to never come to an end. //Especially, they disable a number of menu commands that could open probably persistent dialogs or toolbars, //which are not probably needed by users within Elexis. Moreover, they try to hide all toolbars and only //display the probably needed ones directly after loading the document (which is the earliest point in time //when it is beneficial, according to practical tests). But still, some dialogs can probably not be guaranteed //to never be required, and never persist, so its these remaining few against which the following timeout handler //shall finally help. //NOTE, IMPORTANT: It would also be a good precondition to "fixate" the toolbars within OpenOffice. //I just now remember this was a measure that I had originally taken on all our workstations, and it also appeared to help. //NOTE: Apparently - as demonstrated in the Mustermann letter with the table format dialog, the following beneficial thing happens: //If (!) the user detaches the table format dialog from the toolbars, that dialog becomes floating. //If he then closes the Briefe view, the floating dialog state is saved. //If he then re-loads the same Letter, the open floating dialog would stall the loader thread (for any reason whatsoever) //After some time, the limit below kicks in and the internalThread is destroyed. //The previously stalled OpenOffice, however, appears in the frame, and most probably... //my precautions shown somewhere else do immediately reconfigure the toolbars and cause the floating dialog to become docked! //When the user closes the window again, the new state is saved; and in future sessions, the dialog will not be floating any more //even when the same document is re-loaded. :-) //(Until the user decides to actively pull it out of the dock again, which should hardly ever happen.) //So only in very rare occasions, this very rude timout driven stall recovery needs to kick in, //and its benefits extend beyond resolving the acute situation. For a workaround, I think that's rather nice. //201202252154js if (cyclesWaitedForInternalThreadToComplete >= 0) { // 201210210818js: Counting up is held while the "do you want to destroyThread" dialog is visible. cyclesWaitedForInternalThreadToComplete = cyclesWaitedForInternalThreadToComplete + 1; //Each cycle currently sleeps for 500ms } System.out.println("LoadDocumentOperation: cyclesWaitedForInternalThreadToComplete: " + cyclesWaitedForInternalThreadToComplete); //20130310js: Introduced in NOAText_jsl Version 1.4.8: //The timeout setting for the threaded watchdog is user configurable via the NOAText_jsl configuration dialog. //I don't want to read it from the preferenceStore directly, because we would have to do that in every cycle, //and it includes some string manipulation, needs 3 imports, and accessing a public static variable over there for the default value etc. //Instead, I have created a public static variable over there to provide the desired numeric value directly. int cyclesWatchdogMaximumAllowedHalfSecs = LocalOfficeApplicationPreferencesPage .getTimeoutThreadedWatchdog(); System.out.println("LoadDocumentOperation: Threaded watchdog timeout from NOAText_jsl preferences: " + cyclesWatchdogMaximumAllowedHalfSecs); if (cyclesWatchdogMaximumAllowedHalfSecs == 0) { System.out.println( "LoadDocumentOperation: Please note: Threaded watchdog = 0 means it has been disabled."); } else if (cyclesWaitedForInternalThreadToComplete > cyclesWatchdogMaximumAllowedHalfSecs) { cyclesWaitedForInternalThreadToComplete = -1; //Paranoia: Damit der nchste Thread.destroy() ggf. nicht schon in 0.5 Sek zuschlagen kann... //Version 1.4.5 hatte nach Ablauf des Watchdog automatisch ein internalThread.destroy() ausgelst. //Version 1.4.6 wollte dazu den Benutzer erst einmal fragen - aber wie ich gefunden habe: // Der Dialog mit Frage nach Besttigung erschien keinesfalls vor Fertigstellen des Ladens eines Status in LibreOffice - Dauer 5 Minuten. // In dieser Situation hatte ein vorzeitiges destroy() aber zu doc==null gefhrt, Fehlermeldungen, und nicht ersetzten Platzhaltern. // Vielleicht anschliessend sogar zu nicht gespeichertem Dokument und gegebenenfalls spterer Instabilitt? // Der Dialog erschien jedoch direkt nach Ablauf des Watchdog fr den Fall des wegen offener Toolbars etc. hngenden Ladeprozesses :-) // Und tatschlich wurde in diesem Moment auch der Ladeprozess abgeschlossen. Ohne, dass noch ein destroy() ntig gewesen wre. // Deshalb habe ich aus der MessageDialog.openConfirm() Variante nur noch eine ...openInformation() Variante gemacht. // Hier wird auf das destroy() verzichtet, und der Anwendern nur noch informiert, dass NOAText die Verzgerung bemerkt hat, // und woran sie liegen knnte. //Folgendes gehrt zur MessageDialog.openInformation() Variante: System.out.println( "LoadDocumentOperation: MessageDialog.openInformation: Loading the document has taken too long."); System.out.println( "LoadDocumentOperation: MessageDialog.openInformation: Holding watchdog timer counter while dialog is displayed."); //Folgendes gehrt zur MessageDialog.openConfirm() Variante: //System.out.println("LoadDocumentOperation: Operator question: Shall internalThread be destroyed?"); //System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); //System.out.println("WARNING: We shouldn't use internalthread.suspend, resume, stop, destroy... etc. for good reasons."); //System.out.println("WARNING: Please read the notes in the java online documentation for these methods! 201210210913js"); //System.out.println("WARNING: Specifically, using internalThread.suspend() does NOT let the SWTHelper GUI Thread run anyway..."); //System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); //201210210850js //SWTHelper.askYesNo() wrde das Asynchron machen wollen - und mit allem hier laufenden steckenbleiben. //Also nehme ich den Dialog-Code von dort direkt hierher. Fr Shell, MessageDialogs, Desk kommen oben drei imports hinzu. //Desk.getDisplay(); //Shell shell = Desk.getTopShell(); //if (MessageDialog.openConfirm(shell, "Warning:", //internalThread.suspend(); //if (SWTHelper.askYesNo("Warning:", //if (MessageDialog.openConfirm(null, "Warning:", MessageDialog.openInformation(null, "Hinweis", "NOAText: LoadDocumentOperation:\n\n" + "Das Laden des Dokuments dauert schon lnger als " + cyclesWatchdogMaximumAllowedHalfSecs / 2 + " sec.\n" + "Dies kann folgende Ursachen haben:\n\n" + "(a) Das Starten des Office-Pakets und der Abruf des Dokuments aus der\n" + //<- in den Dialog zur Besttigung des watchdog:destroy() als Hinweis schreiben! " Datenbank dauern einfach so lang, ohne irgendeine Fehlfunktion.\n\n" + " Auf Wunsch kann ich den Grenzwert des Watchdog Timers erhhen.\n\n" + "(b) LibreOffice kann zum ffnen von Dokumenten mit vielen Objekten\n" + //<- in den Dialog zur Besttigung des watchdog:destroy() als Hinweis schreiben! " mehrere Minuten bentigen - das ist keine Fehlfunktion in Elexis.\n\n" + //" Das Problem wird reproduzierbar sichtbar mit meiner experimentellen\n"+ //" Vorlage zur Dokumentation einer krperlichen Untersuchung auf.\n\n"+ " Die Wartezeit tritt auch auf, wenn man solche Dokumente ausserhalb\n" + " von Elexis ffnet. Im Task-Manager sieht man, dass soffice.bin\n" + " arbeitet, und der scheinbare Stillstand endet von selbst.\n\n" + //" Allerdings dauert dies z.B. auf einem i7 Q720 schon 5 Minuten.\n\n"+ " Dies kann allerdings - je nach Dokument - mehrere Minuten dauern.\n\n" + " Falls Sie dieses Problem beobachten, sollten Sie bevorzugt\n" + " ApacheOpenOffice verwenden. Dieses ffnet solche Dokumente\n" + " offenbar ohne grssere Verzgerung.\n\n" + //" Selbst wenn man eine Unterbrechung auslst, lsst sich\n"+ //" diese Wartezeit *nicht* verkrzen.\n\n"+ //" In Folge der versuchten Unterbrechung wird aber das geladene\n"+ //" Dokument fr Elexis nicht ansprechbar sein. Dann erscheinen\n"+ //" mehrere Fehlermeldungen, und die Platzhalter im Dokument\n"+ //" werden nicht mit Werten aus Elexis gefllt.\n\n"+ "(c) In OpenOffice/LibreOffice abgedockte Toolbars oder Dialoge\n" + " knnen das ffnen eines Dokuments aus Elexis heraus zum Stillstand\n" + " bringen. Auch beliebig langes Warten wrde hier *nicht* helfen.\n\n" + " Mit der Anzeige dieses Dialogs wird der Stillstand jedoch behoben.\n" + " Ausserdem werden in OpenOffice/LibreOffice abgedockte Toolbars\n" + " mglichst automatisch gedockt. Beim nchsten Aufruf eines Dokuments\n" + " knnte der Auslser des Fehlers also schon verschwunden sein.\n\n" + "Falls Sie diese Fehlermeldung hufiger sehen, wre ich Ihnen fr\n" + "Informationen zu den nheren Umstnden dankbar: joerg.sigle@jsigle.com\n\n" //Folgendes gehrt zru If MessageDialog.openInformation() Variante: ); System.out.println( "LoadDocumentOperation: MessageDialog.openInformation: Resetting watchdog timer counter."); cyclesWaitedForInternalThreadToComplete = 0; //let the watchdog timer start again // //Folgendes gehrt zur If MessageDialog.openConfirm(...) Variante: // //+"Mchten Sie eine fr Situation (a) gedachte Unterbrechung jetzt auslsen?")) { // // //internalThread.resume(); // //201210210822 - If the user has decided to not destroy, and the process goes on for another watchdog maximum period, he will be asked again. // System.out.println("LoadDocumentOperation: Operator response: Shall internalThread be destroyed? NO."); // System.out.println("LoadDocumentOperation: WARNING: Restarting watchdog timer."); // cyclesWaitedForInternalThreadToComplete=0; //let the watchdog timer start again // } // else { // //internalThread.resume(); // System.out.println("LoadDocumentOperation: Operator response: Shall internalThread be destroyed? YES."); // System.out.println("LoadDocumentOperation: ERROR: internalThread timed out; will now be destroyed."); // System.out.println("WARNING: This functionality should NOT be used except for debugging - see intenalThread.destroy() help ."); // System.out.println("WARNING: Destroying the internalThread is not guaranteed to return Elexis into a responsive state."); // System.out.println("WARNING: Neither can we guarantee that the document that was about to be opened will appear correctly."); // System.out.println("WARNING: That said, however, it DID succeed in some tests (4/5), and made the desired document"); // System.out.println("WARNING: appear with LibreOffice in its desired frame, and even the problematic floating dialog windows"); // System.out.println("WARNING: in addition to that - for either the table properties, or the externally opened F11 Formatvorlagen."); // System.out.println("WARNING: 201202252133js"); // System.out.println("WARNING: For the example of the Status by JS and LibreOffice, however, the waiting will continue"); // System.out.println("WARNING: for almost 5 minutes on i7 720QM (!) with LibreOffice 3.6.2.2, and thereafter, doc==nul"); // System.out.println("WARNING: whereupon findOrReplace() will fail, placeholders will not be filled with data,"); // System.out.println("WARNING: and later on the document may not be saved (?), or the system will still stop after some occurences."); // System.out.println("WARNING: 201210210807js"); // internalThread.destroy(); //this makes progressMonitor detect the end of the thread at least, // //but it is deprecated and very error prone. So this should NOT be used except for debugging. // // internalThread.stop(); //this does not stop progressMonitor from cycling on and on. // // //201210210822 - If we send a destroy while an attempt to open Status Vorlage w/ LibreOffice, // //the thread will continue to require up to 5 mins anyway. Leaving cyclesWaited... at -1 would not show the dialog again, // //putting it back to 0 will show it again. Well, it will probably not make things better if used, but keep the user informed at least. // cyclesWaitedForInternalThreadToComplete=0; //let the watchdog timer start again // Thread.sleep(500); //Nach dem destroy des anderen Threads lasse ich hier noch eine halbe Sekunde Zeit. // } } } System.out.println( "LoadDocumentOperation: run 3 TO DO / WARNING: REMOVED Thread.sleep(3000) here - but comment in code says that this might cause OOo 3.x to crash"); // sleep here for a while otherwise OOo 3.x might crash //Thread.sleep(3000); System.out.println("LoadDocumentOperation: run 4 sleep ends"); if (!isSubTask) progressMonitor.done(); System.out.println("LoadDocumentOperation: run 5 done"); }
From source file:aktie.gui.CocoaUIEnhancer.java
License:Open Source License
private static void showAbout() { MessageDialog.openInformation(null, "About...", "Replace with a proper about text / dialog"); // delegate.runCommand(ActionFactory.ABOUT.getCommandId()); }
From source file:al.gov.asp.smc.e4.linkapp.handlers.AboutHandler.java
License:Open Source License
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) { MessageDialog.openInformation(shell, "About", iPublic.getPersons().toString()); }
From source file:alma.acs.alarmsystemprofiler.handlers.AboutHandler.java
License:Open Source License
@Execute public void execute(Shell shell) { MessageDialog.openInformation(shell, "About", "Eclipse 4 Application example."); }
From source file:alma.acs.eventbrowser.handlers.PreferencesHandler.java
License:Open Source License
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) { MessageDialog.openInformation(shell, "TODO: Preferences", "Eclipse 4 Application example."); }
From source file:amltransformation.composites.InternalTreeTableComposite.java
License:Open Source License
/** * Adds to the tree a context menu for showing and * setting images for its elements. The menu is shown only *//*from w w w. ja v a 2s . co m*/ private void addContextMenu() { MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @SuppressWarnings("unchecked") public void menuAboutToShow(IMenuManager manager) { if (viewer.getSelection().isEmpty()) { return; } if (((IStructuredSelection) viewer.getSelection()).getFirstElement() instanceof Hierarchy<?>) { final Hierarchy<InternalElement> selection = (Hierarchy<InternalElement>) ((IStructuredSelection) viewer .getSelection()).getFirstElement(); manager.add(new Action() { @Override public String getText() { return "Assign for current element"; } @Override public void run() { if (selection instanceof Hierarchy<?>) { Role role = selection.getElement().getRequiredRole(); if (role != null) { Class<? extends ITransformable> trans = AMLTransformationService .getTransformationProvider().getTransformationRepo() .getInterfaceTransformablesMapping().get(role); if (trans != null) { SetElementTransformableDialog dialog = new SetElementTransformableDialog( getShell(), trans); dialog.open(); if (dialog.getReturnCode() != SelectionDialog.CANCEL) { AMLTransformationService.getTransformationProvider() .putElementTransformable(selection.getElement(), (Class<? extends ITransformable>) dialog .getSelectedTransformable()); viewer.refresh(); } } else { MessageDialog.openInformation(getShell(), "Unassigned Role", role.getName() + " has to be assigned to a transformable first!"); } } else { MessageDialog.openInformation(getShell(), "No Role", selection.getName() + " has no role!"); } } } }); manager.add(new Action() { @Override public String getText() { return "Assign for current element and children"; } @Override public void run() { if (selection instanceof Hierarchy<?>) { Role role = selection.getElement().getRequiredRole(); if (role != null) { Class<? extends ITransformable> trans = AMLTransformationService .getTransformationProvider().getTransformationRepo() .getInterfaceTransformablesMapping().get(role); if (trans != null) { SetElementTransformableDialog dialog = new SetElementTransformableDialog( getShell(), trans); dialog.open(); if (dialog.getReturnCode() != SelectionDialog.CANCEL) { Class<? extends ITransformable> selectedTransformable = (Class<? extends ITransformable>) dialog .getSelectedTransformable(); AMLTransformationService.getTransformationProvider() .putElementTransformable(selection.getElement(), selectedTransformable); List<Hierarchy<InternalElement>> children = getFlattenedHierarchyChildren( selection); for (Hierarchy<?> child : children) { Class<? extends ITransformable> childTrans = AMLTransformationService .getTransformationProvider().getTransformationRepo() .getInterfaceTransformablesMapping() .get(((InternalElement) child.getElement()) .getRequiredRole()); if (selection.getElement().getClass() .isAssignableFrom(child.getElement().getClass()) && TransformationUtil .getAllModelsImplementingTransformable(childTrans) .contains(selectedTransformable)) { AMLTransformationService.getTransformationProvider() .putElementTransformable( (InternalElement) child.getElement(), selectedTransformable); } } viewer.refresh(); } } else { MessageDialog.openInformation(getShell(), "Unassigned Role", role.getName() + " has to be assigned to a transformable first!"); } } else { MessageDialog.openInformation(getShell(), "No Role", selection.getName() + " has no role!"); } } } }); manager.add(new Separator()); manager.add(new Action() { @Override public String getText() { return "Assign automatically"; } @Override public void run() { List<Hierarchy<InternalElement>> allHierarchies = AMLTransformationService .getAMLProvider().getAMLModelRepo(InternalElement.class) .getFlattenedHierarchies(); for (Hierarchy<InternalElement> hie : allHierarchies) { String name = hie.getName().toLowerCase(); if (!name.contains("dummy")) { Role role = ((InternalElement) hie.getElement()).getRequiredRole(); if (role != null) { Class<? extends ITransformable> trans = AMLTransformationService .getTransformationProvider().getTransformationRepo() .getInterfaceTransformablesMapping().get(role); if (trans != null) { Set<Class<?>> transformables = TransformationUtil .getAllModelsImplementingTransformable(trans); if (transformables.size() == 1) { AMLTransformationService.getTransformationProvider() .putElementTransformable((InternalElement) hie.getElement(), (Class<? extends ITransformable>) transformables .iterator().next()); } viewer.refresh(); } } } } } }); manager.add(new Separator()); manager.add(new Action() { @Override public String getText() { return "Unassign"; } @Override public void run() { if (selection instanceof Hierarchy<?>) { AMLTransformationService.getTransformationProvider().getTransformationRepo() .getAdapterTransformablesMapping().remove(selection.getElement()); viewer.refresh(); } } }); manager.add(new Action() { @Override public String getText() { return "Unassign all"; } @Override public void run() { AMLTransformationService.getTransformationProvider().getTransformationRepo() .getAdapterTransformablesMapping().clear(); viewer.refresh(); } }); } } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); }
From source file:anylinklicense.views.LicenseView.java
License:Open Source License
private void showMessage(String message) { MessageDialog.openInformation(viewer.getControl().getShell(), "", message); }
From source file:application.e4.handlers.AboutHandler.java
License:Open Source License
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) { MessageDialog.openInformation(shell, "About", "e4 Application example."); }
From source file:ar.com.tadp.xml.rinzo.core.refactors.rename.RenameTagAction.java
License:Open Source License
private void refuse() { String title = "Refuse Refactor"; String message = "Cannot apply this refactor in this file"; MessageDialog.openInformation(getShell(), title, message); }