Example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty

List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty.

Prototype

public boolean isEmpty();

Source Link

Document

Returns whether this selection is empty.

Usage

From source file:com.nokia.carbide.cpp.uiq.ui.viewwizard.InitialContentPage.java

License:Open Source License

public void createControl(Composite parent) {
    initializeDialogUnits(parent);//w  w  w  . ja v a2s  .  co m

    thumbnailComposite = new ThumbnailWithDescriptionComposite(parent, SWT.NULL);
    thumbnailComposite.setData(NAME_KEY, "thumbnailComposite"); //$NON-NLS-1$
    setControl(thumbnailComposite);
    setHelpContextId(ViewWizardManager.INITIAL_CONTENT_PAGE);

    thumbnailComposite.getThumbnailViewer().addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.isEmpty())
                return;
            handleInitialContentChanged(selection.getFirstElement());
        }
    });

    thumbnailComposite.getThumbnailViewer().setContentProvider(new ArrayContentProvider());
    thumbnailComposite.getThumbnailViewer().setLabelProvider(new LabelProvider() {
        Map<IComponent, Image> thumbnailMap = new HashMap<IComponent, Image>();

        @Override
        public void dispose() {
            super.dispose();
            for (Image image : thumbnailMap.values()) {
                image.dispose();
            }
        }

        public Image getImage(Object element) {
            if (element.equals(NO_CONTENT_ELEMENT)) {
                return NO_CONTENT_TN;
            }

            Check.checkArg(element instanceof IComponent);
            IComponent component = (IComponent) element;
            Image image = thumbnailMap.get(component);
            if (image == null) {
                IDesignerImages images = (IDesignerImages) component.getAdapter(IDesignerImages.class);
                if (images != null) {
                    image = images.getThumbnailImage();
                    image = ImageUtils.copyImage(getShell().getDisplay(), image);
                    thumbnailMap.put(component, image);
                }
            }
            return image;
        }

        public String getText(Object element) {
            if (element.equals(NO_CONTENT_ELEMENT)) {
                return NO_CONTENT_NAME;
            }

            Check.checkArg(element instanceof IComponent);
            IComponent component = (IComponent) element;
            return component.getFriendlyName();
        }
    });
    thumbnailComposite.setViewerTitle(Messages.getString("InitialContentPage.ListPrompt")); //$NON-NLS-1$
    thumbnailComposite.setDescriptionTitle(Messages.getString("InitialContentPage.DescriptionPrompt")); //$NON-NLS-1$

}

From source file:com.nokia.carbide.internal.discovery.ui.extension.AbstractDiscoveryPortalPageLayer.java

License:Open Source License

protected IAction[] makeActions(final IEditorPart part) {
    this.part = part;
    selectionListeners = new ArrayList<ISelectionChangedListener>();
    List<IAction> actions = new ArrayList<IAction>();
    IAction action;/* w w w  . java 2 s .  c o  m*/

    // install
    action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_InstallActionLabel) {
        public void run() {
            installCatalogItems(viewer.getCheckedItems());
        };

        protected boolean updateSelection(IStructuredSelection selection) {
            scheduleUpdateAllActionUIs();
            return !selection.isEmpty();
        };
    };
    action.setToolTipText(Messages.AbstractDiscoveryPortalPageLayer_InstallActionTooltip);
    action.setId(INSTALL_ACTION_ID);
    selectionListeners.add((ISelectionChangedListener) action);
    actions.add(action);

    // refresh
    action = new Action(Messages.AbstractDiscoveryPortalPageLayer_RefreshActionLabel) {
        public void run() {
            viewer.setSelection(StructuredSelection.EMPTY);
            viewer.updateCatalog();
            viewer.refresh();
        }
    };
    action.setId(REFRESH_ACTION_ID);
    actions.add(action);

    // check all
    action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_CheckAllActionLabel) {
        public void run() {
            viewer.setSelection(StructuredSelection.EMPTY);
            viewer.setSelection(getAllItemsSelection());
            viewer.refresh();
        }

        private IStructuredSelection getAllItemsSelection() {
            List<CatalogItem> catalogItems = new ArrayList<CatalogItem>();
            for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
                if (!catalogItem.isInstalled())
                    catalogItems.add(catalogItem);
            }
            return new StructuredSelection(catalogItems);
        }

        protected boolean updateSelection(IStructuredSelection selection) {
            scheduleUpdateAllActionUIs();
            return !getAllItemsSelection().equals(selection);
        }
    };
    action.setId(CHECK_ALL_ACTION_ID);
    selectionListeners.add((ISelectionChangedListener) action);
    actions.add(action);

    // uncheck all
    action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel) {
        public void run() {
            viewer.setSelection(StructuredSelection.EMPTY);
            viewer.refresh();
        };

        protected boolean updateSelection(IStructuredSelection selection) {
            scheduleUpdateAllActionUIs();
            return !selection.isEmpty();
        };
    };
    action.setId(UNCHECK_ALL_ACTION_ID);
    selectionListeners.add((ISelectionChangedListener) action);
    actions.add(action);

    // advanced install
    action = new Action(Messages.AbstractDiscoveryPortalPageLayer_AdvancedInstallActionLabel) {
        public void run() {
            showInstallWizard();
        }
    };
    action.setId(ADV_INSTALL_ACTION_ID);
    actions.add(action);

    ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            IActionBars bars = part.getEditorSite().getActionBars();
            bars.getStatusLineManager()
                    .setMessage(selection.isEmpty() ? null
                            : MessageFormat.format(
                                    Messages.AbstractDiscoveryPortalPageLayer_CheckedItemsStatusMessage,
                                    selection.size()));
        }
    };
    selectionListeners.add(selectionListener);

    return (IAction[]) actions.toArray(new IAction[actions.size()]);
}

From source file:com.nokia.carbide.remoteconnections.internal.ui.DeviceDiscoveryPrequisiteErrorDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    initializeDialogUnits(parent);// w  w  w. jav  a  2  s .  c o m

    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    container.setLayout(layout);
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // Message at top
    Text topMessage = new Text(container, SWT.MULTI | SWT.WRAP);
    topMessage.setText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_Description")); //$NON-NLS-1$
    topMessage.setEditable(false);
    topMessage.setDoubleClickEnabled(false);
    GridData topMsgData = new GridData(SWT.LEFT, SWT.CENTER, true, false);
    topMsgData.heightHint = 48;
    topMessage.setLayoutData(topMsgData);
    topMessage.setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_ToolTipText")); //$NON-NLS-1$

    // next two panes can be resized with a sash form
    SashForm sashForm = new SashForm(container, SWT.VERTICAL);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    sashForm.setLayoutData(gridData);

    // this pane lists all the agent display names
    agentListViewer = new ListViewer(sashForm, SWT.V_SCROLL | SWT.BORDER);
    agentListViewer.setContentProvider(new ArrayContentProvider());
    agentListViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((AgentItem) element).agentName;
        }

    });
    agentListViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            AgentItem item = (AgentItem) selection.getFirstElement();
            errorText.setText(item.agentErrorText);
        }

    });
    agentListViewer.setInput(agentList);

    // pane to view the information about the selected agent
    errorText = new Link(sashForm, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
    errorText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    errorText.setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_ErrorTextToolTipText")); //$NON-NLS-1$
    errorText.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            // Launch an external browser
            String siteText = event.text;
            IWorkbench workbench = PlatformUI.getWorkbench();
            try {
                IWebBrowser browser = workbench.getBrowserSupport().getExternalBrowser();
                browser.openURL(new URL(siteText));
            } catch (Exception e) {
                RemoteConnectionsActivator.logError(e);
            }
        }

    });

    // add initial weights to the above two panes
    sashForm.setWeights(new int[] { 150, 200 });

    // now the don't ask again check box
    dontAskAgainCheckBox = new Button(container, SWT.CHECK);
    dontAskAgainCheckBox.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
    dontAskAgainCheckBox.setText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainLabel")); //$NON-NLS-1$
    dontAskAgainCheckBox
            .setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainToolTipText")); //$NON-NLS-1$
    dontAskAgainCheckBox.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            dontAskAgain = dontAskAgainCheckBox.getSelection();
        }

    });

    // now finish by selecting the top most agent in the list
    // and bringing it into view
    Object o = agentListViewer.getElementAt(0);
    if (o != null)
        agentListViewer.setSelection(new StructuredSelection(o));

    ISelection selection = agentListViewer.getSelection();
    if (selection != null && !selection.isEmpty()) {
        agentListViewer.reveal(selection);
    }

    return container;
}

From source file:com.nokia.cdt.internal.debug.launch.wizard.LaunchCategorySelectionPage.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    String description = null;//from   www  .  j a  v  a2  s.com
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    if (!selection.isEmpty()) {
        LaunchCategory selectedCategory = (LaunchCategory) selection.getFirstElement();
        description = selectedCategory.getDescription();
    }
    setDescriptionText(description);
}

From source file:com.nokia.cpp.internal.api.utils.ui.ProjectFolderSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    messageLabel = new Label(composite, SWT.NONE);
    messageLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    messageLabel.setText(message);//from w  ww  . jav  a  2s .  c  om

    folderList = new TreeViewer(composite);
    GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).applyTo(folderList.getTree());
    folderList.setContentProvider(new WorkbenchContentProvider() {
        /* (non-Javadoc)
         * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getChildren(java.lang.Object)
         */
        @Override
        public Object[] getElements(Object element) {
            // first element is the project
            return new Object[] { root };
        }

        public Object[] getChildren(Object element) {
            Object[] orig = super.getChildren(element);
            if (showFiles)
                return orig;

            java.util.List<Object> containers = new ArrayList<Object>();
            for (Object item : orig) {
                if (item instanceof IContainer) {
                    containers.add(item);
                }
            }
            return containers.toArray();
        }
    });
    folderList.setLabelProvider(new WorkbenchLabelProvider());
    folderList.setInput(new Object());

    folderList.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.isEmpty())
                path = null;
            else {
                IResource resource = (IResource) selection.getFirstElement();
                if (resource instanceof IContainer) {
                    path = FileUtils.removePrefixFromPath(root.getLocation(), resource.getLocation());
                } else {
                    path = null;
                }
            }
            Button okButton = getButton(IDialogConstants.OK_ID);
            if (okButton != null)
                okButton.setEnabled(path != null);
        }

    });

    return composite;
}

From source file:com.nokia.s60tools.memspy.ui.views.MemSpyMainView.java

License:Open Source License

/**
 * makeActions./*from w w  w  . j a v a2s.  com*/
 * Creates actions
 */
private void makeActions() {

    launchSWMTAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {

            // get selection list.
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();

            // ensure that selected items are swmt-logs 
            if (!selection.isEmpty()) {

                List<MemSpyFileBundle> list = selection.toList();
                ArrayList<String> swmtLogs = new ArrayList<String>();

                boolean allFilesAreSwmtLogs = true;

                // Go thru bundle list and add all file paths into arraylist
                for (MemSpyFileBundle item : list) {
                    swmtLogs.add(item.getFilePath());
                    if (item.getFileType().equals("SWMT-log")) {
                        allFilesAreSwmtLogs = false;
                    }
                }

                // ensure that all selected files were swmt logs
                if (allFilesAreSwmtLogs) {
                    // launch swmt analyser for selected logs.
                    SwmtAnalyser analyser = new SwmtAnalyser(MemSpyConsole.getInstance());
                    analyser.analyse(swmtLogs);
                }
            }
        }
    };
    launchSWMTAction.setText("Launch SWMT-Analyser");
    launchSWMTAction.setToolTipText("Launch SWMT-Analyser");
    launchSWMTAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_LAUNCH_SWMT));

    compareTwoHeapsAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {

            // get selected items:
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            //verify that to heap files are selected.
            if (getAvailableAction() == FileActionType.COMPARE_HEAPS) {
                compareHeaps(selectionList);
            }
        }
    };

    compareTwoHeapsAction.setText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
    compareTwoHeapsAction.setToolTipText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
    compareTwoHeapsAction
            .setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));

    importAndCompareHeapsAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {

            // get selected items:
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            //verify that only one file is selected.
            if (getAvailableAction() == FileActionType.ANALYSE_HEAP) {
                importAndCompareHeaps(selectionList);
            }
        }
    };

    importAndCompareHeapsAction.setText(TOOLTIP_TEXT_IMPORT_AND_COMPARE);
    importAndCompareHeapsAction.setToolTipText(TOOLTIP_TEXT_IMPORT_AND_COMPARE);
    importAndCompareHeapsAction
            .setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));

    compareHeapsToolbarAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {

            // get selected items:
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            // check if only one file is selected.
            if (getAvailableAction() == FileActionType.ANALYSE_HEAP) {
                importAndCompareHeaps(selectionList);
            }
            // or if two heaps are selected, then compare them.
            else if (getAvailableAction() == FileActionType.COMPARE_HEAPS) {
                compareHeaps(selectionList);
            }
        }
    };

    compareHeapsToolbarAction.setText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
    compareHeapsToolbarAction.setToolTipText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
    compareHeapsToolbarAction
            .setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));

    launchHeapAnalyserAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {

            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            // Get thread name from xml-file
            String xmlFile = selectionList.get(0).getXMLFilePath();
            AnalyserXMLGenerator xml = readXMLFile(xmlFile);

            //If Symbol files has not been set to data, before analyze, user have to set a Symbol file
            if (!xml.hasXMLDebugMetaDataFile()) {
                //verify that only one file is selected.
                if (selectionList.size() == 1) {
                    //Make user to edit symbol files, and after that, continue to launch
                    int retCode = runWizard(MemSpyWizardType.SYMBOLS, xml);
                    //Don't giving an error message if user presses Cancel, instead just return
                    if (retCode == Window.CANCEL) {
                        return;
                    }
                }
            }

            String threadName = xml.getXMLThreadName();

            //verify that only one file is selected.
            if (selectionList.size() == 1) {

                //verify that heap dump file is selected.
                if (selectionList.get(0).hasHeapDumpFile()) {

                    // get xml files path
                    String xmlPath = xmlFile;

                    // launch heap analyser 
                    launchHeapAnalyser(xmlPath, null, threadName, true);

                }

            }
        }
    };
    launchHeapAnalyserAction.setText("Analyse selected heap with Heap Analyser");
    launchHeapAnalyserAction.setToolTipText("Analyse selected heap with Heap Analyser");
    launchHeapAnalyserAction
            .setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_ANALYZE_HEAP));

    launchWizardAction = new Action() {
        public void run() {
            runWizard(MemSpyWizardType.FULL, null);
        }
    };

    launchWizardAction.setText("Launch MemSpy's import Wizard");
    launchWizardAction.setToolTipText("Launch MemSpy's import Wizard");
    launchWizardAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_APP_ICON));

    doubleClickAction = new Action() {
        public void run() {
            FileActionType action = getAvailableAction();
            switch (action) {
            case ANALYSE_HEAP: {
                launchHeapAnalyserAction.run();
                break;
            }
            case ANALYSE_SWMT_ONE:
            case ANALYSE_SWMT_MULTIPLE: {
                launchSWMTAction.run();
                break;
            }
            case COMPARE_HEAPS: {
                compareTwoHeapsAction.run();
                break;
            }
            default: {
                // No need to do anything with other action.
                break;
            }

            }
        }
    };

    deleteAction = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {
            // get selected items:
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            // ensure that some item(s) is selected.
            if (selectionList.size() >= 1) {

                // Display a Confirmation dialog
                MessageBox messageBox = new MessageBox(viewer.getControl().getShell(),
                        SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                messageBox.setText("MemSpy - Delete Files");
                messageBox.setMessage("Are you sure you want to delete selected files?");
                int buttonID = messageBox.open();
                if (buttonID == SWT.YES) {
                    for (MemSpyFileBundle item : selectionList) {

                        // delete it
                        item.delete();

                    }
                    refreshContentAndView();
                }

            }

        }
    };

    deleteAction.setText("Delete");
    deleteAction.setToolTipText("Delete selected item");
    deleteAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));

    openFile = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            //verify that only one file is selected.
            if (selectionList.size() == 1) {

                // open selected log file in editor.
                File fileToOpen = new File(selectionList.get(0).getFilePath());
                if (fileToOpen.exists() && fileToOpen.isFile()) {
                    IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

                    try {
                        IDE.openEditorOnFileStore(page, fileStore);
                    } catch (PartInitException e) {
                        showErrorMessage(ERROR_TOPIC, "MemSpy was unable to open file.");
                    }
                } else {
                    showErrorMessage(ERROR_TOPIC, "File does not exists.");

                }

            }
        }
    };
    openFile.setText("Open selected file in text editor");
    openFile.setToolTipText("Open selected file in text editor");

    editSymbols = new Action() {
        @SuppressWarnings("unchecked")
        public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).toList();

            List<MemSpyFileBundle> selectionList = (List<MemSpyFileBundle>) obj;

            //verify that only one file is selected.
            if (selectionList.size() == 1) {
                AnalyserXMLGenerator info = readXMLFile(selectionList.get(0).getXMLFilePath());
                runWizard(MemSpyWizardType.SYMBOLS, info);
            }
        }
    };
    editSymbols.setText("Edit symbol definitions of selected Heap Dump");
    editSymbols.setToolTipText("Edit symbol definitions of selected Heap Dump");
}

From source file:com.nokia.sdt.series60.component.listCustomizer.ListCustomizerComposite.java

License:Open Source License

/**
 * @param parent//from   ww w  .  j  a va2 s .c  o m
 * @param style
 * @param instance 
 */
public ListCustomizerComposite(Composite parent, int style, EObject instance) {
    super(parent, style);
    IComponentInstance componentInstance = (IComponentInstance) EcoreUtil.getRegisteredAdapter(instance,
            IComponentInstance.class);
    component = componentInstance.getComponent();

    String[] styles = ListLayoutData.getComponentListBoxStyles(component);
    initData(styles);

    getThumbnailViewer().addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                ThumbData thumbData = dataMap.get(selection.getFirstElement());
                getDescriptionText().setText(thumbData.description);
                theValue = thumbData.value;
            }
        }
    });
    getThumbnailViewer().setContentProvider(new ArrayContentProvider());
    getThumbnailViewer().setLabelProvider(new LabelProvider() {
        public Image getImage(Object element) {
            ThumbData data = dataMap.get(element.toString());
            return data.image;
        }

        public String getText(Object element) {
            ThumbData data = dataMap.get(element.toString());
            return data.caption;
        }
    });
    getThumbnailViewer().setInput(dataMap.keySet());
    getThumbnailViewer().getComposite().setFocus();

    setViewerTitle(Messages.getString("ListCustomizerComposite.ViewerTitle")); //$NON-NLS-1$
    setDescriptionTitle(Messages.getString("ListCustomizerComposite.DescriptionTitle")); //$NON-NLS-1$
}

From source file:com.nokia.sdt.symbian.cproject.CProjectUtils.java

License:Open Source License

/**
 * Returns the C Element which corresponds to the given selected object.
 * /*from  w  w  w. jav  a 2  s  .com*/
 * @param selection the selection to be inspected
 * @return a C element matching the selection, or <code>null</code>
 * if no C element exists in the given selection
 */
public static ICElement getCElementFromSelection(IStructuredSelection selection) {
    if (selection != null && !selection.isEmpty()) {
        return getCElementFromSelectedObject(selection.getFirstElement());
    }
    return null;
}

From source file:com.nokia.tools.s60.editor.actions.ColorizeColorGroupAction.java

License:Open Source License

@Override
protected IStructuredSelection getSelection() {
    IStructuredSelection selection = super.getSelection();
    if (selection.isEmpty()) {

        return new StructuredSelection(new Object());
    }/*  w  w w .j  av a2  s.  c  o  m*/
    return selection;
}

From source file:com.nokia.tools.s60.editor.actions.layers.RenameLayerAction.java

License:Open Source License

@Override
public void run() {
    IStructuredSelection sel = getHost().getSelection();
    if (!sel.isEmpty()) {
        IProject project = null;/*from  w ww. ja  v  a2s. co  m*/
        if (getWorkbenchPart() instanceof IEditorPart) {
            IEditorInput input = ((IEditorPart) getWorkbenchPart()).getEditorInput();
            if (input instanceof GraphicsEditorInput) {
                input = ((GraphicsEditorInput) input).getParentEditor().getEditorInput();
            }
            if (input instanceof IFileEditorInput) {
                project = ((IFileEditorInput) input).getFile().getProject();
            }
        }
        LayerPropertiesDialog dialog = new LayerPropertiesDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
        dialog.create();
        dialog.setLayer((ILayer) sel.getFirstElement());
        dialog.setProject(project);
        if (dialog.open() == IDialogConstants.OK_ID) {
            getHost().refresh();
        }
    }
}