Search in sources :

Example 11 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class StarModelerPerspective method createTabForDomain.

public void createTabForDomain(final StarDomain starDomain) throws Exception {
    SpoonPerspectiveManager.getInstance().activatePerspective(getClass());
    final XulTabAndPanel tabAndPanel = createTab();
    PropsUI props = PropsUI.getInstance();
    final Composite comp = (Composite) tabAndPanel.panel.getManagedObject();
    props.setLook(comp);
    comp.setLayout(new FillLayout());
    final ScrolledComposite scrolledComposite = new ScrolledComposite(comp, SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(scrolledComposite);
    scrolledComposite.setLayout(new FillLayout());
    final Composite parentComposite = new Composite(scrolledComposite, SWT.NONE);
    props.setLook(parentComposite);
    int margin = Const.MARGIN;
    FormLayout formLayout = new FormLayout();
    formLayout.marginLeft = 10;
    formLayout.marginRight = 10;
    formLayout.marginTop = 10;
    formLayout.marginBottom = 10;
    formLayout.spacing = margin;
    parentComposite.setLayout(formLayout);
    Control lastControl = addModelsGroupToDomainTab(starDomain, tabAndPanel, parentComposite);
    lastControl = addSharedDimensionsGroupToDomainTab(starDomain, tabAndPanel, parentComposite, lastControl);
    lastControl = addPhysicalGroupToDomainTab(starDomain, tabAndPanel, parentComposite, lastControl);
    parentComposite.layout(true);
    parentComposite.pack();
    // What's the size:
    Rectangle bounds = parentComposite.getBounds();
    scrolledComposite.setContent(parentComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinWidth(bounds.width);
    scrolledComposite.setMinHeight(bounds.height);
    models.add(starDomain);
    setNameForTab(tabAndPanel.tab, starDomain.getDomain().getName(defaultLocale));
    setMetaForTab(tabAndPanel.tab, starDomain);
    setSelectedMeta(starDomain);
    setActive(true);
    comp.layout();
    Spoon.getInstance().enableMenus();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Rectangle(org.eclipse.swt.graphics.Rectangle) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FillLayout(org.eclipse.swt.layout.FillLayout) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 12 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class StarModelerPerspective method addSharedDimensionsGroupToDomainTab.

private Control addSharedDimensionsGroupToDomainTab(final StarDomain starDomain, final XulTabAndPanel tabAndPanel, Composite parentComposite, Control lastControl) {
    PropsUI props = PropsUI.getInstance();
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Add a group for the logical stars
    // 
    final Group dimsGroup = new Group(parentComposite, SWT.SHADOW_NONE);
    props.setLook(dimsGroup);
    dimsGroup.setText(BaseMessages.getString(PKG, "StarModelerPerspective.SharedDimensions.Label"));
    FormLayout groupLayout = new FormLayout();
    groupLayout.marginLeft = 10;
    groupLayout.marginRight = 10;
    groupLayout.marginTop = 10;
    groupLayout.marginBottom = 10;
    groupLayout.spacing = margin;
    dimsGroup.setLayout(groupLayout);
    FormData fdDimsGroup = new FormData();
    fdDimsGroup.top = new FormAttachment(lastControl, margin);
    fdDimsGroup.left = new FormAttachment(0, 0);
    fdDimsGroup.right = new FormAttachment(100, 0);
    dimsGroup.setLayoutData(fdDimsGroup);
    // Then we'll add a table view for the shared dimensions
    // 
    Label dimensionsLabel = new Label(dimsGroup, SWT.RIGHT);
    props.setLook(dimensionsLabel);
    dimensionsLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.ListOfSharedDimensions.Label"));
    FormData fdDimensionsLabel = new FormData();
    fdDimensionsLabel.left = new FormAttachment(0, 0);
    fdDimensionsLabel.right = new FormAttachment(middle, 0);
    fdDimensionsLabel.top = new FormAttachment(lastControl, margin);
    dimensionsLabel.setLayoutData(fdDimensionsLabel);
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.DimensionName.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.DimensionDescription.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
    final TableView dimensionsList = new TableView(new Variables(), dimsGroup, SWT.BORDER, colinf, 1, null, props);
    dimensionsList.setReadonly(true);
    dimensionsList.table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (dimensionsList.getSelectionIndex() < 0)
                return;
            TableItem item = dimensionsList.table.getSelection()[0];
            String name = item.getText(1);
            if (editModel(dimsGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshDimensionsList(starDomain, dimensionsList);
            }
        }
    });
    refreshDimensionsList(starDomain, dimensionsList);
    FormData fdDimensionsList = new FormData();
    fdDimensionsList.top = new FormAttachment(lastControl, margin);
    fdDimensionsList.bottom = new FormAttachment(lastControl, 250);
    fdDimensionsList.left = new FormAttachment(middle, margin);
    fdDimensionsList.right = new FormAttachment(100, 0);
    dimensionsList.setLayoutData(fdDimensionsList);
    lastControl = dimensionsList;
    // A few buttons to edit the list
    // 
    Button newDimensionButton = new Button(dimsGroup, SWT.PUSH);
    newDimensionButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.NewSharedDimension"));
    FormData fdNewModelButton = new FormData();
    fdNewModelButton.top = new FormAttachment(lastControl, margin);
    fdNewModelButton.left = new FormAttachment(middle, margin);
    newDimensionButton.setLayoutData(fdNewModelButton);
    newDimensionButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (newSharedDimension(dimsGroup.getShell(), starDomain)) {
                refreshDimensionsList(starDomain, dimensionsList);
            }
        }
    });
    Button editDimensionButton = new Button(dimsGroup, SWT.PUSH);
    editDimensionButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.EditDimension"));
    FormData fdEditModelButton = new FormData();
    fdEditModelButton.top = new FormAttachment(lastControl, margin);
    fdEditModelButton.left = new FormAttachment(newDimensionButton, margin);
    editDimensionButton.setLayoutData(fdEditModelButton);
    editDimensionButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (dimensionsList.getSelectionIndex() < 0)
                return;
            TableItem item = dimensionsList.table.getSelection()[0];
            String name = item.getText(1);
            if (editSharedDimension(dimsGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshDimensionsList(starDomain, dimensionsList);
            }
        }
    });
    Button delDimensionButton = new Button(dimsGroup, SWT.PUSH);
    delDimensionButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.DeleteDimension"));
    FormData fdDelDimensionButton = new FormData();
    fdDelDimensionButton.top = new FormAttachment(lastControl, margin);
    fdDelDimensionButton.left = new FormAttachment(editDimensionButton, margin);
    delDimensionButton.setLayoutData(fdDelDimensionButton);
    delDimensionButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (dimensionsList.getSelectionIndex() < 0)
                return;
            TableItem item = dimensionsList.table.getSelection()[0];
            String name = item.getText(1);
            if (deleteSharedDimension(dimsGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshDimensionsList(starDomain, dimensionsList);
            }
        }
    });
    Button testDimensionButton = new Button(dimsGroup, SWT.PUSH);
    testDimensionButton.setText("TEST PUR");
    FormData fdtestDimensionButton = new FormData();
    fdtestDimensionButton.top = new FormAttachment(lastControl, margin);
    fdtestDimensionButton.left = new FormAttachment(delDimensionButton, margin);
    testDimensionButton.setLayoutData(fdtestDimensionButton);
    testDimensionButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            testMetaStore();
        }
    });
    return dimsGroup;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) PropsUI(org.pentaho.di.ui.core.PropsUI) Variables(org.pentaho.di.core.variables.Variables) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 13 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class GoogleAuthorizationDialog method createDialog.

private void createDialog(String title, String url, int options, Image logo) {
    Shell parent = getParent();
    display = parent.getDisplay();
    dialog = new Shell(parent, options);
    dialog.setText(title);
    dialog.setImage(logo);
    PropsUI props = PropsUI.getInstance();
    props.setLook(dialog);
    dialog.setSize(width, height);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    dialog.setLayout(formLayout);
    try {
        Label helpButton = new Label(dialog, SWT.NONE);
        helpButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/help.png")));
        FormData helpButtonFormData = new FormData();
        helpButtonFormData.left = new FormAttachment(0, 15);
        helpButtonFormData.bottom = new FormAttachment(100, -24);
        helpButton.setLayoutData(helpButtonFormData);
        StyledText helpLabel = new StyledText(dialog, SWT.NONE);
        helpLabel.setText("Help");
        helpLabel.setCaret(null);
        helpLabel.setEditable(false);
        props.setLook(helpLabel);
        helpLabel.setFont(new Font(display, "Open Sans Regular", 11, SWT.NORMAL));
        helpLabel.setForeground(new Color(display, 0, 94, 170));
        FormData helpLabelFormData = new FormData();
        helpLabelFormData.left = new FormAttachment(0, 40);
        helpLabelFormData.bottom = new FormAttachment(100, -27);
        helpLabel.setLayoutData(helpLabelFormData);
        helpLabel.addListener(SWT.MouseUp, new Listener() {

            public void handleEvent(Event event) {
            }
        });
        helpLabel.addListener(SWT.MouseEnter, new Listener() {

            public void handleEvent(Event event) {
                StyleRange style1 = new StyleRange();
                style1.start = 0;
                style1.length = 4;
                style1.underline = true;
                helpLabel.setStyleRange(style1);
                helpLabel.setForeground(new Color(display, 0, 0, 0));
                helpLabel.setCursor(new Cursor(display, SWT.CURSOR_HAND));
            }
        });
        helpLabel.addListener(SWT.MouseExit, new Listener() {

            public void handleEvent(Event event) {
                StyleRange style1 = new StyleRange();
                style1.start = 0;
                style1.length = 4;
                style1.underline = false;
                helpLabel.setStyleRange(style1);
                helpLabel.setForeground(new Color(display, 0, 94, 170));
            }
        });
        Label cancelButton = new Label(dialog, SWT.NONE);
        cancelButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/close-button.png")));
        FormData cancelButtonFormData = new FormData();
        cancelButtonFormData.right = new FormAttachment(100, -15);
        cancelButtonFormData.bottom = new FormAttachment(100, -15);
        cancelButton.setLayoutData(cancelButtonFormData);
        cancelButton.addListener(SWT.MouseUp, new Listener() {

            public void handleEvent(Event event) {
                browser.dispose();
                dialog.close();
                dialog.dispose();
            }
        });
        cancelButton.addListener(SWT.MouseEnter, new Listener() {

            public void handleEvent(Event event) {
                cancelButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/close-button-hover.png")));
                cancelButton.setCursor(new Cursor(display, SWT.CURSOR_HAND));
            }
        });
        cancelButton.addListener(SWT.MouseExit, new Listener() {

            public void handleEvent(Event event) {
                cancelButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/close-button.png")));
            }
        });
        Label separator = new Label(dialog, SWT.HORIZONTAL | SWT.SEPARATOR);
        FormData separatorFormData = new FormData();
        separatorFormData.left = new FormAttachment(0, 15);
        separatorFormData.right = new FormAttachment(100, -15);
        separatorFormData.bottom = new FormAttachment(cancelButton, -15);
        separator.setLayoutData(separatorFormData);
        browser = new Browser(dialog, SWT.NONE);
        browser.setUrl(url);
        FormData browserFormData = new FormData();
        browserFormData.top = new FormAttachment(0, 5);
        browserFormData.bottom = new FormAttachment(separator, -5);
        browserFormData.left = new FormAttachment(0, 5);
        browserFormData.right = new FormAttachment(100, -5);
        browser.setLayoutData(browserFormData);
        browser.addCloseWindowListener(new CloseWindowListener() {

            @Override
            public void close(WindowEvent event) {
                Browser browser = (Browser) event.widget;
                Shell shell = browser.getShell();
                shell.close();
            }
        });
    } catch (Exception e) {
        MessageBox messageBox = new MessageBox(dialog, SWT.ICON_ERROR | SWT.OK);
        messageBox.setMessage("Browser cannot be initialized.");
        messageBox.setText("Exit");
        messageBox.open();
    }
    setPosition();
    dialog.open();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CloseWindowListener(org.eclipse.swt.browser.CloseWindowListener) StyleRange(org.eclipse.swt.custom.StyleRange) Label(org.eclipse.swt.widgets.Label) PropsUI(org.pentaho.di.ui.core.PropsUI) CloseWindowListener(org.eclipse.swt.browser.CloseWindowListener) WindowEvent(org.eclipse.swt.browser.WindowEvent) Event(org.eclipse.swt.widgets.Event) WindowEvent(org.eclipse.swt.browser.WindowEvent) Browser(org.eclipse.swt.browser.Browser)

Example 14 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class RepositoryBrowserController method storeRecentSearch.

public JSONArray storeRecentSearch(String recentSearch) {
    JSONArray recentSearches = getRecentSearches();
    try {
        if (recentSearch == null || recentSearches.contains(recentSearch)) {
            return recentSearches;
        }
        recentSearches.add(recentSearch);
        if (recentSearches.size() > 5) {
            recentSearches.remove(0);
        }
        PropsUI props = PropsUI.getInstance();
        String jsonValue = props.getRecentSearches();
        JSONParser jsonParser = new JSONParser();
        JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse(jsonValue) : new JSONObject();
        jsonObject.put(getLogin(), recentSearches);
        props.setRecentSearches(jsonObject.toJSONString());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return recentSearches;
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) KettleException(org.pentaho.di.core.exception.KettleException) KettleObjectExistsException(org.pentaho.di.core.exception.KettleObjectExistsException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 15 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class RepositoryBrowserController method getRecentSearches.

public JSONArray getRecentSearches() {
    try {
        PropsUI props = PropsUI.getInstance();
        String jsonString = props.getRecentSearches();
        if (jsonString != null) {
            JSONParser jsonParser = new JSONParser();
            JSONObject jsonObject = (JSONObject) jsonParser.parse(jsonString);
            return (JSONArray) jsonObject.get(getLogin());
        }
    } catch (Exception e) {
    // Log error in console
    }
    return new JSONArray();
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) KettleException(org.pentaho.di.core.exception.KettleException) KettleObjectExistsException(org.pentaho.di.core.exception.KettleObjectExistsException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

PropsUI (org.pentaho.di.ui.core.PropsUI)28 Label (org.eclipse.swt.widgets.Label)9 FormLayout (org.eclipse.swt.layout.FormLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 Text (org.eclipse.swt.widgets.Text)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 Button (org.eclipse.swt.widgets.Button)4 KettleException (org.pentaho.di.core.exception.KettleException)4 Field (java.lang.reflect.Field)3 Group (org.eclipse.swt.widgets.Group)3 Monitor (org.eclipse.swt.widgets.Monitor)3 BeforeClass (org.junit.BeforeClass)3 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)3 TabItem (org.pentaho.xul.swt.tab.TabItem)3 WindowEvent (org.eclipse.swt.browser.WindowEvent)2