Source Code Cross Referenced for ChangeExceptionHandler.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » refactoring » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.internal.ui.refactoring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.ui.refactoring;
011:
012:        import java.lang.reflect.InvocationTargetException;
013:
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.layout.GridData;
016:        import org.eclipse.swt.widgets.Button;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.swt.widgets.Label;
020:        import org.eclipse.swt.widgets.Shell;
021:
022:        import org.eclipse.core.runtime.CoreException;
023:        import org.eclipse.core.runtime.IProgressMonitor;
024:        import org.eclipse.core.runtime.IStatus;
025:        import org.eclipse.core.runtime.ProgressMonitorWrapper;
026:        import org.eclipse.core.runtime.Status;
027:        import org.eclipse.core.runtime.SubProgressMonitor;
028:
029:        import org.eclipse.core.resources.IWorkspaceRunnable;
030:        import org.eclipse.core.resources.ResourcesPlugin;
031:
032:        import org.eclipse.ltk.core.refactoring.Change;
033:        import org.eclipse.ltk.core.refactoring.CompositeChange;
034:        import org.eclipse.ltk.core.refactoring.Refactoring;
035:        import org.eclipse.jface.dialogs.ErrorDialog;
036:        import org.eclipse.jface.dialogs.IDialogConstants;
037:        import org.eclipse.jface.dialogs.ProgressMonitorDialog;
038:
039:        import org.eclipse.jdt.internal.corext.util.Messages;
040:
041:        import org.eclipse.jdt.internal.ui.JavaPlugin;
042:        import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
043:        import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
044:
045:        /**
046:         * Copy of org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler
047:         *
048:         */
049:        public class ChangeExceptionHandler {
050:
051:            public static class NotCancelableProgressMonitor extends
052:                    ProgressMonitorWrapper {
053:                public NotCancelableProgressMonitor(IProgressMonitor monitor) {
054:                    super (monitor);
055:                }
056:
057:                public void setCanceled(boolean b) {
058:                    // ignore set cancel
059:                }
060:
061:                public boolean isCanceled() {
062:                    return false;
063:                }
064:            }
065:
066:            private Shell fParent;
067:            private String fName;
068:
069:            private static class RefactorErrorDialog extends ErrorDialog {
070:                public RefactorErrorDialog(Shell parentShell,
071:                        String dialogTitle, String dialogMessage,
072:                        IStatus status, int displayMask) {
073:                    super (parentShell, dialogTitle, dialogMessage, status,
074:                            displayMask);
075:                }
076:
077:                protected void createButtonsForButtonBar(Composite parent) {
078:                    super .createButtonsForButtonBar(parent);
079:                    Button ok = getButton(IDialogConstants.OK_ID);
080:                    ok
081:                            .setText(RefactoringMessages.ChangeExceptionHandler_undo_button);
082:                    Button abort = createButton(
083:                            parent,
084:                            IDialogConstants.CANCEL_ID,
085:                            RefactoringMessages.ChangeExceptionHandler_abort_button,
086:                            true);
087:                    abort.moveBelow(ok);
088:                    abort.setFocus();
089:                }
090:
091:                protected Control createMessageArea(Composite parent) {
092:                    Control result = super .createMessageArea(parent);
093:                    new Label(parent, SWT.NONE); // filler
094:                    Label label = new Label(parent, SWT.NONE);
095:                    label
096:                            .setText(RefactoringMessages.ChangeExceptionHandler_message);
097:                    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
098:                    applyDialogFont(result);
099:                    return result;
100:                }
101:            }
102:
103:            public ChangeExceptionHandler(Shell parent, Refactoring refactoring) {
104:                fParent = parent;
105:                fName = refactoring.getName();
106:            }
107:
108:            public void handle(Change change, RuntimeException exception) {
109:                JavaPlugin.log(exception);
110:                IStatus status = null;
111:                if (exception.getMessage() == null) {
112:                    status = new Status(
113:                            IStatus.ERROR,
114:                            JavaPlugin.getPluginId(),
115:                            IStatus.ERROR,
116:                            RefactoringMessages.ChangeExceptionHandler_status_without_detail,
117:                            exception);
118:                } else {
119:                    status = new Status(IStatus.ERROR,
120:                            JavaPlugin.getPluginId(), IStatus.ERROR, exception
121:                                    .getMessage(), exception);
122:                }
123:                handle(change, status);
124:            }
125:
126:            public void handle(Change change, CoreException exception) {
127:                JavaPlugin.log(exception);
128:                handle(change, exception.getStatus());
129:            }
130:
131:            private void handle(Change change, IStatus status) {
132:                if (change instanceof  CompositeChange) {
133:                    Change undo = ((CompositeChange) change)
134:                            .getUndoUntilException();
135:                    if (undo != null) {
136:                        JavaPlugin.log(status);
137:                        final ErrorDialog dialog = new RefactorErrorDialog(
138:                                fParent,
139:                                RefactoringMessages.ChangeExceptionHandler_dialog_title,
140:                                Messages
141:                                        .format(
142:                                                RefactoringMessages.ChangeExceptionHandler_dialog_message,
143:                                                fName), status, IStatus.OK
144:                                        | IStatus.INFO | IStatus.WARNING
145:                                        | IStatus.ERROR);
146:                        int result = dialog.open();
147:                        if (result == IDialogConstants.OK_ID) {
148:                            performUndo(undo);
149:                        }
150:                        return;
151:                    }
152:                }
153:                ErrorDialog dialog = new ErrorDialog(
154:                        fParent,
155:                        RefactoringMessages.ChangeExceptionHandler_dialog_title,
156:                        Messages
157:                                .format(
158:                                        RefactoringMessages.ChangeExceptionHandler_dialog_message,
159:                                        fName), status, IStatus.OK
160:                                | IStatus.INFO | IStatus.WARNING
161:                                | IStatus.ERROR);
162:                dialog.open();
163:            }
164:
165:            private void performUndo(final Change undo) {
166:                IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
167:                    public void run(IProgressMonitor monitor)
168:                            throws CoreException {
169:                        monitor.beginTask("", 11); //$NON-NLS-1$
170:                        try {
171:                            undo
172:                                    .initializeValidationData(new NotCancelableProgressMonitor(
173:                                            new SubProgressMonitor(monitor, 1)));
174:                            if (undo
175:                                    .isValid(new SubProgressMonitor(monitor, 1))
176:                                    .hasFatalError()) {
177:                                monitor.done();
178:                                return;
179:                            }
180:                            undo.perform(new SubProgressMonitor(monitor, 9));
181:                        } finally {
182:                            undo.dispose();
183:                        }
184:                    }
185:                };
186:                WorkbenchRunnableAdapter adapter = new WorkbenchRunnableAdapter(
187:                        runnable, ResourcesPlugin.getWorkspace().getRoot());
188:                ProgressMonitorDialog dialog = new ProgressMonitorDialog(
189:                        fParent);
190:                try {
191:                    dialog.run(false, false, adapter);
192:                } catch (InvocationTargetException e) {
193:                    ExceptionHandler
194:                            .handle(
195:                                    e,
196:                                    fParent,
197:                                    RefactoringMessages.ChangeExceptionHandler_undo_dialog_title,
198:                                    RefactoringMessages.ChangeExceptionHandler_undo_dialog_message
199:                                            + fName);
200:                } catch (InterruptedException e) {
201:                    // can't happen
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.