diff options
author | jonas | 2014-12-03 11:01:46 +0000 |
---|---|---|
committer | jonas | 2014-12-03 11:01:46 +0000 |
commit | cefbf79daf5814b142b950bd5947caf6c71acf8e (patch) | |
tree | 3a93e18affd53a31a9dbc52243fa8fa008eb96da /bundles | |
parent | 46e94e5bd34d29fcd79856605cb82d7bc08828da (diff) | |
download | org.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.tar.gz org.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.tar.xz org.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.zip |
Bug 444692 - Remove Warnings
Diffstat (limited to 'bundles')
24 files changed, 755 insertions, 649 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/E4ToolItemMenu.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/E4ToolItemMenu.java index 3dbba0f5..ca8c49c7 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/E4ToolItemMenu.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/E4ToolItemMenu.java @@ -6,13 +6,14 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - initial API and implementation *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; import java.util.ArrayList; import java.util.Collection; + import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.e4.core.commands.ECommandService; @@ -38,12 +39,12 @@ import org.eclipse.swt.widgets.ToolItem; public class E4ToolItemMenu { public static final String SEPARATOR = "~separator~"; //$NON-NLS-1$ - private IEclipseContext context; - private ArrayList<String> commandIds = new ArrayList<String>(); - private Menu menu; - private ECommandService commandService; - private EHandlerService handlerService; - private ToolItem toolItem; + private final IEclipseContext context; + private final ArrayList<String> commandIds = new ArrayList<String>(); + private final Menu menu; + private final ECommandService commandService; + private final EHandlerService handlerService; + private final ToolItem toolItem; public E4ToolItemMenu(final ToolBar parent, IEclipseContext context) { @@ -58,35 +59,35 @@ public class E4ToolItemMenu { @Override public void widgetSelected(SelectionEvent event) { // if (event.detail == SWT.ARROW) { - Rectangle rect = toolItem.getBounds(); + final Rectangle rect = toolItem.getBounds(); Point pt = new Point(rect.x, rect.y + rect.height); pt = parent.toDisplay(pt); menu.setLocation(pt.x, pt.y); menu.setVisible(true); - for (MenuItem mi : menu.getItems()) { + for (final MenuItem mi : menu.getItems()) { if (mi.getData() instanceof ParameterizedCommand) { - ParameterizedCommand cmd = (ParameterizedCommand) mi.getData(); + final ParameterizedCommand cmd = (ParameterizedCommand) mi.getData(); mi.setEnabled(handlerService.canExecute(cmd)); } } // } - }; + } }); } public void addCommands(Collection<String> commandIds) { this.commandIds.addAll(commandIds); - for (String id : commandIds) { + for (final String id : commandIds) { if (id.equals(SEPARATOR)) { new MenuItem(menu, SWT.SEPARATOR); } else { - ParameterizedCommand myCommand = commandService.createCommand(id, null); + final ParameterizedCommand myCommand = commandService.createCommand(id, null); if (myCommand != null) { final MenuItem item = new MenuItem(menu, SWT.PUSH); try { item.setText(myCommand.getName()); - } catch (NotDefinedException e1) { + } catch (final NotDefinedException e1) { item.setText(id); e1.printStackTrace(); } @@ -95,7 +96,7 @@ public class E4ToolItemMenu { @Override public void widgetSelected(SelectionEvent e) { - ParameterizedCommand cmd = (ParameterizedCommand) item.getData(); + final ParameterizedCommand cmd = (ParameterizedCommand) item.getData(); handlerService.executeHandler(cmd); } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeEditingSupport.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeEditingSupport.java index 097cb988..cb66d8d1 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeEditingSupport.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeEditingSupport.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555 + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; @@ -30,10 +30,10 @@ import org.eclipse.swt.SWT; // Restrictions: Only handles boolean and String types class EAttributeEditingSupport extends EditingSupport { - private String attName; - private TableViewer tableViewer; + private final String attName; + private final TableViewer tableViewer; private boolean wasNull; - private IEclipseContext context; + private final IEclipseContext context; static public enum ATT_TYPE { STRING, BOOLEAN, INTEGER, NOT_AN_ATTRIBUTE, OTHER; @@ -55,7 +55,8 @@ class EAttributeEditingSupport extends EditingSupport { case INTEGER: default: if ("contributionURI".equals(attName)) { //$NON-NLS-1$ - return new ContributionUriCellEditor(tableViewer.getTable(), SWT.NONE, context, UriDialogType.BUNDLECLASS); + return new ContributionUriCellEditor(tableViewer.getTable(), SWT.NONE, context, + UriDialogType.BUNDLECLASS); } if ("iconURI".equals(attName)) { //$NON-NLS-1$ return new ContributionUriCellEditor(tableViewer.getTable(), SWT.NONE, context, UriDialogType.ICON); @@ -65,11 +66,11 @@ class EAttributeEditingSupport extends EditingSupport { } static public ATT_TYPE getAttributeType(Object element, String attName) { - EAttribute att = EmfUtil.getAttribute((EObject) element, attName); + final EAttribute att = EmfUtil.getAttribute((EObject) element, attName); if (att == null) { return ATT_TYPE.NOT_AN_ATTRIBUTE; } - String instanceTypeName = att.getEType().getInstanceTypeName(); + final String instanceTypeName = att.getEType().getInstanceTypeName(); if (instanceTypeName.equals(String.class.getName())) { return ATT_TYPE.STRING; } else if (instanceTypeName.equals(boolean.class.getName())) { @@ -83,26 +84,25 @@ class EAttributeEditingSupport extends EditingSupport { @Override protected boolean canEdit(Object element) { - EAttribute att = EmfUtil.getAttribute((EObject) element, attName); + final EAttribute att = EmfUtil.getAttribute((EObject) element, attName); if (att == null) { return false; + } + final String instanceTypeName = att.getEType().getInstanceTypeName(); + if (instanceTypeName.equals(String.class.getName())) { + return true; + } else if (instanceTypeName.equals(boolean.class.getName())) { + return true; + } else if (instanceTypeName.equals(int.class.getName())) { + return true; } else { - String instanceTypeName = att.getEType().getInstanceTypeName(); - if (instanceTypeName.equals(String.class.getName())) { - return true; - } else if (instanceTypeName.equals(boolean.class.getName())) { - return true; - } else if (instanceTypeName.equals(int.class.getName())) { - return true; - } else { - return false; - } + return false; } } @Override protected Object getValue(Object element) { - EObject eObject = (EObject) element; + final EObject eObject = (EObject) element; Object value = eObject.eGet(EmfUtil.getAttribute(eObject, attName)); switch (getAttributeType(element, attName)) { case BOOLEAN: @@ -131,7 +131,7 @@ class EAttributeEditingSupport extends EditingSupport { @Override protected void setValue(Object element, Object value) { - EObject eObject = (EObject) element; + final EObject eObject = (EObject) element; switch (getAttributeType(element, attName)) { case INTEGER: if (value.equals("")) { //$NON-NLS-1$ @@ -139,7 +139,7 @@ class EAttributeEditingSupport extends EditingSupport { } else { try { value = Integer.parseInt(value.toString()); - } catch (Exception e) { + } catch (final Exception e) { return; } } @@ -152,7 +152,8 @@ class EAttributeEditingSupport extends EditingSupport { } break; } - Command cmd = SetCommand.create(context.get(EditingDomain.class), eObject, EmfUtil.getAttribute(eObject, attName), value); + final Command cmd = SetCommand.create(context.get(EditingDomain.class), eObject, + EmfUtil.getAttribute(eObject, attName), value); context.get(EditingDomain.class).getCommandStack().execute(cmd); TableViewerUtil.updateAndPack(tableViewer, eObject); } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java index ef145a1f..f6850a30 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889 + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; @@ -37,7 +37,8 @@ public class EAttributeTableViewerColumn { private String attName; private TableViewer tvResults; - public EAttributeTableViewerColumn(final TableViewer tvResults, String label, final String attName, final IEclipseContext context) { + public EAttributeTableViewerColumn(final TableViewer tvResults, String label, final String attName, + final IEclipseContext context) { this.tvResults = tvResults; this.attName = attName; tableViewerColumn = new TableViewerColumn(tvResults, SWT.NONE); @@ -49,8 +50,8 @@ public class EAttributeTableViewerColumn { tableViewerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - EObject eObject = (EObject) element; - EAttribute eAtt = EmfUtil.getAttribute(eObject, attName); + final EObject eObject = (EObject) element; + final EAttribute eAtt = EmfUtil.getAttribute(eObject, attName); Object value; if (eAtt != null) { value = eObject.eGet(eAtt); @@ -60,7 +61,7 @@ public class EAttributeTableViewerColumn { switch (EAttributeEditingSupport.getAttributeType(element, attName)) { case BOOLEAN: // if no icons provided, use text instead of checkbox - return resourcePool == null && ((Boolean) value) ? "X" : ""; //$NON-NLS-1$ //$NON-NLS-2$ + return resourcePool == null && (Boolean) value ? "X" : ""; //$NON-NLS-1$ //$NON-NLS-2$ case STRING: case NOT_AN_ATTRIBUTE: case OTHER: @@ -74,12 +75,13 @@ public class EAttributeTableViewerColumn { switch (EAttributeEditingSupport.getAttributeType(element, attName)) { case BOOLEAN: if (resourcePool != null) { - Object value = EmfUtil.getAttributeValue((EObject) element, attName); + final Object value = EmfUtil.getAttributeValue((EObject) element, attName); if (value != null && value.equals(true)) { return resourcePool.getImageUnchecked(ResourceProvider.IMG_Widgets_checkbox_obj); } } // fall through + //$FALL-THROUGH$ case STRING: case NOT_AN_ATTRIBUTE: case OTHER: @@ -97,13 +99,12 @@ public class EAttributeTableViewerColumn { } public Color getBackground(Object element) { - EObject eObject = (EObject) element; - EAttribute eAtt = EmfUtil.getAttribute(eObject, attName); + final EObject eObject = (EObject) element; + final EAttribute eAtt = EmfUtil.getAttribute(eObject, attName); if (eAtt == null) { return tvResults.getTable().getDisplay().getSystemColor(SWT.COLOR_GRAY); - } else { - return null; } + return null; } public void dispose() { diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EmfUtil.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EmfUtil.java index ccbfe5a9..8287cde6 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EmfUtil.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EmfUtil.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Ongoing Maintenance + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Ongoing Maintenance *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; @@ -36,7 +36,7 @@ public class EmfUtil { } // return (EAttribute) // eObject.eGet(eObject.eClass().getEStructuralFeature(attName)); - for (EAttribute att : eObject.eClass().getEAllAttributes()) { + for (final EAttribute att : eObject.eClass().getEAllAttributes()) { if (attName.equals(att.getName())) { return att; } @@ -56,12 +56,11 @@ public class EmfUtil { * or has null as the value. */ static public Object getAttributeValue(EObject eObject, String attName) { - EAttribute att = getAttribute(eObject, attName); + final EAttribute att = getAttribute(eObject, attName); if (att == null) { return null; - } else { - return eObject.eGet(att); } + return eObject.eGet(att); } /** @@ -70,15 +69,13 @@ public class EmfUtil { * * @param eObject * @param attName - * @return * @throws Exception */ static public Object getAttributeValueThrows(EObject eObject, String attName) throws Exception { - EAttribute att = getAttribute(eObject, attName); + final EAttribute att = getAttribute(eObject, attName); if (att == null) { throw new Exception(Messages.EmfUtil_ex_attribute_not_found + " : " + attName); //$NON-NLS-1$ - } else { - return eObject.eGet(att); } + return eObject.eGet(att); } }
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java index 43b5a992..268d7342 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889, Bug 437372, Bug 440469, Ongoing Maintenance + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889, Bug 437372, Bug 440469, + * Ongoing Maintenance *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; @@ -22,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; + import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; @@ -36,6 +38,7 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; + import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.e4.core.contexts.IEclipseContext; @@ -175,13 +178,13 @@ public class ListTab implements IViewEObjects { // save custom column and filter settings public void saveSettings() { - IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(Plugin.ID); + final IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(Plugin.ID); try { - Document doc = DocUtil.createDocument("list-tab"); //$NON-NLS-1$ - Element cols = DocUtil.createChild(doc.getDocumentElement(), "columns"); //$NON-NLS-1$ + final Document doc = DocUtil.createDocument("list-tab"); //$NON-NLS-1$ + final Element cols = DocUtil.createChild(doc.getDocumentElement(), "columns"); //$NON-NLS-1$ final ArrayList<TableColumn> allCols = TableViewerUtil.getColumnsInDisplayOrder(tvResults); - for (TableColumn col : allCols) { + for (final TableColumn col : allCols) { String id; if (requiredColumns.containsValue(col)) { id = getKey(requiredColumns, col); @@ -191,35 +194,35 @@ public class ListTab implements IViewEObjects { saveColumn(cols, id, col); } - Element filters = DocUtil.createChild(doc.getDocumentElement(), "filters"); //$NON-NLS-1$ + final Element filters = DocUtil.createChild(doc.getDocumentElement(), "filters"); //$NON-NLS-1$ if (E.notEmpty(filterByAttrName)) { - Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$ + final Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$ DocUtil.createChild(filter, "type").setTextContent("attribute"); //$NON-NLS-1$//$NON-NLS-2$ DocUtil.createChild(filter, "condition").setTextContent(filterByAttrName); //$NON-NLS-1$ DocUtil.createChild(filter, "emptyOption").setTextContent(filterByAttrEmptyOption.name()); //$NON-NLS-1$ } if (E.notEmpty(filterByItemName)) { - Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$ + final Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$ DocUtil.createChild(filter, "type").setTextContent("item"); //$NON-NLS-1$ //$NON-NLS-2$ DocUtil.createChild(filter, "condition").setTextContent(filterByItemName); //$NON-NLS-1$ } pref.put("list-tab-xml", docToString(doc)); //$NON-NLS-1$ - } catch (ParserConfigurationException e1) { + } catch (final ParserConfigurationException e1) { e1.printStackTrace(); - } catch (TransformerException e) { + } catch (final TransformerException e) { e.printStackTrace(); } try { pref.flush(); - } catch (BackingStoreException e) { + } catch (final BackingStoreException e) { e.printStackTrace(); } } private String getKey(Map<String, ?> map, Object value) { - for (Entry<String, ?> entry : map.entrySet()) { + for (final Entry<String, ?> entry : map.entrySet()) { if (entry.getValue().equals(value)) { return entry.getKey(); } @@ -228,37 +231,38 @@ public class ListTab implements IViewEObjects { } private void saveColumn(Element eleCols, String columnName, TableColumn objCol) { - Element col = DocUtil.createChild(eleCols, "column"); //$NON-NLS-1$ + final Element col = DocUtil.createChild(eleCols, "column"); //$NON-NLS-1$ DocUtil.createChild(col, "attribute").setTextContent(columnName); //$NON-NLS-1$ - Integer width = objCol.getWidth(); + final Integer width = objCol.getWidth(); DocUtil.createChild(col, "width").setTextContent(width.toString()); //$NON-NLS-1$ } // load custom column and filter settings private void loadSettings() { - IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(Plugin.ID); + final IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(Plugin.ID); - boolean restoreColumns = pref.getBoolean(ModelEditorPreferences.LIST_TAB_REMEMBER_COLUMNS, false); - boolean restoreFilters = pref.getBoolean(ModelEditorPreferences.LIST_TAB_REMEMBER_FILTERS, false); + final boolean restoreColumns = pref.getBoolean(ModelEditorPreferences.LIST_TAB_REMEMBER_COLUMNS, false); + final boolean restoreFilters = pref.getBoolean(ModelEditorPreferences.LIST_TAB_REMEMBER_FILTERS, false); if (!restoreColumns && !restoreFilters) { return; } - String xml = pref.get("list-tab-xml", ""); //$NON-NLS-1$ //$NON-NLS-2$ + final String xml = pref.get("list-tab-xml", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (E.notEmpty(xml)) { try { - Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))); - XPath xpath = XPathFactory.newInstance().newXPath(); + final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new InputSource(new StringReader(xml))); + final XPath xpath = XPathFactory.newInstance().newXPath(); NodeList list; if (restoreColumns) { // restore columns and column widths list = (NodeList) xpath.evaluate("//columns/column", doc, XPathConstants.NODESET); //$NON-NLS-1$ for (int i = 0; i < list.getLength(); i++) { - Element ele = (Element) list.item(i); + final Element ele = (Element) list.item(i); TableColumn col; - String colName = xpath.evaluate("attribute/text()", ele); //$NON-NLS-1$ + final String colName = xpath.evaluate("attribute/text()", ele); //$NON-NLS-1$ if (colName.isEmpty()) { continue; } @@ -268,8 +272,8 @@ public class ListTab implements IViewEObjects { } // move it to the end of the list. - int currentIndex = TableViewerUtil.getVisibleColumnIndex(tvResults, col); - int[] order = tvResults.getTable().getColumnOrder(); + final int currentIndex = TableViewerUtil.getVisibleColumnIndex(tvResults, col); + final int[] order = tvResults.getTable().getColumnOrder(); for (int idx = 0; idx < order.length; idx++) { if (order[idx] > currentIndex) { order[idx]--; @@ -285,10 +289,10 @@ public class ListTab implements IViewEObjects { // col = colItem; // } - String sWidth = xpath.evaluate("width/text()", ele); //$NON-NLS-1$ + final String sWidth = xpath.evaluate("width/text()", ele); //$NON-NLS-1$ try { col.setWidth(Integer.parseInt(sWidth)); - } catch (Exception e) { + } catch (final Exception e) { } } } @@ -297,43 +301,43 @@ public class ListTab implements IViewEObjects { // restore filters list = (NodeList) xpath.evaluate("//filters/filter", doc, XPathConstants.NODESET); //$NON-NLS-1$ for (int i = 0; i < list.getLength(); i++) { - Element ele = (Element) list.item(i); - String type = xpath.evaluate("type/text()", ele); //$NON-NLS-1$ - String condition = xpath.evaluate("condition/text()", ele); //$NON-NLS-1$ - String emptyOption = xpath.evaluate("emptyOption/text()", ele); //$NON-NLS-1$ + final Element ele = (Element) list.item(i); + final String type = xpath.evaluate("type/text()", ele); //$NON-NLS-1$ + final String condition = xpath.evaluate("condition/text()", ele); //$NON-NLS-1$ + final String emptyOption = xpath.evaluate("emptyOption/text()", ele); //$NON-NLS-1$ if ("item".equals(type)) { //$NON-NLS-1$ filterByItem(condition); } else if ("attribute".equals(type)) { //$NON-NLS-1$ EmptyFilterOption emptyFilterOption; try { emptyFilterOption = EmptyFilterOption.valueOf(emptyOption); - } catch (Exception e) { + } catch (final Exception e) { emptyFilterOption = EmptyFilterOption.INCLUDE; } filterByAttribute(condition, emptyFilterOption); } } } - } catch (Exception e) { + } catch (final Exception e) { } } } // @Refactor static private String docToString(Document doc) throws TransformerException { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); + final TransformerFactory tf = TransformerFactory.newInstance(); + final Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ - StringWriter writer = new StringWriter(); + final StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); - String output = writer.getBuffer().toString().replaceAll("\n|\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ + final String output = writer.getBuffer().toString().replaceAll("\n|\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ return output; } // @Refactor static String join(Collection<String> items, String separator) { - StringBuilder sb = new StringBuilder(); - for (String item : items) { + final StringBuilder sb = new StringBuilder(); + for (final String item : items) { sb.append(item); sb.append(separator); } @@ -355,7 +359,7 @@ public class ListTab implements IViewEObjects { }); try { imgMarkedItem = imageCache.create(Plugin.ID, "/icons/full/obj16/mark_occurrences.png"); //$NON-NLS-1$ - } catch (Exception e2) { + } catch (final Exception e2) { e2.printStackTrace(); } @@ -374,7 +378,7 @@ public class ListTab implements IViewEObjects { tabItem = new CTabItem(tabFolder, SWT.NONE, 1); - Composite composite = new Composite(tabFolder, SWT.NONE); + final Composite composite = new Composite(tabFolder, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.setLayout(new GridLayout(2, false)); tabItem.setControl(composite); @@ -386,19 +390,19 @@ public class ListTab implements IViewEObjects { toolBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); { - ToolItem button = new ToolItem(toolBar, SWT.PUSH); + final ToolItem button = new ToolItem(toolBar, SWT.PUSH); button.setText(Messages.ListTab_addColumn + ELIPSIS); button.setImage(imageCache.create("/icons/full/obj16/add_column.gif")); //$NON-NLS-1$ button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - TitleAreaFilterDialogWithEmptyOptions dlg = createEObjectAttributePicker(Messages.ListTab_addColumn); + final TitleAreaFilterDialogWithEmptyOptions dlg = createEObjectAttributePicker(Messages.ListTab_addColumn); dlg.setShowEmptyOptions(false); if (dlg.open() == Window.OK) { // Add Column - String attName = dlg.getFirstElement().toString(); - EAttributeTableViewerColumn col = addColumn(attName); + final String attName = dlg.getFirstElement().toString(); + final EAttributeTableViewerColumn col = addColumn(attName); col.getTableViewerColumn().getColumn().pack(); tvResults.refresh(); } @@ -407,14 +411,14 @@ public class ListTab implements IViewEObjects { } { - ToolItem button = new ToolItem(toolBar, SWT.PUSH); + final ToolItem button = new ToolItem(toolBar, SWT.PUSH); button.setText(Messages.ListTab_resetColumns); button.setImage(imageCache.create("/icons/full/obj16/reset_columns.gif")); //$NON-NLS-1$ button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - for (EAttributeTableViewerColumn col : optionalColumns.values()) { + for (final EAttributeTableViewerColumn col : optionalColumns.values()) { col.dispose(); } optionalColumns.clear(); @@ -438,7 +442,7 @@ public class ListTab implements IViewEObjects { if (dlg.open() == Window.OK) { filterByItem(dlg.getFirstElement().toString()); } - }; + } }); } @@ -451,11 +455,11 @@ public class ListTab implements IViewEObjects { filterByAttribute.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - TitleAreaFilterDialogWithEmptyOptions dlg = createEObjectAttributePicker(Messages.ListTab_filterByAttribute); + final TitleAreaFilterDialogWithEmptyOptions dlg = createEObjectAttributePicker(Messages.ListTab_filterByAttribute); if (dlg.open() == Window.OK) { filterByAttribute(dlg.getFirstElement().toString(), dlg.getEmptyFilterOption()); } - }; + } }); } @@ -472,7 +476,7 @@ public class ListTab implements IViewEObjects { tvResults.setFilters(new ViewerFilter[0]); filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS); filterByAttribute.setText(Messages.ListTab_markAttribute + ELIPSIS); - }; + } }); } @@ -482,7 +486,7 @@ public class ListTab implements IViewEObjects { final E4ToolItemMenu tiCommands = new E4ToolItemMenu(toolBar, context); tiCommands.getToolItem().setImage(imageCache.create("/icons/full/obj16/command.gif")); //$NON-NLS-1$ - ArrayList<String> commandIds = new ArrayList<String>(); + final ArrayList<String> commandIds = new ArrayList<String>(); commandIds.add("org.eclipse.e4.tools.emf.ui.command.mark_duplicate_attributes"); //$NON-NLS-1$ commandIds.add("org.eclipse.e4.tools.emf.ui.command.mark_duplicate_ids"); //$NON-NLS-1$ commandIds.add("org.eclipse.e4.tools.emf.ui.command.mark_duplicate_labels"); //$NON-NLS-1$ @@ -530,12 +534,12 @@ public class ListTab implements IViewEObjects { @Override public String getText(Object element) { return ""; //$NON-NLS-1$ - }; + } @Override public Image getImage(Object element) { return imgXmi; - }; + } }); tvResults.getTable().addMouseListener(new MouseAdapter() { @@ -560,10 +564,8 @@ public class ListTab implements IViewEObjects { if (isHighlighted(element)) { try { ret = imgMarkedItem; - } catch (Exception e) { + } catch (final Exception e) { } - } else { - ret = null; } return ret; } @@ -580,17 +582,19 @@ public class ListTab implements IViewEObjects { colItem.setLabelProvider(new ColumnLabelProvider_Markable() { @Override public String getText(Object element) { - EObject eObject = (EObject) element; + final EObject eObject = (EObject) element; return super.getText(eObject.eClass().getName()); } }); app.getContext().set("org.eclipse.e4.tools.active-object-viewer", this); //$NON-NLS-1$ - EAttributeTableViewerColumn colId = new EAttributeTableViewerColumn(tvResults, "elementId", "elementId", context); //$NON-NLS-1$//$NON-NLS-2$ + final EAttributeTableViewerColumn colId = new EAttributeTableViewerColumn(tvResults, + "elementId", "elementId", context); //$NON-NLS-1$//$NON-NLS-2$ defaultColumns.put("elementId", colId); //$NON-NLS-1$ - EAttributeTableViewerColumn colLabel = new EAttributeTableViewerColumn_Markable(tvResults, "label", "label", context); //$NON-NLS-1$//$NON-NLS-2$ + final EAttributeTableViewerColumn colLabel = new EAttributeTableViewerColumn_Markable(tvResults, + "label", "label", context); //$NON-NLS-1$//$NON-NLS-2$ defaultColumns.put("label", colLabel); //$NON-NLS-1$ // Custom selection for marked items @@ -599,14 +603,16 @@ public class ListTab implements IViewEObjects { public void handleEvent(Event event) { event.detail &= ~SWT.HOT; if ((event.detail & SWT.SELECTED) == 0) + { return; // / item not selected + } - TableItem item = (TableItem) event.item; + final TableItem item = (TableItem) event.item; if (isHighlighted(item.getData())) { - Table table = (Table) event.widget; - int clientWidth = table.getClientArea().width; - GC gc = event.gc; + final Table table = (Table) event.widget; + final int clientWidth = table.getClientArea().width; + final GC gc = event.gc; // Color oldForeground = gc.getForeground(); // Color oldBackground = gc.getBackground(); @@ -626,19 +632,21 @@ public class ListTab implements IViewEObjects { for (final EAttributeTableViewerColumn col : defaultColumns.values()) { col.getTableViewerColumn().getColumn().setMoveable(true); } - for (TableColumn col : requiredColumns.values()) { + for (final TableColumn col : requiredColumns.values()) { col.setMoveable(true); } - makeSortable(colId.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colId.getTableViewerColumn().getColumn(), "elementId")); //$NON-NLS-1$ - makeSortable(colLabel.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colLabel.getTableViewerColumn().getColumn(), "label")); //$NON-NLS-1$ + makeSortable(colId.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colId + .getTableViewerColumn().getColumn(), "elementId")); //$NON-NLS-1$ + makeSortable(colLabel.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colLabel + .getTableViewerColumn().getColumn(), "label")); //$NON-NLS-1$ makeSortable(colItem.getColumn(), new TableViewerUtil.ColumnLabelSorter(colItem.getColumn())); makeSortable(colMarked.getColumn(), new TableViewerUtil.AbstractInvertableTableSorter() { @Override public int compare(Viewer viewer, Object e1, Object e2) { - boolean mark1 = isHighlighted(e1); - boolean mark2 = isHighlighted(e2); + final boolean mark1 = isHighlighted(e1); + final boolean mark2 = isHighlighted(e2); if (mark1 && !mark2) { return -1; } else if (mark2 && !mark1) { @@ -682,12 +690,12 @@ public class ListTab implements IViewEObjects { @Override public List<EObject> getAllEObjects() { - ArrayList<EObject> list = new ArrayList<EObject>(); - TreeIterator<Object> itTree = EcoreUtil.getAllContents(modelResource.getRoot()); + final ArrayList<EObject> list = new ArrayList<EObject>(); + final TreeIterator<Object> itTree = EcoreUtil.getAllContents(modelResource.getRoot()); while (itTree.hasNext()) { - Object object = itTree.next(); - EObject eObject = (EObject) object; - EAttribute att = EmfUtil.getAttribute(eObject, "elementId"); //$NON-NLS-1$ + final Object object = itTree.next(); + final EObject eObject = (EObject) object; + final EAttribute att = EmfUtil.getAttribute(eObject, "elementId"); //$NON-NLS-1$ if (att != null) { list.add(eObject); } @@ -697,8 +705,8 @@ public class ListTab implements IViewEObjects { @Override public Collection<EObject> getSelectedEObjects() { - ArrayList<EObject> selected = new ArrayList<EObject>(); - for (Object item : ((IStructuredSelection) tvResults.getSelection()).toList()) { + final ArrayList<EObject> selected = new ArrayList<EObject>(); + for (final Object item : ((IStructuredSelection) tvResults.getSelection()).toList()) { if (item instanceof EObject) { selected.add((EObject) item); @@ -710,7 +718,7 @@ public class ListTab implements IViewEObjects { @Override public void deleteEObjects(Collection<EObject> list) { if (list.isEmpty() == false) { - Command cmd = DeleteCommand.create(modelResource.getEditingDomain(), list); + final Command cmd = DeleteCommand.create(modelResource.getEditingDomain(), list); if (cmd.canExecute()) { modelResource.getEditingDomain().getCommandStack().execute(cmd); } @@ -721,9 +729,9 @@ public class ListTab implements IViewEObjects { private TitleAreaFilterDialogWithEmptyOptions createEObjectAttributePicker(final String title) { // Get Attribute Names final HashSet<String> set = new HashSet<String>(); - Collection<EObject> allEObjects = getAllEObjects(); - for (EObject obj : allEObjects) { - for (EAttribute attribute : obj.eClass().getEAllAttributes()) { + final Collection<EObject> allEObjects = getAllEObjects(); + for (final EObject obj : allEObjects) { + for (final EAttribute attribute : obj.eClass().getEAllAttributes()) { set.add(attribute.getName()); } } @@ -731,20 +739,21 @@ public class ListTab implements IViewEObjects { Collections.sort(sorted); // Select Attribute - ILabelProvider renderer = new LabelProvider() { + final ILabelProvider renderer = new LabelProvider() { @Override public String getText(Object element) { return String.valueOf(element); } }; - TitleAreaFilterDialogWithEmptyOptions dlg = new TitleAreaFilterDialogWithEmptyOptions(context.get(Shell.class), renderer) { + final TitleAreaFilterDialogWithEmptyOptions dlg = new TitleAreaFilterDialogWithEmptyOptions( + context.get(Shell.class), renderer) { @Override protected Control createContents(Composite parent) { - Control ret = super.createContents(parent); + final Control ret = super.createContents(parent); setMessage(Messages.ListTab_selectAnAttribute); try { setTitleImage(imageCache.create(Plugin.ID, "/icons/full/wizban/attribute_wiz.gif")); //$NON-NLS-1$ - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } setTitle(title); @@ -758,25 +767,25 @@ public class ListTab implements IViewEObjects { private TitleAreaFilterDialog createElementTypePicker(final String title) { // Get Attribute Names final HashSet<String> set = new HashSet<String>(); - Collection<EObject> allEObjects = getAllEObjects(); - for (EObject obj : allEObjects) { + final Collection<EObject> allEObjects = getAllEObjects(); + for (final EObject obj : allEObjects) { set.add(obj.eClass().getName()); } final ArrayList<String> sorted = new ArrayList<String>(set); Collections.sort(sorted); - ILabelProvider renderer = new LabelProvider() { + final ILabelProvider renderer = new LabelProvider() { @Override public String getText(Object element) { return String.valueOf(element); } }; - TitleAreaFilterDialog dlg = new TitleAreaFilterDialog(context.get(Shell.class), renderer) { + final TitleAreaFilterDialog dlg = new TitleAreaFilterDialog(context.get(Shell.class), renderer) { @Override protected Control createContents(Composite parent) { - Control ret = super.createContents(parent); + final Control ret = super.createContents(parent); setMessage(Messages.ListTab_selectAType); setTitle(title); setElements(sorted.toArray(new String[0])); @@ -800,7 +809,8 @@ public class ListTab implements IViewEObjects { colName = new EAttributeTableViewerColumn_Markable(tvResults, attName, attName, context); optionalColumns.put(attName, colName); colName.getTableViewerColumn().getColumn().setMoveable(true); - makeSortable(colName.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colName.getTableViewerColumn().getColumn(), attName)); + makeSortable(colName.getTableViewerColumn().getColumn(), new AttributeColumnLabelSorter(colName + .getTableViewerColumn().getColumn(), attName)); tvResults.refresh(); } } @@ -809,7 +819,7 @@ public class ListTab implements IViewEObjects { static private class AttributeColumnLabelSorter extends TableViewerUtil.ColumnLabelSorter { - private String attName; + private final String attName; AttributeColumnLabelSorter(TableColumn col, String attName) { super(col); @@ -819,26 +829,26 @@ public class ListTab implements IViewEObjects { @Override public int compare(Viewer viewer, Object e1, Object e2) { // if either is boolean, use boolean value, otherwise use text value - ATT_TYPE e1Type = EAttributeEditingSupport.getAttributeType(e1, attName); - ATT_TYPE e2Type = EAttributeEditingSupport.getAttributeType(e2, attName); + final ATT_TYPE e1Type = EAttributeEditingSupport.getAttributeType(e1, attName); + final ATT_TYPE e2Type = EAttributeEditingSupport.getAttributeType(e2, attName); if (e1Type == ATT_TYPE.BOOLEAN || e2Type == ATT_TYPE.BOOLEAN) { - Boolean b1 = (Boolean) (EmfUtil.getAttributeValue((EObject) e1, attName)); - Boolean b2 = (Boolean) (EmfUtil.getAttributeValue((EObject) e2, attName)); + final Boolean b1 = (Boolean) EmfUtil.getAttributeValue((EObject) e1, attName); + final Boolean b2 = (Boolean) EmfUtil.getAttributeValue((EObject) e2, attName); if (b1 == null && b2 != null) { return -2; } else if (b2 == null && b1 != null) { return 2; } else { - return (b1.compareTo(b2)); + return b1.compareTo(b2); } - } else { - return super.compare(viewer, e1, e2); } + return super.compare(viewer, e1, e2); } } private class EAttributeTableViewerColumn_Markable extends EAttributeTableViewerColumn { - public EAttributeTableViewerColumn_Markable(TableViewer tvResults, String label, String attName, IEclipseContext context) { + public EAttributeTableViewerColumn_Markable(TableViewer tvResults, String label, String attName, + IEclipseContext context) { super(tvResults, label, attName, context); } @@ -882,7 +892,7 @@ public class ListTab implements IViewEObjects { filterByAttrEmptyOption = null; mapId_Object.clear(); final ArrayList<EObject> filtered = new ArrayList<EObject>(); - for (EObject object : getAllEObjects()) { + for (final EObject object : getAllEObjects()) { if (object.eClass().getName().equals(filterByItemName)) { filtered.add(object); // filter.setText(Messages.ListTab_7 + @@ -890,7 +900,7 @@ public class ListTab implements IViewEObjects { } - ViewerFilter viewerFilter = new ViewerFilter() { + final ViewerFilter viewerFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { @@ -910,10 +920,10 @@ public class ListTab implements IViewEObjects { filterByItemName = null; mapId_Object.clear(); final ArrayList<EObject> filtered = new ArrayList<EObject>(); - for (EObject object : getAllEObjects()) { + for (final EObject object : getAllEObjects()) { if (EmfUtil.getAttribute(object, filterByAttrName) != null) { filtered.add(object); - ViewerFilter viewerFilter = new ViewerFilter() { + final ViewerFilter viewerFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { @@ -931,7 +941,7 @@ public class ListTab implements IViewEObjects { return filtered.contains(element); } case ONLY: - if (E.notEmpty((EmfUtil.getAttributeValue((EObject) element, filterByAttrName)))) { + if (E.notEmpty(EmfUtil.getAttributeValue((EObject) element, filterByAttrName))) { return false; } else { return true; @@ -952,13 +962,13 @@ public class ListTab implements IViewEObjects { } } - TableViewerColumn viewerColumn = addColumn(filterByAttrName).getTableViewerColumn(); + final TableViewerColumn viewerColumn = addColumn(filterByAttrName).getTableViewerColumn(); viewerColumn.getColumn().pack(); } @Override public void autosizeContent() { - for (TableColumn col : tvResults.getTable().getColumns()) { + for (final TableColumn col : tvResults.getTable().getColumns()) { col.pack(); if (col.getWidth() < 10) { col.setWidth(10); @@ -968,7 +978,7 @@ public class ListTab implements IViewEObjects { @Override public void resetToDefault() { - for (EAttributeTableViewerColumn col : optionalColumns.values()) { + for (final EAttributeTableViewerColumn col : optionalColumns.values()) { col.dispose(); } optionalColumns.clear(); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/empty/E.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/empty/E.java index 8f6a4cab..b667d444 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/empty/E.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/empty/E.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555 + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs.empty; @@ -35,11 +35,11 @@ public class E { } public static boolean isEmpty(String object) { - return (object == null || object.isEmpty()); + return object == null || object.isEmpty(); } public static boolean isEmpty(Collection<?> object) { - return (object == null || object.isEmpty()); + return object == null || object.isEmpty(); } public static boolean isEmpty(Object object) { @@ -65,9 +65,8 @@ public class E { if (obj1 == null) { if (obj2 == null) { return true; - } else { - return false; } + return false; } else if (obj2 == null) { return false; } else { @@ -88,9 +87,8 @@ public class E { if (obj1 == null) { if (obj2 == null) { return 0; - } else { - return -1; } + return -1; } else if (obj2 == null) { return 1; } else { diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VApplicationAddons.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VApplicationAddons.java index 2b6e1127..6c67aae0 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VApplicationAddons.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VApplicationAddons.java @@ -6,17 +6,19 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Tracy Miranda <tracymiranda@yahoo.com> - bugfix for 430663 - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Tracy Miranda <tracymiranda@yahoo.com> - bugfix for 430663 + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -47,7 +49,7 @@ public class VApplicationAddons extends AbstractComponentEditor { private TableViewer viewer; private EMFDataBindingContext context; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); @Inject public VApplicationAddons() { @@ -56,12 +58,13 @@ public class VApplicationAddons extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VApplicationAddons_AddAddon, createImageDescriptor(ResourceProvider.IMG_Addons)) { - @Override - public void run() { - handleAddAddon(); - } - }); + actions + .add(new Action(Messages.VApplicationAddons_AddAddon, createImageDescriptor(ResourceProvider.IMG_Addons)) { + @Override + public void run() { + handleAddAddon(); + } + }); } @Override @@ -90,27 +93,29 @@ public class VApplicationAddons extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, ApplicationPackageImpl.Literals.APPLICATION__ADDONS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + ApplicationPackageImpl.Literals.APPLICATION__ADDONS) { @Override protected void addPressed() { handleAddAddon(); - }; + } @Override protected List<?> getContainerChildren(Object container) { @@ -127,10 +132,11 @@ public class VApplicationAddons extends AbstractComponentEditor { } private void handleAddAddon() { - MAddon addon = MApplicationFactory.INSTANCE.createAddon(); + final MAddon addon = MApplicationFactory.INSTANCE.createAddon(); setElementId(addon); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), ApplicationPackageImpl.Literals.APPLICATION__ADDONS, addon); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + ApplicationPackageImpl.Literals.APPLICATION__ADDONS, addon); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -145,7 +151,7 @@ public class VApplicationAddons extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java index 226c656e..95d4ce8c 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.core.services.nls.Translation; @@ -52,9 +54,9 @@ public class VCommandEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private TableViewer viewer; - private EStructuralFeature commandsFeature; - private List<Action> actions = new ArrayList<Action>(); - private List<Action> actionsImport = new ArrayList<Action>(); + private final EStructuralFeature commandsFeature; + private final List<Action> actions = new ArrayList<Action>(); + private final List<Action> actionsImport = new ArrayList<Action>(); @Inject @Translation @@ -63,19 +65,21 @@ public class VCommandEditor extends AbstractComponentEditor { @Inject public VCommandEditor() { super(); - this.commandsFeature = ApplicationPackageImpl.Literals.APPLICATION__COMMANDS; + commandsFeature = ApplicationPackageImpl.Literals.APPLICATION__COMMANDS; } @PostConstruct void init() { - actions.add(new Action(Messages.VCommandEditor_AddCommand, createImageDescriptor(ResourceProvider.IMG_Command)) { - @Override - public void run() { - handleAdd(); - } - }); + actions + .add(new Action(Messages.VCommandEditor_AddCommand, createImageDescriptor(ResourceProvider.IMG_Command)) { + @Override + public void run() { + handleAdd(); + } + }); - actionsImport.add(new Action(Messages.VCommandEditor_ImportCommands, createImageDescriptor(ResourceProvider.IMG_Command)) { + actionsImport.add(new Action(Messages.VCommandEditor_ImportCommands, + createImageDescriptor(ResourceProvider.IMG_Command)) { @Override public void run() { handleImport(); @@ -109,27 +113,29 @@ public class VCommandEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, ApplicationPackageImpl.Literals.APPLICATION__COMMANDS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + ApplicationPackageImpl.Literals.APPLICATION__COMMANDS) { @Override protected void addPressed() { handleAdd(); - }; + } @Override protected List<?> getContainerChildren(Object container) { @@ -146,13 +152,13 @@ public class VCommandEditor extends AbstractComponentEditor { } protected void handleAdd() { - MCommand command = CommandsFactoryImpl.eINSTANCE.createCommand(); + final MCommand command = CommandsFactoryImpl.eINSTANCE.createCommand(); addCommand(command); } private void addCommand(MCommand command) { setElementId(command); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), commandsFeature, command); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), commandsFeature, command); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -161,11 +167,11 @@ public class VCommandEditor extends AbstractComponentEditor { } protected void handleImport() { - ModelImportWizard wizard = new ModelImportWizard(MCommand.class, this, resourcePool); - WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), wizard); + final ModelImportWizard wizard = new ModelImportWizard(MCommand.class, this, resourcePool); + final WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), wizard); if (wizardDialog.open() == Window.OK) { - MCommand[] elements = (MCommand[]) wizard.getElements(MCommand.class); - for (MCommand mCommand : elements) { + final MCommand[] elements = (MCommand[]) wizard.getElements(MCommand.class); + for (final MCommand mCommand : elements) { addCommand(mCommand); } } @@ -178,14 +184,14 @@ public class VCommandEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } @Override public List<Action> getActionsImport(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actionsImport); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VHandlerEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VHandlerEditor.java index 80c36738..97e6c338 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VHandlerEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VHandlerEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -48,8 +50,8 @@ public class VHandlerEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); - private List<Action> actionsImport = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); + private final List<Action> actionsImport = new ArrayList<Action>(); @Inject public VHandlerEditor() { @@ -58,15 +60,17 @@ public class VHandlerEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VHandlerEditor_AddHandler, createImageDescriptor(ResourceProvider.IMG_Handler)) { - @Override - public void run() { - handleAdd(); - } - }); + actions + .add(new Action(Messages.VHandlerEditor_AddHandler, createImageDescriptor(ResourceProvider.IMG_Handler)) { + @Override + public void run() { + handleAdd(); + } + }); // -- import -- - actionsImport.add(new Action(Messages.VHandlerEditor_AddHandler, createImageDescriptor(ResourceProvider.IMG_Handler)) { + actionsImport.add(new Action(Messages.VHandlerEditor_AddHandler, + createImageDescriptor(ResourceProvider.IMG_Handler)) { @Override public void run() { handleImport(); @@ -100,23 +104,25 @@ public class VHandlerEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS) { @Override protected void addPressed() { handleAdd(); @@ -126,9 +132,8 @@ public class VHandlerEditor extends AbstractComponentEditor { protected List<?> getContainerChildren(Object container) { if (container instanceof MHandlerContainer) { return ((MHandlerContainer) container).getHandlers(); - } else { - return null; } + return null; } }; pickList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); @@ -146,13 +151,14 @@ public class VHandlerEditor extends AbstractComponentEditor { } protected void handleAdd() { - MHandler handler = MCommandsFactory.INSTANCE.createHandler(); + final MHandler handler = MCommandsFactory.INSTANCE.createHandler(); addToModel(handler); } private void addToModel(MHandler handler) { setElementId(handler); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS, handler); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS, handler); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); getEditor().setSelection(handler); @@ -160,11 +166,11 @@ public class VHandlerEditor extends AbstractComponentEditor { } protected void handleImport() { - ModelImportWizard wizard = new ModelImportWizard(MHandler.class, this, resourcePool); - WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), wizard); + final ModelImportWizard wizard = new ModelImportWizard(MHandler.class, this, resourcePool); + final WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), wizard); if (wizardDialog.open() == Window.OK) { - MHandler[] elements = (MHandler[]) wizard.getElements(MHandler.class); - for (MHandler handler : elements) { + final MHandler[] elements = (MHandler[]) wizard.getElements(MHandler.class); + for (final MHandler handler : elements) { addToModel(handler); } } @@ -172,14 +178,14 @@ public class VHandlerEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } @Override public List<Action> getActionsImport(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActionsImport(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActionsImport(element)); l.addAll(actionsImport); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VItemParametersEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VItemParametersEditor.java index 1084fb64..f0ea6bba 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VItemParametersEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VItemParametersEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -47,9 +49,10 @@ public class VItemParametersEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); - private IEMFListProperty HANDLED_ITEM__PARAMETERS = EMFProperties.list(MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS); + private final IEMFListProperty HANDLED_ITEM__PARAMETERS = EMFProperties + .list(MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS); @Inject public VItemParametersEditor() { @@ -58,7 +61,8 @@ public class VItemParametersEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VItemParametersEditor_AddParameter, createImageDescriptor(ResourceProvider.IMG_Parameter)) { + actions.add(new Action(Messages.VItemParametersEditor_AddParameter, + createImageDescriptor(ResourceProvider.IMG_Parameter)) { @Override public void run() { handleAdd(); @@ -92,23 +96,25 @@ public class VItemParametersEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS) { @Override protected void addPressed() { handleAdd(); @@ -118,9 +124,8 @@ public class VItemParametersEditor extends AbstractComponentEditor { protected List<?> getContainerChildren(Object container) { if (container instanceof MHandledItem) { return ((MHandledItem) container).getParameters(); - } else { - return null; } + return null; } }; pickList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); @@ -138,10 +143,11 @@ public class VItemParametersEditor extends AbstractComponentEditor { } protected void handleAdd() { - MParameter handler = MCommandsFactory.INSTANCE.createParameter(); + final MParameter handler = MCommandsFactory.INSTANCE.createParameter(); setElementId(handler); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS, handler); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + MenuPackageImpl.Literals.HANDLED_ITEM__PARAMETERS, handler); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -151,7 +157,7 @@ public class VItemParametersEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java index 37f08309..46a7d539 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance, Bug 443945 + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance, Bug 443945 ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -45,7 +47,7 @@ public class VModelFragmentsEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); @Inject public VModelFragmentsEditor() { @@ -54,7 +56,8 @@ public class VModelFragmentsEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VModelFragmentsEditor_AddFragment, createImageDescriptor(ResourceProvider.IMG_ModelFragments)) { + actions.add(new Action(Messages.VModelFragmentsEditor_AddFragment, + createImageDescriptor(ResourceProvider.IMG_ModelFragments)) { @Override public void run() { handleAdd(); @@ -88,23 +91,25 @@ public class VModelFragmentsEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS) { @Override protected void addPressed() { handleAdd(); @@ -114,9 +119,8 @@ public class VModelFragmentsEditor extends AbstractComponentEditor { protected List<?> getContainerChildren(Object container) { if (container instanceof MModelFragments) { return ((MModelFragments) container).getFragments(); - } else { - return null; } + return null; } }; pickList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); @@ -135,14 +139,15 @@ public class VModelFragmentsEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } private void handleAdd() { - MStringModelFragment eObject = MFragmentFactory.INSTANCE.createStringModelFragment(); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS, eObject); + final MStringModelFragment eObject = MFragmentFactory.INSTANCE.createStringModelFragment(); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS, eObject); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VSnippetsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VSnippetsEditor.java index d0b7d3e3..3540865c 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VSnippetsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VSnippetsEditor.java @@ -7,7 +7,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; + import javax.annotation.PostConstruct; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -43,18 +45,19 @@ public class VSnippetsEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); - private EStructuralFeature targetFeature; + private final List<Action> actions = new ArrayList<Action>(); + private final EStructuralFeature targetFeature; public VSnippetsEditor() { super(); - this.targetFeature = UiPackageImpl.Literals.SNIPPET_CONTAINER__SNIPPETS; + targetFeature = UiPackageImpl.Literals.SNIPPET_CONTAINER__SNIPPETS; } @PostConstruct void init() { - actions.add(new Action(Messages.VWindowControlEditor_AddArea, createImageDescriptor(ResourceProvider.IMG_Area_vertical)) { + actions.add(new Action(Messages.VWindowControlEditor_AddArea, + createImageDescriptor(ResourceProvider.IMG_Area_vertical)) { @Override public void run() { handleAdd(AdvancedPackageImpl.Literals.AREA); @@ -68,48 +71,55 @@ public class VSnippetsEditor extends AbstractComponentEditor { } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPart, createImageDescriptor(ResourceProvider.IMG_Part)) { - @Override - public void run() { - handleAdd(BasicPackageImpl.Literals.PART); - } - }); + actions + .add(new Action(Messages.VWindowControlEditor_AddPart, createImageDescriptor(ResourceProvider.IMG_Part)) { + @Override + public void run() { + handleAdd(BasicPackageImpl.Literals.PART); + } + }); - actions.add(new Action(Messages.VWindowControlEditor_AddPartSashContainer, createImageDescriptor(ResourceProvider.IMG_PartSashContainer_vertical)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPartSashContainer, + createImageDescriptor(ResourceProvider.IMG_PartSashContainer_vertical)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.PART_SASH_CONTAINER); } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPartStack, createImageDescriptor(ResourceProvider.IMG_PartStack)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPartStack, + createImageDescriptor(ResourceProvider.IMG_PartStack)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.PART_STACK); } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPerspectiveStack, createImageDescriptor(ResourceProvider.IMG_PerspectiveStack)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPerspectiveStack, + createImageDescriptor(ResourceProvider.IMG_PerspectiveStack)) { @Override public void run() { handleAdd(AdvancedPackageImpl.Literals.PERSPECTIVE_STACK); } }); - actions.add(new Action(Messages.PerspectiveStackEditor_AddPerspective, createImageDescriptor(ResourceProvider.IMG_Perspective)) { + actions.add(new Action(Messages.PerspectiveStackEditor_AddPerspective, + createImageDescriptor(ResourceProvider.IMG_Perspective)) { @Override public void run() { handleAdd(AdvancedPackageImpl.Literals.PERSPECTIVE); } }); - actions.add(new Action(Messages.VTrimContributionsEditor_AddTrimContribution, createImageDescriptor(ResourceProvider.IMG_TrimContribution)) { + actions.add(new Action(Messages.VTrimContributionsEditor_AddTrimContribution, + createImageDescriptor(ResourceProvider.IMG_TrimContribution)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.TRIM_ELEMENT); } }); - actions.add(new Action(Messages.VWindowEditor_AddTrimmedWindow, createImageDescriptor(ResourceProvider.IMG_Window)) { + actions.add(new Action(Messages.VWindowEditor_AddTrimmedWindow, + createImageDescriptor(ResourceProvider.IMG_Window)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.TRIMMED_WINDOW); @@ -121,13 +131,15 @@ public class VSnippetsEditor extends AbstractComponentEditor { handleAdd(BasicPackageImpl.Literals.WINDOW); } }); - actions.add(new Action(Messages.VWindowTrimEditor_AddWindowTrim, createImageDescriptor(ResourceProvider.IMG_WindowTrim)) { + actions.add(new Action(Messages.VWindowTrimEditor_AddWindowTrim, + createImageDescriptor(ResourceProvider.IMG_WindowTrim)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.TRIM_BAR); } }); - actions.add(new Action(Messages.VWindowEditor_AddWizardDialog, createImageDescriptor(ResourceProvider.IMG_WizardDialog)) { + actions.add(new Action(Messages.VWindowEditor_AddWizardDialog, + createImageDescriptor(ResourceProvider.IMG_WizardDialog)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.WIZARD_DIALOG); @@ -169,27 +181,27 @@ public class VSnippetsEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, null, Messages, this, targetFeature) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, null, Messages, this, targetFeature) { @Override protected void addPressed() { - EClass eClass = (EClass) ((IStructuredSelection) getSelection()).getFirstElement(); + final EClass eClass = (EClass) ((IStructuredSelection) getSelection()).getFirstElement(); handleAdd(eClass); - }; + } @Override protected List<?> getContainerChildren(Object container) { @@ -200,7 +212,11 @@ public class VSnippetsEditor extends AbstractComponentEditor { viewer = pickList.getList(); pickList.setLabelProvider(new EClassLabelProvider(getEditor())); - pickList.setInput(new EClass[] { BasicPackageImpl.Literals.TRIMMED_WINDOW, BasicPackageImpl.Literals.WINDOW, AdvancedPackageImpl.Literals.PERSPECTIVE_STACK, AdvancedPackageImpl.Literals.PERSPECTIVE, AdvancedPackageImpl.Literals.AREA, BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, BasicPackageImpl.Literals.TRIM_BAR, BasicPackageImpl.Literals.TRIM_ELEMENT, }); + pickList.setInput(new EClass[] { BasicPackageImpl.Literals.TRIMMED_WINDOW, BasicPackageImpl.Literals.WINDOW, + AdvancedPackageImpl.Literals.PERSPECTIVE_STACK, AdvancedPackageImpl.Literals.PERSPECTIVE, + AdvancedPackageImpl.Literals.AREA, BasicPackageImpl.Literals.PART_SASH_CONTAINER, + BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, + BasicPackageImpl.Literals.TRIM_BAR, BasicPackageImpl.Literals.TRIM_ELEMENT, }); pickList.setSelection(new StructuredSelection(AdvancedPackageImpl.Literals.PERSPECTIVE)); folder.setSelection(0); @@ -215,16 +231,16 @@ public class VSnippetsEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } protected void handleAdd(EClass eClass) { - EObject handler = EcoreUtil.create(eClass); + final EObject handler = EcoreUtil.create(eClass); setElementId(handler); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), targetFeature, handler); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), targetFeature, handler); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VToolBarContributionsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VToolBarContributionsEditor.java index 3ae28e17..39d6a578 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VToolBarContributionsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VToolBarContributionsEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -45,7 +47,7 @@ public class VToolBarContributionsEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); @Inject public VToolBarContributionsEditor() { @@ -54,7 +56,8 @@ public class VToolBarContributionsEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VToolBarContributionsEditor_AddToolBarContribution, createImageDescriptor(ResourceProvider.IMG_ToolBarContribution)) { + actions.add(new Action(Messages.VToolBarContributionsEditor_AddToolBarContribution, + createImageDescriptor(ResourceProvider.IMG_ToolBarContribution)) { @Override public void run() { handleAdd(); @@ -88,27 +91,29 @@ public class VToolBarContributionsEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, MenuPackageImpl.Literals.TOOL_BAR_CONTRIBUTIONS__TOOL_BAR_CONTRIBUTIONS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + MenuPackageImpl.Literals.TOOL_BAR_CONTRIBUTIONS__TOOL_BAR_CONTRIBUTIONS) { @Override protected void addPressed() { handleAdd(); - }; + } @Override protected List<?> getContainerChildren(Object container) { @@ -130,10 +135,11 @@ public class VToolBarContributionsEditor extends AbstractComponentEditor { } protected void handleAdd() { - MToolBarContribution command = MMenuFactory.INSTANCE.createToolBarContribution(); + final MToolBarContribution command = MMenuFactory.INSTANCE.createToolBarContribution(); setElementId(command); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MenuPackageImpl.Literals.TOOL_BAR_CONTRIBUTIONS__TOOL_BAR_CONTRIBUTIONS, command); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + MenuPackageImpl.Literals.TOOL_BAR_CONTRIBUTIONS__TOOL_BAR_CONTRIBUTIONS, command); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -143,7 +149,7 @@ public class VToolBarContributionsEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VTrimContributionsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VTrimContributionsEditor.java index c4339507..2588e523 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VTrimContributionsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VTrimContributionsEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -45,7 +47,7 @@ public class VTrimContributionsEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); @Inject public VTrimContributionsEditor() { @@ -54,7 +56,8 @@ public class VTrimContributionsEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VTrimContributionsEditor_AddTrimContribution, createImageDescriptor(ResourceProvider.IMG_TrimContribution)) { + actions.add(new Action(Messages.VTrimContributionsEditor_AddTrimContribution, + createImageDescriptor(ResourceProvider.IMG_TrimContribution)) { @Override public void run() { handleAdd(); @@ -88,27 +91,29 @@ public class VTrimContributionsEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, MenuPackageImpl.Literals.TRIM_CONTRIBUTIONS__TRIM_CONTRIBUTIONS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + MenuPackageImpl.Literals.TRIM_CONTRIBUTIONS__TRIM_CONTRIBUTIONS) { @Override protected void addPressed() { handleAdd(); - }; + } @Override protected List<?> getContainerChildren(Object container) { @@ -130,10 +135,11 @@ public class VTrimContributionsEditor extends AbstractComponentEditor { } protected void handleAdd() { - MTrimContribution command = MMenuFactory.INSTANCE.createTrimContribution(); + final MTrimContribution command = MMenuFactory.INSTANCE.createTrimContribution(); setElementId(command); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MenuPackageImpl.Literals.TRIM_CONTRIBUTIONS__TRIM_CONTRIBUTIONS, command); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + MenuPackageImpl.Literals.TRIM_CONTRIBUTIONS__TRIM_CONTRIBUTIONS, command); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -143,7 +149,7 @@ public class VTrimContributionsEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowControlEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowControlEditor.java index d49669ca..1a0753a7 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowControlEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowControlEditor.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; @@ -15,8 +15,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.core.contexts.IEclipseContext; @@ -50,7 +52,7 @@ import org.eclipse.swt.widgets.Display; public class VWindowControlEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); private TableViewer viewer; @Inject @@ -64,34 +66,39 @@ public class VWindowControlEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VWindowControlEditor_AddPerspectiveStack, createImageDescriptor(ResourceProvider.IMG_PerspectiveStack)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPerspectiveStack, + createImageDescriptor(ResourceProvider.IMG_PerspectiveStack)) { @Override public void run() { handleAdd(AdvancedPackageImpl.Literals.PERSPECTIVE_STACK); } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPartSashContainer, createImageDescriptor(ResourceProvider.IMG_PartSashContainer_vertical)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPartSashContainer, + createImageDescriptor(ResourceProvider.IMG_PartSashContainer_vertical)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.PART_SASH_CONTAINER); } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPartStack, createImageDescriptor(ResourceProvider.IMG_PartStack)) { + actions.add(new Action(Messages.VWindowControlEditor_AddPartStack, + createImageDescriptor(ResourceProvider.IMG_PartStack)) { @Override public void run() { handleAdd(BasicPackageImpl.Literals.PART_STACK); } }); - actions.add(new Action(Messages.VWindowControlEditor_AddPart, createImageDescriptor(ResourceProvider.IMG_Part)) { - @Override - public void run() { - handleAdd(BasicPackageImpl.Literals.PART); - } - }); - actions.add(new Action(Messages.VWindowControlEditor_AddArea, createImageDescriptor(ResourceProvider.IMG_Area_vertical)) { + actions + .add(new Action(Messages.VWindowControlEditor_AddPart, createImageDescriptor(ResourceProvider.IMG_Part)) { + @Override + public void run() { + handleAdd(BasicPackageImpl.Literals.PART); + } + }); + actions.add(new Action(Messages.VWindowControlEditor_AddArea, + createImageDescriptor(ResourceProvider.IMG_Area_vertical)) { @Override public void run() { handleAdd(AdvancedPackageImpl.Literals.AREA); @@ -132,28 +139,29 @@ public class VWindowControlEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, null, Messages, this, UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, null, Messages, this, + UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN) { @Override protected void addPressed() { - EClass eClass = (EClass) ((IStructuredSelection) getSelection()).getFirstElement(); + final EClass eClass = (EClass) ((IStructuredSelection) getSelection()).getFirstElement(); handleAdd(eClass); - }; + } }; pickList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); viewer = pickList.getList(); @@ -161,12 +169,16 @@ public class VWindowControlEditor extends AbstractComponentEditor { pickList.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { - EClass eclass = (EClass) element; + final EClass eclass = (EClass) element; return eclass.getName(); } }); - pickList.setInput(new EClass[] { AdvancedPackageImpl.Literals.PERSPECTIVE_STACK, BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, AdvancedPackageImpl.Literals.AREA }); + pickList + .setInput(new EClass[] { AdvancedPackageImpl.Literals.PERSPECTIVE_STACK, + BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, + BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, + AdvancedPackageImpl.Literals.AREA }); pickList.setSelection(new StructuredSelection(AdvancedPackageImpl.Literals.PERSPECTIVE_STACK)); } @@ -181,11 +193,12 @@ public class VWindowControlEditor extends AbstractComponentEditor { } private void handleAdd(EClass eClass) { - EObject eObject = EcoreUtil.create(eClass); + final EObject eObject = EcoreUtil.create(eClass); setElementId(eObject); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -195,7 +208,7 @@ public class VWindowControlEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowTrimEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowTrimEditor.java index c3459ac0..bd9f1e2d 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowTrimEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VWindowTrimEditor.java @@ -6,16 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing maintenance + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -45,7 +47,7 @@ public class VWindowTrimEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; private TableViewer viewer; - private List<Action> actions = new ArrayList<Action>(); + private final List<Action> actions = new ArrayList<Action>(); @Inject public VWindowTrimEditor() { @@ -54,7 +56,8 @@ public class VWindowTrimEditor extends AbstractComponentEditor { @PostConstruct void init() { - actions.add(new Action(Messages.VWindowTrimEditor_AddWindowTrim, createImageDescriptor(ResourceProvider.IMG_WindowTrim)) { + actions.add(new Action(Messages.VWindowTrimEditor_AddWindowTrim, + createImageDescriptor(ResourceProvider.IMG_WindowTrim)) { @Override public void run() { handleAdd(); @@ -88,23 +91,25 @@ public class VWindowTrimEditor extends AbstractComponentEditor { context = new EMFDataBindingContext(); composite = createForm(parent, context, getMaster()); } - VirtualEntry<?> o = (VirtualEntry<?>) object; + final VirtualEntry<?> o = (VirtualEntry<?>) object; viewer.setInput(o.getList()); getMaster().setValue(o.getOriginalParent()); return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) { - CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); + final CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); - CTabItem item = new CTabItem(folder, SWT.NONE); + final CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); { - AbstractPickList pickList = new E4PickList(parent, SWT.NONE, Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, BasicPackageImpl.Literals.TRIMMED_WINDOW__TRIM_BARS) { + final AbstractPickList pickList = new E4PickList(parent, SWT.NONE, + Arrays.asList(PickListFeatures.NO_PICKER), Messages, this, + BasicPackageImpl.Literals.TRIMMED_WINDOW__TRIM_BARS) { @Override protected void addPressed() { handleAdd(); @@ -114,9 +119,8 @@ public class VWindowTrimEditor extends AbstractComponentEditor { protected List<?> getContainerChildren(Object master) { if (master instanceof MTrimmedWindow) { return ((MTrimmedWindow) master).getTrimBars(); - } else { - return null; } + return null; } }; pickList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); @@ -134,10 +138,11 @@ public class VWindowTrimEditor extends AbstractComponentEditor { } protected void handleAdd() { - MTrimBar handler = MBasicFactory.INSTANCE.createTrimBar(); + final MTrimBar handler = MBasicFactory.INSTANCE.createTrimBar(); setElementId(handler); - Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), BasicPackageImpl.Literals.TRIMMED_WINDOW__TRIM_BARS, handler); + final Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), + BasicPackageImpl.Literals.TRIMMED_WINDOW__TRIM_BARS, handler); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); @@ -147,7 +152,7 @@ public class VWindowTrimEditor extends AbstractComponentEditor { @Override public List<Action> getActions(Object element) { - ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + final ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); l.addAll(actions); return l; } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/JavaAttribute.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/JavaAttribute.java index dd81738f..da701e26 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/JavaAttribute.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/JavaAttribute.java @@ -4,8 +4,10 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Collections; import java.util.List; + import javax.inject.Inject; import javax.inject.Named; + import org.eclipse.e4.core.di.extensions.EventTopic; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.core.services.nls.Translation; @@ -13,9 +15,9 @@ import org.eclipse.e4.ui.di.UIEventTopic; import org.osgi.framework.FrameworkUtil; public class JavaAttribute { - private JavaObject object; + private final JavaObject object; - private Field field; + private final Field field; public JavaAttribute(JavaObject object, Field field) { this.object = object; @@ -24,32 +26,31 @@ public class JavaAttribute { } public boolean isInjected() { - return this.field.getAnnotation(Inject.class) != null; + return field.getAnnotation(Inject.class) != null; } public boolean isStatic() { - return (this.field.getModifiers() & Modifier.STATIC) == Modifier.STATIC; + return (field.getModifiers() & Modifier.STATIC) == Modifier.STATIC; } public String getValue() { - Object value = getFieldValue(); + final Object value = getFieldValue(); if (field.getType().isPrimitive()) { return value + ""; //$NON-NLS-1$ + } + if (value == null) { + return "<null>"; //$NON-NLS-1$ + } else if (value instanceof String) { + return value.toString(); } else { - if (value == null) { - return "<null>"; //$NON-NLS-1$ - } else if (value instanceof String) { - return value.toString(); + String name; + if (value.getClass().isAnonymousClass()) { + name = value.getClass().getName().substring(value.getClass().getPackage().getName().length() + 1); } else { - String name; - if (value.getClass().isAnonymousClass()) { - name = value.getClass().getName().substring(value.getClass().getPackage().getName().length() + 1); - } else { - name = value.getClass().getSimpleName(); - } - - return name + " (id = " + Integer.toHexString(System.identityHashCode(value)) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + name = value.getClass().getSimpleName(); } + + return name + " (id = " + Integer.toHexString(System.identityHashCode(value)) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -57,14 +58,13 @@ public class JavaAttribute { try { if (field.getType().isPrimitive()) { return Collections.emptyList(); - } else { - return new JavaObject(field.get(object.getInstance())).getAttributes(); } + return new JavaObject(field.get(object.getInstance())).getAttributes(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -80,7 +80,7 @@ public class JavaAttribute { } public AccessLevel getAccessLevel() { - int m = field.getModifiers(); + final int m = field.getModifiers(); if ((m & Modifier.PUBLIC) == Modifier.PUBLIC) { return AccessLevel.PUBLIC; } else if ((m & Modifier.PRIVATE) == Modifier.PRIVATE) { @@ -94,12 +94,12 @@ public class JavaAttribute { public String getContextKey() { if (isInjected()) { - Named named = field.getAnnotation(Named.class); + final Named named = field.getAnnotation(Named.class); if (named != null) { return "@Named(" + named.value() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } - Preference preference = field.getAnnotation(Preference.class); + final Preference preference = field.getAnnotation(Preference.class); if (preference != null) { String path = preference.nodePath(); if (path == null || path.trim().length() == 0) { @@ -108,18 +108,18 @@ public class JavaAttribute { return "@Preference(" + preference.nodePath() + "/" + preference.value() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - EventTopic topic = field.getAnnotation(EventTopic.class); + final EventTopic topic = field.getAnnotation(EventTopic.class); if (topic != null) { return "@Topic(" + topic.value() + ")"; //$NON-NLS-1$//$NON-NLS-2$ } - UIEventTopic uiTopic = field.getAnnotation(UIEventTopic.class); + final UIEventTopic uiTopic = field.getAnnotation(UIEventTopic.class); if (uiTopic != null) { return "@UITopic(" + uiTopic.value() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } - Translation translation = field.getAnnotation(Translation.class); + final Translation translation = field.getAnnotation(Translation.class); if (translation != null) { return "@Translation(" + field.getType().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$ } @@ -133,10 +133,10 @@ public class JavaAttribute { public Object getFieldValue() { try { return field.get(object.getInstance()); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/ObjectViewer.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/ObjectViewer.java index 646673e7..87691d66 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/ObjectViewer.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/objectdata/ObjectViewer.java @@ -2,6 +2,7 @@ package org.eclipse.e4.tools.emf.ui.internal.common.objectdata; import java.util.Collection; import java.util.Collections; + import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.databinding.observable.value.IValueChangeListener; import org.eclipse.core.databinding.observable.value.ValueChangeEvent; @@ -43,13 +44,14 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; public class ObjectViewer { - public TreeViewer createViewer(Composite parent, EStructuralFeature feature, final IObservableValue master, IResourcePool resourcePool, final Messages messages) { + public TreeViewer createViewer(Composite parent, EStructuralFeature feature, final IObservableValue master, + IResourcePool resourcePool, final Messages messages) { final TreeViewer viewer = new TreeViewer(parent); viewer.setContentProvider(new ContentProviderImpl()); viewer.setLabelProvider(new LabelProviderImpl(resourcePool)); viewer.setComparator(new ViewerComparatorImpl()); - IEMFValueProperty property = EMFProperties.value(feature); - IObservableValue value = property.observeDetail(master); + final IEMFValueProperty property = EMFProperties.value(feature); + final IObservableValue value = property.observeDetail(master); value.addValueChangeListener(new IValueChangeListener() { @Override @@ -63,8 +65,8 @@ public class ObjectViewer { } }); - IExtensionRegistry registry = RegistryFactory.getRegistry(); - IExtensionPoint extPoint = registry.getExtensionPoint("org.eclipse.e4.tools.emf.ui.scripting"); //$NON-NLS-1$ + final IExtensionRegistry registry = RegistryFactory.getRegistry(); + final IExtensionPoint extPoint = registry.getExtensionPoint("org.eclipse.e4.tools.emf.ui.scripting"); //$NON-NLS-1$ final IConfigurationElement[] elements = extPoint.getConfigurationElements(); if (elements.length > 0) { @@ -78,16 +80,18 @@ public class ObjectViewer { return; } - MenuManager scriptExecute = new MenuManager(messages.ObjectViewer_Script); + final MenuManager scriptExecute = new MenuManager(messages.ObjectViewer_Script); mgr.add(scriptExecute); - for (IConfigurationElement e : elements) { + for (final IConfigurationElement e : elements) { final IConfigurationElement le = e; scriptExecute.add(new Action(e.getAttribute("label")) { //$NON-NLS-1$ @Override public void run() { try { - IScriptingSupport support = (IScriptingSupport) le.createExecutableExtension("class"); //$NON-NLS-1$ - Object o = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); + final IScriptingSupport support = (IScriptingSupport) le + .createExecutableExtension("class"); //$NON-NLS-1$ + final Object o = ((IStructuredSelection) viewer.getSelection()) + .getFirstElement(); Object mainObject = null; if (o instanceof JavaObject) { mainObject = ((JavaObject) o).getInstance(); @@ -96,10 +100,11 @@ public class ObjectViewer { } if (mainObject != null) { - MApplicationElement value = (MApplicationElement) master.getValue(); - support.openEditor(viewer.getControl().getShell(), mainObject, ModelUtils.getContainingContext(value)); + final MApplicationElement value = (MApplicationElement) master.getValue(); + support.openEditor(viewer.getControl().getShell(), mainObject, + ModelUtils.getContainingContext(value)); } - } catch (CoreException e) { + } catch (final CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -117,10 +122,11 @@ public class ObjectViewer { } class TooltipSupportImpl extends ColumnViewerToolTipSupport { - private IResourcePool resourcePool; - private Messages messages; + private final IResourcePool resourcePool; + private final Messages messages; - protected TooltipSupportImpl(ColumnViewer viewer, int style, boolean manualActivation, IResourcePool resourcePool, Messages messages) { + protected TooltipSupportImpl(ColumnViewer viewer, int style, boolean manualActivation, + IResourcePool resourcePool, Messages messages) { super(viewer, style, manualActivation); this.resourcePool = resourcePool; this.messages = messages; @@ -128,26 +134,26 @@ public class ObjectViewer { @Override protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) { - JavaAttribute attribute = (JavaAttribute) cell.getElement(); + final JavaAttribute attribute = (JavaAttribute) cell.getElement(); - Composite container = new Composite(parent, SWT.NONE); + final Composite container = new Composite(parent, SWT.NONE); container.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_WHITE)); container.setLayout(new GridLayout(2, false)); { - Composite headerContainer = new Composite(container, SWT.NONE); + final Composite headerContainer = new Composite(container, SWT.NONE); headerContainer.setBackgroundMode(SWT.INHERIT_DEFAULT); headerContainer.setData(ModelEditor.CSS_CLASS_KEY, "headerSectionContainer"); //$NON-NLS-1$ - GridLayout fl = new GridLayout(2, false); + final GridLayout fl = new GridLayout(2, false); fl.marginHeight = 5; fl.marginWidth = 5; headerContainer.setLayout(fl); headerContainer.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1)); - Label iconLabel = new Label(headerContainer, SWT.NONE); + final Label iconLabel = new Label(headerContainer, SWT.NONE); iconLabel.setImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_bullet_go)); - Label textLabel = new Label(headerContainer, SWT.NONE); + final Label textLabel = new Label(headerContainer, SWT.NONE); textLabel.setText(attribute.getName()); textLabel.setData(ModelEditor.CSS_CLASS_KEY, "sectionHeader"); //$NON-NLS-1$ } @@ -177,8 +183,8 @@ public class ObjectViewer { public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof JavaAttribute) { if (e2 instanceof JavaAttribute) { - JavaAttribute a1 = (JavaAttribute) e1; - JavaAttribute a2 = (JavaAttribute) e2; + final JavaAttribute a1 = (JavaAttribute) e1; + final JavaAttribute a2 = (JavaAttribute) e2; if (a1.isStatic() && !a2.isStatic()) { return -1; @@ -186,15 +192,13 @@ public class ObjectViewer { return 1; } - int rv = Integer.valueOf(a1.getAccessLevel().value).compareTo(a2.getAccessLevel().value); + final int rv = Integer.valueOf(a1.getAccessLevel().value).compareTo(a2.getAccessLevel().value); if (rv == 0) { return a1.getName().compareTo(a2.getName()); - } else { - return rv; } - } else { - return -1; + return rv; } + return -1; } return super.compare(viewer, e1, e2); } @@ -202,7 +206,7 @@ public class ObjectViewer { class LabelProviderImpl extends StyledCellLabelProvider { - private IResourcePool resourcePool; + private final IResourcePool resourcePool; public LabelProviderImpl(IResourcePool resourcePool) { this.resourcePool = resourcePool; @@ -219,12 +223,12 @@ public class ObjectViewer { @Override public void update(ViewerCell cell) { if (cell.getElement() instanceof JavaObject) { - JavaObject o = (JavaObject) cell.getElement(); + final JavaObject o = (JavaObject) cell.getElement(); cell.setImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_class_obj)); cell.setText(o.getName()); } else if (cell.getElement() instanceof JavaAttribute) { - JavaAttribute o = (JavaAttribute) cell.getElement(); - StyledString string = new StyledString(); + final JavaAttribute o = (JavaAttribute) cell.getElement(); + final StyledString string = new StyledString(); if (o.isInjected()) { string.append("<injected> ", StyledString.COUNTER_STYLER); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java index 74c7f6f2..1a964c76 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java @@ -12,8 +12,10 @@ import java.util.Locale; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import java.util.ResourceBundle.Control; + import javax.inject.Inject; import javax.inject.Named; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceChangeEvent; @@ -76,7 +78,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro return ProjectOSGiTranslationProvider.this.visit(delta); } }); - } catch (CoreException e) { + } catch (final CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -85,7 +87,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro }); setLocale(locale, false); - IFile f = this.project.getFile(MANIFEST_DEFAULT_PATH); + final IFile f = this.project.getFile(MANIFEST_DEFAULT_PATH); if (f.exists()) { handleManifestChange(f); } else { @@ -99,20 +101,22 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro void setLocale(@Named(TranslationService.LOCALE) String locale, @Optional Boolean performUpdate) { try { this.locale = locale == null ? Locale.getDefault() : ResourceBundleHelper.toLocale(locale); - } catch (Exception e) { + } catch (final Exception e) { this.locale = Locale.getDefault(); } - if (performUpdate == null || performUpdate) + if (performUpdate == null || performUpdate) { updateResourceBundle(); + } } @Inject void setLocale(@Named(TranslationService.LOCALE) Locale locale, @Optional Boolean performUpdate) { this.locale = locale == null ? Locale.getDefault() : locale; - if (performUpdate == null || performUpdate) + if (performUpdate == null || performUpdate) { updateResourceBundle(); + } } /** @@ -126,7 +130,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro boolean visit(IResourceDelta delta) { if (delta.getResource() instanceof IWorkspaceRoot) { return true; - } else if (delta.getResource().equals(this.project)) { + } else if (delta.getResource().equals(project)) { return true; } else if (delta.getResource().getProjectRelativePath().toString().equals(META_INF_DIRECTORY_NAME)) { return true; @@ -134,21 +138,21 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro handleManifestChange((IFile) delta.getResource()); return false; } else if (delta.getResource() instanceof IFile) { - String filename = ((IFile) delta.getResource()).getName(); + final String filename = ((IFile) delta.getResource()).getName(); // extract base bundle name out of local basename - String fileBaseName = this.basename.substring(this.basename.lastIndexOf("/") + 1, this.basename.length()); //$NON-NLS-1$ + final String fileBaseName = basename.substring(basename.lastIndexOf("/") + 1, basename.length()); //$NON-NLS-1$ if (filename.startsWith(fileBaseName)) { updateResourceBundle(); return false; } } - if (delta.getResource().getProjectRelativePath().toString().equals(this.basename)) { + if (delta.getResource().getProjectRelativePath().toString().equals(basename)) { updateResourceBundle(); return false; } - String[] p = this.basename.split("/"); //$NON-NLS-1$ + final String[] p = basename.split("/"); //$NON-NLS-1$ int i = 0; String path = ""; //$NON-NLS-1$ do { @@ -172,7 +176,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro */ private void handleManifestChange(IFile file) { try { - String newValue = extractBasenameFromManifest(file); + final String newValue = extractBasenameFromManifest(file); if (!newValue.equals(basename)) { basename = newValue; @@ -181,10 +185,10 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro } } - } catch (CoreException e) { + } catch (final CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -206,8 +210,8 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro * @see IFile#getContents() */ public static String extractBasenameFromManifest(IFile file) throws CoreException, IOException { - InputStream in = file.getContents(); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); + final InputStream in = file.getContents(); + final BufferedReader r = new BufferedReader(new InputStreamReader(in)); String line; String newValue = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME; while ((line = r.readLine()) != null) { @@ -225,12 +229,13 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro * Reloads the underlying ResourceBundle. */ protected void updateResourceBundle() { - setResourceBundle(ResourceBundleHelper.getEquinoxResourceBundle(this.basename, this.locale, new ProjectResourceBundleControl(true), new ProjectResourceBundleControl(false))); + setResourceBundle(ResourceBundleHelper.getEquinoxResourceBundle(basename, locale, + new ProjectResourceBundleControl(true), new ProjectResourceBundleControl(false))); } /** - * Specialization of {@link Control} which loads the {@link ResourceBundle} - * by using file structures of a project instead of using a classloader. + * Specialization of {@link Control} which loads the {@link ResourceBundle} by using file structures of a project + * instead of using a classloader. * * @author Dirk Fauth */ @@ -246,17 +251,17 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro /** * @param useFallback * <code>true</code> if the default locale should be used as - * fallback locale in the search path or <code>false</code> - * if there should be no fallback. + * fallback locale in the search path or <code>false</code> if there should be no fallback. */ ProjectResourceBundleControl(boolean useFallback) { this.useFallback = useFallback; } @Override - public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { + public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, + boolean reload) throws IllegalAccessException, InstantiationException, IOException { - String bundleName = toBundleName(baseName, locale); + final String bundleName = toBundleName(baseName, locale); ResourceBundle bundle = null; if (format.equals("java.properties")) { //$NON-NLS-1$ final String resourceName = toResourceName(bundleName, "properties"); //$NON-NLS-1$ @@ -268,7 +273,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro return getResourceAsStream(resourceName); } }); - } catch (PrivilegedActionException e) { + } catch (final PrivilegedActionException e) { throw (IOException) e.getException(); } if (stream != null) { @@ -285,21 +290,19 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro } /** - * Loads the properties file by using the {@link IProject} of the - * {@link ProjectOSGiTranslationProvider}. + * Loads the properties file by using the {@link IProject} of the {@link ProjectOSGiTranslationProvider}. * * @param name * @return The {@link InputStream} to the properties file to load */ protected InputStream getResourceAsStream(String name) { - IFile f = project.getFile(name); + final IFile f = project.getFile(name); try { if (f.exists()) { return f.getContents(); - } else { - return null; } - } catch (CoreException e) { + return null; + } catch (final CoreException e) { return null; } } @@ -311,7 +314,7 @@ public class ProjectOSGiTranslationProvider extends ResourceBundleTranslationPro @Override public Locale getFallbackLocale(String baseName, Locale locale) { - return this.useFallback ? super.getFallbackLocale(baseName, locale) : null; + return useFallback ? super.getFallbackLocale(baseName, locale) : null; } // this implementation simply doesn't cache the values in the diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java index fedab5d7..d1a55456 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java @@ -6,13 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 437569, Ongoing Maintenance + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 437569, Ongoing Maintenance *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.dialogs; -import org.eclipse.e4.tools.emf.ui.common.Plugin; - import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -21,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.jar.Manifest; import java.util.zip.ZipFile; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -28,6 +27,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.tools.emf.ui.common.IClassContributionProvider.ContributionData; +import org.eclipse.e4.tools.emf.ui.common.Plugin; import org.eclipse.e4.tools.emf.ui.internal.ResourceProvider; import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.BundleImageCache; import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.ContributionDataFile; @@ -36,7 +36,6 @@ import org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.BundleConvert import org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.Messages; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.pde.internal.core.util.CoreUtility; import org.eclipse.swt.SWT; @@ -58,17 +57,18 @@ import org.eclipse.swt.widgets.Text; * @author Steven Spungin * */ -public class NonReferencedActionPage extends WizardPage implements IWizardPage { +public class NonReferencedActionPage extends WizardPage { - private IProject project; + private final IProject project; private String bundle; - private IFile file; - private String installLocation; - private IEclipseContext context; + private final IFile file; + private final String installLocation; + private final IEclipseContext context; private String className; - private BundleImageCache imageCache; + private final BundleImageCache imageCache; - protected NonReferencedActionPage(IProject project, String bundle, IFile file, String installLocation, IEclipseContext context) { + protected NonReferencedActionPage(IProject project, String bundle, IFile file, String installLocation, + IEclipseContext context) { super(Messages.NonReferencedActionPage_NonreferencedResourceAction); this.project = project; @@ -79,14 +79,15 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { imageCache = context.get(BundleImageCache.class); - setImageDescriptor(ImageDescriptor.createFromImage(imageCache.create(Plugin.ID, "/icons/full/wizban/newefix_wizban.png"))); //$NON-NLS-1$ + setImageDescriptor(ImageDescriptor.createFromImage(imageCache.create(Plugin.ID, + "/icons/full/wizban/newefix_wizban.png"))); //$NON-NLS-1$ if (bundle == null && installLocation != null) { this.bundle = FilteredContributionDialog.getBundle(installLocation); } if (file instanceof ContributionDataFile) { - ContributionDataFile cdf = (ContributionDataFile) file; - this.className = cdf.getContributionData().className; + final ContributionDataFile cdf = (ContributionDataFile) file; + className = cdf.getContributionData().className; } setTitle(Messages.NonReferencedActionPage_NonreferencedResourceAction); @@ -101,32 +102,32 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { @Override public void createControl(Composite compParent) { - Composite comp = new Composite(compParent, SWT.NONE); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + final Composite comp = new Composite(compParent, SWT.NONE); + final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.horizontalSpan = 2; comp.setLayoutData(layoutData); comp.setLayout(new GridLayout(2, false)); - String message = ""; //$NON-NLS-1$ + final String message = ""; //$NON-NLS-1$ Button defaultButton = null; if (installLocation != null) { - Label label = new Label(comp, SWT.NONE); + final Label label = new Label(comp, SWT.NONE); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label.setText(Messages.NonReferencedResourceDialog_installLocation); - Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label2.setText(installLocation); } if (className != null) { - ContributionData cd = ((ContributionDataFile) file).getContributionData(); - Label label = new Label(comp, SWT.NONE); + final ContributionData cd = ((ContributionDataFile) file).getContributionData(); + final Label label = new Label(comp, SWT.NONE); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label.setText(Messages.NonReferencedResourceDialog_2); - Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); if (bundle != null) { label2.setText(bundle); @@ -134,37 +135,37 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { label2.setText(Messages.NonReferencedResourceDialog__ast_notInABundle_ast); } - Label label3 = new Label(comp, SWT.NONE); + final Label label3 = new Label(comp, SWT.NONE); label3.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label3.setText(Messages.NonReferencedResourceDialog_package); - Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label4.setText(getPackageFromClassName(className)); - Label label5 = new Label(comp, SWT.NONE); + final Label label5 = new Label(comp, SWT.NONE); label5.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label5.setText(Messages.NonReferencedResourceDialog_class); - Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label6.setText(cd.className.substring(cd.className.lastIndexOf('.') + 1)); if (bundle != null) { - Label label7 = new Label(comp, SWT.NONE); + final Label label7 = new Label(comp, SWT.NONE); label7.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label7.setText(Messages.NonReferencedResourceDialog_url); - Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label8.setText("bundleclass://" + bundle + "/" + className); //$NON-NLS-1$ //$NON-NLS-2$ } } else { - Label label = new Label(comp, SWT.NONE); + final Label label = new Label(comp, SWT.NONE); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label.setText(Messages.NonReferencedResourceDialog_bundle); - Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); if (bundle != null) { label2.setText(bundle); @@ -172,38 +173,39 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { label2.setText(Messages.NonReferencedResourceDialog_ast_notInABundle_ast); } - Label label7 = new Label(comp, SWT.NONE); + final Label label7 = new Label(comp, SWT.NONE); label7.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label7.setText(Messages.NonReferencedResourceDialog_directory); - Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label8.setText(file.getFullPath().removeFirstSegments(1).removeLastSegments(1).toOSString()); - Label label3 = new Label(comp, SWT.NONE); + final Label label3 = new Label(comp, SWT.NONE); label3.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label3.setText(Messages.NonReferencedResourceDialog_resource); - Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label4.setText(file.getFullPath().lastSegment()); if (bundle != null) { - Label label5 = new Label(comp, SWT.NONE); + final Label label5 = new Label(comp, SWT.NONE); label5.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); label5.setText(Messages.NonReferencedResourceDialog_url); - Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); + final Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY); label6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - label6.setText("platform:/plugin/" + bundle + "/" + file.getFullPath().removeFirstSegments(1).toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ + label6 + .setText("platform:/plugin/" + bundle + "/" + file.getFullPath().removeFirstSegments(1).toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } } - Label lblMessage = new Label(comp, SWT.NONE); + final Label lblMessage = new Label(comp, SWT.NONE); lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 0)); lblMessage.setText(message); - Group group = new Group(comp, SWT.NONE); + final Group group = new Group(comp, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0)); group.setLayout(new GridLayout(1, false)); group.setText(Messages.NonReferencedActionPage_Action); @@ -217,7 +219,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { @Override public void widgetSelected(SelectionEvent e) { if (btnRequire.getSelection()) { - Runnable okAction = new Runnable() { + final Runnable okAction = new Runnable() { @Override public void run() { @@ -241,16 +243,16 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { @Override public void widgetSelected(SelectionEvent e) { if (btnImport.getSelection()) { - Runnable okAction = new Runnable() { + final Runnable okAction = new Runnable() { @Override public void run() { - IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$ + final IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$ Manifest manifest; try { manifest = new Manifest(fileManifest.getContents()); String value = manifest.getMainAttributes().getValue("Import-Package"); //$NON-NLS-1$ - String packageName = getPackageFromClassName(className); + final String packageName = getPackageFromClassName(className); // TODO ensure the packageName is not // already in the manifest (although it // should not be if we are here) @@ -260,12 +262,12 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { value += "," + packageName; //$NON-NLS-1$ } manifest.getMainAttributes().putValue("Import-Package", value); //$NON-NLS-1$ - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); manifest.write(bos); - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); fileManifest.setContents(bis, true, true, null); context.set("resolvedFile", file); //$NON-NLS-1$ - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -307,24 +309,30 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { @Override public void widgetSelected(SelectionEvent e) { if (btnConvertToBundle.getSelection()) { - Runnable okAction = new Runnable() { + final Runnable okAction = new Runnable() { @Override public void run() { String bundleId; try { - ContributionData contributionData = cdf.getContributionData(); - bundleId = BundleConverter.convertProjectToBundle(contributionData.installLocation, project.getWorkspace()); + final ContributionData contributionData = cdf.getContributionData(); + bundleId = BundleConverter.convertProjectToBundle( + contributionData.installLocation, project.getWorkspace()); if (bundleId != null) { - ContributionData cdConverted = new ContributionData(bundleId, contributionData.className, contributionData.sourceType, contributionData.iconPath); + final ContributionData cdConverted = new ContributionData(bundleId, + contributionData.className, contributionData.sourceType, + contributionData.iconPath); cdConverted.installLocation = installLocation; - cdConverted.resourceRelativePath = Path.fromOSString(contributionData.iconPath).removeFirstSegments(1).toOSString(); + cdConverted.resourceRelativePath = Path + .fromOSString(contributionData.iconPath).removeFirstSegments(1) + .toOSString(); doRequireBundle(bundleId, installLocation); context.set("resolvedFile", new ContributionDataFile(cdConverted)); //$NON-NLS-1$ } - } catch (Exception e1) { - MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error, e1.getMessage()); + } catch (final Exception e1) { + MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error, + e1.getMessage()); } } }; @@ -345,7 +353,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { @Override public void widgetSelected(SelectionEvent e) { if (btnCopy.getSelection()) { - Runnable okAction = new Runnable() { + final Runnable okAction = new Runnable() { @Override public void run() { @@ -369,7 +377,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { public void widgetSelected(SelectionEvent e) { if (btnCopy2.getSelection()) { - Runnable okAction = new Runnable() { + final Runnable okAction = new Runnable() { @Override public void run() { @@ -401,8 +409,8 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { } public void copyResourceToProject() { - IProject project = (IProject) context.get("projectToCopyTo"); //$NON-NLS-1$ - String path = (String) context.get("folderToCopyTo"); //$NON-NLS-1$ + final IProject project = (IProject) context.get("projectToCopyTo"); //$NON-NLS-1$ + final String path = (String) context.get("folderToCopyTo"); //$NON-NLS-1$ try { // String filename = ((ContributionDataFile) // file).getContributionData().className + ".class"; @@ -413,13 +421,13 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { if (className != null) { newPath.append(className + ".class"); //$NON-NLS-1$ } else { - String name = file.getFullPath().lastSegment(); + final String name = file.getFullPath().lastSegment(); newPath = newPath.append(name); } - IFile fileClone = project.getFile(newPath); + final IFile fileClone = project.getFile(newPath); fileClone.create(file.getContents(), false, null); context.set("resolvedFile", fileClone); //$NON-NLS-1$ - } catch (CoreException e1) { + } catch (final CoreException e1) { e1.printStackTrace(); MessageDialog.openError(getShell(), "Error", e1.getMessage()); //$NON-NLS-1$ } @@ -433,7 +441,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { try { Manifest manifestSource; if (installLocation.endsWith(".jar")) { //$NON-NLS-1$ - ZipFile zip = new ZipFile(installLocation); + final ZipFile zip = new ZipFile(installLocation); srcStream = zip.getInputStream(zip.getEntry("META-INF/MANIFEST.MF")); //$NON-NLS-1$ manifestSource = new Manifest(srcStream); zip.close(); @@ -445,17 +453,17 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { if (version != null) { version = version.replaceFirst("\\.qualifier", ""); //$NON-NLS-1$ //$NON-NLS-2$ } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); return; } finally { try { srcStream.close(); - } catch (Exception e) { + } catch (final Exception e) { } } - IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$ + final IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$ Manifest manifest; try { manifest = new Manifest(fileManifest.getContents()); @@ -469,22 +477,22 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage { } manifest.getMainAttributes().putValue("Require-Bundle", value); //$NON-NLS-1$ } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); manifest.write(bos); // StringReader reader = new - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); fileManifest.setContents(bis, true, true, null); context.set("resolvedFile", file); //$NON-NLS-1$ - } catch (IOException e1) { + } catch (final IOException e1) { e1.printStackTrace(); - } catch (CoreException e1) { + } catch (final CoreException e1) { e1.printStackTrace(); } } // @Refactor static public String getPackageFromClassName(String className) { - int index = className.lastIndexOf('.'); + final int index = className.lastIndexOf('.'); if (index >= 0) { return className.substring(0, index); } else { diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/uistructure/ViewerElement.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/uistructure/ViewerElement.java index c5e36133..6502826d 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/uistructure/ViewerElement.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/uistructure/ViewerElement.java @@ -6,13 +6,15 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wim Jongman <wim.jongman@remainsoftware.com> - initial API and implementation - * Steven Spungin <steve@spungin.tv> -Bug 439284 - [model editor] make list a combo with autocomplete for add part descriptor - * Toni Umbreit - Bug 440289 + * Wim Jongman <wim.jongman@remainsoftware.com> - initial API and implementation + * Steven Spungin <steve@spungin.tv> -Bug 439284 - [model editor] make list a combo with autocomplete for add part + * descriptor + * Toni Umbreit - Bug 440289 ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.uistructure; import javax.inject.Inject; + import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.nls.Translation; @@ -40,10 +42,10 @@ public class ViewerElement { Messages Messages; private StructuredViewer viewer; - private AbstractComponentEditor editor; + private final AbstractComponentEditor editor; private ComboViewer dropDown; private Button addButton; - private Composite parent; + private final Composite parent; private Button removeButton; @@ -53,7 +55,6 @@ public class ViewerElement { /** * @param parent - * @param reference * @param editor */ @Inject @@ -72,10 +73,11 @@ public class ViewerElement { createTopButtons(); - if (viewer == null) + if (viewer == null) { viewer = new TableViewer(parent); + } - GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1); + final GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1); viewer.getControl().setLayoutData(gd); createBottomButtons(); @@ -83,9 +85,9 @@ public class ViewerElement { } private void createBottomButtons() { - Composite buttonCompBot = new Composite(parent, SWT.NONE); + final Composite buttonCompBot = new Composite(parent, SWT.NONE); buttonCompBot.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false, 3, 1)); - GridLayout gl = new GridLayout(3, false); + final GridLayout gl = new GridLayout(3, false); gl.marginLeft = 0; gl.marginRight = 0; gl.marginWidth = 0; @@ -113,17 +115,16 @@ public class ViewerElement { * Returns the button that removes an element from the list. Use it to add * your {@link SelectionListener} to it. * - * @return + * @return the {@link Button} */ public Button getButtonRemove() { return removeButton; } /** - * Returns the button that adds an element to the list. Use it to add your - * {@link SelectionListener} to it. + * Returns the button that adds an element to the list. Use it to add your {@link SelectionListener} to it. * - * @return + * @return the {@link Button} */ public Button getButtonAdd() { return addButton; @@ -133,7 +134,7 @@ public class ViewerElement { * Returns the button that moves an element down in the list. Use it to add * your {@link SelectionListener} to it. * - * @return + * @return the {@link Button} */ public Button getButtonDown() { return downButton; @@ -143,16 +144,16 @@ public class ViewerElement { * Returns the button that moves an element up in the list. Use it to add * your {@link SelectionListener} to it. * - * @return + * @return the {@link Button} */ public Button getButtonUp() { return upButton; } private void createTopButtons() { - Composite buttonCompTop = new Composite(parent, SWT.NONE); + final Composite buttonCompTop = new Composite(parent, SWT.NONE); buttonCompTop.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false, 3, 1)); - GridLayout buttonCompTopLayout = new GridLayout(2, false); + final GridLayout buttonCompTopLayout = new GridLayout(2, false); buttonCompTopLayout.marginLeft = 0; buttonCompTopLayout.marginRight = 0; buttonCompTopLayout.marginWidth = 0; @@ -179,12 +180,11 @@ public class ViewerElement { * * @param parentContext * @param parent - * @param reference * @param editor * @return a new {@link ViewerElement} */ public static ViewerElement create(IEclipseContext parentContext, Composite parent, AbstractComponentEditor editor) { - IEclipseContext mycontext = parentContext.createChild(); + final IEclipseContext mycontext = parentContext.createChild(); mycontext.set(Composite.class, parent); mycontext.set(AbstractComponentEditor.class, editor); return ContextInjectionFactory.make(ViewerElement.class, mycontext); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/xml/EMFDocumentResourceMediator.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/xml/EMFDocumentResourceMediator.java index e2c10bd2..1896f56e 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/xml/EMFDocumentResourceMediator.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/xml/EMFDocumentResourceMediator.java @@ -1,6 +1,6 @@ /******************************************************************************* * Contributors: - * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 391089 + * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 391089 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.xml; @@ -11,6 +11,7 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import org.eclipse.e4.tools.emf.ui.common.IModelResource; import org.eclipse.e4.tools.emf.ui.internal.common.component.tabs.empty.E; import org.eclipse.e4.ui.internal.workbench.E4XMIResource; @@ -33,8 +34,8 @@ public class EMFDocumentResourceMediator { public EMFDocumentResourceMediator(final IModelResource modelResource) { this.modelResource = modelResource; - this.document = new Document(); - this.document.addDocumentListener(new IDocumentListener() { + document = new Document(); + document.addDocumentListener(new IDocumentListener() { @Override public void documentChanged(DocumentEvent event) { @@ -42,8 +43,8 @@ public class EMFDocumentResourceMediator { return; } - String doc = document.get(); - E4XMIResource res = new E4XMIResource(); + final String doc = document.get(); + final E4XMIResource res = new E4XMIResource(); try { res.load(new InputSource(new StringReader(doc)), null); modelResource.replaceRoot(res.getContents().get(0)); @@ -51,7 +52,7 @@ public class EMFDocumentResourceMediator { if (documentValidationChanged != null) { documentValidationChanged.run(); } - } catch (IOException e) { + } catch (final IOException e) { errorList = res.getErrors(); if (documentValidationChanged != null) { documentValidationChanged.run(); @@ -79,7 +80,7 @@ public class EMFDocumentResourceMediator { public void updateFromEMF() { try { updateFromEMF = true; - this.document.set(toXMI((EObject) modelResource.getRoot().get(0))); + document.set(toXMI((EObject) modelResource.getRoot().get(0))); } finally { updateFromEMF = false; } @@ -90,12 +91,12 @@ public class EMFDocumentResourceMediator { } private String toXMI(EObject root) { - E4XMIResource resource = (E4XMIResource) root.eResource(); + final E4XMIResource resource = (E4XMIResource) root.eResource(); // resource.getContents().add(EcoreUtil.copy(root)); - StringWriter writer = new StringWriter(); + final StringWriter writer = new StringWriter(); try { resource.save(writer, null); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -111,23 +112,23 @@ public class EMFDocumentResourceMediator { if (object == null) { return null; } - E4XMIResource root = (E4XMIResource) ((EObject) modelResource.getRoot().get(0)).eResource(); - String xmiId = root.getID(object); + final E4XMIResource root = (E4XMIResource) ((EObject) modelResource.getRoot().get(0)).eResource(); + final String xmiId = root.getID(object); - FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(document); + final FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(document); IRegion region; try { // TODO This will not work if the element has '<' or '>' in an // attribute value region = find.find(0, "<.*?" + xmiId + ".*?>", true, true, false, true); //$NON-NLS-1$ //$NON-NLS-2$ return region; - } catch (BadLocationException e) { + } catch (final BadLocationException e) { return null; } } /** - * @param object + * * @return The region for the start of the text, or null if not found or the * text is empty. */ @@ -136,12 +137,12 @@ public class EMFDocumentResourceMediator { return null; } - FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(document); + final FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(document); IRegion region; try { region = find.find(startOffset, text, true, true, false, false); return region; - } catch (BadLocationException e) { + } catch (final BadLocationException e) { return null; } } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/ModelImportWizard.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/ModelImportWizard.java index f09d4a1e..e9afdeef 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/ModelImportWizard.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/ModelImportWizard.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wim Jongmam <wim.jongman@remainsoftware.com> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing Maintenance + * Wim Jongmam <wim.jongman@remainsoftware.com> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing Maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.imp; @@ -24,28 +24,33 @@ import org.eclipse.jface.wizard.Wizard; public class ModelImportWizard extends Wizard { - private Class<? extends MApplicationElement> applicationElement; + private final Class<? extends MApplicationElement> applicationElement; private ModelImportPage1 page1; - private MApplication application; + private final MApplication application; - private AbstractComponentEditor editor; + private final AbstractComponentEditor editor; private final String hint; - public ModelImportWizard(Class<? extends MApplicationElement> applicationElement, AbstractComponentEditor editor, IResourcePool resourcePool) { + public ModelImportWizard(Class<? extends MApplicationElement> applicationElement, AbstractComponentEditor editor, + IResourcePool resourcePool) { this(applicationElement, editor, "", resourcePool); //$NON-NLS-1$ } - public ModelImportWizard(Class<? extends MApplicationElement> applicationElement, AbstractComponentEditor editor, String hint, IResourcePool resourcePool) { + public ModelImportWizard(Class<? extends MApplicationElement> applicationElement, AbstractComponentEditor editor, + String hint, IResourcePool resourcePool) { this.applicationElement = applicationElement; this.editor = editor; this.hint = hint; - this.application = (MApplication) editor.getEditor().getModelProvider().getRoot().get(0); - setWindowTitle(Messages.ModelImportWizard_Model + " " + applicationElement.getSimpleName() + " " + Messages.ModelImportWizard_ImportWizard); //$NON-NLS-1$ //$NON-NLS-2$ - setDefaultPageImageDescriptor(ImageDescriptor.createFromImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_Wizban16_imp3x_wiz))); - Assert.isNotNull(RegistryUtil.getStruct(applicationElement, getHint()), Messages.ModelImportWizard_UnknownElement + ": " + applicationElement.getClass().getName()); //$NON-NLS-1$ + application = (MApplication) editor.getEditor().getModelProvider().getRoot().get(0); + setWindowTitle(Messages.ModelImportWizard_Model + + " " + applicationElement.getSimpleName() + " " + Messages.ModelImportWizard_ImportWizard); //$NON-NLS-1$ //$NON-NLS-2$ + setDefaultPageImageDescriptor(ImageDescriptor.createFromImage(resourcePool + .getImageUnchecked(ResourceProvider.IMG_Wizban16_imp3x_wiz))); + Assert.isNotNull(RegistryUtil.getStruct(applicationElement, getHint()), + Messages.ModelImportWizard_UnknownElement + ": " + applicationElement.getClass().getName()); //$NON-NLS-1$ } @Override @@ -69,8 +74,8 @@ public class ModelImportWizard extends Wizard { } /** - * @return the extension point name associated with the - * {@link MApplicationElement} that is passed in the constructor of + * @return the extension point name associated with the {@link MApplicationElement} that is passed in the + * constructor of * this wizard. * @see #MAPPING_EXTENSION * @see #getApplicationElement() @@ -80,8 +85,8 @@ public class ModelImportWizard extends Wizard { } /** - * @return the extension point id associated with the - * {@link MApplicationElement} that is passed in the constructor of + * @return the extension point id associated with the {@link MApplicationElement} that is passed in the constructor + * of * this wizard. * @see #MAPPING_EXTENSION * @see #getApplicationElement() @@ -103,9 +108,9 @@ public class ModelImportWizard extends Wizard { * Returns the list of {@link MApplicationElement}s of the type passed in * the constructor of the wizard. * - * @param <T> * - * @return + * + * @return an array of {@link MApplicationElement} */ public MApplicationElement[] getElements(Class<? extends MApplicationElement> type) { return RegistryUtil.getModelElements(type, getHint(), application, page1.getConfigurationElements()); @@ -127,7 +132,7 @@ public class ModelImportWizard extends Wizard { /** * Returns the hint that explains the meaning of the caller. * - * @return + * @return the hint as a String */ public String getHint() { return hint; diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/RegistryUtil.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/RegistryUtil.java index 71c377ec..537a4494 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/RegistryUtil.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/imp/RegistryUtil.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wim Jongmam <wim.jongman@remainsoftware.com> - initial API and implementation - * Steven Spungin <steven@spungin.tv> - Ongoing Maintenance + * Wim Jongmam <wim.jongman@remainsoftware.com> - initial API and implementation + * Steven Spungin <steven@spungin.tv> - Ongoing Maintenance ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.imp; @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; + import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; @@ -71,9 +72,9 @@ public class RegistryUtil { * @param t * @param application * @param elements - * @return */ - public static MApplicationElement[] getModelElements(Class<? extends MApplicationElement> t, String hint, MApplication application, IConfigurationElement... elements) { + public static MApplicationElement[] getModelElements(Class<? extends MApplicationElement> t, String hint, + MApplication application, IConfigurationElement... elements) { Assert.isNotNull(t); Assert.isNotNull(elements); @@ -105,21 +106,21 @@ public class RegistryUtil { private static MCommand[] getCommands(IConfigurationElement[] elements, MApplication application) { - ArrayList<MCommand> result = new ArrayList<MCommand>(); + final ArrayList<MCommand> result = new ArrayList<MCommand>(); - MCommandsFactory commandsFactory = MCommandsFactory.INSTANCE; + final MCommandsFactory commandsFactory = MCommandsFactory.INSTANCE; - for (IConfigurationElement element : elements) { + for (final IConfigurationElement element : elements) { - MCommand command = commandsFactory.createCommand(); + final MCommand command = commandsFactory.createCommand(); command.setCommandName(element.getAttribute(NAME)); command.setDescription(element.getAttribute(DESCRIPTION)); command.setElementId(element.getAttribute(ID)); - String catId = element.getAttribute(CATEGORY_ID); + final String catId = element.getAttribute(CATEGORY_ID); if (catId != null && catId.trim().length() > 0) { - List<MCategory> categories = application.getCategories(); - for (MCategory category : categories) { + final List<MCategory> categories = application.getCategories(); + for (final MCategory category : categories) { if (category.getElementId().equals(catId)) { command.setCategory(category); break; @@ -135,12 +136,12 @@ public class RegistryUtil { private static MPerspective[] getPerspectives(IConfigurationElement[] elements) { - ArrayList<MPerspective> result = new ArrayList<MPerspective>(); + final ArrayList<MPerspective> result = new ArrayList<MPerspective>(); - MAdvancedFactory factory = MAdvancedFactory.INSTANCE; + final MAdvancedFactory factory = MAdvancedFactory.INSTANCE; - for (IConfigurationElement element : elements) { - MPerspective perspective = factory.createPerspective(); + for (final IConfigurationElement element : elements) { + final MPerspective perspective = factory.createPerspective(); perspective.setLabel(element.getAttribute(NAME)); perspective.setIconURI(getIconURI(element, ICON)); perspective.setElementId(element.getAttribute(ID)); @@ -154,13 +155,13 @@ public class RegistryUtil { private static MCategory[] getCategories(IConfigurationElement[] elements) { - ArrayList<MCategory> result = new ArrayList<MCategory>(); + final ArrayList<MCategory> result = new ArrayList<MCategory>(); - MCommandsFactory commandsFactory = MCommandsFactory.INSTANCE; + final MCommandsFactory commandsFactory = MCommandsFactory.INSTANCE; - for (IConfigurationElement element : elements) { + for (final IConfigurationElement element : elements) { - MCategory category = commandsFactory.createCategory(); + final MCategory category = commandsFactory.createCategory(); category.setDescription(element.getAttribute(DESCRIPTION)); category.setElementId(element.getAttribute(ID)); category.setName(element.getAttribute(NAME)); @@ -173,9 +174,9 @@ public class RegistryUtil { private static MPart[] getViews(IConfigurationElement[] elements) { - ArrayList<MPart> result = new ArrayList<MPart>(); - for (IConfigurationElement element : elements) { - MPart part = (MPart) EcoreUtil.create(BasicPackageImpl.Literals.PART); + final ArrayList<MPart> result = new ArrayList<MPart>(); + for (final IConfigurationElement element : elements) { + final MPart part = (MPart) EcoreUtil.create(BasicPackageImpl.Literals.PART); part.setElementId(element.getAttribute(ID)); part.setLabel(element.getAttribute(NAME)); part.setIconURI(getIconURI(element, ICON)); @@ -196,22 +197,22 @@ public class RegistryUtil { } private static MToolBar createToolBar(MPart part) { - MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); + final MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); toolBar.setElementId(part.getElementId()); return toolBar; } private static MMenu createViewMenu(MPart part) { - MMenu menu = MMenuFactory.INSTANCE.createMenu(); + final MMenu menu = MMenuFactory.INSTANCE.createMenu(); menu.setElementId(part.getElementId()); menu.getTags().add(VIEW_MENU); return menu; } private static MPart[] getViewsAsCompatibilityViews(IConfigurationElement[] elements) { - ArrayList<MPart> result = new ArrayList<MPart>(); - MPart[] parts = getViews(elements); - for (MPart part : parts) { + final ArrayList<MPart> result = new ArrayList<MPart>(); + final MPart[] parts = getViews(elements); + for (final MPart part : parts) { part.setContributionURI(COMPATIBILITY_VIEW); result.add(part); } @@ -219,9 +220,9 @@ public class RegistryUtil { } private static MPartDescriptor[] getPartDescriptorsAsCompatibilyViews(IConfigurationElement[] elements) { - ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); - MPartDescriptor[] parts = getViewPartDescriptors(elements); - for (MPartDescriptor part : parts) { + final ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); + final MPartDescriptor[] parts = getViewPartDescriptors(elements); + for (final MPartDescriptor part : parts) { part.setContributionURI(COMPATIBILITY_VIEW); result.add(part); } @@ -230,10 +231,10 @@ public class RegistryUtil { private static MPart[] getEditors(IConfigurationElement[] elements) { - ArrayList<MPart> result = new ArrayList<MPart>(); - for (IConfigurationElement element : elements) { + final ArrayList<MPart> result = new ArrayList<MPart>(); + for (final IConfigurationElement element : elements) { if ("editor".equals(element.getName())) /* Sanity Check */{ //$NON-NLS-1$ - MPart part = (MPart) EcoreUtil.create(BasicPackageImpl.Literals.PART); + final MPart part = (MPart) EcoreUtil.create(BasicPackageImpl.Literals.PART); part.setElementId(element.getAttribute("id")); //$NON-NLS-1$ part.setLabel(element.getAttribute("name")); //$NON-NLS-1$ part.setIconURI(getIconURI(element, "icon")); //$NON-NLS-1$ @@ -256,9 +257,10 @@ public class RegistryUtil { private static MPartDescriptor[] getEditorPartDescriptors(IConfigurationElement[] elements) { - ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); - for (IConfigurationElement element : elements) { - MPartDescriptor part = (MPartDescriptor) EcoreUtil.create(org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicPackageImpl.Literals.PART_DESCRIPTOR); + final ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); + for (final IConfigurationElement element : elements) { + final MPartDescriptor part = (MPartDescriptor) EcoreUtil + .create(org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicPackageImpl.Literals.PART_DESCRIPTOR); part.setElementId(element.getAttribute(ID)); part.setLabel(element.getAttribute(NAME)); part.setIconURI(getIconURI(element, ICON)); @@ -270,11 +272,11 @@ public class RegistryUtil { part.setDirtyable(true); part.setAllowMultiple(true); - MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); + final MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); toolBar.setElementId(part.getElementId()); part.setToolbar(toolBar); - MMenu menu = MMenuFactory.INSTANCE.createMenu(); + final MMenu menu = MMenuFactory.INSTANCE.createMenu(); menu.setElementId(part.getElementId()); menu.getTags().add(VIEW_MENU); part.getMenus().add(menu); @@ -288,18 +290,19 @@ public class RegistryUtil { private static MPartDescriptor[] getViewPartDescriptors(IConfigurationElement[] elements) { - ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); - for (IConfigurationElement element : elements) { - MPartDescriptor part = (MPartDescriptor) EcoreUtil.create(org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicPackageImpl.Literals.PART_DESCRIPTOR); + final ArrayList<MPartDescriptor> result = new ArrayList<MPartDescriptor>(); + for (final IConfigurationElement element : elements) { + final MPartDescriptor part = (MPartDescriptor) EcoreUtil + .create(org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicPackageImpl.Literals.PART_DESCRIPTOR); part.setElementId(element.getAttribute(ID)); part.setLabel(element.getAttribute(NAME)); part.setIconURI(getIconURI(element, ICON)); - MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); + final MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); toolBar.setElementId(part.getElementId()); part.setToolbar(toolBar); - MMenu menu = MMenuFactory.INSTANCE.createMenu(); + final MMenu menu = MMenuFactory.INSTANCE.createMenu(); menu.setElementId(part.getElementId()); menu.getTags().add(VIEW_MENU); part.getMenus().add(menu); @@ -313,17 +316,17 @@ public class RegistryUtil { private static MHandler[] getHandlers(IConfigurationElement[] elements, MApplication application) { - ArrayList<MHandler> result = new ArrayList<MHandler>(); - for (IConfigurationElement element : elements) { - MHandler hand = MCommandsFactory.INSTANCE.createHandler(); + final ArrayList<MHandler> result = new ArrayList<MHandler>(); + for (final IConfigurationElement element : elements) { + final MHandler hand = MCommandsFactory.INSTANCE.createHandler(); hand.setElementId(element.getAttribute(ID)); hand.setContributionURI(getContributionURI(element, CLASS)); - String cmdId = element.getAttribute(COMMAND_ID); + final String cmdId = element.getAttribute(COMMAND_ID); if (cmdId != null && cmdId.trim().length() > 0) { - List<MCommand> categories = application.getCommands(); - for (MCommand command : categories) { + final List<MCommand> categories = application.getCommands(); + for (final MCommand command : categories) { if (command.getElementId().equals(cmdId)) { hand.setCommand(command); break; @@ -356,29 +359,29 @@ public class RegistryUtil { * * @param registry * @param extensionPoint - * @return + * @return the bundle ids as an array of Strings */ public static String[] getProvidingBundles(IExtensionRegistry registry, String extensionPoint, boolean isLive) { - IExtensionLookup service = getService(IExtensionLookup.class, null); + final IExtensionLookup service = getService(IExtensionLookup.class, null); if (service == null) { return new String[] { "No " + IExtensionLookup.class.getName() + " service found." }; //$NON-NLS-1$ //$NON-NLS-2$ } - ArrayList<String> result = new ArrayList<String>(); + final ArrayList<String> result = new ArrayList<String>(); - IExtension[] extensions = service.findExtensions(extensionPoint, isLive); - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (IConfigurationElement element : elements) { + final IExtension[] extensions = service.findExtensions(extensionPoint, isLive); + for (final IExtension extension : extensions) { + final IConfigurationElement[] elements = extension.getConfigurationElements(); + for (final IConfigurationElement element : elements) { if (!result.contains(element.getContributor().getName())) { result.add(element.getContributor().getName()); } } } - String[] resultArray = result.toArray(new String[0]); + final String[] resultArray = result.toArray(new String[0]); Arrays.sort(resultArray); return resultArray; } @@ -390,19 +393,20 @@ public class RegistryUtil { * @return the array of {@link IConfigurationElement} objects that meets the * passed criteria. */ - public static IConfigurationElement[] getExtensions(IExtensionRegistry registry, RegistryStruct struct, boolean isLive) { + public static IConfigurationElement[] getExtensions(IExtensionRegistry registry, RegistryStruct struct, + boolean isLive) { - IExtensionLookup service = getService(IExtensionLookup.class, null); + final IExtensionLookup service = getService(IExtensionLookup.class, null); if (struct == null || service == null) { return new IConfigurationElement[0]; } - ArrayList<IConfigurationElement> result = new ArrayList<IConfigurationElement>(); + final ArrayList<IConfigurationElement> result = new ArrayList<IConfigurationElement>(); - IExtension[] extensions = service.findExtensions(struct.getExtensionPoint(), isLive); - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (IConfigurationElement element : elements) { + final IExtension[] extensions = service.findExtensions(struct.getExtensionPoint(), isLive); + for (final IExtension extension : extensions) { + final IConfigurationElement[] elements = extension.getConfigurationElements(); + for (final IConfigurationElement element : elements) { if (element.getContributor().getName().equals(struct.getBundle())) { if (element.getName().equals(struct.getExtensionPointName())) { result.add(element); @@ -419,27 +423,21 @@ public class RegistryUtil { * are looking for. * * @param applicationElement - * @return the structure that matches the extension registry to the passed - * {@link ApplicationElement} + * @return the structure that matches the extension registry to the passed {@link ApplicationElement} */ public static RegistryStruct getStruct(Class<? extends MApplicationElement> applicationElement, String hint) { - if (applicationElement == MCommand.class) + if (applicationElement == MCommand.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.commands", "command", NAME); //$NON-NLS-1$ //$NON-NLS-2$ - - else if (applicationElement == MCategory.class) + } else if (applicationElement == MCategory.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.commands", CATEGORY, NAME); //$NON-NLS-1$ - - else if (applicationElement == MPerspective.class) + } else if (applicationElement == MPerspective.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.perspectives", "perspective", NAME); //$NON-NLS-1$ //$NON-NLS-2$ - - else if (applicationElement == MPart.class) + } else if (applicationElement == MPart.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.views", "view", NAME); //$NON-NLS-1$ //$NON-NLS-2$ - - else if (applicationElement == MHandler.class) + } else if (applicationElement == MHandler.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.handlers", "handler", COMMAND_ID); //$NON-NLS-1$ //$NON-NLS-2$ - - else if (applicationElement == MPart.class) { + } else if (applicationElement == MPart.class) { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.views", "view", NAME); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -449,9 +447,13 @@ public class RegistryUtil { else if (applicationElement == MPartDescriptor.class) { if (hint == HINT_EDITOR) + { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.editors", EDITOR, NAME); //$NON-NLS-1$ + } if (hint == HINT_VIEW || hint == HINT_COMPAT_VIEW) + { return new RegistryStruct(EMPTY_STRING, "org.eclipse.ui.views", "view", NAME); //$NON-NLS-1$ //$NON-NLS-2$ + } } return null; @@ -460,13 +462,13 @@ public class RegistryUtil { private static <T> T getService(Class<T> clazz, String filter) { try { - BundleContext context = FrameworkUtil.getBundle(RegistryUtil.class).getBundleContext(); + final BundleContext context = FrameworkUtil.getBundle(RegistryUtil.class).getBundleContext(); Collection<ServiceReference<T>> references; references = context.getServiceReferences(clazz, filter); - for (ServiceReference<T> reference : references) { + for (final ServiceReference<T> reference : references) { return context.getService(reference); } - } catch (InvalidSyntaxException e) { + } catch (final InvalidSyntaxException e) { // FIXME log } return null; |