Source Code Cross Referenced for WindowImagesSection.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » product » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.editor.product 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 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.pde.internal.ui.editor.product;
011:
012:        import org.eclipse.core.resources.IFile;
013:        import org.eclipse.jface.window.Window;
014:        import org.eclipse.pde.core.IModelChangedEvent;
015:        import org.eclipse.pde.internal.core.iproduct.IProduct;
016:        import org.eclipse.pde.internal.core.iproduct.IProductModel;
017:        import org.eclipse.pde.internal.core.iproduct.IWindowImages;
018:        import org.eclipse.pde.internal.ui.PDEPlugin;
019:        import org.eclipse.pde.internal.ui.PDEUIMessages;
020:        import org.eclipse.pde.internal.ui.editor.EditorUtilities;
021:        import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
022:        import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
023:        import org.eclipse.pde.internal.ui.editor.PDEFormPage;
024:        import org.eclipse.pde.internal.ui.editor.PDESection;
025:        import org.eclipse.pde.internal.ui.editor.validation.TextValidator;
026:        import org.eclipse.pde.internal.ui.parts.FormEntry;
027:        import org.eclipse.pde.internal.ui.util.FileExtensionFilter;
028:        import org.eclipse.pde.internal.ui.util.FileValidator;
029:        import org.eclipse.swt.dnd.Clipboard;
030:        import org.eclipse.swt.layout.GridData;
031:        import org.eclipse.swt.widgets.Composite;
032:        import org.eclipse.swt.widgets.Control;
033:        import org.eclipse.swt.widgets.Display;
034:        import org.eclipse.swt.widgets.Text;
035:        import org.eclipse.ui.IActionBars;
036:        import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
037:        import org.eclipse.ui.forms.events.HyperlinkEvent;
038:        import org.eclipse.ui.forms.widgets.FormToolkit;
039:        import org.eclipse.ui.forms.widgets.Section;
040:        import org.eclipse.ui.model.WorkbenchContentProvider;
041:        import org.eclipse.ui.model.WorkbenchLabelProvider;
042:
043:        public class WindowImagesSection extends PDESection {
044:
045:            private TextValidator[] fWinImageEntryValidator;
046:
047:            private static final int[][] F_ICON_DIMENSIONS = new int[][] {
048:                    { 16, 16 }, { 32, 32 }, { 48, 48 }, { 64, 64 },
049:                    { 128, 128 } };
050:            private static final String[] F_ICON_LABELS = new String[] {
051:                    PDEUIMessages.WindowImagesSection_16,
052:                    PDEUIMessages.WindowImagesSection_32,
053:                    PDEUIMessages.WindowImagesSection_48,
054:                    PDEUIMessages.WindowImagesSection_64,
055:                    PDEUIMessages.WindowImagesSection_128 };
056:            private FormEntry[] fImages = new FormEntry[F_ICON_LABELS.length];
057:
058:            public WindowImagesSection(PDEFormPage page, Composite parent) {
059:                super (page, parent, Section.DESCRIPTION);
060:                createClient(getSection(), page.getEditor().getToolkit());
061:            }
062:
063:            /* (non-Javadoc)
064:             * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
065:             */
066:            protected void createClient(Section section, FormToolkit toolkit) {
067:                section.setLayout(FormLayoutFactory.createClearGridLayout(
068:                        false, 1));
069:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
070:                section.setLayoutData(data);
071:
072:                section.setText(PDEUIMessages.WindowImagesSection_title);
073:                section.setDescription(PDEUIMessages.WindowImagesSection_desc);
074:
075:                Composite client = toolkit.createComposite(section);
076:                client.setLayout(FormLayoutFactory
077:                        .createSectionClientGridLayout(false, 3));
078:                client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
079:
080:                IActionBars actionBars = getPage().getPDEEditor()
081:                        .getEditorSite().getActionBars();
082:                // Store all image entry validators
083:                fWinImageEntryValidator = new TextValidator[F_ICON_LABELS.length];
084:                for (int i = 0; i < fImages.length; i++) {
085:                    final int index = i;
086:                    fImages[index] = new FormEntry(client, toolkit,
087:                            F_ICON_LABELS[index],
088:                            PDEUIMessages.WindowImagesSection_browse,
089:                            isEditable());
090:                    fImages[index].setEditable(isEditable());
091:                    // Create validator
092:                    fWinImageEntryValidator[index] = new TextValidator(
093:                            getManagedForm(), fImages[index].getText(),
094:                            getProject(), true) {
095:                        protected boolean validateControl() {
096:                            return validateWinImageEntry(index);
097:                        }
098:                    };
099:                    fImages[index].setFormEntryListener(new FormEntryAdapter(
100:                            this , actionBars) {
101:                        public void textValueChanged(FormEntry entry) {
102:                            getWindowImages().setImagePath(entry.getValue(),
103:                                    index);
104:                        }
105:
106:                        public void browseButtonSelected(FormEntry entry) {
107:                            handleBrowse(entry);
108:                        }
109:
110:                        public void linkActivated(HyperlinkEvent e) {
111:                            EditorUtilities.openImage(
112:                                    fImages[index].getValue(), getProduct()
113:                                            .getDefiningPluginId());
114:                        }
115:                    });
116:                }
117:
118:                toolkit.paintBordersFor(client);
119:                section.setClient(client);
120:                // Register to be notified when the model changes
121:                getModel().addModelChangedListener(this );
122:            }
123:
124:            public void refresh() {
125:                IWindowImages images = getWindowImages();
126:                // Turn off auto message update until after values are set
127:                fWinImageEntryValidator[0].setRefresh(false);
128:                for (int i = 0; i < F_ICON_LABELS.length; i++) {
129:                    fImages[i].setValue(images.getImagePath(i), true);
130:                }
131:                // Turn back on auto message update
132:                fWinImageEntryValidator[0].setRefresh(true);
133:                super .refresh();
134:            }
135:
136:            /**
137:             * @return
138:             */
139:            private boolean validateWinImageEntry(int index) {
140:                return EditorUtilities.imageEntryHasExactSize(
141:                        fWinImageEntryValidator[index], fImages[index],
142:                        getProduct(), F_ICON_DIMENSIONS[index][0],
143:                        F_ICON_DIMENSIONS[index][1]);
144:            }
145:
146:            private IWindowImages getWindowImages() {
147:                IWindowImages images = getProduct().getWindowImages();
148:                if (images == null) {
149:                    images = getModel().getFactory().createWindowImages();
150:                    getProduct().setWindowImages(images);
151:                }
152:                return images;
153:            }
154:
155:            private IProduct getProduct() {
156:                return getModel().getProduct();
157:            }
158:
159:            private IProductModel getModel() {
160:                return (IProductModel) getPage().getPDEEditor()
161:                        .getAggregateModel();
162:            }
163:
164:            public void commit(boolean onSave) {
165:                for (int i = 0; i < F_ICON_LABELS.length; i++) {
166:                    fImages[i].commit();
167:                }
168:                super .commit(onSave);
169:            }
170:
171:            public void cancelEdit() {
172:                for (int i = 0; i < F_ICON_LABELS.length; i++) {
173:                    fImages[i].cancelEdit();
174:                }
175:                super .cancelEdit();
176:            }
177:
178:            private void handleBrowse(FormEntry entry) {
179:                ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
180:                        getSection().getShell(), new WorkbenchLabelProvider(),
181:                        new WorkbenchContentProvider());
182:
183:                dialog.setValidator(new FileValidator());
184:                dialog.setAllowMultiple(false);
185:                dialog.setTitle(PDEUIMessages.WindowImagesSection_dialogTitle);
186:                dialog
187:                        .setMessage(PDEUIMessages.WindowImagesSection_dialogMessage);
188:                dialog.addFilter(new FileExtensionFilter("gif")); //$NON-NLS-1$
189:                dialog.setInput(PDEPlugin.getWorkspace().getRoot());
190:
191:                if (dialog.open() == Window.OK) {
192:                    IFile file = (IFile) dialog.getFirstResult();
193:                    entry.setValue(file.getFullPath().toString());
194:                }
195:            }
196:
197:            public boolean canPaste(Clipboard clipboard) {
198:                Display d = getSection().getDisplay();
199:                Control c = d.getFocusControl();
200:                if (c instanceof  Text)
201:                    return true;
202:                return false;
203:            }
204:
205:            /* (non-Javadoc)
206:             * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
207:             */
208:            public void modelChanged(IModelChangedEvent e) {
209:                // No need to call super, handling world changed event here
210:                if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
211:                    handleModelEventWorldChanged(e);
212:                }
213:            }
214:
215:            /**
216:             * @param event
217:             */
218:            private void handleModelEventWorldChanged(IModelChangedEvent event) {
219:                refresh();
220:            }
221:
222:            /* (non-Javadoc)
223:             * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
224:             */
225:            public void dispose() {
226:                IProductModel model = getModel();
227:                if (model != null) {
228:                    model.removeModelChangedListener(this);
229:                }
230:                super.dispose();
231:            }
232:        }
w__w___w___.__j___ava___2__s_.__c_o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.