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

Enhancement to add new options of diagonals and antidiagonals #996 #1224

Merged
merged 16 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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 @@ -312,6 +312,8 @@ BordersPage.Tooltip.Left=Left Border
BordersPage.Tooltip.None=None
BordersPage.Tooltip.Right=Right Border
BordersPage.Tooltip.Top=Top Border
BordersPage.Tooltip.Diagonal=Diagonal
BordersPage.Tooltip.Antidiagonal=Antidiagonal
BordersPage.text.Preview=Preview:
BordersPage.Trans.SelectBorder=Select Border
BordersPage.Trans.UnSelectBorder=Unselect Border
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public static void refreshBorderData(int[] data, int style, int width, int color
* always lose; then compare the width, greater win; if width is equal, compare
* the style, less win; or keep the original. This is the part 1 of the
* algorithm.
*
* @param data border data array
* @param style border style of cell
* @param width border width of cell
* @param color border color of cell
* @param rowIndex row index cell
* @param colIndex column index of cell
* @param type 0, 1 type of bottom-, top-attribute from row or cell (0: row,
* 1: cell)
*/
public static void refreshBorderData(int[] data, int style, int width, int color, int rowIndex, int colIndex,
int type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@

package org.eclipse.birt.report.designer.internal.ui.views.attributes.page;

import java.util.List;

import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.BorderColorDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.BorderStyleDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.BorderToggleDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.BorderWidthDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.section.BorderSection;
import org.eclipse.birt.report.designer.nls.Messages;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
import org.eclipse.birt.report.model.elements.interfaces.IStyleModel;
import org.eclipse.swt.widgets.Composite;

/**
Expand All @@ -41,7 +44,7 @@ public class BordersPage extends ResetAttributePage {
@Override
public void buildUI(Composite parent) {
super.buildUI(parent);
container.setLayout(WidgetUtil.createGridLayout(1, 15));
container.setLayout(org.eclipse.birt.report.designer.internal.ui.util.WidgetUtil.createGridLayout(1, 15));

// BorderStyleDescriptorProvider styleProvider = new
// BorderStyleDescriptorProvider( );
Expand Down Expand Up @@ -86,18 +89,25 @@ public void buildUI(Composite parent) {
// BorderDescriptorProvider[]{
// styleProvider, colorProvider, widthProvider
// };
//
providers = new BorderToggleDescriptorProvider[] {
new BorderToggleDescriptorProvider(StyleHandle.BORDER_TOP_STYLE_PROP),
new BorderToggleDescriptorProvider(StyleHandle.BORDER_BOTTOM_STYLE_PROP),
new BorderToggleDescriptorProvider(StyleHandle.BORDER_LEFT_STYLE_PROP),
new BorderToggleDescriptorProvider(StyleHandle.BORDER_RIGHT_STYLE_PROP) };
//
// TogglesSection borderSection = new TogglesSection( container,
// LABEL_BORDER );
// borderSection.setProviders( providers );
// borderSection.setGridPlaceholder( 4, true );
// addSection( PageSectionId.BORDERS_BORDER_STYLE, borderSection );

// diagonal and antidiagonal buttons only added on cell object (cell handle)
if (input != null && ((List<?>) input).size() >= 1 && ((List<?>) input).get(0) instanceof CellHandle) {
providers = new BorderToggleDescriptorProvider[] {
new BorderToggleDescriptorProvider(IStyleModel.BORDER_TOP_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_BOTTOM_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_LEFT_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_RIGHT_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_DIAGONAL_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_ANTIDIAGONAL_STYLE_PROP)
};

} else {
providers = new BorderToggleDescriptorProvider[] {
new BorderToggleDescriptorProvider(IStyleModel.BORDER_TOP_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_BOTTOM_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_LEFT_STYLE_PROP),
new BorderToggleDescriptorProvider(IStyleModel.BORDER_RIGHT_STYLE_PROP) };
}

borderSection = new BorderSection(LABEL_BORDER, container, true);
BorderStyleDescriptorProvider styleProvider = new BorderStyleDescriptorProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.birt.report.model.api.metadata.IChoiceSet;
import org.eclipse.birt.report.model.elements.interfaces.IStyleModel;

public class BorderColorDescriptorProvider extends BorderDescriptorProvider {

Expand All @@ -40,28 +41,42 @@ public String getDisplayName() {

@Override
public Object load() {
String value = getLocalStringValue(StyleHandle.BORDER_LEFT_COLOR_PROP);
String value = getLocalStringValue(IStyleModel.BORDER_LEFT_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
return value;
}

value = getLocalStringValue(StyleHandle.BORDER_RIGHT_COLOR_PROP);
value = getLocalStringValue(IStyleModel.BORDER_RIGHT_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
return value;
}

value = getLocalStringValue(StyleHandle.BORDER_TOP_COLOR_PROP);
value = getLocalStringValue(IStyleModel.BORDER_TOP_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
return value;
}

value = getLocalStringValue(StyleHandle.BORDER_BOTTOM_COLOR_PROP);
value = getLocalStringValue(IStyleModel.BORDER_BOTTOM_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
return value;
}

value = getLocalStringValue(IStyleModel.BORDER_DIAGONAL_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
return value;
}

value = getLocalStringValue(IStyleModel.BORDER_ANTIDIAGONAL_COLOR_PROP);
if (!"".equals(value)) //$NON-NLS-1$
{
this.indexText = value;
Expand All @@ -79,28 +94,40 @@ public void setIndex(Object index) {
@Override
public void save(Object value) throws SemanticException {
this.indexText = value == null ? "" : value; //$NON-NLS-1$
if (((Boolean) styleMap.get(StyleHandle.BORDER_TOP_STYLE_PROP)).booleanValue()) {
save(StyleHandle.BORDER_TOP_COLOR_PROP, value);
if ((styleMap.get(IStyleModel.BORDER_TOP_STYLE_PROP)).booleanValue()) {
save(IStyleModel.BORDER_TOP_COLOR_PROP, value);
} else {
save(IStyleModel.BORDER_TOP_COLOR_PROP, null);
}

if ((styleMap.get(IStyleModel.BORDER_BOTTOM_STYLE_PROP)).booleanValue()) {
save(IStyleModel.BORDER_BOTTOM_COLOR_PROP, value);
} else {
save(IStyleModel.BORDER_BOTTOM_COLOR_PROP, null);
}

if ((styleMap.get(IStyleModel.BORDER_LEFT_STYLE_PROP)).booleanValue()) {
save(IStyleModel.BORDER_LEFT_COLOR_PROP, value);
} else {
save(StyleHandle.BORDER_TOP_COLOR_PROP, null);
save(IStyleModel.BORDER_LEFT_COLOR_PROP, null);
}

if (((Boolean) styleMap.get(StyleHandle.BORDER_BOTTOM_STYLE_PROP)).booleanValue()) {
save(StyleHandle.BORDER_BOTTOM_COLOR_PROP, value);
if ((styleMap.get(IStyleModel.BORDER_RIGHT_STYLE_PROP)).booleanValue()) {
save(IStyleModel.BORDER_RIGHT_COLOR_PROP, value);
} else {
save(StyleHandle.BORDER_BOTTOM_COLOR_PROP, null);
save(IStyleModel.BORDER_RIGHT_COLOR_PROP, null);
}

if (((Boolean) styleMap.get(StyleHandle.BORDER_LEFT_STYLE_PROP)).booleanValue()) {
save(StyleHandle.BORDER_LEFT_COLOR_PROP, value);
if ((styleMap.get(IStyleModel.BORDER_DIAGONAL_STYLE_PROP)).booleanValue()) {
save(IStyleModel.BORDER_DIAGONAL_COLOR_PROP, value);
} else {
save(StyleHandle.BORDER_LEFT_COLOR_PROP, null);
save(IStyleModel.BORDER_DIAGONAL_COLOR_PROP, null);
}

if (((Boolean) styleMap.get(StyleHandle.BORDER_RIGHT_STYLE_PROP)).booleanValue()) {
save(StyleHandle.BORDER_RIGHT_COLOR_PROP, value);
if (styleMap.get(IStyleModel.BORDER_ANTIDIAGONAL_STYLE_PROP).booleanValue()) {
save(IStyleModel.BORDER_ANTIDIAGONAL_COLOR_PROP, value);
} else {
save(StyleHandle.BORDER_RIGHT_COLOR_PROP, null);
save(IStyleModel.BORDER_ANTIDIAGONAL_COLOR_PROP, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@
import org.eclipse.birt.report.designer.util.DEUtil;
import org.eclipse.birt.report.model.api.GroupElementHandle;
import org.eclipse.birt.report.model.api.GroupPropertyHandle;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.elements.interfaces.IStyleModel;

public abstract class BorderDescriptorProvider extends AbstractDescriptorProvider {

protected Object input;

protected HashMap styleMap = new HashMap();
protected HashMap<String, Boolean> styleMap = new HashMap();

public BorderDescriptorProvider() {
styleMap.put(StyleHandle.BORDER_LEFT_STYLE_PROP, Boolean.FALSE);
styleMap.put(StyleHandle.BORDER_RIGHT_STYLE_PROP, Boolean.FALSE);
styleMap.put(StyleHandle.BORDER_TOP_STYLE_PROP, Boolean.FALSE);
styleMap.put(StyleHandle.BORDER_BOTTOM_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_LEFT_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_RIGHT_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_TOP_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_BOTTOM_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_DIAGONAL_STYLE_PROP, Boolean.FALSE);
styleMap.put(IStyleModel.BORDER_ANTIDIAGONAL_STYLE_PROP, Boolean.FALSE);
}

public void setStyleProperty(String style, Boolean value) {
Expand All @@ -47,7 +49,7 @@ public void setInput(Object input) {
protected String getLocalStringValue(String property) {
GroupElementHandle handle = null;
if (input instanceof List) {
handle = DEUtil.getGroupElementHandle((List) input);
handle = DEUtil.getGroupElementHandle((List<?>) input);
}
if (handle == null) {
return ""; //$NON-NLS-1$
Expand All @@ -64,7 +66,7 @@ protected String getLocalStringValue(String property) {
protected String getStringValue(String property) {
GroupElementHandle handle = null;
if (input instanceof List) {
handle = DEUtil.getGroupElementHandle((List) input);
handle = DEUtil.getGroupElementHandle((List<?>) input);
}
if (handle == null) {
return ""; //$NON-NLS-1$
Expand All @@ -81,26 +83,28 @@ protected String getStringValue(String property) {
protected String getDisplayValue(String property) {
GroupElementHandle handle = null;
if (input instanceof List) {
handle = DEUtil.getGroupElementHandle((List) input);
handle = DEUtil.getGroupElementHandle((List<?>) input);
}
if (handle == null) {
return ""; //$NON-NLS-1$
}
if (getLocalStringValue(property).equals("")) {
String value = handle.getPropertyHandle(property).getStringValue();
if (value == null) {
value = ""; //$NON-NLS-1$
String value = "";
if (handle.getPropertyHandle(property) != null) {
value = handle.getPropertyHandle(property).getStringValue();
if (value == null) {
value = ""; //$NON-NLS-1$
}
}
return value;
} else {
return ""; //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
}

protected String getDefaultStringValue(String property) {
GroupElementHandle handle = null;
if (input instanceof List) {
handle = DEUtil.getGroupElementHandle((List) input);
handle = DEUtil.getGroupElementHandle((List<?>) input);
}
if (handle == null) {
return ""; //$NON-NLS-1$
Expand All @@ -113,9 +117,8 @@ protected String getDefaultStringValue(String property) {
value = ""; //$NON-NLS-1$
}
return value;
} else {
return ""; //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
}

protected void save(String property, Object value) throws SemanticException {
Expand All @@ -124,7 +127,7 @@ protected void save(String property, Object value) throws SemanticException {
if (input instanceof GroupElementHandle) {
groupElementHandle = (GroupElementHandle) input;
} else if (input instanceof List) {
groupElementHandle = DEUtil.getGroupElementHandle((List) input);
groupElementHandle = DEUtil.getGroupElementHandle((List<?>) input);
}

if (groupElementHandle != null) {
Expand Down
Loading