This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
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
c10233f
commit 5e87705
Showing
19 changed files
with
631 additions
and
107 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/CommonOperationCallable.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.utils.operation; | |||
|
|||
import java.util.concurrent.Callable; | |||
|
|||
import org.eclipse.core.runtime.CoreException; | |||
|
|||
import melnorme.utilbox.concurrency.OperationCancellation; | |||
import melnorme.utilbox.core.CommonException; | |||
|
|||
public interface CommonOperationCallable<RET> extends Callable<RET> { | |||
|
|||
@Override | |||
RET call() throws CoreException, CommonException, OperationCancellation; | |||
|
|||
} |
22 changes: 22 additions & 0 deletions
22
plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/CommonProgressRunnable.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.utils.operation; | |||
|
|||
import org.eclipse.core.runtime.IProgressMonitor; | |||
|
|||
import melnorme.utilbox.concurrency.OperationCancellation; | |||
import melnorme.utilbox.core.CommonException; | |||
|
|||
public interface CommonProgressRunnable { | |||
|
|||
void run(IProgressMonitor pm) throws CommonException, OperationCancellation; | |||
|
|||
} |
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
118 changes: 118 additions & 0 deletions
118
plugin_ide.ui/src-lang/melnorme/lang/ide/ui/operations/StartBundleDownloadOperation.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,118 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.ui.operations; | |||
|
|||
|
|||
import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; | |||
|
|||
import org.eclipse.debug.core.DebugPlugin; | |||
import org.eclipse.jface.dialogs.Dialog; | |||
import org.eclipse.jface.dialogs.IconAndMessageDialog; | |||
import org.eclipse.jface.layout.GridDataFactory; | |||
import org.eclipse.swt.SWT; | |||
import org.eclipse.swt.graphics.Image; | |||
import org.eclipse.swt.widgets.Composite; | |||
import org.eclipse.swt.widgets.Control; | |||
import org.eclipse.swt.widgets.Display; | |||
import org.eclipse.swt.widgets.Shell; | |||
|
|||
import melnorme.lang.ide.core.LangCore; | |||
import melnorme.lang.ide.core.operations.AbstractToolManager; | |||
import melnorme.lang.ide.core.utils.operation.EclipseCancelMonitor; | |||
import melnorme.lang.ide.ui.utils.WorkbenchUtils; | |||
import melnorme.lang.ide.ui.utils.operations.BasicUIOperation; | |||
import melnorme.lang.ide.ui.utils.operations.RunOperationAsJob; | |||
import melnorme.util.swt.SWTFactory; | |||
import melnorme.utilbox.misc.ArrayUtil; | |||
|
|||
public abstract class StartBundleDownloadOperation extends BasicUIOperation { | |||
|
|||
protected final AbstractToolManager toolMgr = LangCore.getToolManager(); | |||
|
|||
public StartBundleDownloadOperation(String operationName) { | |||
super(operationName); | |||
} | |||
|
|||
protected void startProcessUnderJob(ProcessBuilder pb, String toolLocation) { | |||
String cmdLineRender = DebugPlugin.renderArguments(ArrayUtil.createFrom(pb.command(), String.class), null); | |||
|
|||
startProcessUnderJob(pb, cmdLineRender, toolLocation); | |||
} | |||
|
|||
protected void startProcessUnderJob(ProcessBuilder pb, String cmdLineRender, String toolLocation) { | |||
boolean confirm = openIntroDialog(cmdLineRender, toolLocation); | |||
|
|||
if(confirm) { | |||
scheduleDownloadJob(pb); | |||
} | |||
} | |||
|
|||
protected boolean openIntroDialog(String cmdLineRender, String toolLocation) { | |||
Shell shell = WorkbenchUtils.getActiveWorkbenchShell(); | |||
IntroDialog introDialog = new IntroDialog(shell, operationName, cmdLineRender, toolLocation); | |||
boolean confirm = introDialog.open() == Dialog.OK; | |||
return confirm; | |||
} | |||
|
|||
protected void scheduleDownloadJob(ProcessBuilder pb) { | |||
new RunOperationAsJob(operationName, (pm) -> { | |||
toolMgr.new RunEngineClientOperation(pb, new EclipseCancelMonitor(pm)).runProcess(null); | |||
Display.getDefault().asyncExec(() -> afterDownloadJobCompletes_inUI()); | |||
}).schedule(); | |||
} | |||
|
|||
protected void afterDownloadJobCompletes_inUI() { | |||
} | |||
|
|||
protected static class IntroDialog extends IconAndMessageDialog { | |||
|
|||
protected final String dialogTitle; | |||
protected final String commandLine; | |||
protected final String binLocation; | |||
|
|||
public IntroDialog(Shell parentShell, String dialogTitle, String commandLine, String binLocation) { | |||
super(parentShell); | |||
this.dialogTitle = assertNotNull(dialogTitle); | |||
this.commandLine = assertNotNull(commandLine); | |||
this.binLocation = assertNotNull(binLocation);; | |||
} | |||
|
|||
@Override | |||
protected void configureShell(Shell newShell) { | |||
super.configureShell(newShell); | |||
newShell.setText(dialogTitle); | |||
} | |||
|
|||
@Override | |||
protected Image getImage() { | |||
return Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION); | |||
} | |||
|
|||
@Override | |||
protected Control createDialogArea(Composite parent) { | |||
Composite dialogArea = (Composite) super.createDialogArea(parent); | |||
SWTFactory.createLabel(dialogArea, SWT.NONE, | |||
"The following process will be started in the background:"); | |||
|
|||
SWTFactory.createReadonlyText(dialogArea, commandLine, | |||
GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).create()); | |||
|
|||
SWTFactory.createLabel(dialogArea, SWT.NONE, | |||
"The executable will be located at:"); | |||
|
|||
SWTFactory.createReadonlyText(dialogArea, binLocation, GridDataFactory.fillDefaults().create()); | |||
|
|||
return dialogArea; | |||
} | |||
|
|||
} | |||
|
|||
} |
88 changes: 88 additions & 0 deletions
88
plugin_ide.ui/src-lang/melnorme/lang/ide/ui/preferences/pages/DownloadToolTextField.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,88 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.ui.preferences.pages; | |||
|
|||
import static melnorme.utilbox.core.CoreUtil.array; | |||
|
|||
import org.eclipse.swt.widgets.Button; | |||
import org.eclipse.swt.widgets.Composite; | |||
|
|||
import melnorme.lang.ide.ui.utils.ControlUtils; | |||
import melnorme.lang.ide.ui.utils.operations.BasicUIOperation; | |||
import melnorme.util.swt.SWTFactoryUtil; | |||
import melnorme.util.swt.SWTLayoutUtil; | |||
import melnorme.util.swt.SWTUtil; | |||
import melnorme.util.swt.WidgetSelectedRunner; | |||
import melnorme.util.swt.components.fields.ButtonTextField; | |||
import melnorme.util.swt.components.fields.FileTextField; | |||
import melnorme.util.swt.components.fields.SetFieldValueOperation; | |||
import melnorme.utilbox.concurrency.OperationCancellation; | |||
|
|||
public abstract class DownloadToolTextField extends ButtonTextField { | |||
|
|||
protected String downloadButtonLabel; | |||
protected Button downloadButton; | |||
|
|||
public DownloadToolTextField(String label, String downloadButtonLabel) { | |||
this(label, FileTextField.DEFAULT_BUTTON_LABEL, downloadButtonLabel); | |||
} | |||
|
|||
public DownloadToolTextField(String label, String buttonlabel, String downloadButtonLabel) { | |||
super(label, buttonlabel); | |||
this.downloadButtonLabel = downloadButtonLabel; | |||
} | |||
|
|||
@Override | |||
public int getPreferredLayoutColumns() { | |||
return 4; | |||
} | |||
|
|||
@Override | |||
protected void createContents_all(Composite topControl) { | |||
super.createContents_all(topControl); | |||
|
|||
createContents_DownloadButton(topControl); | |||
} | |||
|
|||
@Override | |||
protected void createContents_layout() { | |||
SWTLayoutUtil.layoutControls(array(label, text, button, downloadButton), text, text); | |||
} | |||
|
|||
@Override | |||
protected void doSetEnabled(boolean enabled) { | |||
super.doSetEnabled(enabled); | |||
SWTUtil.setEnabledIfOk(downloadButton, enabled); | |||
} | |||
|
|||
/* ----------------- Button ----------------- */ | |||
|
|||
@Override | |||
protected BasicUIOperation getButtonHandler() { | |||
return new SetFieldValueOperation<String>(this, this::getNewValueFromButtonSelection2); | |||
} | |||
|
|||
@Override | |||
protected String getNewValueFromButtonSelection2() throws OperationCancellation { | |||
return ControlUtils.openFileDialog(getFieldValue(), button.getShell()); | |||
} | |||
|
|||
/* ----------------- Download Button ----------------- */ | |||
|
|||
protected void createContents_DownloadButton(Composite topControl) { | |||
downloadButton = SWTFactoryUtil.createPushButton(topControl, downloadButtonLabel, null); | |||
downloadButton.addSelectionListener(new WidgetSelectedRunner(getDownloadButtonHandler())); | |||
} | |||
|
|||
|
|||
protected abstract BasicUIOperation getDownloadButtonHandler(); | |||
|
|||
} |
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
Oops, something went wrong.