Skip to content

Commit

Permalink
Replace deprecated Navigator with Project Explorer in Report Design
Browse files Browse the repository at this point in the history
perspective eclipse-birt#710

Removed the handlers calculated enablement state. We are now relying on
the visibility of the menu items instead. Also switch back to contentId
tests in places where it was previously used.
  • Loading branch information
claesrosell committed Jan 3, 2022
1 parent 8a19df6 commit 991743c
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 257 deletions.
4 changes: 2 additions & 2 deletions UI/org.eclipse.birt.report.debug.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@
<iterate operator="or" ifEmpty="false">
<adapt type="org.eclipse.core.resources.IResource">
<or>
<test property="org.eclipse.core.resources.extension" value="rpttemplate" />
<test property="org.eclipse.core.resources.extension" value="rptdesign" />
<test property="org.eclipse.core.resources.contentTypeId" value="org.eclipse.birt.report.designer.ui.editors.reporttemplate" />
<test property="org.eclipse.core.resources.contentTypeId" value="org.eclipse.birt.report.designer.ui.editors.reportdesign" />
</or>
</adapt>
</iterate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.expressions
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.birt.report.designer.ui.actions,
org.eclipse.birt.report.designer.ui.ide.navigator,
org.eclipse.birt.report.designer.ui.preview,
org.eclipse.birt.report.designer.ui.preview.editors,
org.eclipse.birt.report.designer.ui.preferences
Expand Down
386 changes: 192 additions & 194 deletions UI/org.eclipse.birt.report.designer.ui.preview.web/plugin.xml

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
import org.eclipse.birt.report.designer.ui.preview.PreviewUtil;
import org.eclipse.birt.report.designer.ui.util.ExceptionUtil;
import org.eclipse.birt.report.viewer.utilities.WebViewer;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.handlers.HandlerUtil;

/**
* The handler to generate report document in navigator view
*/
public class GenerateDocumentHandler extends AbstractViewHandler {
public class GenerateDocumentHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
PreviewUtil.clearSystemProperties();

IFile file = getSelectedFile();
IFile file = ViewHandlerUtil.getSelectedFile(HandlerUtil.getCurrentStructuredSelection(event));
if (file != null) {
String url = file.getLocation().toOSString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@
import org.eclipse.birt.report.designer.ui.util.ExceptionUtil;
import org.eclipse.birt.report.model.api.ModuleHandle;
import org.eclipse.birt.report.viewer.utilities.WebViewer;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.handlers.HandlerUtil;

/**
* The handler to run a report in navigator view
*/
public class RunReportHandler extends AbstractViewHandler {
public class RunReportHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
PreviewUtil.clearSystemProperties();
IFile file = getSelectedFile();
if (file != null) {

IFile file = ViewHandlerUtil.getSelectedFile(HandlerUtil.getCurrentStructuredSelection(event));

if (file != null) {
String url = file.getLocation().toOSString();
try {
ModuleHandle handle = SessionHandleAdapter.getInstance().getSessionHandle().openDesign(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@
import org.eclipse.birt.report.designer.ui.ReportPlugin;
import org.eclipse.birt.report.designer.ui.preview.PreviewUtil;
import org.eclipse.birt.report.viewer.utilities.WebViewer;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.handlers.HandlerUtil;

/**
* The handler to view report document in navigator view
*/
public class ViewDocumentHandler extends AbstractViewHandler {
public class ViewDocumentHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) {
PreviewUtil.clearSystemProperties();
IFile file = getSelectedFile();

IFile file = ViewHandlerUtil.getSelectedFile(HandlerUtil.getCurrentStructuredSelection(event));

if (file != null) {
String url = file.getLocation().toString();
Map<String, Object> options = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2021 Solme AB and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Claes Rosell - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.designer.ui.ide.explorer;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.IStructuredSelection;

/**
*
* Abstract handler used for all handlers in the explorer
*
*/
class ViewHandlerUtil {

public static IFile getSelectedFile(IStructuredSelection selection) {
IFile selectedFile = null;
if (selection.size() == 1 && selection.getFirstElement() instanceof IFile) {
selectedFile = (IFile) selection.getFirstElement();
}

return selectedFile;
}
}

0 comments on commit 991743c

Please sign in to comment.