### Eclipse Workspace Patch 1.0 #P org.eclipse.compare Index: compare/org/eclipse/compare/internal/CompareMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java,v retrieving revision 1.26 diff -u -r1.26 CompareMessages.java --- compare/org/eclipse/compare/internal/CompareMessages.java 25 Mar 2009 11:07:06 -0000 1.26 +++ compare/org/eclipse/compare/internal/CompareMessages.java 16 Apr 2009 12:34:16 -0000 @@ -130,6 +130,9 @@ public static String CompareContentViewerSwitchingPane_defaultViewer; public static String CompareContentViewerSwitchingPane_switchButtonTooltip; public static String CompareContentViewerSwitchingPane_discoveredLabel; + public static String CompareStructureViewerSwitchingPane_defaultViewer; + public static String CompareStructureViewerSwitchingPane_switchButtonTooltip; + public static String CompareStructureViewerSwitchingPane_discoveredLabel; public static String ReaderCreator_fileIsNotAccessible; Index: compare/org/eclipse/compare/internal/CompareMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties,v retrieving revision 1.37 diff -u -r1.37 CompareMessages.properties --- compare/org/eclipse/compare/internal/CompareMessages.properties 8 Apr 2009 09:08:49 -0000 1.37 +++ compare/org/eclipse/compare/internal/CompareMessages.properties 16 Apr 2009 12:34:17 -0000 @@ -143,5 +143,8 @@ CompareContentViewerSwitchingPane_defaultViewer=Default Compare CompareContentViewerSwitchingPane_switchButtonTooltip=Switch Compare Viewer CompareContentViewerSwitchingPane_discoveredLabel={0} Compare +CompareStructureViewerSwitchingPane_defaultViewer=Default Structure Compare +CompareStructureViewerSwitchingPane_switchButtonTooltip=Switch Structure Compare Viewer +CompareStructureViewerSwitchingPane_discoveredLabel={0} Structure Compare ReaderCreator_fileIsNotAccessible=Cannot create a reader because the file is inaccessible. Index: compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java,v retrieving revision 1.4 diff -u -r1.4 CompareContentViewerSwitchingPane.java --- compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java 30 Mar 2009 11:06:52 -0000 1.4 +++ compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java 16 Apr 2009 12:34:16 -0000 @@ -71,7 +71,7 @@ if (list.contains(fSelectedViewerDescriptor)) { // use selected viewer only when appropriate for the new input fCompareEditorInput - .setViewerDescriptor(fSelectedViewerDescriptor); + .setContentViewerDescriptor(fSelectedViewerDescriptor); Viewer viewer = fCompareEditorInput.findContentViewer( oldViewer, (ICompareInput) input, this); return viewer; @@ -80,10 +80,10 @@ fSelectedViewerDescriptor = null; } if (input instanceof ICompareInput) { - fCompareEditorInput.setViewerDescriptor(null); + fCompareEditorInput.setContentViewerDescriptor(null); Viewer viewer = fCompareEditorInput.findContentViewer(oldViewer, (ICompareInput) input, this); - fCompareEditorInput.setViewerDescriptor(fSelectedViewerDescriptor); + fCompareEditorInput.setContentViewerDescriptor(fSelectedViewerDescriptor); return viewer; } return null; @@ -125,7 +125,7 @@ protected boolean inputChanged(Object input) { return getInput() != input - || fCompareEditorInput.getViewerDescriptor() != fSelectedViewerDescriptor; + || fCompareEditorInput.getContentViewerDescriptor() != fSelectedViewerDescriptor; } public void setInput(Object input) { @@ -135,7 +135,7 @@ getCompareConfiguration()); toolBar.setVisible(vd != null && vd.length > 1); } - + private void showMenu() { ViewerDescriptor[] vd = CompareUIPlugin.getDefault() .findContentViewerDescriptor(getViewer(), getInput(), Index: compare/org/eclipse/compare/internal/CompareUIPlugin.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java,v retrieving revision 1.79 diff -u -r1.79 CompareUIPlugin.java --- compare/org/eclipse/compare/internal/CompareUIPlugin.java 1 Apr 2009 10:03:13 -0000 1.79 +++ compare/org/eclipse/compare/internal/CompareUIPlugin.java 16 Apr 2009 12:34:18 -0000 @@ -758,6 +758,46 @@ return null; } + public ViewerDescriptor[] findStructureViewerDescriptor(Viewer oldViewer, + ICompareInput input, CompareConfiguration configuration) { + if (input == null) + return null; + // we don't show the structure of additions or deletions + if (input == null || input.getLeft() == null || input.getRight() == null) + return null; + + Set result = new LinkedHashSet(); + + // content type search + IContentType ctype= getCommonType(input); + if (ctype != null) { + initializeRegistries(); + List list = fStructureMergeViewers.searchAll(ctype); + if (list != null) + result.addAll(list); + } + + // old style search + String[] types= getTypes(input); + String type= null; + if (isHomogenous(types)) { + type= normalizeCase(types[0]); + initializeRegistries(); + List list = fStructureMergeViewers.searchAll(type); + if (list != null) + result.addAll(list); + String alias= getStructureViewerAlias(type); + if (alias != null) { + list = fStructureMergeViewers.searchAll(alias); + if (list != null) + result.addAll(list); + } + } + + return result.size() > 0 ? (ViewerDescriptor[]) result + .toArray(new ViewerDescriptor[0]) : null; + } + /** * Returns a structure compare viewer based on an old viewer and an input object. * If the old viewer is suitable for showing the input, the old viewer @@ -773,56 +813,38 @@ */ public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, CompareConfiguration configuration) { + ViewerDescriptor[] descriptors = findStructureViewerDescriptor(oldViewer, input, configuration); + if (descriptors == null || descriptors.length == 0) { + // we didn't found any viewer so far. + // now we try to find a structure creator for the generic StructureDiffViewer + IContentType ctype= getCommonType(input); + + String[] types= getTypes(input); + String type= null; + if (isHomogenous(types)) { + type= normalizeCase(types[0]); + } - if (input.getLeft() == null || input.getRight() == null) // we don't show the structure of additions or deletions - return null; - - // content type search - IContentType ctype= getCommonType(input); - if (ctype != null) { - initializeRegistries(); - Viewer viewer= getViewer(fStructureMergeViewers.search(ctype), oldViewer, parent, configuration); - if (viewer != null) - return viewer; - } - - // old style search - String[] types= getTypes(input); - String type= null; - if (isHomogenous(types)) { - type= normalizeCase(types[0]); + StructureCreatorDescriptor scc= null; initializeRegistries(); - IViewerDescriptor vd= (IViewerDescriptor) fStructureMergeViewers.search(type); - if (vd == null) { - String alias= getStructureViewerAlias(type); - if (alias != null) - vd= (IViewerDescriptor) fStructureMergeViewers.search(alias); - } - if (vd != null) - return vd.createViewer(oldViewer, parent, configuration); - } - - // we didn't found any viewer so far. - // now we try to find a structure creator for the generic StructureDiffViewer - - StructureCreatorDescriptor scc= null; - initializeRegistries(); - Object desc= fStructureCreators.search(ctype); // search for content type - if (desc instanceof StructureCreatorDescriptor) - scc= (StructureCreatorDescriptor) desc; - if (scc == null && type != null) - scc= getStructureCreator(type); // search for old-style type scheme - if (scc != null) { - IStructureCreator sc= scc.createStructureCreator(); - if (sc != null) { - StructureDiffViewer sdv= new StructureDiffViewer(parent, configuration); - sdv.setStructureCreator(sc); - return sdv; + Object desc= fStructureCreators.search(ctype); // search for content type + if (desc instanceof StructureCreatorDescriptor) + scc= (StructureCreatorDescriptor) desc; + if (scc == null && type != null) + scc= getStructureCreator(type); // search for old-style type scheme + if (scc != null) { + IStructureCreator sc= scc.createStructureCreator(); + if (sc != null) { + StructureDiffViewer sdv= new StructureDiffViewer(parent, configuration); + sdv.setStructureCreator(sc); + return sdv; + } } + return null; } - return null; + return getViewer(descriptors[0], oldViewer, parent, configuration); } - + public ViewerDescriptor[] findContentViewerDescriptor(Viewer oldViewer, Object in, CompareConfiguration cc) { Set result = new LinkedHashSet(); if (in instanceof IStreamContentAccessor) { @@ -1352,4 +1374,43 @@ } return null; } + + String findStructureTypeNameOrType(ICompareInput input, ViewerDescriptor vd, CompareConfiguration cc) { + if (input == null) + return null; + // we don't show the structure of additions or deletions + if (input == null || input.getLeft() == null || input.getRight() == null) + return null; + + // content type search + IContentType ctype= getCommonType(input); + if (ctype != null) { + initializeRegistries(); + List list = fStructureMergeViewers.searchAll(ctype); + if (list != null) + if (list.contains(vd)) + return ctype.getName(); + } + + // old style search + String[] types= getTypes(input); + String type= null; + if (isHomogenous(types)) { + type= normalizeCase(types[0]); + initializeRegistries(); + List list = fStructureMergeViewers.searchAll(type); + if (list != null) + if (list.contains(vd)) + return type; + String alias= getStructureViewerAlias(type); + if (alias != null) { + list = fStructureMergeViewers.searchAll(alias); + if (list != null) + if (list.contains(vd)) + return alias; + } + } + + return null; + } } Index: compare/org/eclipse/compare/CompareEditorInput.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java,v retrieving revision 1.108 diff -u -r1.108 CompareEditorInput.java --- compare/org/eclipse/compare/CompareEditorInput.java 30 Mar 2009 12:51:14 -0000 1.108 +++ compare/org/eclipse/compare/CompareEditorInput.java 16 Apr 2009 12:34:16 -0000 @@ -21,6 +21,7 @@ import org.eclipse.compare.internal.CompareEditorInputNavigator; import org.eclipse.compare.internal.CompareMessages; import org.eclipse.compare.internal.ComparePreferencePage; +import org.eclipse.compare.internal.CompareStructureViewerSwitchingPane; import org.eclipse.compare.internal.CompareUIPlugin; import org.eclipse.compare.internal.ICompareUIConstants; import org.eclipse.compare.internal.OutlineViewerCreator; @@ -201,7 +202,8 @@ private String fHelpContextId; private InternalOutlineViewerCreator fOutlineView; - private ViewerDescriptor vd; + private ViewerDescriptor fContentViewerDescriptor; + private ViewerDescriptor fStructureViewerDescriptor; private class InternalOutlineViewerCreator extends OutlineViewerCreator { private OutlineViewerCreator getWrappedCreator() { @@ -599,22 +601,10 @@ if (hasChildren(getCompareResult())) fFocusPane= fStructureInputPane; - fStructurePane1= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; + fStructurePane1= new CompareStructureViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true, this); h.setVisible(fStructurePane1, false); - fStructurePane2= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; + fStructurePane2= new CompareStructureViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true, this); h.setVisible(fStructurePane2, false); // setup the wiring for top left pane @@ -673,14 +663,12 @@ */ protected CompareViewerPane createStructureInputPane( final Composite parent) { - return new CompareViewerSwitchingPane(parent, SWT.BORDER | SWT.FLAT, true) { + return new CompareStructureViewerSwitchingPane(parent, SWT.BORDER | SWT.FLAT, true, this) { protected Viewer getViewer(Viewer oldViewer, Object input) { if (CompareEditorInput.this.hasChildren(input)) { return createDiffViewer(this); } - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; + return super.getViewer(oldViewer, input); } }; } @@ -891,7 +879,9 @@ * @return a compare viewer which is suitable for the given input object or null */ public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - return CompareUI.findStructureViewer(oldViewer, input, parent, fCompareConfiguration); + return fStructureViewerDescriptor != null ? fStructureViewerDescriptor.createViewer(oldViewer, parent, + fCompareConfiguration) : CompareUI.findStructureViewer(oldViewer, + input, parent, fCompareConfiguration); } /** @@ -912,7 +902,7 @@ */ public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - Viewer newViewer = vd != null ? vd.createViewer(oldViewer, parent, + Viewer newViewer = fContentViewerDescriptor != null ? fContentViewerDescriptor.createViewer(oldViewer, parent, fCompareConfiguration) : CompareUI.findContentViewer(oldViewer, input, parent, fCompareConfiguration); @@ -938,23 +928,44 @@ /** * @param vd - * the viewer descriptor + * the content viewer descriptor + * @noreference This method is not intended to be referenced by clients. + * @nooverride This method is not intended to be re-implemented or extended + * by clients. + */ + public void setContentViewerDescriptor(ViewerDescriptor vd) { + this.fContentViewerDescriptor = vd; + } + + /** + * @return the content viewer descriptor set for the input + * @noreference This method is not intended to be referenced by clients. + * @nooverride This method is not intended to be re-implemented or extended + * by clients. + */ + public ViewerDescriptor getContentViewerDescriptor() { + return this.fContentViewerDescriptor; + } + + /** + * @param vd + * the structure viewer descriptor * @noreference This method is not intended to be referenced by clients. * @nooverride This method is not intended to be re-implemented or extended * by clients. */ - public void setViewerDescriptor(ViewerDescriptor vd) { - this.vd = vd; + public void setStructureViewerDescriptor(ViewerDescriptor vd) { + this.fStructureViewerDescriptor = vd; } /** - * @return the viewer descriptor set for the input + * @return the structure viewer descriptor set for the input * @noreference This method is not intended to be referenced by clients. * @nooverride This method is not intended to be re-implemented or extended * by clients. */ - public ViewerDescriptor getViewerDescriptor() { - return this.vd; + public ViewerDescriptor getStructureViewerDescriptor() { + return this.fStructureViewerDescriptor; } /** Index: compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java =================================================================== RCS file: compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java diff -N compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,254 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.compare.internal; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.CompareEditorInput; +import org.eclipse.compare.CompareViewerSwitchingPane; +import org.eclipse.compare.structuremergeviewer.ICompareInput; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.ui.PlatformUI; + +public class CompareStructureViewerSwitchingPane extends + CompareViewerSwitchingPane { + + private CompareEditorInput fCompareEditorInput; + + private ViewerDescriptor fSelectedViewerDescriptor; + + private ToolBar toolBar; + + public CompareStructureViewerSwitchingPane(Composite parent, int style, + boolean visibility, CompareEditorInput cei) { + super(parent, style, visibility); + fCompareEditorInput = cei; + } + + private CompareConfiguration getCompareConfiguration() { + return fCompareEditorInput.getCompareConfiguration(); + } + + protected Viewer getViewer(Viewer oldViewer, Object input) { + if (input instanceof ICompareInput) { + if (fSelectedViewerDescriptor != null) { + ViewerDescriptor[] array = CompareUIPlugin.getDefault().findStructureViewerDescriptor( + oldViewer, (ICompareInput)input, getCompareConfiguration()); + List list = array != null ? Arrays.asList(array) + : Collections.EMPTY_LIST; + if (list.contains(fSelectedViewerDescriptor)) { + // use selected viewer only when appropriate for the new input + fCompareEditorInput + .setStructureViewerDescriptor(fSelectedViewerDescriptor); + Viewer viewer = fCompareEditorInput.findStructureViewer( + oldViewer, (ICompareInput) input, this); + return viewer; + } + // fallback to default otherwise + fSelectedViewerDescriptor = null; + } + + fCompareEditorInput.setStructureViewerDescriptor(null); + Viewer viewer = fCompareEditorInput.findStructureViewer(oldViewer, + (ICompareInput) input, this); + fCompareEditorInput.setStructureViewerDescriptor(fSelectedViewerDescriptor); + return viewer; + } + return null; + } + + protected Control createTopLeft(Composite p) { + final Composite composite = new Composite(p, SWT.NONE) { + public Point computeSize(int wHint, int hHint, boolean changed) { + return super.computeSize(wHint, Math.max(24, hHint), changed); + } + }; + + RowLayout layout = new RowLayout(); + layout.marginTop = 0; + composite.setLayout(layout); + + CLabel cl = new CLabel(composite, SWT.NONE); + cl.setText(null); + + toolBar = new ToolBar(composite, SWT.FLAT); + toolBar.setVisible(false); // hide by default + final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH, 0); + toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage( + /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU")); //$NON-NLS-1$ + toolItem + .setToolTipText(CompareMessages.CompareStructureViewerSwitchingPane_switchButtonTooltip); + toolItem.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + showMenu(); + } + }); + toolBar.addMouseListener(new MouseAdapter() { + public void mouseDown(MouseEvent e) { + showMenu(); + } + }); + return composite; + } + + protected boolean inputChanged(Object input) { + return getInput() != input + || fCompareEditorInput.getStructureViewerDescriptor() != fSelectedViewerDescriptor; + } + + public void setInput(Object input) { + super.setInput(input); + ViewerDescriptor[] vd = null; + if (getInput() instanceof ICompareInput) { + vd = CompareUIPlugin.getDefault().findStructureViewerDescriptor( + getViewer(), (ICompareInput) getInput(), + getCompareConfiguration()); + } + toolBar.setVisible(vd != null && vd.length > 1); + } + + private void showMenu() { + if (!(getInput() instanceof ICompareInput)) + return; + + ViewerDescriptor[] vd = CompareUIPlugin.getDefault() + .findStructureViewerDescriptor(getViewer(), + (ICompareInput) getInput(), getCompareConfiguration()); + + // 1. create + final Menu menu = new Menu(getShell(), SWT.POP_UP); + + // add default + String label = CompareMessages.CompareStructureViewerSwitchingPane_defaultViewer; + MenuItem defaultItem = new MenuItem(menu, SWT.RADIO); + defaultItem.setText(label); + defaultItem.addSelectionListener(createSelectionListener(null)); + defaultItem.setSelection(fSelectedViewerDescriptor == null); + + new MenuItem(menu, SWT.SEPARATOR); + + // add others + for (int i = 0; i < vd.length; i++) { + final ViewerDescriptor vdi = vd[i]; + label = vdi.getLabel(); + if (label == null || label.equals("")) { //$NON-NLS-1$ + String l = CompareUIPlugin.getDefault().findStructureTypeNameOrType((ICompareInput) getInput(), vdi, getCompareConfiguration()); + if (l == null) + // couldn't figure out the label, skip the viewer + continue; + label = NLS.bind(CompareMessages.CompareStructureViewerSwitchingPane_discoveredLabel, new Object[] {l}); + } + MenuItem item = new MenuItem(menu, SWT.RADIO); + item.setText(label); + item.addSelectionListener(createSelectionListener(vdi)); + item.setSelection(vdi == fSelectedViewerDescriptor); + } + + // 2. show + Rectangle bounds = toolBar.getItem(0).getBounds(); + Point topLeft = new Point(bounds.x, bounds.y + bounds.height); + topLeft = toolBar.toDisplay(topLeft); + menu.setLocation(topLeft.x, topLeft.y); + menu.setVisible(true); + + // 3. dispose on close + menu.addMenuListener(new MenuAdapter() { + public void menuHidden(MenuEvent e) { + e.display.asyncExec(new Runnable() { + public void run() { + menu.dispose(); + } + }); + } + }); + } + + private SelectionListener createSelectionListener(final ViewerDescriptor vd) { + return new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + MenuItem mi = (MenuItem) e.widget; + if (mi.getSelection()) { + Viewer oldViewer = getViewer(); + fSelectedViewerDescriptor = vd; + CompareStructureViewerSwitchingPane.this.setInput(oldViewer + .getInput()); + } + } + + public void widgetDefaultSelected(SelectionEvent e) { + // nothing to do + } + }; + } + + public void setText(String label) { + Composite c = (Composite) getTopLeft(); + Control[] children = c.getChildren(); + for (int i = 0; i < children.length; i++) { + if (children[i] instanceof CLabel) { + CLabel cl = (CLabel) children[i]; + if (cl != null && !cl.isDisposed()) { + cl.setText(label); + c.layout(); + } + return; + } + } + } + + public void setImage(Image image) { + Composite c = (Composite) getTopLeft(); + Control[] children = c.getChildren(); + for (int i = 0; i < children.length; i++) { + if (children[i] instanceof CLabel) { + CLabel cl = (CLabel) children[i]; + if (cl != null && !cl.isDisposed()) + cl.setImage(image); + return; + } + } + } + + public void addMouseListener(MouseListener listener) { + Composite c = (Composite) getTopLeft(); + Control[] children = c.getChildren(); + for (int i = 0; i < children.length; i++) { + if (children[i] instanceof CLabel) { + CLabel cl = (CLabel) children[i]; + cl.addMouseListener(listener); + } + } + } +}