use of org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement in project linuxtools by eclipse.
the class ImageBuildPage method createControl.
@Override
public void createControl(Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
FormLayout layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
container.setLayout(layout);
Label label = new Label(container, SWT.NULL);
Label nameLabel = new Label(container, SWT.NULL);
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
nameText.addModifyListener(Listener);
nameText.setToolTipText(WizardMessages.getString(NAME_TOOLTIP));
Label dirLabel = new Label(container, SWT.NULL);
dirLabel.setText(WizardMessages.getString(DIRECTORY_LABEL));
directoryText = new Text(container, SWT.BORDER | SWT.SINGLE);
directoryText.addModifyListener(Listener);
directoryText.setToolTipText(WizardMessages.getString(DIRECTORY_TOOLTIP));
Button browse = new Button(container, SWT.NULL);
browse.setText(WizardMessages.getString(BROWSE_LABEL));
browse.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
DirectoryDialog d = new DirectoryDialog(container.getShell());
String k = d.open();
if (k != null)
directoryText.setText(k);
}));
editButton = new Button(container, SWT.NULL);
editButton.setText(WizardMessages.getString(EDIT_LABEL));
editButton.setEnabled(false);
editButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String dir = directoryText.getText();
IFileStore fileStore = EFS.getLocalFileSystem().getStore(// $NON-NLS-1$
new Path(dir).append("Dockerfile"));
// $NON-NLS-1$
java.nio.file.Path filePath = Paths.get(dir, "Dockerfile");
if (!Files.exists(filePath)) {
try {
Files.createFile(filePath);
} catch (IOException e1) {
// File won't exist, and directory should be
// writable
}
}
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart dockerFileEditor = IDE.openEditorOnFileStore(page, fileStore);
IWorkbenchPartSite site = page.getActivePart().getSite();
EModelService s = site.getService(EModelService.class);
MPartSashContainerElement p = site.getService(MPart.class);
s.detach(p, 100, 100, 500, 375);
dockerFileEditor.getEditorSite().getShell().setText(WizardMessages.getString(// $NON-NLS-1$
"ImageBuild.editor.name"));
editors.add(dockerFileEditor);
} catch (PartInitException e1) {
Activator.log(e1);
}
validate();
}));
Point p1 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point p2 = directoryText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point p3 = browse.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int centering = (p2.y - p1.y + 1) / 2;
int centering2 = (p3.y - p2.y + 1) / 2;
FormData f = new FormData();
f.top = new FormAttachment(0);
label.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(label, 11 + centering + centering2);
f.left = new FormAttachment(0, 0);
nameLabel.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(label, 11 + centering2);
f.left = new FormAttachment(nameLabel, 5);
f.right = new FormAttachment(browse, -10);
nameText.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(nameLabel, 11 + centering + centering2);
f.left = new FormAttachment(0, 0);
dirLabel.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(nameLabel, 11);
f.right = new FormAttachment(100);
editButton.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(nameLabel, 11);
f.right = new FormAttachment(editButton, -10);
browse.setLayoutData(f);
f = new FormData();
f.top = new FormAttachment(nameLabel, 11 + centering2);
f.left = new FormAttachment(nameLabel, 5);
f.right = new FormAttachment(browse, -10);
directoryText.setLayoutData(f);
if (lastDirectoryPath != null) {
directoryText.setText(lastDirectoryPath);
}
setControl(container);
setPageComplete(false);
}
use of org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement in project yamcs-studio by yamcs.
the class UIHelper method detachView.
/**
* @param view
* View to 'detach'
*/
public void detachView(IViewPart view) {
// TODO Use more generic IWorkbenchPart?, getPartSite()?
// Pre-E4 code:
// ((WorkbenchPage)page).detachView(page.findViewReference(OPIView.ID, secondID));
// See http://tomsondev.bestsolution.at/2012/07/13/so-you-used-internal-api/
final EModelService model = view.getSite().getService(EModelService.class);
MPartSashContainerElement p = view.getSite().getService(MPart.class);
// Part may be shared by several perspectives, get the shared instance
if (p.getCurSharedRef() != null)
p = p.getCurSharedRef();
model.detach(p, 100, 100, 600, 800);
}
Aggregations