Search in sources :

Example 1 with TwoPaneElementSelector

use of org.eclipse.ui.dialogs.TwoPaneElementSelector in project linuxtools by eclipse.

the class SystemTapOptionsTab method chooseBinary.

private IBinary chooseBinary(IBinary[] binaries) {
    ILabelProvider programLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                name.append(bin.getPath().lastSegment());
                return name.toString();
            }
            return super.getText(element);
        }
    };
    ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                // $NON-NLS-1$ //$NON-NLS-2$
                name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be"));
                // $NON-NLS-1$
                name.append(" - ");
                name.append(bin.getPath().toString());
                return name.toString();
            }
            return super.getText(element);
        }
    };
    TwoPaneElementSelector dialog = new TwoPaneElementSelector(getActiveWorkbenchShell(), programLabelProvider, qualifierLabelProvider);
    dialog.setElements(binaries);
    // $NON-NLS-1$
    dialog.setTitle(Messages.getString("SystemtTapOptionsTab.Callgraph"));
    // $NON-NLS-1$
    dialog.setMessage(Messages.getString("SystemtTapOptionsTab.Choose_a_local_application"));
    // $NON-NLS-1$
    dialog.setUpperListLabel(Messages.getString("SystemtTapOptionsTab.Binaries"));
    // $NON-NLS-1$
    dialog.setLowerListLabel(Messages.getString("SystemtTapOptionsTab.Qualifier"));
    dialog.setMultipleSelection(false);
    if (dialog.open() == Window.OK) {
        return (IBinary) dialog.getFirstResult();
    }
    return null;
}
Also used : CElementLabelProvider(org.eclipse.cdt.ui.CElementLabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IBinary(org.eclipse.cdt.core.model.IBinary) TwoPaneElementSelector(org.eclipse.ui.dialogs.TwoPaneElementSelector)

Example 2 with TwoPaneElementSelector

use of org.eclipse.ui.dialogs.TwoPaneElementSelector in project linuxtools by eclipse.

the class ProfileLaunchShortcut method chooseBinary.

/**
 * Prompts the user to select a  binary
 * @param binList The list of binaries.
 * @param mode Old and not used parameter.
 *
 * @return the selected binary or <code>null</code> if none.
 */
// TODO remove unused mode parameter for 4.0
protected IBinary chooseBinary(List<IBinary> binList, String mode) {
    ILabelProvider programLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                return ((IBinary) element).getPath().lastSegment();
            }
            return super.getText(element);
        }
    };
    ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuilder name = new StringBuilder();
                // $NON-NLS-1$ //$NON-NLS-2$
                name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be"));
                // $NON-NLS-1$
                name.append(" - ");
                name.append(bin.getPath().toString());
                return name.toString();
            }
            return super.getText(element);
        }
    };
    TwoPaneElementSelector dialog = new TwoPaneElementSelector(getActiveWorkbenchShell(), programLabelProvider, qualifierLabelProvider);
    dialog.setElements(binList.toArray());
    dialog.setTitle(Messages.ProfileLaunchShortcut_Profile);
    dialog.setMessage(Messages.ProfileLaunchShortcut_Choose_a_local_application);
    dialog.setUpperListLabel(Messages.ProfileLaunchShortcut_Binaries);
    dialog.setLowerListLabel(Messages.ProfileLaunchShortcut_Qualifier);
    dialog.setMultipleSelection(false);
    if (dialog.open() == Window.OK) {
        return (IBinary) dialog.getFirstResult();
    }
    return null;
}
Also used : CElementLabelProvider(org.eclipse.cdt.ui.CElementLabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IBinary(org.eclipse.cdt.core.model.IBinary) TwoPaneElementSelector(org.eclipse.ui.dialogs.TwoPaneElementSelector)

Example 3 with TwoPaneElementSelector

use of org.eclipse.ui.dialogs.TwoPaneElementSelector in project linuxtools by eclipse.

the class RemoteProxyCMainTab method handleSearchButtonSelected.

/**
 * Show a dialog that lists all main types
 */
@Override
protected void handleSearchButtonSelected() {
    if (getCProject() == null) {
        MessageDialog.openInformation(getShell(), LaunchMessages.CMainTab_Project_required, LaunchMessages.CMainTab_Enter_project_before_searching_for_program);
        return;
    }
    ILabelProvider programLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                name.append(bin.getPath().lastSegment());
                return name.toString();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (!(element instanceof ICElement)) {
                return super.getImage(element);
            }
            ICElement celement = (ICElement) element;
            if (celement.getElementType() == ICElement.C_BINARY) {
                IBinary belement = (IBinary) celement;
                if (belement.isExecutable()) {
                    return DebugUITools.getImage(IDebugUIConstants.IMG_ACT_RUN);
                }
            }
            return super.getImage(element);
        }
    };
    ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                name.append(bin.getCPU() + // $NON-NLS-1$ //$NON-NLS-2$
                (bin.isLittleEndian() ? "le" : "be"));
                // $NON-NLS-1$
                name.append(" - ");
                name.append(bin.getPath().toString());
                return name.toString();
            }
            return super.getText(element);
        }
    };
    TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
    dialog.setElements(getBinaryFiles(getCProject()));
    dialog.setMessage(LaunchMessages.CMainTab_Choose_program_to_run);
    dialog.setTitle(LaunchMessages.CMainTab_Program_Selection);
    dialog.setUpperListLabel(LaunchMessages.Launch_common_BinariesColon);
    dialog.setLowerListLabel(LaunchMessages.Launch_common_QualifierColon);
    dialog.setMultipleSelection(false);
    // dialog.set
    if (dialog.open() == Window.OK) {
        IBinary binary = (IBinary) dialog.getFirstResult();
        fProgText.setText(binary.getResource().getProjectRelativePath().toString());
    }
}
Also used : CElementLabelProvider(org.eclipse.cdt.ui.CElementLabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IBinary(org.eclipse.cdt.core.model.IBinary) ICElement(org.eclipse.cdt.core.model.ICElement) TwoPaneElementSelector(org.eclipse.ui.dialogs.TwoPaneElementSelector)

Aggregations

IBinary (org.eclipse.cdt.core.model.IBinary)3 CElementLabelProvider (org.eclipse.cdt.ui.CElementLabelProvider)3 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)3 TwoPaneElementSelector (org.eclipse.ui.dialogs.TwoPaneElementSelector)3 ICElement (org.eclipse.cdt.core.model.ICElement)1