use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MigrationProblemPreferencePage method createContents.
@Override
public Control createContents(Composite parent) {
Composite pageComponent = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
pageComponent.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
pageComponent.setLayoutData(data);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
Label label = new Label(pageComponent, SWT.LEFT);
label.setText("These are ignored breaking change problems.\n You can remove them if you want to show this type of " + "problem next time.");
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.horizontalSpan = 2;
label.setLayoutData(data);
_ignoredProblemTable = new TableViewer(pageComponent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
data = new GridData(GridData.FILL_HORIZONTAL);
_createColumns(_ignoredProblemTable);
final Table table = _ignoredProblemTable.getTable();
table.setHeaderVisible(true);
data.heightHint = 200;
_ignoredProblemTable.getTable().setLayoutData(data);
_ignoredProblemTable.setContentProvider(ArrayContentProvider.getInstance());
Composite groupComponent = new Composite(pageComponent, SWT.NULL);
GridLayout groupLayout = new GridLayout();
groupLayout.marginWidth = 0;
groupLayout.marginHeight = 0;
groupComponent.setLayout(groupLayout);
data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
groupComponent.setLayoutData(data);
_removeButton = new Button(groupComponent, SWT.PUSH);
_removeButton.setText("Remove");
_removeButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
@Override
public void widgetSelected(SelectionEvent arg0) {
StructuredSelection selection = (StructuredSelection) _ignoredProblemTable.getSelection();
if ((selection != null) && (selection.getFirstElement() instanceof Problem)) {
try {
Problem problem = (Problem) selection.getFirstElement();
_mpContainer.remove(problem);
Map<String, Problem> problemMap = _mpContainer.getProblemMap();
_ignoredProblemTable.setInput(problemMap.values().toArray(new Problem[0]));
} catch (Exception e) {
ProjectUI.logError(e);
}
}
}
});
setButtonLayoutData(_removeButton);
label = new Label(pageComponent, SWT.LEFT);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.horizontalSpan = 2;
label.setLayoutData(data);
_detailInfoLabel = new Label(pageComponent, SWT.LEFT);
_detailInfoLabel.setText("Detail Information");
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.horizontalSpan = 2;
_detailInfoLabel.setLayoutData(data);
_browser = new Browser(pageComponent, SWT.BORDER);
data = new GridData(GridData.FILL_BOTH);
_browser.setLayoutData(data);
groupComponent = new Composite(pageComponent, SWT.NULL);
groupLayout = new GridLayout();
groupLayout.marginWidth = 0;
groupLayout.marginHeight = 0;
groupComponent.setLayout(groupLayout);
data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
groupComponent.setLayoutData(data);
_fillIgnoredProblemTable();
_ignoredProblemTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
UIUtil.async(new Runnable() {
public void run() {
_updateForm(event);
}
}, 50);
}
});
return pageComponent;
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MigrationProblemPreferencePage method _fillIgnoredProblemTable.
private void _fillIgnoredProblemTable() {
try {
IgnoredProblemsContainer mpContainer = UpgradeAssistantSettingsUtil.getObjectFromStore(IgnoredProblemsContainer.class);
if (mpContainer != null) {
Map<String, Problem> problemMap = mpContainer.getProblemMap();
Problem[] problems = problemMap.values().toArray(new Problem[0]);
_ignoredProblemTable.setInput(problems);
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MigrationProblemPreferencePage method _createColumns.
private void _createColumns(final TableViewer problemsViewer) {
final String[] titles = { "Tickets", "Problem" };
final int[] bounds = { 65, 55 };
TableViewerColumn col = _createTableViewerColumn(titles[0], bounds[0], problemsViewer);
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Problem p = (Problem) element;
return p.getTicket();
}
});
col = _createTableViewerColumn(titles[1], bounds[1], problemsViewer);
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Problem p = (Problem) element;
return p.getTitle();
}
@Override
public void update(ViewerCell cell) {
super.update(cell);
Table table = problemsViewer.getTable();
table.getColumn(1).pack();
}
});
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MigrationUtil method updateMigrationProblemToStore.
public static void updateMigrationProblemToStore(Problem problem) {
File file = problem.getFile();
try {
MigrationProblemsContainer container = UpgradeAssistantSettingsUtil.getObjectFromStore(MigrationProblemsContainer.class);
boolean found = false;
for (MigrationProblems mp : container.getProblemsArray()) {
for (FileProblems fileProblem : mp.getProblems()) {
if (fileProblem.getFile().equals(file)) {
for (int i = 0; i < fileProblem.getProblems().size(); i++) {
Problem p = fileProblem.getProblems().get(i);
if (p.equals(problem)) {
fileProblem.getProblems().set(i, problem);
found = true;
break;
}
}
}
if (found) {
break;
}
}
if (found) {
break;
}
}
UpgradeAssistantSettingsUtil.setObjectToStore(MigrationProblemsContainer.class, container);
} catch (IOException ioe) {
}
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MigrationUtil method getCurrentProblemsFromTreeNode.
@SuppressWarnings("rawtypes")
public static List<Problem> getCurrentProblemsFromTreeNode(ISelection selection) {
List<Problem> notIgnoreProblems = new ArrayList<>();
if (selection instanceof IStructuredSelection) {
final IStructuredSelection ss = (IStructuredSelection) selection;
Iterator iterator = ss.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
if (element instanceof FileProblems) {
FileProblems fp = (FileProblems) element;
for (Problem problem : fp.getProblems()) {
if (problem.getStatus() != Problem.STATUS_IGNORE) {
notIgnoreProblems.add(problem);
}
}
} else if (element instanceof MigrationProblems) {
MigrationProblems migrationProblems = (MigrationProblems) element;
for (FileProblems fProblems : migrationProblems.getProblems()) {
for (Problem problem : fProblems.getProblems()) {
if (problem.getStatus() != Problem.STATUS_IGNORE) {
notIgnoreProblems.add(problem);
}
}
}
} else if (element instanceof MigrationProblemsContainer) {
MigrationProblemsContainer migrationProblemsContainer = (MigrationProblemsContainer) element;
for (MigrationProblems migrationProblems : migrationProblemsContainer.getProblemsArray()) {
for (FileProblems fProblems : migrationProblems.getProblems()) {
for (Problem problem : fProblems.getProblems()) {
if (problem.getStatus() != Problem.STATUS_IGNORE) {
notIgnoreProblems.add(problem);
}
}
}
}
}
}
// remove duplicate problem
HashSet<Problem> hashSet = new HashSet<>(notIgnoreProblems);
notIgnoreProblems.clear();
notIgnoreProblems.addAll(hashSet);
return notIgnoreProblems;
}
return notIgnoreProblems;
}
Aggregations