Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy Validation errors / suggest missing items to add #223 #1024

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

package org.eclipse.pde.ui.tests.launcher;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.jface.window.IShellProvider;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.launcher.PluginStatusDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -55,13 +57,24 @@ private void checkEditConfigurationLink(Control[] element) {
} else if ((control instanceof Link)) {
isEditLaunchConfigurationLinkAvilable(element, control);
break;
} else if ((control instanceof Button) && (control.getToolTipText() != null) && (control.getToolTipText()
.equals(PDEUIMessages.PluginStatusDialog_copyValidationError_Tooltip))) {
isCopyValidationButtonAvilable(element, control);
break;
}
}
}

private void isEditLaunchConfigurationLinkAvilable(Control[] element, Control control) {
Control editConfigLink = element[0];
((Link) control).notifyListeners(SWT.Selection, new Event());
assertNotNull(editConfigLink.isVisible());
assertTrue(editConfigLink.isVisible());
}

private void isCopyValidationButtonAvilable(Control[] element, Control control) {
Control copyValidationError = element[1];
((Button) control).notifyListeners(SWT.Selection, new Event());
assertTrue(copyValidationError.isVisible());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,8 @@ public class PDEUIMessages extends NLS {
public static String PluginWorkingSet_noPluginsChecked;
public static String PluginStatusDialog_pluginValidation;
public static String PluginStatusDialog_validationLink;
public static String PluginStatusDialog_copyValidationError_Button;
public static String PluginStatusDialog_copyValidationError_Tooltip;
public static String PluginsView_openWith;
public static String PluginsView_import;
public static String PluginsView_select;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <[email protected]> - Bug 487943
* Dinesh Palanisamy (ETAS GmbH) - Issue 305
* Dinesh Palanisamy (ETAS GmbH) - Issue 305, 223
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.Map;

import org.eclipse.core.runtime.MultiStatus;
Expand All @@ -32,13 +35,15 @@
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.internal.ui.IHelpContextIds;
import org.eclipse.pde.internal.ui.PDELabelProvider;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -137,6 +142,8 @@ protected int getDialogBoundsStrategy() {
protected void createButtonsForButtonBar(Composite parent) {
if (fShowLink) {
createLink(parent, IDialogConstants.YES_ID, PDEUIMessages.PluginStatusDialog_validationLink, true);
createCopyValidationButton(parent, IDialogConstants.YES_ID,
PDEUIMessages.PluginStatusDialog_copyValidationError_Button, true);
}
createButton(parent, IDialogConstants.OK_ID, PDEUIMessages.PluginStatusDialog_continueButtonLabel, true);
if (fShowCancelButton) {
Expand Down Expand Up @@ -169,6 +176,34 @@ public void widgetSelected(SelectionEvent e) {
}
}

private void createCopyValidationButton(Composite parent, int yesId,
String pluginStatusDialog_copyValidationErrorButton, boolean b) {
Button copyValidationError = new Button(parent, SWT.PUSH);
copyValidationError.setText(PDEUIMessages.PluginStatusDialog_copyValidationError_Button);
copyValidationError.setToolTipText(PDEUIMessages.PluginStatusDialog_copyValidationError_Tooltip);
setButtonLayoutData(copyValidationError);
copyValidationError.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
StringBuilder validationError = new StringBuilder();
PDELabelProvider pdeLabelProvider = new PDELabelProvider();
for (Map.Entry<?, ?> validationEntry : fInput.entrySet()) {
if (validationEntry.getKey() != null) {
validationError
.append(pdeLabelProvider.getText(validationEntry.getKey()) + System.lineSeparator());
Object[] valueObject = (Object[]) validationEntry.getValue();
for (Object valueString : valueObject) {
validationError.append(" " + valueString.toString() + System.lineSeparator()); //$NON-NLS-1$
}
}
}
StringSelection strSelection = new StringSelection(validationError.toString());
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
systemClipboard.setContents(strSelection, null);
}
});
}

@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
Expand All @@ -179,7 +214,7 @@ protected void configureShell(Shell shell) {
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
gd.widthHint = 700;
gd.heightHint = 300;
container.setLayoutData(gd);

Expand All @@ -191,6 +226,7 @@ protected Control createDialogArea(Composite parent) {
treeViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
treeViewer.setComparator(new ViewerComparator());
treeViewer.setInput(fInput);
treeViewer.expandAll();
treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

getShell().setText(PDEUIMessages.PluginStatusDialog_pluginValidation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,8 @@ PluginEditor_exportTooltip=Export deployable plug-ins and fragments
PluginWorkingSet_noPluginsChecked=At least one plug-in must be checked
PluginStatusDialog_pluginValidation=Validation
PluginStatusDialog_validationLink=<A>Edit Launch Configuration</A>
PluginStatusDialog_copyValidationError_Button=Copy Errors
PluginStatusDialog_copyValidationError_Tooltip=Copy Validation Error
PluginsView_openWith=Open &With
PluginsView_import=I&mport As
PluginsView_select=Se&lect
Expand Down
Loading