add help dialog
This commit is contained in:
parent
ff87e72510
commit
36f628c365
|
@ -164,7 +164,7 @@ public class WaveformView implements IWaveformView {
|
||||||
setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false);
|
setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false);
|
||||||
} else
|
} else
|
||||||
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0,
|
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0,
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
|
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
|
||||||
}
|
}
|
||||||
|
@ -197,59 +197,64 @@ public class WaveformView implements IWaveformView {
|
||||||
down = false;
|
down = false;
|
||||||
if (start == null)
|
if (start == null)
|
||||||
return;
|
return;
|
||||||
if ((e.stateMask & SWT.MODIFIER_MASK & ~SWT.SHIFT) != 0)
|
if ((e.stateMask & SWT.MODIFIER_MASK & ~(SWT.SHIFT | SWT.CTRL)) != 0)
|
||||||
return; // don't react on modifier except shift
|
return; // don't react on modifier except shift and control
|
||||||
if (e.button == 1 && Math.abs(e.x - start.x) > 3) {
|
boolean isCtrl = (e.stateMask & SWT.CTRL)!=0;
|
||||||
asyncUpdate(e.widget);
|
boolean isShift = (e.stateMask & SWT.SHIFT)!=0;
|
||||||
long startTime = waveformCanvas.getTimeForOffset(start.x);
|
if (e.button == 1) {
|
||||||
long endTime = waveformCanvas.getTimeForOffset(end.x);
|
if (Math.abs(e.x - start.x) > 3) { // was drag event
|
||||||
long targetTimeRange = endTime - startTime;
|
|
||||||
long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime();
|
|
||||||
if (targetTimeRange == 0)
|
|
||||||
return;
|
|
||||||
long relation = currentTimeRange / targetTimeRange;
|
|
||||||
long i = 1;
|
|
||||||
int level = 0;
|
|
||||||
do {
|
|
||||||
if (relation < 0) {
|
|
||||||
if (-relation < i) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
level--;
|
|
||||||
if (-relation < i * 3) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
level--;
|
|
||||||
} else {
|
|
||||||
if (relation < i) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
level++;
|
|
||||||
if (relation < i * 3) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
level++;
|
|
||||||
}
|
|
||||||
i = i * 10;
|
|
||||||
} while (i < 10000);
|
|
||||||
if (i < 10000) {
|
|
||||||
int curLevel = waveformCanvas.getZoomLevel();
|
|
||||||
waveformCanvas.setZoomLevel(curLevel - level, (startTime + endTime) / 2);
|
|
||||||
}
|
|
||||||
} else if (e.button == 1 && ((e.stateMask & SWT.SHIFT) == 0)) {
|
|
||||||
// set cursor (button 1 and no shift)
|
|
||||||
if (Math.abs(e.x - start.x) < 3 && Math.abs(e.y - start.y) < 3) {
|
|
||||||
// first set cursor time
|
|
||||||
setCursorTime(snapOffsetToEvent(start));
|
|
||||||
// then set selection and reveal
|
|
||||||
setSelection(new StructuredSelection(initialSelected));
|
|
||||||
asyncUpdate(e.widget);
|
asyncUpdate(e.widget);
|
||||||
|
long startTime = waveformCanvas.getTimeForOffset(start.x);
|
||||||
|
long endTime = waveformCanvas.getTimeForOffset(end.x);
|
||||||
|
long targetTimeRange = endTime - startTime;
|
||||||
|
long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime();
|
||||||
|
if (targetTimeRange == 0)
|
||||||
|
return;
|
||||||
|
long relation = currentTimeRange / targetTimeRange;
|
||||||
|
long i = 1;
|
||||||
|
int level = 0;
|
||||||
|
do {
|
||||||
|
if (relation < 0) {
|
||||||
|
if (-relation < i) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level--;
|
||||||
|
if (-relation < i * 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level--;
|
||||||
|
} else {
|
||||||
|
if (relation < i) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
if (relation < i * 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
i = i * 10;
|
||||||
|
} while (i < 10000);
|
||||||
|
if (i < 10000) {
|
||||||
|
int curLevel = waveformCanvas.getZoomLevel();
|
||||||
|
waveformCanvas.setZoomLevel(curLevel - level, (startTime + endTime) / 2);
|
||||||
|
}
|
||||||
|
} else if( isShift) { // set marker (button 1 and shift)
|
||||||
|
setMarkerTime(snapOffsetToEvent(start), selectedMarker);
|
||||||
|
} else if(isCtrl) { // set cursor (button 1 and ctrl)
|
||||||
|
setCursorTime(snapOffsetToEvent(start));
|
||||||
|
} else { // set cursor (button 1 only)
|
||||||
|
if (Math.abs(e.y - start.y) < 3) {
|
||||||
|
// first set cursor time
|
||||||
|
setCursorTime(snapOffsetToEvent(start));
|
||||||
|
// then set selection and reveal
|
||||||
|
setSelection(new StructuredSelection(initialSelected));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (e.button == 2 || (e.button == 1 && (e.stateMask & SWT.SHIFT) != 0)) {
|
} else if (e.button == 2) { // set marker (button 2)
|
||||||
// set marker (button 1 and shift)
|
|
||||||
setMarkerTime(snapOffsetToEvent(start), selectedMarker);
|
setMarkerTime(snapOffsetToEvent(start), selectedMarker);
|
||||||
asyncUpdate(e.widget);
|
|
||||||
}
|
}
|
||||||
|
asyncUpdate(e.widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long snapOffsetToEvent(Point p) {
|
protected long snapOffsetToEvent(Point p) {
|
||||||
|
@ -287,8 +292,8 @@ public class WaveformView implements IWaveformView {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(Event e) {
|
public void handleEvent(Event e) {
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case SWT.MouseWheel:
|
// case SWT.MouseWheel:
|
||||||
break;
|
// break;
|
||||||
case SWT.MouseDown:
|
case SWT.MouseDown:
|
||||||
start = new Point(e.x, e.y);
|
start = new Point(e.x, e.y);
|
||||||
end = new Point(e.x, e.y);
|
end = new Point(e.x, e.y);
|
||||||
|
@ -756,7 +761,7 @@ public class WaveformView implements IWaveformView {
|
||||||
ITx txSel = (ITx) selList.get(0);
|
ITx txSel = (ITx) selList.get(0);
|
||||||
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
|
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
|
||||||
? (TrackEntry) selList.get(1)
|
? (TrackEntry) selList.get(1)
|
||||||
: null;
|
: null;
|
||||||
if (trackEntry == null) {
|
if (trackEntry == null) {
|
||||||
trackEntry = getEntryFor(txSel);
|
trackEntry = getEntryFor(txSel);
|
||||||
if (trackEntry == null && addIfNeeded) {
|
if (trackEntry == null && addIfNeeded) {
|
||||||
|
@ -930,7 +935,7 @@ public class WaveformView implements IWaveformView {
|
||||||
return candidates.get(0);
|
return candidates.get(0);
|
||||||
default:
|
default:
|
||||||
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(this::streamsVisible)
|
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(this::streamsVisible)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
if (visibleCandidates.isEmpty()) {
|
if (visibleCandidates.isEmpty()) {
|
||||||
return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
||||||
} else if (visibleCandidates.size() == 1) {
|
} else if (visibleCandidates.size() == 1) {
|
||||||
|
@ -1230,7 +1235,7 @@ public class WaveformView implements IWaveformView {
|
||||||
if (event.y < tracksVerticalHeight) {
|
if (event.y < tracksVerticalHeight) {
|
||||||
event.doit = true;
|
event.doit = true;
|
||||||
LocalSelectionTransfer.getTransfer()
|
LocalSelectionTransfer.getTransfer()
|
||||||
.setSelection(new StructuredSelection(currentWaveformSelection));
|
.setSelection(new StructuredSelection(currentWaveformSelection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
</children>
|
</children>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog" label="About SCViewer" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA"/>
|
<children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog" label="About SCViewer" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA"/>
|
||||||
|
<children xsi:type="basic:Part" xmi:id="_hXh-kEYFEeyPM8G0E2EYww" elementId="com.minres.scviewer.e4.application.dialog.onlinehelp" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.HelpDialog" label="SCViewer Online Help" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA" closeable="true"/>
|
||||||
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
|
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
|
||||||
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
|
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||||
|
@ -55,7 +56,8 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:Menu" xmi:id="_95QGxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.help" label="Help">
|
<children xsi:type="menu:Menu" xmi:id="_95QGxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.help" label="Help">
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_UQRi0B07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handledmenuitem.checkforupdate" visible="false" label="Check for Update" enabled="false" command="_-9ED4B06EeuiP60JNw0iiA"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_UQRi0B07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handledmenuitem.checkforupdate" visible="false" label="Check for Update" enabled="false" command="_-9ED4B06EeuiP60JNw0iiA"/>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGxXNmEeWBq8z1Dv39LA" label="About" command="_95PfxnNmEeWBq8z1Dv39LA"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGxXNmEeWBq8z1Dv39LA" label="Online Help" command="_lqjIYEYEEeyPM8G0E2EYww"/>
|
||||||
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_4xtmgEYEEeyPM8G0E2EYww" label="About" command="_95PfxnNmEeWBq8z1Dv39LA"/>
|
||||||
</children>
|
</children>
|
||||||
</mainMenu>
|
</mainMenu>
|
||||||
<trimBars xmi:id="_95QGy3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.main.toolbar">
|
<trimBars xmi:id="_95QGy3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.main.toolbar">
|
||||||
|
@ -139,6 +141,7 @@
|
||||||
<handlers xmi:id="_h3jU8BkWEeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.handler.reloadCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ReloadHandler" command="_srACsBkREeudD5MqrWoETQ"/>
|
<handlers xmi:id="_h3jU8BkWEeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.handler.reloadCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ReloadHandler" command="_srACsBkREeudD5MqrWoETQ"/>
|
||||||
<handlers xmi:id="_gn_boBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.txSearch" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler" command="_XDxTYBlEEeuiP60JNw0iiA"/>
|
<handlers xmi:id="_gn_boBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.txSearch" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler" command="_XDxTYBlEEeuiP60JNw0iiA"/>
|
||||||
<handlers xmi:id="_CCEtAB07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.update" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.UpdateHandler" command="_-9ED4B06EeuiP60JNw0iiA"/>
|
<handlers xmi:id="_CCEtAB07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.update" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.UpdateHandler" command="_-9ED4B06EeuiP60JNw0iiA"/>
|
||||||
|
<handlers xmi:id="_ru2NIEYEEeyPM8G0E2EYww" elementId="com.minres.scviewer.e4.application.handler.helpCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.HelpHandler" command="_lqjIYEYEEeyPM8G0E2EYww"/>
|
||||||
<bindingTables xmi:id="_95PfvnNmEeWBq8z1Dv39LA" bindingContext="_95PfuXNmEeWBq8z1Dv39LA">
|
<bindingTables xmi:id="_95PfvnNmEeWBq8z1Dv39LA" bindingContext="_95PfuXNmEeWBq8z1Dv39LA">
|
||||||
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
|
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
|
||||||
<tags>type:user</tags>
|
<tags>type:user</tags>
|
||||||
|
@ -280,6 +283,7 @@
|
||||||
<commands xmi:id="_srACsBkREeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.reload" commandName="Reload Command"/>
|
<commands xmi:id="_srACsBkREeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.reload" commandName="Reload Command"/>
|
||||||
<commands xmi:id="_XDxTYBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.txSearch" commandName="Search Command"/>
|
<commands xmi:id="_XDxTYBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.txSearch" commandName="Search Command"/>
|
||||||
<commands xmi:id="_-9ED4B06EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.command.update" commandName="Update"/>
|
<commands xmi:id="_-9ED4B06EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.command.update" commandName="Update"/>
|
||||||
|
<commands xmi:id="_lqjIYEYEEeyPM8G0E2EYww" elementId="org.eclipse.ui.help.helpAction" commandName="Help Command"/>
|
||||||
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
|
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
|
||||||
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
|
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
|
||||||
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
|
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015-2021 MINRES Technologies GmbH 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:
|
||||||
|
* MINRES Technologies GmbH - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package com.minres.scviewer.e4.application.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.e4.core.di.annotations.Execute;
|
||||||
|
import org.eclipse.e4.ui.model.application.MApplication;
|
||||||
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||||
|
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
||||||
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
public class HelpHandler {
|
||||||
|
|
||||||
|
static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.onlinehelp";
|
||||||
|
|
||||||
|
@Execute
|
||||||
|
public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
|
||||||
|
MPart mel = (MPart) ms.find(DIALOG_ID, app); //$NON-NLS-1$
|
||||||
|
mel.setToBeRendered(true);
|
||||||
|
mel.setToBeRendered(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -131,7 +131,9 @@ public class AboutDialog extends Dialog {
|
||||||
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
||||||
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
||||||
}
|
}
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException e) {}
|
} catch (IOException | URISyntaxException | IllegalArgumentException e) {
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
styleRange.start = 0;
|
styleRange.start = 0;
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
package com.minres.scviewer.e4.application.parts;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.SWTError;
|
||||||
|
import org.eclipse.swt.browser.Browser;
|
||||||
|
import org.eclipse.swt.browser.LocationListener;
|
||||||
|
import org.eclipse.swt.browser.ProgressEvent;
|
||||||
|
import org.eclipse.swt.browser.ProgressListener;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
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.Listener;
|
||||||
|
import org.eclipse.swt.widgets.ProgressBar;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
import org.eclipse.swt.widgets.ToolBar;
|
||||||
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
|
|
||||||
|
public class HelpDialog extends Dialog {
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*
|
||||||
|
* @param parentShell the parent shell
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
public HelpDialog(Shell parentShell) {
|
||||||
|
super(parentShell);
|
||||||
|
setShellStyle(getShellStyle() | SWT.MODELESS | SWT.MAX | SWT.BORDER | SWT.TITLE);
|
||||||
|
setBlockOnOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isResizable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Point getInitialSize() {
|
||||||
|
return new Point(800, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create contents of the dialog.
|
||||||
|
*
|
||||||
|
* @param parent the parent
|
||||||
|
* @return the control
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite container = (Composite) super.createDialogArea(parent);
|
||||||
|
GridLayout gridLayout = new GridLayout();
|
||||||
|
gridLayout.numColumns = 3;
|
||||||
|
container.setLayout(gridLayout);
|
||||||
|
ToolBar toolbar = new ToolBar(container, SWT.NONE);
|
||||||
|
ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
|
||||||
|
itemBack.setText("Back");
|
||||||
|
ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
|
||||||
|
itemForward.setText("Forward");
|
||||||
|
ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
|
||||||
|
itemStop.setText("Stop");
|
||||||
|
ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
|
||||||
|
itemRefresh.setText("Refresh");
|
||||||
|
ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
|
||||||
|
itemGo.setText("Go");
|
||||||
|
|
||||||
|
GridData data = new GridData();
|
||||||
|
data.horizontalSpan = 3;
|
||||||
|
toolbar.setLayoutData(data);
|
||||||
|
|
||||||
|
Label labelAddress = new Label(container, SWT.NONE);
|
||||||
|
labelAddress.setText("Address");
|
||||||
|
|
||||||
|
final Text location = new Text(container, SWT.BORDER);
|
||||||
|
data = new GridData();
|
||||||
|
data.horizontalAlignment = GridData.FILL;
|
||||||
|
data.horizontalSpan = 2;
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
location.setLayoutData(data);
|
||||||
|
|
||||||
|
final Browser browser;
|
||||||
|
try {
|
||||||
|
browser = new Browser(container, SWT.NONE);
|
||||||
|
data = new GridData();
|
||||||
|
// data.widthHint = 800;
|
||||||
|
// data.heightHint =600;
|
||||||
|
data.horizontalAlignment = GridData.FILL;
|
||||||
|
data.verticalAlignment = GridData.FILL;
|
||||||
|
data.horizontalSpan = 3;
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
data.grabExcessVerticalSpace = true;
|
||||||
|
browser.setLayoutData(data);
|
||||||
|
|
||||||
|
final Label status = new Label(container, SWT.NONE);
|
||||||
|
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
data.horizontalSpan = 2;
|
||||||
|
status.setLayoutData(data);
|
||||||
|
|
||||||
|
final ProgressBar progressBar = new ProgressBar(container, SWT.NONE);
|
||||||
|
data = new GridData();
|
||||||
|
data.horizontalAlignment = GridData.END;
|
||||||
|
progressBar.setLayoutData(data);
|
||||||
|
|
||||||
|
/* event handling */
|
||||||
|
Listener listener = event -> {
|
||||||
|
ToolItem item = (ToolItem) event.widget;
|
||||||
|
String string = item.getText();
|
||||||
|
if (string.equals("Back"))
|
||||||
|
browser.back();
|
||||||
|
else if (string.equals("Forward"))
|
||||||
|
browser.forward();
|
||||||
|
else if (string.equals("Stop"))
|
||||||
|
browser.stop();
|
||||||
|
else if (string.equals("Refresh"))
|
||||||
|
browser.refresh();
|
||||||
|
else if (string.equals("Go"))
|
||||||
|
browser.setUrl(location.getText());
|
||||||
|
};
|
||||||
|
browser.addProgressListener(new ProgressListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ProgressEvent event) {
|
||||||
|
if (event.total == 0) return;
|
||||||
|
int ratio = event.current * 100 / event.total;
|
||||||
|
progressBar.setSelection(ratio);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void completed(ProgressEvent event) {
|
||||||
|
progressBar.setSelection(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
browser.addStatusTextListener(event -> status.setText(event.text));
|
||||||
|
browser.addLocationListener(LocationListener.changedAdapter(event -> {
|
||||||
|
if (event.top) location.setText(event.location);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
itemBack.addListener(SWT.Selection, listener);
|
||||||
|
itemForward.addListener(SWT.Selection, listener);
|
||||||
|
itemStop.addListener(SWT.Selection, listener);
|
||||||
|
itemRefresh.addListener(SWT.Selection, listener);
|
||||||
|
itemGo.addListener(SWT.Selection, listener);
|
||||||
|
location.addListener(SWT.DefaultSelection, e -> browser.setUrl(location.getText()));
|
||||||
|
|
||||||
|
browser.setUrl("http://eclipse.org");
|
||||||
|
} catch (SWTError e) {
|
||||||
|
System.out.println("Could not instantiate Browser: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void createButtonsForButtonBar(Composite parent) {
|
||||||
|
// create OK button
|
||||||
|
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the dialog.
|
||||||
|
* @return the result
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
@Override
|
||||||
|
public int open() {
|
||||||
|
return super.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue