public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>flintstones.group</groupId>
<artifactId>flintstones.bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.nebula.widgets.opal.checkboxgroup</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Opal Checkboxgroup plug-in</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.nebula.widgets.opal.checkboxgroup</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1779484362758</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Opal Checkboxgroup plug-in
Bundle-SymbolicName: org.eclipse.nebula.widgets.opal.checkboxgroup
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.nebula.widgets.opal.commons;bundle-version="1.0.0";visibility:=reexport
Export-Package: org.eclipse.nebula.widgets.opal.checkboxgroup
Automatic-Module-Name: org.eclipse.nebula.widgets.opal.checkboxgroup
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018, Laurent CARON.
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
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.nebula</groupId>
<artifactId>checkboxgroup</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.nebula.widgets.opal.checkboxgroup</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
@@ -0,0 +1,346 @@
/*******************************************************************************
* Copyright (c) 2011,2012 Laurent CARON 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: Laurent CARON (laurent.caron at gmail dot com) - Initial
* implementation and API Marnix van Bochove (mgvanbochove at gmail dot com) -
* Enhancements and bug fixes
*******************************************************************************/
package org.eclipse.nebula.widgets.opal.checkboxgroup;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
/**
* Instances of this class provide an etched border with a title and a checkbox.
* If the checkbox is checked, the content of the composite is enabled. If the
* checkbox is unchecked, the content of the composite is disabled, thus not
* editable.
* <p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>BORDER</dd>
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
*/
public class CheckBoxGroup extends Canvas implements PaintListener {
protected Button button;
private final Composite content;
private final List<SelectionListener> selectionListeners;
private boolean transparent = false;
/**
* Constructs a new instance of this class given its parent and a style value
* describing its behavior and appearance.
* <p>
* The style value is either one of the style constants defined in class
* <code>SWT</code> which is applicable to instances of this class, or must be
* built by <em>bitwise OR</em>'ing together (that is, using the
* <code>int</code> "|" operator) two or more of those <code>SWT</code> style
* constants. The class description lists the style constants that are
* applicable to the class. Style bits are also inherited from superclasses.
* </p>
*
* @param parent a widget which will be the parent of the new instance (cannot
* be null)
* @param style the style of widget to construct
*
* @exception IllegalArgumentException
* <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* </ul>
* @exception SWTException
* <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the parent</li>
* </ul>
*
* @see Composite#Composite(Composite, int)
* @see SWT#BORDER
* @see Widget#getStyle
*/
public CheckBoxGroup(final Composite parent, final int style) {
super(parent, style);
super.setLayout(new GridLayout());
selectionListeners = new ArrayList<SelectionListener>();
createCheckBoxButton();
content = new Composite(this, style);
content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
addPaintListener(this);
}
private void createCheckBoxButton() {
button = new Button(this, SWT.CHECK);
final GridData gdButton = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
gdButton.horizontalIndent = 15;
button.setLayoutData(gdButton);
button.setSelection(true);
button.pack();
button.addSelectionListener(new SelectionAdapter() {
/**
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(final SelectionEvent e) {
e.doit = fireSelectionListeners(e);
if (!e.doit) {
return;
}
if (button.getSelection()) {
activate();
} else {
deactivate();
}
}
});
}
/**
* Fire the selection listeners
*
* @param selectionEvent mouse event
* @return true if the selection could be changed, false otherwise
*/
private boolean fireSelectionListeners(final SelectionEvent selectionEvent) {
selectionEvent.widget = this;
for (final SelectionListener listener : selectionListeners) {
listener.widgetSelected(selectionEvent);
if (!selectionEvent.doit) {
return false;
}
}
return true;
}
/**
* Activate the content
*/
public void activate() {
button.setSelection(true);
SWTGraphicUtil.enableAllChildrenWidgets(content);
}
/**
* Adds the listener to the collection of listeners who will be notified when
* the user changes the receiver's selection, by sending it one of the messages
* defined in the <code>SelectionListener</code> interface.
* <p>
* When <code>widgetSelected</code> is called, the item field of the event
* object is valid. If the receiver has the <code>SWT.CHECK</code> style and the
* check selection changes, the event object detail field contains the value
* <code>SWT.CHECK</code>. <code>widgetDefaultSelected</code> is typically
* called when an item is double-clicked. The item field of the event object is
* valid for default selection, but the detail field is not used.
* </p>
*
* @param listener the listener which should be notified when the user changes
* the receiver's selection
*
* @exception IllegalArgumentException
* <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException
* <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been
* disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver</li>
* </ul>
*
* @see SelectionListener
* @see #removeSelectionListener
* @see SelectionEvent
*/
public void addSelectionListener(final SelectionListener listener) {
checkWidget();
selectionListeners.add(listener);
}
/**
* Deactivate the content
*/
public void deactivate() {
button.setSelection(false);
SWTGraphicUtil.disableAllChildrenWidgets(content);
}
/**
* @return <code>true</code> if the content is activated, <code>false</code>
* otherwise
*/
public boolean isActivated() {
return button.getSelection();
}
/**
* @see org.eclipse.swt.widgets.Composite#getLayout()
*/
@Override
public Layout getLayout() {
return content.getLayout();
}
/**
* Removes the listener from the collection of listeners who will be notified
* when the user changes the receiver's selection.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException
* <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException
* <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been
* disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver</li>
* </ul>
*
* @see SelectionListener
* @see #addSelectionListener
*/
public void removeSelectionListener(final SelectionListener listener) {
checkWidget();
selectionListeners.remove(listener);
}
/**
* @see org.eclipse.swt.widgets.Composite#setFocus()
*/
@Override
public boolean setFocus() {
return content.setFocus();
}
/**
* @see org.eclipse.swt.widgets.Composite#setLayout(org.eclipse.swt.widgets.Layout)
*/
@Override
public void setLayout(final Layout layout) {
content.setLayout(layout);
}
// ------------------------------------ Getters and Setters
/**
* @return the text of the button
*/
public String getText() {
return button.getText();
}
/**
* @param text the text of the button to set
*/
public void setText(final String text) {
button.setText(text);
}
/**
* @return the font of the button
*/
@Override
public Font getFont() {
return button.getFont();
}
/**
* @param font the font to set
*/
@Override
public void setFont(final Font font) {
button.setFont(font);
}
/**
* @return the content of the group
*/
public Composite getContent() {
return content;
}
public boolean isTransparent() {
return transparent;
}
public void setTransparent(final boolean transparent) {
this.transparent = transparent;
if (transparent) {
setBackgroundMode(SWT.INHERIT_DEFAULT);
content.setBackgroundMode(SWT.INHERIT_DEFAULT);
}
}
@Override
public void paintControl(final PaintEvent paintEvent) {
if (paintEvent.widget == this) {
drawWidget(paintEvent.gc);
}
}
/**
* Draws the widget
*/
private void drawWidget(final GC gc) {
final Rectangle rect = getClientArea();
final int margin = (int) (button.getSize().y * 1.5);
final int startY = margin / 2;
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
gc.drawRoundRectangle(1, startY, rect.width - 2, rect.height - startY - 2, 2, 2);
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
gc.drawRoundRectangle(2, startY + 1, rect.width - 4, rect.height - startY - 4, 2, 2);
}
/**
* Sets the selection state of the receiver
*
* @param selection the new selection state
*/
public void setSelection(boolean selection) {
if (selection) {
activate();
} else {
deactivate();
}
}
/**
* Returns <code>true</code> if the receiver is selected, and false otherwise
*
* @return the selection state
*/
public boolean getSelection() {
return isActivated();
}
}