Example usage for org.eclipse.jface.resource ImageDescriptor ImageDescriptor

List of usage examples for org.eclipse.jface.resource ImageDescriptor ImageDescriptor

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor ImageDescriptor.

Prototype

protected ImageDescriptor() 

Source Link

Document

Constructs an image descriptor.

Usage

From source file:hydrograph.ui.dataviewer.window.DebugDataViewer.java

License:Apache License

private void addtoolbarAction(ToolBarManager toolBarManager, final ImagePathConstant imagePath, Action action) {

    ImageDescriptor exportImageDescriptor = new ImageDescriptor() {
        @Override/*from ww w.j ava 2  s. c o m*/
        public ImageData getImageData() {
            return imagePath.getImageFromRegistry().getImageData();
        }
    };
    action.setImageDescriptor(exportImageDescriptor);
    toolBarManager.add(action);
}

From source file:hydrograph.ui.graph.action.CommentBoxAction.java

License:Apache License

/**
 * return ImageDescriptor for comment box
 * @return ImageDescriptor/*www .  j a v a 2 s.  co m*/
 */
private ImageDescriptor getImageDisDescriptor() {
    ImageDescriptor imageDescriptor = new ImageDescriptor() {

        @Override
        public ImageData getImageData() {
            return new ImageData(XMLConfigUtil.INSTANCE.CONFIG_FILES_PATH + "/icons/comment-box-icon.png");
        }
    };
    return imageDescriptor;
}

From source file:hydrograph.ui.graph.action.GraphRuntimePropertiesAction.java

License:Apache License

private ImageDescriptor getImageDisDescriptor() {
    ImageDescriptor imageDescriptor = new ImageDescriptor() {

        @Override//from  ww  w  .ja  va 2s.co m
        public ImageData getImageData() {
            return new ImageData(XMLConfigUtil.INSTANCE.CONFIG_FILES_PATH + "/icons/graph_property_window.png");
        }
    };
    return imageDescriptor;
}

From source file:hydrograph.ui.graph.action.subjob.SubJobUpdateAction.java

License:Apache License

private ImageDescriptor getImageDisDescriptor() {
    ImageDescriptor imageDescriptor = new ImageDescriptor() {

        @Override//  w w w  . j ava2 s  .  c  o m
        public ImageData getImageData() {
            return new ImageData(XMLConfigUtil.INSTANCE.CONFIG_FILES_PATH + "/icons/refresh.png");
        }
    };
    return imageDescriptor;
}

From source file:hydrograph.ui.graph.canvas.search.HydrographComponentProposalProvider.java

License:Apache License

/**
 * Provides the image descriptor for Comment box
 * @return imageDescriptor/*  www . j av  a 2  s .  c o m*/
 */
private ImageDescriptor getCommentBoxImageDisDescriptor() {
    ImageDescriptor imageDescriptor = new ImageDescriptor() {

        @Override
        public ImageData getImageData() {
            return new ImageData(XMLConfigUtil.INSTANCE.CONFIG_FILES_PATH + Constants.COMMENT_BOX_IMAGE_PATH);
        }
    };
    return imageDescriptor;
}

From source file:hydrograph.ui.graph.execution.tracking.windows.ExecutionTrackingConsole.java

License:Apache License

/**
 * Addtoolbar action.//w  w  w  .j ava2 s  .com
 *
 * @param toolBarManager the tool bar manager
 * @param imagePath the image path
 * @param action the action
 */
private void addtoolbarAction(ToolBarManager toolBarManager, final ImagePathConstant imagePath, Action action) {

    ImageDescriptor exportImageDescriptor = new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return imagePath.getImageFromRegistry().getImageData();
        }
    };
    action.setImageDescriptor(exportImageDescriptor);
    toolBarManager.add(action);
}

From source file:info.ajaxplorer.synchro.gui.JobEditor.java

License:Open Source License

public void populateToolkit() {

    toolkit = new FormToolkit(this.getDisplay());
    final Form form = toolkit.createForm(this);
    this.form = form;
    toolkit.decorateFormHeading(form);//from w w  w .  ja  v  a2s . c  o  m
    StackLayout sLayout = new StackLayout();
    form.getBody().setLayout(sLayout);

    connexionSection = configureSection(toolkit, form, Manager.getMessage("jobeditor_header_connection"),
            Manager.getMessage("jobeditor_legend_connection"), 1, false);
    sectionClient = toolkit.createComposite(connexionSection);
    GridLayout layout = new GridLayout();
    sectionClient.setLayout(layout);
    layout.numColumns = 3;
    layout.horizontalSpacing = 10;
    layout.verticalSpacing = 10;
    sLayout.topControl = connexionSection;
    connexionSection.setClient(sectionClient);
    stackData.get("connexion").put("SECTION", connexionSection);

    // HOST
    Label label = toolkit.createLabel(sectionClient, Manager.getMessage("jobeditor_hostURL"));
    label.setLayoutData(getGridDataLabel());
    tfHost = toolkit.createText(sectionClient, "");
    tfHost.setLayoutData(getGridDataField(2));

    // LOGIN
    label = toolkit.createLabel(sectionClient, Manager.getMessage("jobeditor_login"));
    label.setLayoutData(getGridDataLabel());
    tfLogin = toolkit.createText(sectionClient, "");
    tfLogin.setLayoutData(getGridDataField(2));

    // PASSWORD
    label = toolkit.createLabel(sectionClient, Manager.getMessage("jobeditor_password"));
    label.setLayoutData(getGridDataLabel());
    tfPassword = toolkit.createText(sectionClient, "", SWT.PASSWORD);
    tfPassword.setLayoutData(getGridDataField(2));

    // REPOSITORY CHOOSER
    label = toolkit.createLabel(sectionClient, Manager.getMessage("jobeditor_repository"));
    label.setLayoutData(getGridDataLabel());

    tfRepo = toolkit.createText(sectionClient, "click to load the repositories...", SWT.READ_ONLY);
    tfRepo.setLayoutData(getGridDataField(1));

    linkLoadRepositories = toolkit.createImageHyperlink(sectionClient, SWT.NULL);
    linkLoadRepositories.setImage(new Image(getDisplay(),
            new ImageData(this.getClass().getClassLoader().getResourceAsStream("images/reload.png"))));
    linkLoadRepositories.setLayoutData(new GridData(GridData.FILL));
    linkLoadRepositories.setUnderlined(false);
    linkLoadRepositories.addHyperlinkListener(new IHyperlinkListener() {
        @Override
        public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
            if (tfRepo != null && (tfHost.getText().equals("") || tfLogin.getText().equals("")
                    || tfPassword.getText().equals(""))) {
                MessageBox dialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
                dialog.setText(Manager.getMessage("jobeditor_diag_noserverdata"));
                dialog.setMessage(Manager.getMessage("jobeditor_diag_noserverdata_msg"));
                dialog.open();
                return;
            }
            toggleRepositoryComponent();
            if (comboRepository != null) {
                loadRepositories();
            }
        }
    });

    // TARGET FOLDER CHOOSER
    label = toolkit.createLabel(sectionClient, Manager.getMessage("jobeditor_localfolder"));
    label.setLayoutData(getGridDataLabel());
    tfTarget = toolkit.createText(sectionClient, "", SWT.READ_ONLY);
    tfTarget.setLayoutData(getGridDataField(1));

    buttonFileChooser = toolkit.createImageHyperlink(sectionClient, SWT.NULL);
    buttonFileChooser.setImage(new Image(getDisplay(),
            new ImageData(this.getClass().getClassLoader().getResourceAsStream("images/folder_home.png"))));
    buttonFileChooser.setUnderlined(false);
    buttonFileChooser.addHyperlinkListener(new IHyperlinkListener() {
        @Override
        public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
            DirectoryDialog dialog = new DirectoryDialog(JobEditor.this.getShell());
            String res = dialog.open();
            if (res != null) {
                tfTarget.setText(res);
            }
        }
    });

    parametersSection = configureSection(toolkit, form, Manager.getMessage("jobeditor_header_execution"),
            Manager.getMessage("jobeditor_legend_execution"), 1, true);
    Composite sectionClient3 = toolkit.createComposite(parametersSection);
    TableWrapLayout layout2 = new TableWrapLayout();
    sectionClient3.setLayout(layout2);
    layout2.numColumns = 1;
    parametersSection.setClient(sectionClient3);
    stackData.get("parameters").put("SECTION", parametersSection);

    Label lab = toolkit.createLabel(sectionClient3, Manager.getMessage("jobeditor_direction") + " : ");
    lab.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    Composite rComp = toolkit.createComposite(sectionClient3);
    rComp.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    layout2 = new TableWrapLayout();
    layout2.numColumns = 1;
    rComp.setLayout(layout2);
    comboDirection = new Combo(sectionClient3, SWT.READ_ONLY | SWT.BORDER);
    comboDirection.setItems(new String[] { Manager.getMessage("jobeditor_bi"),
            Manager.getMessage("jobeditor_up"), Manager.getMessage("jobeditor_down") });
    //toolkit.adapt(comboDirection);
    TableWrapData test = new TableWrapData(TableWrapData.FILL_GRAB);
    test.maxWidth = 180;
    comboDirection.setLayoutData(test);
    comboDirection.select(0);

    Label lab2 = toolkit.createLabel(sectionClient3, Manager.getMessage("jobeditor_frequency") + " : ");
    lab2.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    Composite rComp2 = toolkit.createComposite(sectionClient3);
    rComp2.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    layout2 = new TableWrapLayout();
    layout2.numColumns = 3;
    rComp2.setLayout(layout2);
    radioSyncInterval1 = toolkit.createButton(rComp2, Manager.getMessage("jobeditor_min"), SWT.RADIO);
    radioSyncInterval2 = toolkit.createButton(rComp2, Manager.getMessage("jobeditor_hours"), SWT.RADIO);
    radioSyncInterval3 = toolkit.createButton(rComp2, Manager.getMessage("jobeditor_days"), SWT.RADIO);
    radioSyncInterval2.setSelection(true);

    saveAction = new Action("Save", new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return new ImageData(this.getClass().getClassLoader().getResourceAsStream("images/filesave.png"));
        }
    }) {
        @Override
        public void run() {
            super.run();
            if (saveConfig()) {
                saveAction.setEnabled(false);
            }
        }
    };
    ModifyListener tfMod = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            saveAction.setEnabled(true);
        }
    };
    SelectionListener rSel = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            saveAction.setEnabled(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    };
    tfHost.addModifyListener(tfMod);
    tfLogin.addModifyListener(tfMod);
    tfPassword.addModifyListener(tfMod);
    tfTarget.addModifyListener(tfMod);
    comboDirection.addModifyListener(tfMod);
    radioSyncInterval1.addSelectionListener(rSel);

    closeAction = new Action("Close", new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return new ImageData(this.getClass().getClassLoader().getResourceAsStream("images/fileclose.png"));
        }
    }) {
        @Override
        public void run() {
            super.run();
            if (saveAction.isEnabled()) {
                MessageBox dialog = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
                dialog.setText(Manager.getMessage("jobeditor_diag_savenotchanges"));
                dialog.setMessage(Manager.getMessage("jobeditor_diag_savenotchanges_msg"));
                int returnCode = dialog.open();
                if (returnCode == SWT.CANCEL)
                    return;
            }

            new AnimationRunner().runEffect(new AlphaEffect(getShell(), 255 /*initial value*/,
                    0 /*final value*/, 1500 /*duration*/, new ExpoOut() /*movement*/, new Runnable() {
                        @Override
                        public void run() {
                            closeConfig();
                        }
                    }, null /*run on cancel*/
            ));
        }
    };

    updateFormActions();

    logsSection = configureSection(toolkit, form, Manager.getMessage("jobeditor_header_execution"), null, 1,
            false);
    logs = new LogViewer(logsSection, SWT.NONE);
    logs.initGUI();
    logsSection.setClient(logs);
    stackData.get("logs").put("SECTION", logsSection);

    toolkit.paintBordersFor(sectionClient);
    toolkit.paintBordersFor(logs);
    toolkit.paintBordersFor(sectionClient3);
}

From source file:info.ajaxplorer.synchro.gui.JobEditor.java

License:Open Source License

protected void updateFormActions() {
    if (form == null)
        return;/*  www. jav a2s.  c om*/
    form.getToolBarManager().removeAll();
    form.getMenuManager().removeAll();

    Iterator<Entry<String, HashMap<String, Object>>> it = stackData.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, HashMap<String, Object>> e = it.next();
        final String key = e.getKey();
        final String label = (String) e.getValue().get("LABEL");
        final String icon = (String) e.getValue().get("ICON");
        Section sec = (Section) e.getValue().get("SECTION");

        Action a = new Action(label, new ImageDescriptor() {
            @Override
            public ImageData getImageData() {
                return new ImageData(
                        this.getClass().getClassLoader().getResourceAsStream("images/" + icon + ".png"));
            }
        }) {
            @Override
            public void run() {
                super.run();
                toggleSection(key, true);
            }
        };
        if (((StackLayout) form.getBody().getLayout()).topControl == sec) {
            a.setEnabled(false);
        }
        form.getMenuManager().add(a);
    }

    form.getToolBarManager().add(saveAction);
    form.getToolBarManager().add(closeAction);

    form.getToolBarManager().update(true);

}

From source file:io.pyd.synchro.gui.JobEditor.java

License:Open Source License

public void populateToolkit() {

    toolkit = new FormToolkit(this.getDisplay());
    final Form form = toolkit.createForm(this);
    this.form = form;
    toolkit.decorateFormHeading(form);//from   w w  w.j av  a  2 s  .co  m
    StackLayout sLayout = new StackLayout();
    form.getBody().setLayout(sLayout);

    connexionSection = configureSection(toolkit, form, CoreManager.getMessage("jobeditor_header_connection"),
            CoreManager.getMessage("jobeditor_legend_connection"), 1, false);
    sectionClient = toolkit.createComposite(connexionSection);
    GridLayout layout = new GridLayout();
    sectionClient.setLayout(layout);
    layout.numColumns = 3;
    layout.horizontalSpacing = 10;
    layout.verticalSpacing = 10;
    sLayout.topControl = connexionSection;
    connexionSection.setClient(sectionClient);
    stackData.get("connexion").put("SECTION", connexionSection);

    // HOST
    Label label = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_hostURL"));
    label.setLayoutData(getGridDataLabel());
    tfHost = toolkit.createText(sectionClient, "");
    tfHost.setLayoutData(getGridDataField(2));

    // TRUST
    label = toolkit.createLabel(sectionClient, "");
    label.setLayoutData(getGridDataLabel());
    trustSSL = toolkit.createButton(sectionClient, CoreManager.getMessage("jobeditor_trustSSL"), SWT.CHECK);
    trustSSL.setLayoutData(getGridDataField(2));
    trustSSL.setEnabled(false);

    tfHost.addListener(SWT.FocusOut, new Listener() {
        public void handleEvent(Event e) {
            String t = tfHost.getText().trim();
            if (!t.startsWith("http://") && !t.startsWith("https://")) {
                tfHost.setText("http://" + t);
            }
            trustSSL.setEnabled(tfHost.getText().startsWith("https://"));
        }
    });

    // LOGIN
    label = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_login"));
    label.setLayoutData(getGridDataLabel());
    tfLogin = toolkit.createText(sectionClient, "");
    tfLogin.setLayoutData(getGridDataField(2));

    // PASSWORD
    label = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_password"));
    label.setLayoutData(getGridDataLabel());
    tfPassword = toolkit.createText(sectionClient, "", SWT.PASSWORD);
    tfPassword.setLayoutData(getGridDataField(2));

    // EXPLANATION LABEL
    Label t = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_workspace_hint"),
            SWT.WRAP | SWT.READ_ONLY);

    GridData ld = getGridDataField(3);
    if (this.heightHint > 0)
        ld.heightHint = this.heightHint * 4;
    else
        ld.heightHint = 45;
    t.setLayoutData(ld);

    // REPOSITORY CHOOSER
    label = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_repository"));
    label.setLayoutData(getGridDataLabel());

    linkLoadRepositories = toolkit.createImageHyperlink(sectionClient, SWT.NULL);
    linkLoadRepositories.setImage(new Image(getDisplay(), new ImageData(
            this.getClass().getClassLoader().getResourceAsStream("images/fa/blue/cloud-download.png"))));
    linkLoadRepositories.setLayoutData(new GridData(GridData.FILL));
    linkLoadRepositories.setUnderlined(false);
    linkLoadRepositories.addHyperlinkListener(new IHyperlinkListener() {
        @Override
        public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
            if (tfRepo != null && (tfHost.getText().trim().equals("") || tfLogin.getText().trim().equals("")
                    || tfPassword.getText().trim().equals(""))) {
                MessageBox dialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
                dialog.setText(CoreManager.getMessage("jobeditor_diag_noserverdata"));
                dialog.setMessage(CoreManager.getMessage("jobeditor_diag_noserverdata_msg"));
                dialog.open();
                return;
            }
            toggleRepositoryComponent();
            if (comboRepository != null) {
                loadRepositories();
            }
        }
    });

    tfRepo = toolkit.createText(sectionClient, "click to load the repositories...", SWT.READ_ONLY);
    tfRepo.setLayoutData(getGridDataField(1));
    tfRepo.setBackground(new Color(this.getDisplay(), 240, 240, 240));

    // TARGET FOLDER CHOOSER
    label = toolkit.createLabel(sectionClient, CoreManager.getMessage("jobeditor_localfolder"));
    label.setLayoutData(getGridDataLabel());

    buttonFileChooser = toolkit.createImageHyperlink(sectionClient, SWT.NULL);
    buttonFileChooser.setImage(new Image(getDisplay(), new ImageData(
            this.getClass().getClassLoader().getResourceAsStream("images/fa/blue/folder-open.png"))));
    buttonFileChooser.setUnderlined(false);
    buttonFileChooser.addHyperlinkListener(new IHyperlinkListener() {
        @Override
        public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
        }

        @Override
        public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent arg0) {
            DirectoryDialog dialog = new DirectoryDialog(JobEditor.this.getShell());
            String res = dialog.open();
            if (res != null) {
                tfTarget.setText(res);
            }
        }
    });
    tfTarget = toolkit.createText(sectionClient, "", SWT.READ_ONLY);
    tfTarget.setLayoutData(getGridDataField(1));
    tfTarget.setBackground(new Color(this.getDisplay(), 240, 240, 240));

    parametersSection = configureSection(toolkit, form, CoreManager.getMessage("jobeditor_header_execution"),
            CoreManager.getMessage("jobeditor_legend_execution"), 1, true);
    Composite sectionClient3 = toolkit.createComposite(parametersSection);
    TableWrapLayout layout2 = new TableWrapLayout();
    sectionClient3.setLayout(layout2);
    layout2.numColumns = 1;
    parametersSection.setClient(sectionClient3);
    stackData.get("parameters").put("SECTION", parametersSection);

    Label lab = toolkit.createLabel(sectionClient3, CoreManager.getMessage("jobeditor_direction") + " : ");
    lab.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    Composite rComp = toolkit.createComposite(sectionClient3);
    rComp.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    layout2 = new TableWrapLayout();
    layout2.numColumns = 1;
    rComp.setLayout(layout2);
    comboDirection = new Combo(sectionClient3, SWT.READ_ONLY | SWT.BORDER);
    comboDirection.setItems(new String[] { CoreManager.getMessage("jobeditor_bi"),
            CoreManager.getMessage("jobeditor_up"), CoreManager.getMessage("jobeditor_down") });
    //toolkit.adapt(comboDirection);
    TableWrapData test = new TableWrapData(TableWrapData.FILL_GRAB);
    test.maxWidth = 180;
    comboDirection.setLayoutData(test);
    comboDirection.select(0);
    comboDirection.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            updateAutoKeeping(true);
        }
    });

    // checkbox for setting auto keeping remote
    keepAutoRemote = toolkit.createButton(sectionClient3, CoreManager.getMessage("jobeditor_autokeepremote"),
            SWT.CHECK);
    keepAutoRemote.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    // checkbox for setting auto keeping local
    keepAutoLocal = toolkit.createButton(sectionClient3, CoreManager.getMessage("jobeditor_autokeeplocal"),
            SWT.CHECK);
    keepAutoLocal.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));

    Label lab2 = toolkit.createLabel(sectionClient3, CoreManager.getMessage("jobeditor_frequency") + " : ");
    lab2.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    Composite rComp2 = toolkit.createComposite(sectionClient3);
    rComp2.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    layout2 = new TableWrapLayout();
    layout2.numColumns = 3;
    rComp2.setLayout(layout2);
    radioSyncInterval1 = toolkit.createButton(rComp2, CoreManager.getMessage("jobeditor_min"), SWT.RADIO);
    radioSyncInterval2 = toolkit.createButton(rComp2, CoreManager.getMessage("jobeditor_hours"), SWT.RADIO);
    radioSyncInterval3 = toolkit.createButton(rComp2, CoreManager.getMessage("jobeditor_days"), SWT.RADIO);
    radioSyncInterval2.setSelection(true);

    Label lab3 = toolkit.createLabel(sectionClient3,
            CoreManager.getMessage("jobeditor_radioserverlegend") + " : ", SWT.WRAP | SWT.READ_ONLY);

    TableWrapData twd = new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE);
    if (this.heightHint > 0)
        twd.heightHint = this.heightHint * 4;
    else
        twd.heightHint = 42;
    lab3.setLayoutData(twd);

    Composite rComp3 = toolkit.createComposite(sectionClient3);
    rComp3.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
    layout2 = new TableWrapLayout();
    layout2.numColumns = 3;
    rComp3.setLayout(layout2);
    radioServerLoadLow = toolkit.createButton(rComp3, CoreManager.getMessage("jobeditor_radioserverlow"),
            SWT.RADIO);
    radioServerLoadMedium = toolkit.createButton(rComp3, CoreManager.getMessage("jobeditor_radioservermedium"),
            SWT.RADIO);
    radioServerLoadHigh = toolkit.createButton(rComp3, CoreManager.getMessage("jobeditor_radioserverhigh"),
            SWT.RADIO);
    radioServerLoadMedium.setSelection(true);

    saveAction = new Action("Save", new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return new ImageData(
                    this.getClass().getClassLoader().getResourceAsStream("images/fa/blue/check-circle-o.png"));
        }
    }) {
        @Override
        public void run() {
            super.run();
            if (saveConfig()) {
                saveAction.setEnabled(false);
            }
        }
    };
    ModifyListener tfMod = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            saveAction.setEnabled(true);
        }
    };
    SelectionListener rSel = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            saveAction.setEnabled(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    };
    tfHost.addModifyListener(tfMod);
    tfLogin.addModifyListener(tfMod);
    tfPassword.addModifyListener(tfMod);
    tfTarget.addModifyListener(tfMod);
    trustSSL.addSelectionListener(rSel);
    comboDirection.addModifyListener(tfMod);
    keepAutoRemote.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            autoKeepRemoteState = keepAutoRemote.getSelection();
            autoKeepLocalState = false;
            updateAutoKeeping(false);
            saveAction.setEnabled(true);
        }
    });
    keepAutoLocal.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            autoKeepRemoteState = false;
            autoKeepLocalState = keepAutoLocal.getSelection();
            updateAutoKeeping(false);
            saveAction.setEnabled(true);
        }
    });
    radioSyncInterval1.addSelectionListener(rSel);
    radioSyncInterval2.addSelectionListener(rSel);
    radioSyncInterval3.addSelectionListener(rSel);
    radioServerLoadLow.addSelectionListener(rSel);
    radioServerLoadMedium.addSelectionListener(rSel);
    radioServerLoadHigh.addSelectionListener(rSel);

    closeAction = new Action("Close", new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return new ImageData(
                    this.getClass().getClassLoader().getResourceAsStream("images/fa/blue/times-circle-o.png"));
        }
    }) {
        @Override
        public void run() {
            super.run();
            if (saveAction.isEnabled()) {
                MessageBox dialog = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
                dialog.setText(CoreManager.getMessage("jobeditor_diag_savenotchanges"));
                dialog.setMessage(CoreManager.getMessage("jobeditor_diag_savenotchanges_msg"));
                int returnCode = dialog.open();
                if (returnCode == SWT.CANCEL)
                    return;
            }

            new AnimationRunner().runEffect(new AlphaEffect(getShell(), 255 /*initial value*/,
                    0 /*final value*/, 1500 /*duration*/, new ExpoOut() /*movement*/, new Runnable() {
                        @Override
                        public void run() {
                            closeConfig();
                        }
                    }, null /*run on cancel*/
            ));
        }
    };

    updateFormActions();

    logsSection = configureSection(toolkit, form, CoreManager.getMessage("jobeditor_header_execution"), null, 1,
            false);
    logs = new LogViewer(logsSection, SWT.NONE);
    logs.initGUI();
    logsSection.setClient(logs);
    stackData.get("logs").put("SECTION", logsSection);

    toolkit.paintBordersFor(sectionClient);
    toolkit.paintBordersFor(logs);
    toolkit.paintBordersFor(sectionClient3);
}

From source file:net.refractions.udig.catalog.internal.wms.WMSGeoResourceImpl.java

License:Open Source License

/**
 * This method will fetch the Icon associated with this url (if such is available).
 * /*w  w  w.ja  v a2 s. c o m*/
 * @see WMSFolder
 * @param monitor
 * @return Requested Icon or ISharedImages.GRID_OBJ
 */
protected static ImageDescriptor fetchIcon(IProgressMonitor monitor, Layer layer, WMSServiceImpl service) {
    try {
        if (monitor != null)
            monitor.beginTask(Messages.WMSGeoResourceImpl_acquiring_task, 3);
        if (monitor != null)
            monitor.worked(1);

        if (layer.getChildren() != null && layer.getChildren().length != 0) {
            // Do not request "parent" layer graphics - this kills Mapserver
            return CatalogUIPlugin.getDefault().getImageDescriptor(ISharedImages.GRID_OBJ);
        }

        ImageDescriptor imageDescriptor = requestImage(monitor, layer, service);

        Image image = null;
        Image swatch = null;
        try {
            if (monitor != null)
                monitor.worked(2);
            if (monitor != null)
                monitor.subTask(Messages.WMSGeoResourceImpl_downloading_icon);
            image = imageDescriptor.createImage();
            Rectangle bound = image.getBounds();
            if (bound.width == 16 && bound.height == 16) {
                // perfect! it did what was expected!
                //
                final ImageData data = (ImageData) image.getImageData().clone();
                return new ImageDescriptor() {
                    public ImageData getImageData() {
                        return (ImageData) data.clone();
                    }
                };
            }
            if (bound.height < 16 || bound.width < 16) {
                // the image is smaller than what we asked for
                // perhaps we should display nothing?
                // in stead we will try scaling it up
                if (WmsPlugin.getDefault().isDebugging()) {
                    System.out.println("Icon scaled up to requested size"); //$NON-NLS-1$                                        
                }
                final ImageData data = image.getImageData().scaledTo(16, 16);
                return new ImageDescriptor() {
                    public ImageData getImageData() {
                        return (ImageData) data.clone();
                    }
                };
            }
            // the image is larger than the size we asked for
            // (so this WMS is not being nice!)
            // we will try and decide what to do here ...
            // let us select the image we want ...

            swatch = new Image(null, 16, 16);
            GC gc = new GC(swatch);
            int sy = 0; // (bound.height / 2 ) - 8;
            int sx = 0;
            int sw = 0;
            int sh = 0;
            ImageData contents = image.getImageData();
            if (contents == null) {
                return CatalogUIPlugin.getDefault().getImageDescriptor(ISharedImages.GRID_MISSING);
            }
            if (contents.maskData != null) {
                // ((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad
                int maskPad = contents.maskPad;
                int scanLine = ((contents.width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad;
                // skip leading mask ...
                SKIPY: for (int y = 0; y < contents.height / 2; y++) {
                    sy = y;
                    for (int x = 0; x < contents.width / 2; x++) {
                        int mask = contents.maskData[y * scanLine + x];
                        if (mask != 0)
                            break SKIPY;
                    }
                }
                SKIPX: for (int x = 0; x < contents.width / 2; x++) {
                    sx = x;
                    for (int y = sy; y < contents.height / 2; y++) {
                        int mask = contents.maskData[y * scanLine + x];
                        if (mask != 0)
                            break SKIPX;
                    }
                }
                sh = Math.min(contents.height - sy, 16);
                sw = Math.min(contents.width - sx, 16);
                if (WmsPlugin.getDefault().isDebugging())
                    System.out.println("Mask offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                        
            } else if (contents.alphaData != null) {
                SKIPY: for (int y = 0; y < contents.height / 2; y++) {
                    sy = y;
                    for (int x = 0; x < contents.width / 2; x++) {
                        int alpha = contents.alphaData[y * contents.width + x];
                        if (alpha != 0)
                            break SKIPY;
                    }
                }
                SKIPX: for (int x = 0; x < contents.width / 2; x++) {
                    sx = x;
                    for (int y = sy; y < contents.height / 2; y++) {
                        int alpha = contents.alphaData[y * contents.width + x];
                        if (alpha != 0)
                            break SKIPX;
                    }
                }
                sh = Math.min(contents.height - sy, 16);
                sw = Math.min(contents.width - sx, 16);
                if (WmsPlugin.getDefault().isDebugging())
                    System.out.println("Alpha offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                        
            } else {
                // try ignoring "white"
                int depth = contents.depth;
                int scanLine = contents.bytesPerLine;
                SKIPY: for (int y = 0; y < contents.height / 2; y++) {
                    sy = y;
                    for (int x = 0; x < contents.width / 2; x++) {
                        int datum = contents.data[y * scanLine + x * depth];
                        if (datum != 0)
                            break SKIPY;
                    }
                }
                SKIPX: for (int x = 0; x < contents.width / 2; x++) {
                    sx = x;
                    for (int y = sy; y < contents.height / 2; y++) {
                        int datum = contents.data[y * scanLine + x * depth];
                        if (datum != 0)
                            break SKIPX;
                    }
                }
                sh = Math.min(contents.height - sy, 16);
                sw = Math.min(contents.width - sx, 16);
                if (WmsPlugin.getDefault().isDebugging())
                    System.out.println("Alpha offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                        
            }
            // else {
            // sh = Math.min( bound.height, bound.width );
            // sw = Math.min( bound.height, bound.width );
            // }
            if (WmsPlugin.getDefault().isDebugging())
                System.out.println("Image resized to " + sh + "x" + sw); //$NON-NLS-1$ //$NON-NLS-2$

            // gc.drawImage(image, sx, sy, sw, sh, 0, 0, 16, 16);

            // chances are this has a label or category view or something
            // grab the gply from the bottom left corner and we are good to
            // (based on mapserver example)
            //
            gc.drawImage(image, 0, bound.height - 16, 16, 16, 0, 0, 16, 16);

            final ImageData data = (ImageData) swatch.getImageData().clone();
            return new ImageDescriptor() {
                public ImageData getImageData() {
                    return (ImageData) data.clone();
                }
            };
        } finally {
            if (image != null) {
                image.dispose();
            }
            if (swatch != null) {
                swatch.dispose();
            }
            if (monitor != null)
                monitor.worked(3);
        }
    } catch (IOException t) {
        WmsPlugin.trace("Could not get icon", t); //$NON-NLS-1$
        return CatalogUIPlugin.getDefault().getImageDescriptor(ISharedImages.GRID_MISSING);
    }
}