Skip to content

Commit

Permalink
Fixed issue #1010.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 authored Feb 2, 2024
1 parent e059ad0 commit 6db645c
Show file tree
Hide file tree
Showing 8 changed files with 3,775 additions and 0 deletions.
3,632 changes: 3,632 additions & 0 deletions ldparteditor_cheat_sheet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* 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.infographic;

import org.eclipse.jface.dialogs.Dialog;
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.Shell;
import org.nschmidt.ldparteditor.resource.ResourceManager;
import org.nschmidt.ldparteditor.widget.NButton;

class InfographicDesign extends Dialog {

private static final String CHEAT_SHEET_IMAGE = "ldparteditor_cheat_sheet_100dpi.png"; //$NON-NLS-1$

InfographicDesign(Shell parentShell) {
super(parentShell);
this.setShellStyle(SWT.RESIZE | this.getShellStyle());
}

/**
* 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 = 10;
gridLayout.horizontalSpacing = 10;

NButton btnCheatSheet = new NButton(cmpContainer, SWT.NONE);
btnCheatSheet.setImage(ResourceManager.getImage(CHEAT_SHEET_IMAGE));
btnCheatSheet.setEnabled(false);
btnCheatSheet.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));

cmpContainer.pack();
return cmpContainer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* 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.infographic;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Shell;
import org.nschmidt.ldparteditor.i18n.I18n;
import org.nschmidt.ldparteditor.resource.ResourceManager;

public class InfographicDialog extends InfographicDesign {

public static final String CHEAT_SHEET_PDF = "ldparteditor_cheat_sheet.pdf"; //$NON-NLS-1$

/**
* Create the dialog.
*
* @param parentShell
*/
public InfographicDialog(Shell parentShell) {
super(parentShell);
}

@Override
public int open() {
super.create();
this.getButton(IDialogConstants.OK_ID).setText(I18n.INFOGRAPHIC_HELP_SAVE_AS_PDF);
getShell().setImage(ResourceManager.getImage("imgDuke2.png")); //$NON-NLS-1$
return super.open();
}
}
6 changes: 6 additions & 0 deletions src/org/nschmidt/ldparteditor/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private I18n() {}
private static final ResourceBundle ERRORFIXER = ResourceBundle.getBundle("org.nschmidt.ldparteditor.i18n.ErrorFixer", MyLanguage.getLocale()); //$NON-NLS-1$
private static final ResourceBundle SPINNER = ResourceBundle.getBundle("org.nschmidt.ldparteditor.i18n.Spinner", MyLanguage.getLocale()); //$NON-NLS-1$
private static final ResourceBundle DIRECTION = ResourceBundle.getBundle("org.nschmidt.ldparteditor.i18n.Direction", MyLanguage.getLocale()); //$NON-NLS-1$
private static final ResourceBundle INFOGRAPHIC = ResourceBundle.getBundle("org.nschmidt.ldparteditor.i18n.Infographic", MyLanguage.getLocale()); //$NON-NLS-1$
// Bundles end

private static boolean notAdjusted = true;
Expand Down Expand Up @@ -823,6 +824,11 @@ private static void adjust() { // Calculate line offset
public static final String ERRORFIXER_MOVED_TO = ERRORFIXER.getString(getProperty());
public static final String ERRORFIXER_MOVED_TO_HINT = ERRORFIXER.getString(getProperty());
public static final String HINTFIXER_TITLE = HINTFIXER.getString(getProperty());
public static final String INFOGRAPHIC_HELP_BUTTON_TITLE = INFOGRAPHIC.getString(getProperty());
public static final String INFOGRAPHIC_HELP_ERROR = INFOGRAPHIC.getString(getProperty());
public static final String INFOGRAPHIC_HELP_PDF_FORMAT = INFOGRAPHIC.getString(getProperty());
public static final String INFOGRAPHIC_HELP_SAVE_AS_PDF = INFOGRAPHIC.getString(getProperty());
public static final String INFOGRAPHIC_HELP_TOOLTIP = INFOGRAPHIC.getString(getProperty());
public static final String INTERSECTOR_COLOUR_MODS = INTERSECTOR.getString(getProperty());
public static final String INTERSECTOR_DESCRIPTION = INTERSECTOR.getString(getProperty());
public static final String INTERSECTOR_HIDE_OTHER = INTERSECTOR.getString(getProperty());
Expand Down
5 changes: 5 additions & 0 deletions src/org/nschmidt/ldparteditor/i18n/Infographic.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
HELP_BUTTON_TITLE = ?
HELP_ERROR = Can't export file as PDF.
HELP_PDF_FORMAT = Portable Document Format (*.pdf)
HELP_SAVE_AS_PDF = Save as PDF...
HELP_TOOLTIP = Show Help (Infographic)
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -74,6 +76,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import org.nschmidt.ldparteditor.data.VertexManager;
import org.nschmidt.ldparteditor.dialog.direction.DirectionDialog;
import org.nschmidt.ldparteditor.dialog.edger2.EdgerDialog;
import org.nschmidt.ldparteditor.dialog.infographic.InfographicDialog;
import org.nschmidt.ldparteditor.dialog.intersector.IntersectorDialog;
import org.nschmidt.ldparteditor.dialog.isecalc.IsecalcDialog;
import org.nschmidt.ldparteditor.dialog.lines2pattern.Lines2PatternDialog;
Expand Down Expand Up @@ -710,6 +713,35 @@ private static void createWidgets(MiscToolItem miscToolItem) {
Editor3DWindow.getWindow().regainFocus();
});

final NButton btnInfographic = new NButton(miscToolItem, SWT.PUSH | Cocoa.getStyle());
btnInfographic.setText(I18n.INFOGRAPHIC_HELP_BUTTON_TITLE);
btnInfographic.setToolTipText(I18n.INFOGRAPHIC_HELP_TOOLTIP);
widgetUtil(btnInfographic).addSelectionListener(e -> {
if (new InfographicDialog(Editor3DWindow.getWindow().getShell()).open() == IDialogConstants.OK_ID) {
FileDialog fd = new FileDialog(Editor3DWindow.getWindow().getShell(), SWT.SAVE);
fd.setText(I18n.INFOGRAPHIC_HELP_SAVE_AS_PDF);

fd.setFilterPath(Project.getLastVisitedPath());
fd.setFileName(InfographicDialog.CHEAT_SHEET_PDF);

String[] filterExt = { "*.pdf", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
fd.setFilterExtensions(filterExt);
String[] filterNames = { I18n.INFOGRAPHIC_HELP_PDF_FORMAT, I18n.E3D_ALL_FILES };
fd.setFilterNames(filterNames);

String selected = fd.open();
try {
Files.copy(ResourceManager.class.getResourceAsStream(InfographicDialog.CHEAT_SHEET_PDF), Path.of(selected), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ioe) {
NLogger.error(MiscToolItem.class, ioe);
MessageBox messageBox = new MessageBox(Editor3DWindow.getWindow().getShell(), SWT.ICON_ERROR | SWT.OK);
messageBox.setText(I18n.DIALOG_ERROR);
messageBox.setMessage(I18n.INFOGRAPHIC_HELP_ERROR);
messageBox.open();
}
}
});

MenuItem mntmPartReview = new MenuItem(mnuTools, SWT.PUSH);
MiscToolItem.mntmPartReviewPtr[0] = mntmPartReview;
mntmPartReview.setText(I18n.PARTREVIEW_TITLE);
Expand Down

0 comments on commit 6db645c

Please # to comment.