Search in sources :

Example 11 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project tdi-studio-se by Talend.

the class SurrogateSection method createContents.

@Override
protected void createContents(Composite parent) {
    dragDropManager = new DragDropManager();
    key = new SurrogateKey();
    final Color white = parent.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    parent.setBackground(white);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setBackground(white);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.CENTER, SWT.CENTER).applyTo(composite);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
    // row 1
    Label nameLabel = new Label(composite, SWT.NONE);
    //$NON-NLS-1$
    nameLabel.setText("name");
    nameLabel.setBackground(white);
    GridDataFactory.swtDefaults().applyTo(nameLabel);
    nameText = new Text(composite, SWT.BORDER);
    GridDataFactory.swtDefaults().hint(SURROGATE_FIELD_WIDTH, SWT.DEFAULT).applyTo(nameText);
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (StringUtils.isEmpty(nameText.getText())) {
                nameText.setBackground(ERROR_COLOR);
            } else {
                nameText.setBackground(white);
            }
            // update model value
            key.setColumn(nameText.getText());
        }
    });
    // row 2
    Label creationLabel = new Label(composite, SWT.NONE);
    //$NON-NLS-1$
    creationLabel.setText("creation");
    creationLabel.setBackground(white);
    GridDataFactory.swtDefaults().applyTo(creationLabel);
    creationCombo = new CCombo(composite, SWT.READ_ONLY | SWT.BORDER);
    creationCombo.setItems(getScdManager().getSurrogateCreationTypeNames());
    GridDataFactory.swtDefaults().hint(SURROGATE_FIELD_WIDTH + 3, SWT.DEFAULT).applyTo(creationCombo);
    // row 3
    Label complementLabel = new Label(composite, SWT.NONE);
    //$NON-NLS-1$
    complementLabel.setText("complement");
    complementLabel.setBackground(white);
    GridDataFactory.swtDefaults().applyTo(complementLabel);
    final Composite complementComp = new Composite(composite, SWT.NONE);
    GridDataFactory.swtDefaults().applyTo(complementComp);
    final StackLayout stack = new StackLayout();
    complementComp.setLayout(stack);
    final Composite inputFieldComp = new Composite(complementComp, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(inputFieldComp);
    inputFieldLabel = new Label(inputFieldComp, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).hint(100, SWT.DEFAULT).applyTo(inputFieldLabel);
    // add drag and drop support for input field
    IDragDropDelegate delegate = createDragDropDelegate(inputFieldLabel);
    dragDropManager.addDragSupport(inputFieldLabel, delegate);
    dragDropManager.addDropSupport(inputFieldLabel, delegate);
    // show DB_SEQUENCE in OraleSCD
    // final boolean enableOracle = getScdManager().enableOracle();
    // if (enableOracle) {
    dbSequenceComp = new Composite(complementComp, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(dbSequenceComp);
    dbSequenceText = new Text(dbSequenceComp, SWT.BORDER);
    dbSequenceText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (StringUtils.isEmpty(dbSequenceText.getText())) {
                dbSequenceText.setBackground(ERROR_COLOR);
            } else {
                dbSequenceText.setBackground(white);
            }
            if (key.getCreation() == SurrogateCreationType.DB_SEQUENCE) {
                key.setComplement(dbSequenceText.getText());
            }
        }
    });
    GridDataFactory.fillDefaults().hint(SURROGATE_FIELD_WIDTH, SWT.DEFAULT).applyTo(dbSequenceText);
    TalendProposalUtils.installOn(dbSequenceText, null);
    // }
    final Composite routineFieldComp = new Composite(complementComp, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(routineFieldComp);
    routineText = new Text(routineFieldComp, SWT.BORDER);
    routineText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (StringUtils.isEmpty(routineText.getText())) {
                routineText.setBackground(ERROR_COLOR);
            } else {
                routineText.setBackground(white);
            }
            if (key.getCreation() == SurrogateCreationType.ROUTINE) {
                // update model value
                key.setComplement(routineText.getText());
            }
        }
    });
    GridDataFactory.fillDefaults().hint(SURROGATE_FIELD_WIDTH, SWT.DEFAULT).applyTo(routineText);
    // add content proposal for routine
    TalendProposalUtils.installOn(routineText, null);
    final Label emptyLabel = new Label(complementComp, SWT.NONE);
    emptyLabel.setBackground(white);
    stack.topControl = emptyLabel;
    // when combo is changed, also change the control in complement
    creationSwitch = new Runnable() {

        public void run() {
            String diaplayName = creationCombo.getText();
            // SurrogateCreationType type = SurrogateCreationType.getTypeByIndex(index + 1);
            SurrogateCreationType type = SurrogateCreationType.getTypeByName(diaplayName);
            key.setCreation(type);
            if (type == SurrogateCreationType.ROUTINE) {
                // routineText;
                stack.topControl = routineFieldComp;
                if (StringUtils.isEmpty(routineText.getText())) {
                    routineText.setBackground(ERROR_COLOR);
                    //$NON-NLS-1$
                    key.setComplement("");
                } else {
                    routineText.setBackground(white);
                }
                //$NON-NLS-1$
                inputFieldLabel.setText("");
                // if (enableOracle) {
                //$NON-NLS-1$
                dbSequenceText.setText("");
            // }
            } else if (type == SurrogateCreationType.INPUT_FIELD) {
                // inputFieldLabel;
                stack.topControl = inputFieldComp;
                if (StringUtils.isEmpty(inputFieldLabel.getText())) {
                    inputFieldLabel.setBackground(ERROR_COLOR);
                    //$NON-NLS-1$
                    key.setComplement("");
                } else {
                    inputFieldLabel.setBackground(null);
                }
                //$NON-NLS-1$
                routineText.setText("");
                // if (enableOracle) {
                //$NON-NLS-1$
                dbSequenceText.setText("");
            // }
            } else if (type == SurrogateCreationType.DB_SEQUENCE) {
                // else if (type == SurrogateCreationType.DB_SEQUENCE && enableOracle) {
                // dbSequenceText;
                stack.topControl = dbSequenceComp;
                if (StringUtils.isEmpty(dbSequenceText.getText())) {
                    dbSequenceText.setBackground(ERROR_COLOR);
                    //$NON-NLS-1$
                    key.setComplement("");
                } else {
                    dbSequenceText.setBackground(white);
                }
                //$NON-NLS-1$
                inputFieldLabel.setText("");
                routineText.setText("");
            } else {
                stack.topControl = emptyLabel;
                //$NON-NLS-1$
                routineText.setText("");
                //$NON-NLS-1$
                inputFieldLabel.setText("");
                // if (enableOracle) {
                //$NON-NLS-1$     
                dbSequenceText.setText("");
                // }
                //$NON-NLS-1$
                key.setComplement("");
            }
            scdManager.fireFieldChange();
            complementComp.layout();
        }
    };
    creationCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            creationSwitch.run();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SurrogateKey(org.talend.designer.scd.model.SurrogateKey) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) SurrogateCreationType(org.talend.designer.scd.model.SurrogateCreationType) StackLayout(org.eclipse.swt.custom.StackLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DragDropManager(org.talend.designer.scd.util.DragDropManager)

Example 12 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project tdi-studio-se by Talend.

the class LoginDialog method createDialogArea.

/**
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    container.setLayout(layout);
    // container.setBackground(new Color(null, 215, 215, 215));
    container.setBackground(new Color(null, 255, 255, 255));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    new ImageCanvas(container, brandingService.getLoginVImage());
    if (!perReader.isHaveUserPer()) {
        perReader.createPropertyFile();
    }
    base = new Composite(container, SWT.NONE);
    base.setLayoutData(new GridData(GridData.FILL_BOTH));
    stackLayout = new StackLayout();
    base.setLayout(stackLayout);
    if (!PluginChecker.isSVNProviderPluginLoaded()) {
        // tos
        loginComposite = new LoginComposite(base, SWT.NONE, this, tosLoginComposite, stackLayout);
        loginComposite.populateProjectList();
        tosLoginComposite = new TOSLoginComposite(base, SWT.NONE, loginComposite, this);
    } else {
        loginComposite = new LoginComposite(base, SWT.NONE, this, tosLoginComposite, stackLayout);
    }
    GridData data = new GridData(GridData.FILL_BOTH);
    // data.widthHint = INNER_LOGIN_COMPOSITE_WIDTH;
    // data.heightHint = DIALOG_HEIGHT;
    loginComposite.setLayoutData(data);
    stackLayout.topControl = loginComposite;
    base.layout();
    if (!PluginChecker.isSVNProviderPluginLoaded()) {
        Project[] projectList = readProject();
        if (projectList.length > 0) {
            advanced();
        }
    }
    return container;
}
Also used : Project(org.talend.core.model.general.Project) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) GridData(org.eclipse.swt.layout.GridData) StackLayout(org.eclipse.swt.custom.StackLayout) IBrandingService(org.talend.core.ui.branding.IBrandingService)

Example 13 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project tdi-studio-se by Talend.

the class LoginDialogV2 method createLogonInfoArea.

protected void createLogonInfoArea(Composite container) {
    // vertical seperator line
    Composite verticalLine = new Composite(container, SWT.NONE);
    verticalLine.setBackground(VERTICAL_SEPERATOR_LINE_COLOR);
    GridData verticalLineGridData = new GridData(GridData.FILL_VERTICAL);
    verticalLineGridData.widthHint = 1;
    verticalLine.setLayoutData(verticalLineGridData);
    Composite loginInfoArea = new Composite(container, SWT.NONE);
    GridData brandingAreaGridData = (GridData) brandingArea.getLayoutData();
    GridData loginInfoAreaGridData = new GridData(GridData.FILL_BOTH);
    // loginInfoAreaGridData.minimumWidth = 350;
    // loginInfoAreaGridData.minimumHeight = brandingAreaGridData.minimumHeight;
    loginInfoAreaGridData.widthHint = (int) Math.ceil(realWidthRate * logonInfoAreaWidth);
    loginInfoAreaGridData.heightHint = brandingAreaGridData.heightHint;
    loginInfoArea.setLayoutData(loginInfoAreaGridData);
    loginInfoArea.setLayout(new FormLayout());
    base = new Composite(loginInfoArea, SWT.NONE);
    FormData baseFormData = new FormData();
    baseFormData.top = new FormAttachment(0, 0);
    baseFormData.bottom = new FormAttachment(100, 0);
    baseFormData.left = new FormAttachment(0, 10);
    baseFormData.right = new FormAttachment(100, 0);
    base.setLayoutData(baseFormData);
    base.setBackground(backgroundColor);
    stackLayout = new StackLayout();
    stackLayout.marginWidth = 10;
    stackLayout.marginHeight = 10;
    base.setLayout(stackLayout);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) StackLayout(org.eclipse.swt.custom.StackLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 14 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project bndtools by bndtools.

the class ResolutionResultsWizardPage method createControl.

/**
     * Create contents of the wizard.
     *
     * @param parent
     */
@Override
public void createControl(Composite parent) {
    parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    stack = new StackLayout();
    container.setLayout(stack);
    resolutionSuccessPanel.createControl(container);
    resolutionFailurePanel.createControl(container);
    updateUi();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) StackLayout(org.eclipse.swt.custom.StackLayout)

Example 15 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project eclipse.platform.text by eclipse.

the class StatusTextEditor method createPartControl.

/*
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    fParent = new Composite(parent, SWT.NONE);
    fStackLayout = new StackLayout();
    fParent.setLayout(fStackLayout);
    fDefaultComposite = new Composite(fParent, SWT.NONE);
    fDefaultComposite.setLayout(new FillLayout());
    super.createPartControl(fDefaultComposite);
    updatePartControl(getEditorInput());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) StackLayout(org.eclipse.swt.custom.StackLayout) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

StackLayout (org.eclipse.swt.custom.StackLayout)18 Composite (org.eclipse.swt.widgets.Composite)16 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)7 Label (org.eclipse.swt.widgets.Label)6 FillLayout (org.eclipse.swt.layout.FillLayout)5 Text (org.eclipse.swt.widgets.Text)4 Button (org.eclipse.swt.widgets.Button)3 JpmPreferences (bndtools.preferences.JpmPreferences)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Color (org.eclipse.swt.graphics.Color)2 Control (org.eclipse.swt.widgets.Control)2 PartInitException (org.eclipse.ui.PartInitException)2 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)2 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)2 Workspace (aQute.bnd.build.Workspace)1 HttpClient (aQute.bnd.http.HttpClient)1