Search in sources :

Example 1 with ILiferayRuntimeStub

use of com.liferay.ide.server.core.ILiferayRuntimeStub in project liferay-ide by liferay.

the class LiferayRuntimeStubComposite method updateStubs.

protected void updateStubs() {
    ILiferayRuntimeStub[] stubs = LiferayServerCore.getRuntimeStubs();
    if (ListUtil.isEmpty(stubs)) {
        return;
    }
    String[] names = new String[stubs.length];
    LiferayRuntimeStubDelegate delegate = getStubDelegate();
    String stubId = delegate.getRuntimeStubTypeId();
    int stubIndex = -1;
    for (int i = 0; i < stubs.length; i++) {
        names[i] = stubs[i].getName();
        if (stubs[i].getRuntimeStubTypeId().equals(stubId)) {
            stubIndex = i;
        }
    }
    comboRuntimeStubType.setItems(names);
    if (stubIndex >= 0) {
        comboRuntimeStubType.select(stubIndex);
    }
}
Also used : ILiferayRuntimeStub(com.liferay.ide.server.core.ILiferayRuntimeStub) LiferayRuntimeStubDelegate(com.liferay.ide.server.core.LiferayRuntimeStubDelegate)

Example 2 with ILiferayRuntimeStub

use of com.liferay.ide.server.core.ILiferayRuntimeStub in project liferay-ide by liferay.

the class LiferayRuntimeStubComposite method createControl.

protected void createControl(Composite parent) {
    setLayout(new GridLayout(2, false));
    setLayoutData(new GridData(GridData.FILL_BOTH));
    setBackground(parent.getBackground());
    Label lblName = new Label(this, SWT.NONE);
    lblName.setText(Msgs.name);
    new Label(this, SWT.NONE);
    textName = new Text(this, SWT.BORDER);
    textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            runtimeWC.setName(textName.getText());
            validate();
        }
    });
    createSpacer();
    Label lblRuntimeStubType = new Label(this, SWT.NONE);
    lblRuntimeStubType.setText(Msgs.liferayBundleType);
    createSpacer();
    comboRuntimeStubType = new Combo(this, SWT.READ_ONLY);
    comboRuntimeStubType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    createSpacer();
    final Label lblInstall = new Label(this, SWT.WRAP);
    lblInstall.setText(Msgs.liferayBundleDirectory);
    new Label(this, SWT.NONE);
    textInstallDir = new Text(this, SWT.BORDER);
    textInstallDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboRuntimeStubType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int index = comboRuntimeStubType.getSelectionIndex();
            ILiferayRuntimeStub selectedStub = LiferayServerCore.getRuntimeStubs()[index];
            LiferayRuntimeStubDelegate delegate = getStubDelegate();
            delegate.setRuntimeStubTypeId(selectedStub.getRuntimeStubTypeId());
            String stubTypeId = selectedStub.getRuntimeStubTypeId();
            IRuntimeType runtimeType = ServerCore.findRuntimeType(stubTypeId);
            for (IRuntime runtime : ServerCore.getRuntimes()) {
                if (runtime.getRuntimeType().equals(runtimeType)) {
                    textInstallDir.setText(runtime.getLocation().toOSString());
                }
            }
            validate();
        }
    });
    textInstallDir.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            textInstallDirChanged(textInstallDir.getText());
        }
    });
    Button btnBrowse = new Button(this, SWT.NONE);
    btnBrowse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    btnBrowse.setText(Msgs.browse);
    btnBrowse.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            DirectoryDialog dialog = new DirectoryDialog(LiferayRuntimeStubComposite.this.getShell());
            dialog.setMessage(Msgs.selectRuntimeStubDirectory);
            dialog.setFilterPath(textInstallDir.getText());
            String selectedDirectory = dialog.open();
            if (selectedDirectory != null) {
                textInstallDir.setText(selectedDirectory);
            }
        }
    });
    new Label(this, SWT.NONE);
    Dialog.applyDialogFont(this);
    textName.forceFocus();
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ILiferayRuntimeStub(com.liferay.ide.server.core.ILiferayRuntimeStub) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) IRuntime(org.eclipse.wst.server.core.IRuntime) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LiferayRuntimeStubDelegate(com.liferay.ide.server.core.LiferayRuntimeStubDelegate) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

ILiferayRuntimeStub (com.liferay.ide.server.core.ILiferayRuntimeStub)2 LiferayRuntimeStubDelegate (com.liferay.ide.server.core.LiferayRuntimeStubDelegate)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)1