-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bbde8f
commit 56fbc36
Showing
6 changed files
with
212 additions
and
9 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
src/org/nschmidt/ldparteditor/dialog/selectgdata/SelectionDesign.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* MIT - License | ||
Copyright (c) 2012 - this year, Nils Schmidt | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
package org.nschmidt.ldparteditor.dialog.selectgdata; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.jface.dialogs.Dialog; | ||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.nschmidt.ldparteditor.i18n.I18n; | ||
import org.nschmidt.ldparteditor.resource.ResourceManager; | ||
import org.nschmidt.ldparteditor.widget.Tree; | ||
import org.nschmidt.ldparteditor.widget.TreeColumn; | ||
import org.nschmidt.ldparteditor.widget.TreeItem; | ||
|
||
/** | ||
* The data selection dialog | ||
* <p> | ||
* Note: This class should not be instantiated, it defines the gui layout and no | ||
* business logic. | ||
*/ | ||
class SelectionDesign<T> extends Dialog { | ||
|
||
final String title; | ||
final List<T> selectionData = new ArrayList<>(); | ||
final Tree[] treePtr = new Tree[1]; | ||
|
||
// Use final only for subclass/listener references! | ||
|
||
SelectionDesign(Shell parentShell, String title) { | ||
super(parentShell); | ||
this.title = title; | ||
} | ||
|
||
/** | ||
* Create contents of the dialog. | ||
* | ||
* @param parent | ||
*/ | ||
@Override | ||
protected Control createDialogArea(Composite parent) { | ||
Composite cmpContainer = (Composite) super.createDialogArea(parent); | ||
GridLayout gridLayout = (GridLayout) cmpContainer.getLayout(); | ||
gridLayout.verticalSpacing = 5; | ||
gridLayout.horizontalSpacing = 10; | ||
|
||
Label lblSpecify = new Label(cmpContainer, SWT.NONE); | ||
lblSpecify.setText(title); | ||
|
||
Label lblSeparator = new Label(cmpContainer, SWT.SEPARATOR | SWT.HORIZONTAL); | ||
lblSeparator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); | ||
|
||
final Tree tree = new Tree(cmpContainer, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL, selectionData.size()); | ||
this.treePtr[0] = tree; | ||
|
||
tree.setLinesVisible(true); | ||
tree.setHeaderVisible(true); | ||
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | ||
|
||
TreeColumn trclmnDescription = new TreeColumn(tree, SWT.NONE); | ||
trclmnDescription.setWidth(598); | ||
trclmnDescription.setText(I18n.E3D_DESCRIPTION); | ||
|
||
for (T item : selectionData) { | ||
TreeItem trtmEditor3D = new TreeItem(tree); | ||
trtmEditor3D.setImage(ResourceManager.getImage("icon16_primitives.png")); //$NON-NLS-1$ | ||
trtmEditor3D.setText(new String[] { item.toString() }); | ||
trtmEditor3D.setVisible(true); | ||
trtmEditor3D.setData(item); | ||
} | ||
|
||
tree.build(); | ||
cmpContainer.pack(); | ||
return cmpContainer; | ||
} | ||
|
||
/** | ||
* Create contents of the button bar. | ||
* | ||
* @param parent | ||
*/ | ||
@Override | ||
protected void createButtonsForButtonBar(Composite parent) { | ||
createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, false); | ||
createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_CANCEL, false); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/org/nschmidt/ldparteditor/dialog/selectgdata/SelectionDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* MIT - License | ||
Copyright (c) 2012 - this year, Nils Schmidt | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
package org.nschmidt.ldparteditor.dialog.selectgdata; | ||
|
||
import java.util.Collection; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.nschmidt.ldparteditor.logger.NLogger; | ||
|
||
/** | ||
* | ||
* <p> | ||
* Note: This class should be instantiated, it defines all listeners and part of | ||
* the business logic. It overrides the {@code open()} method to invoke the | ||
* listener definitions ;) | ||
*/ | ||
public class SelectionDialog<T> extends SelectionDesign<T> { | ||
|
||
private T selection; | ||
|
||
/** | ||
* Create the dialog. | ||
* | ||
* @param parentShell | ||
*/ | ||
public SelectionDialog(Shell parentShell, String title) { | ||
super(parentShell, title); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public int open() { | ||
super.create(); | ||
// MARK All final listeners will be configured here.. | ||
treePtr[0].addSelectionListener(ev -> { | ||
selection = (T) treePtr[0].getSelection()[0].getData(); | ||
NLogger.debug(SelectionDialog.class, "Selected data: {0}", selection); //$NON-NLS-1$ | ||
}); | ||
return super.open(); | ||
} | ||
|
||
public void addData(Collection<T> selection) { | ||
selectionData.addAll(selection); | ||
} | ||
|
||
public T getSelection() { | ||
return selection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
0 Move to manipulator test | ||
0 Name: new.dat | ||
0 Author: Nils Schmidt [BlackBrick89] | ||
0 !LDRAW_ORG Unofficial_Part | ||
0 !LICENSE Licensed under CC BY 4.0 : see CAreadme.txt | ||
|
||
0 BFC CERTIFY CCW | ||
|
||
1 4 -7.70209 29.6 -10 0 0 -1.34 1.34 0 0 0 1 0 1-4chrd.dat | ||
1 2 -7.70209 29.6 -10 0 0 1.34 -1.34 0 0 0 1 0 1-4chrd.dat | ||
1 1 -7.70209 29.6 -10 0 0 -1.34 -1.34 0 0 0 1 0 1-4chrd.dat |