public LocalizeDialog(Shell shell, ITranslatableText tabTitle, ITranslatableSet targetLanguageSet, ITranslatableSet menuTextSet) { super(shell); this.tabTitle = tabTitle; this.targetLanguageSet = targetLanguageSet; this.menuTextSet = menuTextSet; // create a descriptive object for each BundleGroup IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); LinkedList groups = new LinkedList(); if (providers != null) { for (int i = 0; i < providers.length; ++i) { IBundleGroup[] bundleGroups = providers[i].getBundleGroups(); for (int j = 0; j < bundleGroups.length; ++j) { groups.add(new AboutBundleGroupData(bundleGroups[j])); } } } bundleGroupInfos = (AboutBundleGroupData[]) groups .toArray(new AboutBundleGroupData[0]); }
/** * The Plugins button was pressed. Open an about dialog on the plugins for * the selected feature. */ private void handlePluginInfoPressed() { final TableItem[] items = table.getSelection(); if (items.length <= 0) { return; } final AboutBundleGroupData info = (AboutBundleGroupData) items[0] .getData(); final IBundleGroup bundleGroup = info.getBundleGroup(); final Bundle[] bundles = bundleGroup == null ? new Bundle[0] : bundleGroup.getBundles(); final AboutPluginsDialog d = new AboutPluginsDialog(getShell(), getProductName(), bundles, WorkbenchMessages.AboutFeaturesDialog_pluginInfoTitle, NLS.bind( WorkbenchMessages.AboutFeaturesDialog_pluginInfoMessage, bundleGroup.getIdentifier()), IWorkbenchHelpContextIds.ABOUT_FEATURES_PLUGINS_DIALOG); d.open(); }
/** * Update the button enablement */ private void updateButtons(AboutBundleGroupData info) { if (info == null) { moreButton.setEnabled(false); pluginsButton.setEnabled(false); return; } // Creating the feature map is too much just to determine enablement, so // if // it doesn't already exist, just enable the buttons. If this was the // wrong // choice, then when the button is actually pressed an dialog will be // opened. if (featuresMap == null) { moreButton.setEnabled(true); pluginsButton.setEnabled(true); return; } moreButton.setEnabled(info.getLicenseUrl() != null); pluginsButton.setEnabled(true); }
/** * Update the info area */ private void updateInfoArea(AboutBundleGroupData info) { if (info == null) { imageLabel.setImage(null); text.setText(""); //$NON-NLS-1$ return; } final ImageDescriptor desc = info.getFeatureImage(); Image image = (Image) cachedImages.get(desc); if (image == null && desc != null) { image = desc.createImage(); cachedImages.put(desc, image); } imageLabel.setImage(image); final String aboutText = info.getAboutText(); textManager.setItem(null); if (aboutText != null) { textManager.setItem(AboutUtils.scan(aboutText)); } if (textManager.getItem() == null) { text.setText(WorkbenchMessages.AboutFeaturesDialog_noInformation); } }
/** * The More Info button was pressed. Open a browser with the license for the * selected item or an information dialog if there is no license, or the * browser cannot be opened. */ private void handleMoreInfoPressed() { final TableItem[] items = table.getSelection(); if (items.length <= 0) { return; } final AboutBundleGroupData info = (AboutBundleGroupData) items[0] .getData(); if (info == null || !AboutUtils.openBrowser(getShell(), info.getLicenseUrl())) { MessageDialog.openInformation(getShell(), WorkbenchMessages.AboutFeaturesDialog_noInfoTitle, WorkbenchMessages.AboutFeaturesDialog_noInformation); } }
/** * @param shell */ public AboutDialog(Shell shell) { super(shell); product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { productName = WorkbenchMessages.AboutDialog_defaultProductName; } // create a descriptive object for each BundleGroup final IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); final LinkedList<AboutBundleGroupData> groups = new LinkedList<AboutBundleGroupData>(); if (providers != null) { for (final IBundleGroupProvider provider : providers) { final IBundleGroup[] bundleGroups = provider.getBundleGroups(); for (final IBundleGroup bundleGroup : bundleGroups) { groups.add(new AboutBundleGroupData(bundleGroup)); } } } bundleGroupInfos = groups.toArray(new AboutBundleGroupData[0]); }
/** * Constructor for AboutFeaturesDialog. * * @param parentShell * the parent shell * @param productName * the product name * @param bundleGroupInfos * the bundle info */ public AboutFeaturesDialog(Shell parentShell, String productName, AboutBundleGroupData[] bundleGroupInfos, AboutBundleGroupData initialSelection) { super(parentShell); final AboutFeaturesPage page = new AboutFeaturesPage(); page.setProductName(productName); page.setBundleGroupInfos(bundleGroupInfos); page.setInitialSelection(initialSelection); String title; if (productName != null) { title = NLS.bind(WorkbenchMessages.AboutFeaturesDialog_shellTitle, productName); } else { title = WorkbenchMessages.AboutFeaturesDialog_SimpleTitle; } initializeDialog(page, title, IWorkbenchHelpContextIds.ABOUT_FEATURES_DIALOG); }
private void initializeBundleGroupInfos() { if (bundleGroupInfos == null) { final IBundleGroupProvider[] providers = Platform .getBundleGroupProviders(); // create a descriptive object for each BundleGroup final LinkedList groups = new LinkedList(); if (providers != null) { for (int i = 0; i < providers.length; ++i) { final IBundleGroup[] bundleGroups = providers[i] .getBundleGroups(); for (int j = 0; j < bundleGroups.length; ++j) { groups.add(new AboutBundleGroupData(bundleGroups[j])); } } } bundleGroupInfos = (AboutBundleGroupData[]) groups .toArray(new AboutBundleGroupData[0]); } else { // the order of the array may be changed due to sorting, so create a // copy, since the client set this value. final AboutBundleGroupData[] clientArray = bundleGroupInfos; bundleGroupInfos = new AboutBundleGroupData[clientArray.length]; System.arraycopy(clientArray, 0, bundleGroupInfos, 0, clientArray.length); } AboutData.sortByProvider(reverseSort, bundleGroupInfos); }
@Override public void createPageButtons(Composite parent) { moreButton = createButton(parent, MORE_ID, WorkbenchMessages.AboutFeaturesDialog_moreInfo); pluginsButton = createButton(parent, PLUGINS_ID, WorkbenchMessages.AboutFeaturesDialog_pluginsInfo); createButton(parent, COLUMNS_ID, WorkbenchMessages.AboutFeaturesDialog_columns); final TableItem[] items = table.getSelection(); if (items.length > 0) { updateButtons((AboutBundleGroupData) items[0].getData()); } }
private void createFeatureImageButtonRow(Composite parent) { final Composite featureContainer = new Composite(parent, SWT.NONE); final RowLayout rowLayout = new RowLayout(); rowLayout.wrap = true; featureContainer.setLayout(rowLayout); final GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; featureContainer.setLayoutData(data); for (final AboutBundleGroupData bundleGroupInfo : bundleGroupInfos) { createFeatureButton(featureContainer, bundleGroupInfo); } }
private Button createFeatureButton(Composite parent, final AboutBundleGroupData info) { if (!buttonManager.add(info)) { return null; } final ImageDescriptor desc = info.getFeatureImage(); Image featureImage = null; final Button button = new Button(parent, SWT.FLAT | SWT.PUSH); button.setData(info); featureImage = desc.createImage(); images.add(featureImage); button.setImage(featureImage); button.setToolTipText(info.getProviderName()); button.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = info.getProviderName(); } }); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { final AboutBundleGroupData[] groupInfos = buttonManager .getRelatedInfos(info); final AboutBundleGroupData selection = (AboutBundleGroupData) event.widget .getData(); final AboutFeaturesDialog d = new AboutFeaturesDialog( getShell(), productName, groupInfos, selection); d.open(); } }); return button; }
public void setBundleGroupInfos(AboutBundleGroupData[] bundleGroupInfos) { this.bundleGroupInfos = bundleGroupInfos; }
/** * Create the info area containing the image and text */ protected void createInfoArea(Composite parent) { final Font font = parent.getFont(); infoArea = new Composite(parent, SWT.BORDER); infoArea.setBackground(infoArea.getDisplay() .getSystemColor(SWT.COLOR_LIST_BACKGROUND)); infoArea.setBackgroundMode(SWT.INHERIT_FORCE); GridData data = new GridData(GridData.FILL, GridData.FILL, true, false); // need to provide space for arbitrary feature infos, not just the // one selected by default data.heightHint = convertVerticalDLUsToPixels(INFO_HEIGHT); infoArea.setLayoutData(data); final GridLayout layout = new GridLayout(); layout.numColumns = 2; infoArea.setLayout(layout); imageLabel = new Label(infoArea, SWT.NONE); data = new GridData(GridData.FILL, GridData.BEGINNING, false, false); data.widthHint = 32; data.heightHint = 32; imageLabel.setLayoutData(data); imageLabel.setFont(font); // text on the right text = new StyledText(infoArea, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); text.setAlwaysShowScrollBars(false); // Don't set caret to 'null' as this causes // https://bugs.eclipse.org/293263. // text.setCaret(null); text.setFont(parent.getFont()); data = new GridData(GridData.FILL, GridData.FILL, true, true); text.setLayoutData(data); text.setFont(font); text.setCursor(null); textManager = new AboutTextManager(text); final TableItem[] items = table.getSelection(); if (items.length > 0) { updateInfoArea((AboutBundleGroupData) items[0].getData()); } }
/** * Select the initial selection * * @param info * the info */ public void setInitialSelection(AboutBundleGroupData info) { lastSelection = info; }
/** * Return an array of strings containing the argument's information in the * proper order for this table's columns. * * @param info * the source information for the new row, must not be null */ private static String[] createRow(AboutBundleGroupData info) { return new String[] { info.getProviderName(), info.getName(), info.getVersion(), info.getId() }; }